Spaces:
Runtime error
Runtime error
Update graph/workflow.py
Browse files- graph/workflow.py +20 -7
graph/workflow.py
CHANGED
|
@@ -20,6 +20,7 @@ from agents.tools import (
|
|
| 20 |
tool_get_confidence
|
| 21 |
)
|
| 22 |
|
|
|
|
| 23 |
def create_agent_graph(anthropic_client, db):
|
| 24 |
"""
|
| 25 |
Create the agent workflow graph.
|
|
@@ -137,7 +138,8 @@ def create_agent_graph(anthropic_client, db):
|
|
| 137 |
lambda x: x["current_agent"],
|
| 138 |
{
|
| 139 |
"understanding_agent": "understanding_agent",
|
| 140 |
-
"planning_agent": "planning_agent"
|
|
|
|
| 141 |
}
|
| 142 |
)
|
| 143 |
|
|
@@ -146,7 +148,8 @@ def create_agent_graph(anthropic_client, db):
|
|
| 146 |
lambda x: x["current_agent"],
|
| 147 |
{
|
| 148 |
"planning_agent": "planning_agent",
|
| 149 |
-
"sql_generator_agent": "sql_generator_agent"
|
|
|
|
| 150 |
}
|
| 151 |
)
|
| 152 |
|
|
@@ -155,17 +158,27 @@ def create_agent_graph(anthropic_client, db):
|
|
| 155 |
lambda x: x["current_agent"],
|
| 156 |
{
|
| 157 |
"sql_generator_agent": "sql_generator_agent",
|
| 158 |
-
"executor_agent": "executor_agent"
|
|
|
|
| 159 |
}
|
| 160 |
)
|
| 161 |
|
| 162 |
# Executor agent finishes the workflow
|
| 163 |
workflow.add_edge("executor_agent", END)
|
| 164 |
|
| 165 |
-
# Add
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
|
| 170 |
# Compile the workflow
|
| 171 |
app = workflow.compile()
|
|
|
|
| 20 |
tool_get_confidence
|
| 21 |
)
|
| 22 |
|
| 23 |
+
# Fix for the workflow.py file
|
| 24 |
def create_agent_graph(anthropic_client, db):
|
| 25 |
"""
|
| 26 |
Create the agent workflow graph.
|
|
|
|
| 138 |
lambda x: x["current_agent"],
|
| 139 |
{
|
| 140 |
"understanding_agent": "understanding_agent",
|
| 141 |
+
"planning_agent": "planning_agent",
|
| 142 |
+
"tools": "tools" # Add tools as a possible destination
|
| 143 |
}
|
| 144 |
)
|
| 145 |
|
|
|
|
| 148 |
lambda x: x["current_agent"],
|
| 149 |
{
|
| 150 |
"planning_agent": "planning_agent",
|
| 151 |
+
"sql_generator_agent": "sql_generator_agent",
|
| 152 |
+
"tools": "tools" # Add tools as a possible destination
|
| 153 |
}
|
| 154 |
)
|
| 155 |
|
|
|
|
| 158 |
lambda x: x["current_agent"],
|
| 159 |
{
|
| 160 |
"sql_generator_agent": "sql_generator_agent",
|
| 161 |
+
"executor_agent": "executor_agent",
|
| 162 |
+
"tools": "tools" # Add tools as a possible destination
|
| 163 |
}
|
| 164 |
)
|
| 165 |
|
| 166 |
# Executor agent finishes the workflow
|
| 167 |
workflow.add_edge("executor_agent", END)
|
| 168 |
|
| 169 |
+
# Add edge from tools back to the calling agent
|
| 170 |
+
# This is a simplified approach - in a production system, you would
|
| 171 |
+
# need to track which agent called the tool and return to that agent
|
| 172 |
+
workflow.add_conditional_edges(
|
| 173 |
+
"tools",
|
| 174 |
+
lambda x: x["current_agent"],
|
| 175 |
+
{
|
| 176 |
+
"understanding_agent": "understanding_agent",
|
| 177 |
+
"planning_agent": "planning_agent",
|
| 178 |
+
"sql_generator_agent": "sql_generator_agent",
|
| 179 |
+
"executor_agent": "executor_agent"
|
| 180 |
+
}
|
| 181 |
+
)
|
| 182 |
|
| 183 |
# Compile the workflow
|
| 184 |
app = workflow.compile()
|