Update multi_agent.py
Browse files- multi_agent.py +8 -8
multi_agent.py
CHANGED
@@ -43,7 +43,7 @@ def today_tool(text: str) -> str:
|
|
43 |
Any date mathematics should occur outside this function."""
|
44 |
return (str(date.today()) + "\n\nIf you have completed all tasks, respond with FINAL ANSWER.")
|
45 |
|
46 |
-
def create_graph(model, topic):
|
47 |
tavily_tool = TavilySearchResults(max_results=10)
|
48 |
|
49 |
members = ["Researcher"]
|
@@ -87,7 +87,7 @@ def create_graph(model, topic):
|
|
87 |
]
|
88 |
).partial(options=str(options), members=", ".join(members))
|
89 |
|
90 |
-
llm = ChatOpenAI(model=model, max_tokens=
|
91 |
|
92 |
supervisor_chain = (
|
93 |
prompt
|
@@ -96,11 +96,11 @@ def create_graph(model, topic):
|
|
96 |
)
|
97 |
|
98 |
researcher_agent = create_agent(llm, [tavily_tool, today_tool], system_prompt=
|
99 |
-
"You are
|
100 |
-
"1. Research content on topic: " + topic + ", prioritizing academic papers. "
|
101 |
-
"2. Based on your research, write a
|
102 |
"3. At the beginning of the article, add current date and author: Multi-Agent AI System. "
|
103 |
-
"4. At the end of the article, add a references section with links to
|
104 |
researcher_node = functools.partial(agent_node, agent=researcher_agent, name="Researcher")
|
105 |
|
106 |
workflow = StateGraph(AgentState)
|
@@ -119,8 +119,8 @@ def create_graph(model, topic):
|
|
119 |
|
120 |
return workflow.compile()
|
121 |
|
122 |
-
def run_multi_agent(
|
123 |
-
graph = create_graph(
|
124 |
|
125 |
result = graph.invoke({
|
126 |
"messages": [
|
|
|
43 |
Any date mathematics should occur outside this function."""
|
44 |
return (str(date.today()) + "\n\nIf you have completed all tasks, respond with FINAL ANSWER.")
|
45 |
|
46 |
+
def create_graph(model, max_tokens, temperature, topic):
|
47 |
tavily_tool = TavilySearchResults(max_results=10)
|
48 |
|
49 |
members = ["Researcher"]
|
|
|
87 |
]
|
88 |
).partial(options=str(options), members=", ".join(members))
|
89 |
|
90 |
+
llm = ChatOpenAI(model=model, max_tokens=max_tokens, temperature=temperature)
|
91 |
|
92 |
supervisor_chain = (
|
93 |
prompt
|
|
|
96 |
)
|
97 |
|
98 |
researcher_agent = create_agent(llm, [tavily_tool, today_tool], system_prompt=
|
99 |
+
"You are a Sr. Research Scientist at an ivy league university. "
|
100 |
+
"1. Research content on topic: '" + topic + "', prioritizing academic papers. "
|
101 |
+
"2. Based on your research, write a detailed article on the topic in markdown format. "
|
102 |
"3. At the beginning of the article, add current date and author: Multi-Agent AI System. "
|
103 |
+
"4. At the end of the article, add a references section with links to relevant context.")
|
104 |
researcher_node = functools.partial(agent_node, agent=researcher_agent, name="Researcher")
|
105 |
|
106 |
workflow = StateGraph(AgentState)
|
|
|
119 |
|
120 |
return workflow.compile()
|
121 |
|
122 |
+
def run_multi_agent(llm, max_tokens, temperature, topic):
|
123 |
+
graph = create_graph(llm, max_tokens, temperature, topic)
|
124 |
|
125 |
result = graph.invoke({
|
126 |
"messages": [
|