Update rag_langgraph.py
Browse files- 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 |
-
|
50 |
|
51 |
system_prompt = (
|
52 |
"You are a Manager tasked with managing a conversation between the"
|
53 |
-
" following agents: {
|
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"] +
|
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(
|
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
|
111 |
-
workflow.add_edge(
|
112 |
|
113 |
-
conditional_map = {k: k for k in
|
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)
|