bstraehle commited on
Commit
0818020
·
verified ·
1 Parent(s): c4cae4c

Update multi_agent.py

Browse files
Files changed (1) hide show
  1. 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=10000, temperature=0)
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 the chief 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 5000-word detailed paper 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 academic papers.")
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(model, topic):
123
- graph = create_graph(model, topic)
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": [