Spaces:
Sleeping
Sleeping
Commit
·
d87bf59
1
Parent(s):
7581542
focus on 3 questions now
Browse files- gaia_agent.py +12 -15
gaia_agent.py
CHANGED
@@ -29,23 +29,17 @@ class GaiaAgent:
|
|
29 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
30 |
|
31 |
prompt = f"""
|
32 |
-
|
33 |
-
|
34 |
-
CRITICAL INSTRUCTIONS:
|
35 |
-
1. If question starts with period or looks backwards → use ReverseTextTool first
|
36 |
-
2. For Wikipedia research → use WikipediaSearchTool or VisitWebpageTool
|
37 |
-
3. For simple reasoning → solve directly without tools
|
38 |
-
4. Return ONLY the final answer (number, name, word, etc.)
|
39 |
-
|
40 |
-
ANSWER REQUIREMENTS:
|
41 |
-
- Numbers: return just the number (e.g., "4")
|
42 |
-
- Names: return exact name as requested (e.g., "Ian Rose")
|
43 |
-
- Words: return just the word (e.g., "right")
|
44 |
-
- Be precise and concise
|
45 |
|
46 |
Question: {question}
|
47 |
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
"""
|
50 |
|
51 |
try:
|
@@ -59,12 +53,15 @@ class GaiaAgent:
|
|
59 |
return str(result["answer"]).strip()
|
60 |
elif "content" in result:
|
61 |
return str(result["content"]).strip()
|
|
|
|
|
|
|
62 |
else:
|
63 |
# Try to find any string value in the dict
|
64 |
for key, value in result.items():
|
65 |
if isinstance(value, str) and value.strip():
|
66 |
return value.strip()
|
67 |
-
return
|
68 |
elif isinstance(result, str):
|
69 |
return result.strip()
|
70 |
elif isinstance(result, list):
|
|
|
29 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
30 |
|
31 |
prompt = f"""
|
32 |
+
Answer this question with ONLY the final answer. No explanations.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
Question: {question}
|
35 |
|
36 |
+
INSTRUCTIONS:
|
37 |
+
- If text looks reversed (starts with period), use ReverseTextTool to reverse it first
|
38 |
+
- If you need Wikipedia info, use WikipediaSearchTool
|
39 |
+
- If you can solve with reasoning alone, do it directly
|
40 |
+
- Always end with just the final answer
|
41 |
+
|
42 |
+
Answer:
|
43 |
"""
|
44 |
|
45 |
try:
|
|
|
53 |
return str(result["answer"]).strip()
|
54 |
elif "content" in result:
|
55 |
return str(result["content"]).strip()
|
56 |
+
elif len(result) == 0:
|
57 |
+
# Empty dictionary - likely a tool calling issue
|
58 |
+
return "ERROR: Empty response from agent"
|
59 |
else:
|
60 |
# Try to find any string value in the dict
|
61 |
for key, value in result.items():
|
62 |
if isinstance(value, str) and value.strip():
|
63 |
return value.strip()
|
64 |
+
return f"ERROR: No valid content in response: {result}"
|
65 |
elif isinstance(result, str):
|
66 |
return result.strip()
|
67 |
elif isinstance(result, list):
|