Update rag_langgraph.py
Browse files- rag_langgraph.py +6 -16
rag_langgraph.py
CHANGED
@@ -45,8 +45,8 @@ class AgentState(TypedDict):
|
|
45 |
messages: Annotated[Sequence[BaseMessage], operator.add]
|
46 |
# The 'next' field indicates where to route to next
|
47 |
next: str
|
48 |
-
|
49 |
-
def
|
50 |
tavily_tool = TavilySearchResults(max_results=5)
|
51 |
python_repl_tool = PythonREPLTool()
|
52 |
|
@@ -126,19 +126,9 @@ def run_multi_agent(prompt):
|
|
126 |
# Finally, add entrypoint
|
127 |
workflow.set_entry_point("supervisor")
|
128 |
|
129 |
-
|
130 |
|
131 |
-
|
|
|
132 |
|
133 |
-
|
134 |
-
{
|
135 |
-
"messages": [
|
136 |
-
HumanMessage(content="Code hello world and print it to the terminal")
|
137 |
-
]
|
138 |
-
}
|
139 |
-
):
|
140 |
-
if "__end__" not in s:
|
141 |
-
print(s)
|
142 |
-
print("----")
|
143 |
-
|
144 |
-
return result
|
|
|
45 |
messages: Annotated[Sequence[BaseMessage], operator.add]
|
46 |
# The 'next' field indicates where to route to next
|
47 |
next: str
|
48 |
+
|
49 |
+
def create_graph(topic, word_count):
|
50 |
tavily_tool = TavilySearchResults(max_results=5)
|
51 |
python_repl_tool = PythonREPLTool()
|
52 |
|
|
|
126 |
# Finally, add entrypoint
|
127 |
workflow.set_entry_point("supervisor")
|
128 |
|
129 |
+
return workflow.compile()
|
130 |
|
131 |
+
def run_multi_agent(topic, word_count):
|
132 |
+
graph = create_graph(topic, word_count)
|
133 |
|
134 |
+
return graph.invoke(new HumanMessage("Code hello world and print it to the terminal"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|