bstraehle commited on
Commit
f3da07d
1 Parent(s): 4b88018

Update rag_langgraph.py

Browse files
Files changed (1) hide show
  1. rag_langgraph.py +7 -7
rag_langgraph.py CHANGED
@@ -46,17 +46,17 @@ def today_tool(text: str) -> str:
46
  def create_graph(topic):
47
  tavily_tool = TavilySearchResults(max_results=10)
48
 
49
- agents = ["Researcher", "Writer"]
50
 
51
  system_prompt = (
52
  "You are a Manager tasked with managing a conversation between the"
53
- " following agents: {agents}. Given the following user request,"
54
  " respond with the agent to act next. Each agent will perform a"
55
  " task and respond with their results and status. When finished,"
56
  " respond with FINISH."
57
  )
58
 
59
- options = ["FINISH"] + agents
60
 
61
  function_def = {
62
  "name": "route",
@@ -86,7 +86,7 @@ def create_graph(topic):
86
  " Or should we FINISH? Select one of: {options}",
87
  ),
88
  ]
89
- ).partial(options=str(options), members=", ".join(agents))
90
 
91
  llm = ChatOpenAI(model=LLM)
92
 
@@ -107,10 +107,10 @@ def create_graph(topic):
107
  workflow.add_node("Writer", writer_node)
108
  workflow.add_node("Manager", supervisor_chain)
109
 
110
- for agent in agents:
111
- workflow.add_edge(agent, "Manager")
112
 
113
- conditional_map = {k: k for k in agents}
114
  conditional_map["FINISH"] = END
115
 
116
  workflow.add_conditional_edges("Manager", lambda x: x["next"], conditional_map)
 
46
  def create_graph(topic):
47
  tavily_tool = TavilySearchResults(max_results=10)
48
 
49
+ members = ["Researcher", "Writer"]
50
 
51
  system_prompt = (
52
  "You are a Manager tasked with managing a conversation between the"
53
+ " following agents: {members}. Given the following user request,"
54
  " respond with the agent to act next. Each agent will perform a"
55
  " task and respond with their results and status. When finished,"
56
  " respond with FINISH."
57
  )
58
 
59
+ options = ["FINISH"] + members
60
 
61
  function_def = {
62
  "name": "route",
 
86
  " Or should we FINISH? Select one of: {options}",
87
  ),
88
  ]
89
+ ).partial(options=str(options), members=", ".join(members))
90
 
91
  llm = ChatOpenAI(model=LLM)
92
 
 
107
  workflow.add_node("Writer", writer_node)
108
  workflow.add_node("Manager", supervisor_chain)
109
 
110
+ for member in members:
111
+ workflow.add_edge(member, "Manager")
112
 
113
+ conditional_map = {k: k for k in members}
114
  conditional_map["FINISH"] = END
115
 
116
  workflow.add_conditional_edges("Manager", lambda x: x["next"], conditional_map)