Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -33,13 +33,17 @@ class BasicAgent:
|
|
33 |
"""Run the agent and return whatever FINAL_ANSWER the graph produces."""
|
34 |
print(f"Agent received question: {question}")
|
35 |
|
|
|
|
|
|
|
|
|
|
|
36 |
# Initialize the state properly with all required fields
|
37 |
init_state = {
|
38 |
"messages": [
|
39 |
-
SystemMessage(content=
|
40 |
HumanMessage(content=question)
|
41 |
-
]
|
42 |
-
"task_id": task_id
|
43 |
}
|
44 |
|
45 |
# IMPORTANT: invoke() returns a **new** state instance (or an AddableValuesDict),
|
@@ -54,7 +58,6 @@ class BasicAgent:
|
|
54 |
if hasattr(last_message, 'content'):
|
55 |
content = last_message.content
|
56 |
# Look for FINAL ANSWER: pattern
|
57 |
-
print("task_id: ", out_state["task_id"])
|
58 |
print("content: ", content)
|
59 |
print("\n\n\n\n")
|
60 |
if "FINAL ANSWER:" in content:
|
|
|
33 |
"""Run the agent and return whatever FINAL_ANSWER the graph produces."""
|
34 |
print(f"Agent received question: {question}")
|
35 |
|
36 |
+
# Create system prompt with task_id included
|
37 |
+
system_prompt_with_task = SYSTEM_PROMPT
|
38 |
+
if task_id:
|
39 |
+
system_prompt_with_task += f"\n\nIMPORTANT: Your current task_id is: {task_id}. When using any tools that require a task_id parameter (audio_transcriber_tool, excel_tool, analyze_code_tool, image_tool), use this exact task_id: {task_id}"
|
40 |
+
|
41 |
# Initialize the state properly with all required fields
|
42 |
init_state = {
|
43 |
"messages": [
|
44 |
+
SystemMessage(content=system_prompt_with_task),
|
45 |
HumanMessage(content=question)
|
46 |
+
]
|
|
|
47 |
}
|
48 |
|
49 |
# IMPORTANT: invoke() returns a **new** state instance (or an AddableValuesDict),
|
|
|
58 |
if hasattr(last_message, 'content'):
|
59 |
content = last_message.content
|
60 |
# Look for FINAL ANSWER: pattern
|
|
|
61 |
print("content: ", content)
|
62 |
print("\n\n\n\n")
|
63 |
if "FINAL ANSWER:" in content:
|