bstraehle commited on
Commit
fcfee08
1 Parent(s): c9037da

Update rag_langgraph.py

Browse files
Files changed (1) hide show
  1. 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 run_multi_agent(prompt):
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
- graph = workflow.compile()
130
 
131
- result = "DONE"
 
132
 
133
- for s in graph.stream(
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"));