forked from yigbt/EcoToxFred
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraph_agent.py
26 lines (19 loc) · 875 Bytes
/
graph_agent.py
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
from langgraph.prebuilt.chat_agent_executor import create_react_agent
from llm import get_chat_llm
from tools.geographic_map import GeographicMap
from tools.wikipedia import WikipediaSearch
from tools.cypher import CypherSearch
from prompts import Prompts
class GraphEcoToxFredAgent:
system_prompt = Prompts.agent.prompt
def __init__(self):
self.pm_tool = GeographicMap()
self.wiki_tool = WikipediaSearch()
self.cypher_tool = CypherSearch()
self.tools = [self.pm_tool, self.cypher_tool, self.wiki_tool]
self.llm = get_chat_llm().bind_tools(self.tools, parallel_tool_calls=False)
self.agent = create_react_agent(self.llm, self.tools)
def invoke(self, messages):
return self.agent.invoke(messages)
def astream_events(self, messages):
return self.agent.astream_events(messages, version="v2")