Update multi_agent.py
Browse files- multi_agent.py +24 -4
multi_agent.py
CHANGED
@@ -46,7 +46,7 @@ def today_tool(text: str) -> str:
|
|
46 |
def create_graph(model, max_tokens, temperature, topic):
|
47 |
tavily_tool = TavilySearchResults(max_results=10)
|
48 |
|
49 |
-
members = ["
|
50 |
options = ["FINISH"] + members
|
51 |
|
52 |
system_prompt = (
|
@@ -95,18 +95,38 @@ def create_graph(model, max_tokens, temperature, topic):
|
|
95 |
| JsonOutputFunctionsParser()
|
96 |
)
|
97 |
|
98 |
-
|
99 |
"You are a Sr. Research Scientist at an ivy league university. "
|
100 |
"1. Research content on topic '" + topic + "'. "
|
101 |
"2. Based on your research, write an accurate, concise, and objective article in markdown format (omit the triple backticks). "
|
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 content.")
|
104 |
-
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
workflow = StateGraph(AgentState)
|
107 |
|
108 |
workflow.add_node("Manager", supervisor_chain)
|
109 |
-
workflow.add_node("
|
|
|
|
|
110 |
|
111 |
for member in members:
|
112 |
workflow.add_edge(member, "Manager")
|
|
|
46 |
def create_graph(model, max_tokens, temperature, topic):
|
47 |
tavily_tool = TavilySearchResults(max_results=10)
|
48 |
|
49 |
+
members = ["Content Planner", "Article Author", "Article Editor"]
|
50 |
options = ["FINISH"] + members
|
51 |
|
52 |
system_prompt = (
|
|
|
95 |
| JsonOutputFunctionsParser()
|
96 |
)
|
97 |
|
98 |
+
content_planner_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 + "'. "
|
101 |
"2. Based on your research, write an accurate, concise, and objective article in markdown format (omit the triple backticks). "
|
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 content.")
|
104 |
+
content_planner_node = functools.partial(agent_node, agent=content_planner_agent, name="Content Planner")
|
105 |
|
106 |
+
###
|
107 |
+
article_author_agent = create_agent(llm, [tavily_tool, today_tool], system_prompt=
|
108 |
+
"You are a Sr. Research Scientist at an ivy league university. "
|
109 |
+
"1. Research content on topic '" + topic + "'. "
|
110 |
+
"2. Based on your research, write an accurate, concise, and objective article in markdown format (omit the triple backticks). "
|
111 |
+
"3. At the beginning of the article, add current date and author: Multi-Agent AI System. "
|
112 |
+
"4. At the end of the article, add a references section with links to relevant content.")
|
113 |
+
article_author_node = functools.partial(agent_node, agent=article_author_agent, name="Article Author")
|
114 |
+
|
115 |
+
article_editor_agent = create_agent(llm, [tavily_tool, today_tool], system_prompt=
|
116 |
+
"You are a Sr. Research Scientist at an ivy league university. "
|
117 |
+
"1. Research content on topic '" + topic + "'. "
|
118 |
+
"2. Based on your research, write an accurate, concise, and objective article in markdown format (omit the triple backticks). "
|
119 |
+
"3. At the beginning of the article, add current date and author: Multi-Agent AI System. "
|
120 |
+
"4. At the end of the article, add a references section with links to relevant content.")
|
121 |
+
article_editor_node = functools.partial(agent_node, agent=article_editor_agent, name="Article Editor")
|
122 |
+
###
|
123 |
+
|
124 |
workflow = StateGraph(AgentState)
|
125 |
|
126 |
workflow.add_node("Manager", supervisor_chain)
|
127 |
+
workflow.add_node("Content Planner", content_planner_node)
|
128 |
+
workflow.add_node("Article Author", article_author_node)
|
129 |
+
workflow.add_node("Article Editor", article_editor_node)
|
130 |
|
131 |
for member in members:
|
132 |
workflow.add_edge(member, "Manager")
|