Spaces:
Runtime error
Runtime error
Update agents/sql_generator.py
Browse files- agents/sql_generator.py +6 -12
agents/sql_generator.py
CHANGED
|
@@ -4,7 +4,7 @@ This agent converts a data pipeline plan into executable SQL queries.
|
|
| 4 |
"""
|
| 5 |
|
| 6 |
import time
|
| 7 |
-
from typing import Dict, Any, List
|
| 8 |
from agents.state import AgentState
|
| 9 |
from anthropic import Anthropic
|
| 10 |
from anthropic.types import MessageParam
|
|
@@ -20,15 +20,11 @@ def sql_generator_agent(anthropic_client: Anthropic, state: AgentState) -> Agent
|
|
| 20 |
Returns:
|
| 21 |
Updated state
|
| 22 |
"""
|
| 23 |
-
#
|
| 24 |
messages = state.get("messages", [])
|
| 25 |
-
current_agent = state.get("current_agent", "sql_generator_agent")
|
| 26 |
pipeline_plan = state.get("pipeline_plan", {})
|
| 27 |
|
| 28 |
-
# Ensure current_agent is a list
|
| 29 |
-
if isinstance(current_agent, str):
|
| 30 |
-
current_agent = [current_agent]
|
| 31 |
-
|
| 32 |
# Add agent-specific instructions
|
| 33 |
system_message = """
|
| 34 |
You are an AI assistant specializing in generating SQL for pharmaceutical data pipelines.
|
|
@@ -99,13 +95,11 @@ def sql_generator_agent(anthropic_client: Anthropic, state: AgentState) -> Agent
|
|
| 99 |
sql_queries = _extract_sql_queries(agent_response)
|
| 100 |
|
| 101 |
new_state["sql_queries"] = sql_queries
|
| 102 |
-
# Append next agent
|
| 103 |
-
current_agent.append("executor_agent")
|
| 104 |
-
new_state["current_agent"] = current_agent
|
| 105 |
else:
|
| 106 |
# Append current agent if SQL generation is not complete
|
| 107 |
-
current_agent.append("sql_generator_agent")
|
| 108 |
-
new_state["current_agent"] = current_agent
|
| 109 |
|
| 110 |
return new_state
|
| 111 |
|
|
|
|
| 4 |
"""
|
| 5 |
|
| 6 |
import time
|
| 7 |
+
from typing import Dict, Any, List
|
| 8 |
from agents.state import AgentState
|
| 9 |
from anthropic import Anthropic
|
| 10 |
from anthropic.types import MessageParam
|
|
|
|
| 20 |
Returns:
|
| 21 |
Updated state
|
| 22 |
"""
|
| 23 |
+
# Get current messages and pipeline plan
|
| 24 |
messages = state.get("messages", [])
|
| 25 |
+
current_agent = state.get("current_agent", ["sql_generator_agent"])
|
| 26 |
pipeline_plan = state.get("pipeline_plan", {})
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
# Add agent-specific instructions
|
| 29 |
system_message = """
|
| 30 |
You are an AI assistant specializing in generating SQL for pharmaceutical data pipelines.
|
|
|
|
| 95 |
sql_queries = _extract_sql_queries(agent_response)
|
| 96 |
|
| 97 |
new_state["sql_queries"] = sql_queries
|
| 98 |
+
# Append next agent
|
| 99 |
+
new_state["current_agent"].append("executor_agent")
|
|
|
|
| 100 |
else:
|
| 101 |
# Append current agent if SQL generation is not complete
|
| 102 |
+
new_state["current_agent"].append("sql_generator_agent")
|
|
|
|
| 103 |
|
| 104 |
return new_state
|
| 105 |
|