forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlangchain_ex.py
More file actions
39 lines (29 loc) · 1 KB
/
Copy pathlangchain_ex.py
File metadata and controls
39 lines (29 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import asyncio
import os
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI
from dotenv import load_dotenv
load_dotenv()
model = ChatOpenAI(model="o4-mini-2025-04-16")
uid = os.getenv("OMI_UID")
prompt = f"""
You are a helpful assistant that can answer questions and help with tasks.
My Omi UID is {uid}.
Check my memories, and get an overall idea of who I am, then retrieve my 5 most recent conversations and summarize them.
"""
async def run_agent():
async with MultiServerMCPClient(
{
"omi": {
"command": "uvx",
"args": ["mcp-server-omi", "-v"],
"transport": "stdio",
},
}
) as client:
agent = create_react_agent(model, client.get_tools())
response = await agent.ainvoke({"messages": prompt})
print(response["messages"][-1].content)
if __name__ == "__main__":
asyncio.run(run_agent())