cryogenic22 commited on
Commit
99c722d
·
verified ·
1 Parent(s): 89f9134

Update agents/planning.py

Browse files
Files changed (1) hide show
  1. agents/planning.py +21 -9
agents/planning.py CHANGED
@@ -23,7 +23,7 @@ def planning_agent(anthropic_client, state: Dict[str, Any]) -> Dict[str, Any]:
23
  messages = state.get("messages", [])
24
  user_intent = state.get("user_intent", {})
25
 
26
- # Add agent-specific instructions
27
  system_message = """
28
  You are an AI assistant specializing in pharmaceutical data pipeline planning.
29
  Your job is to create a comprehensive ETL pipeline plan based on the user's intent.
@@ -50,17 +50,29 @@ def planning_agent(anthropic_client, state: Dict[str, Any]) -> Dict[str, Any]:
50
  - Data products: DP_SALES_DASHBOARD, DP_HCP_TARGETING
51
  """
52
 
53
- # Prepare prompt for Claude
54
- prompt_messages = [
55
- MessageParam(role="system", content=system_message),
56
- *[MessageParam(role=m["role"], content=m["content"]) for m in messages],
57
- MessageParam(role="user", content=f"Based on my request, create a data pipeline plan. Here is information about available data: {context}")
58
- ]
 
 
 
59
 
60
- # Call Claude API
 
 
 
 
 
 
 
 
61
  response = anthropic_client.messages.create(
62
  model="claude-3-7-sonnet-20250219",
63
- messages=prompt_messages,
 
64
  max_tokens=3000
65
  )
66
 
 
23
  messages = state.get("messages", [])
24
  user_intent = state.get("user_intent", {})
25
 
26
+ # Add agent-specific instructions as system parameter
27
  system_message = """
28
  You are an AI assistant specializing in pharmaceutical data pipeline planning.
29
  Your job is to create a comprehensive ETL pipeline plan based on the user's intent.
 
50
  - Data products: DP_SALES_DASHBOARD, DP_HCP_TARGETING
51
  """
52
 
53
+ # Convert state messages to the format expected by Anthropic API
54
+ # Excluding any messages with role "system"
55
+ anthropic_messages = []
56
+ for msg in messages:
57
+ if msg["role"] != "system": # Skip system messages
58
+ anthropic_messages.append(MessageParam(
59
+ role=msg["role"],
60
+ content=msg["content"]
61
+ ))
62
 
63
+ # Add final user message with context
64
+ anthropic_messages.append(
65
+ MessageParam(
66
+ role="user",
67
+ content=f"Based on my request, create a data pipeline plan. Here is information about available data: {context}"
68
+ )
69
+ )
70
+
71
+ # Call Claude API with system message as separate parameter
72
  response = anthropic_client.messages.create(
73
  model="claude-3-7-sonnet-20250219",
74
+ system=system_message,
75
+ messages=anthropic_messages,
76
  max_tokens=3000
77
  )
78