Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -418,34 +418,38 @@ class SlpMultiAgent:
|
|
| 418 |
lambda: manager_agent.run(f"""
|
| 419 |
Question: {short_question}
|
| 420 |
|
| 421 |
-
CRITICAL:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 422 |
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
- File analysis: Use file_processor
|
| 429 |
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
|
|
|
| 438 |
|
| 439 |
-
|
| 440 |
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
REMEMBER: Answer format matters! Follow instructions exactly.
|
| 449 |
""")
|
| 450 |
)
|
| 451 |
break # Success, exit retry loop
|
|
@@ -469,20 +473,12 @@ class SlpMultiAgent:
|
|
| 469 |
|
| 470 |
# Extract clean answer from result
|
| 471 |
if result and isinstance(result, str):
|
| 472 |
-
# Look for final_answer pattern
|
| 473 |
import re
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
r'Answer: ([^\n]+)'
|
| 479 |
-
]
|
| 480 |
-
|
| 481 |
-
for pattern in patterns:
|
| 482 |
-
match = re.search(pattern, result, re.IGNORECASE)
|
| 483 |
-
if match:
|
| 484 |
-
clean_answer = match.group(1).strip('"\'')
|
| 485 |
-
return clean_answer
|
| 486 |
|
| 487 |
# If no final_answer found, try to extract the last meaningful line
|
| 488 |
lines = result.strip().split('\n')
|
|
|
|
| 418 |
lambda: manager_agent.run(f"""
|
| 419 |
Question: {short_question}
|
| 420 |
|
| 421 |
+
CRITICAL INSTRUCTIONS:
|
| 422 |
+
1. Use tools DIRECTLY, not in code execution
|
| 423 |
+
2. For factual questions: Use google_search() tool immediately
|
| 424 |
+
3. For math: Use math_calculator() tool directly
|
| 425 |
+
4. DO NOT write complex code - use tools instead
|
| 426 |
+
5. DO NOT call ResearchAgent() or SolverAgent() in code
|
| 427 |
|
| 428 |
+
Available tools:
|
| 429 |
+
- google_search(query): Search the web
|
| 430 |
+
- math_calculator(expression): Calculate math
|
| 431 |
+
- file_processor(action, data): Handle files
|
| 432 |
+
- knowledge_base(topic): Get knowledge
|
|
|
|
| 433 |
|
| 434 |
+
SIMPLE APPROACH:
|
| 435 |
+
- Call the appropriate tool
|
| 436 |
+
- Get the result
|
| 437 |
+
- Provide final_answer()
|
| 438 |
|
| 439 |
+
Example for factual question:
|
| 440 |
+
1. Call google_search("your query")
|
| 441 |
+
2. Extract answer from results
|
| 442 |
+
3. Call final_answer("the answer")
|
| 443 |
|
| 444 |
+
NO complex code execution. Use tools directly.
|
| 445 |
|
| 446 |
+
Take your time and think every step out, be confident and precise.
|
| 447 |
+
|
| 448 |
+
Google should be able to answer all these questions and you have access to it.
|
| 449 |
+
|
| 450 |
+
They are simple yet tricky questions, so be careful and double check your answers. Make sure to use google_search for any factual question.
|
| 451 |
+
|
| 452 |
+
always provide a final_answer in the format final_answer("your answer here") when you have the answer.
|
|
|
|
| 453 |
""")
|
| 454 |
)
|
| 455 |
break # Success, exit retry loop
|
|
|
|
| 473 |
|
| 474 |
# Extract clean answer from result
|
| 475 |
if result and isinstance(result, str):
|
| 476 |
+
# Look for final_answer pattern
|
| 477 |
import re
|
| 478 |
+
final_answer_match = re.search(r'final_answer\(["\']([^"\']*)["\'\)]', result) # Fixed regex
|
| 479 |
+
if final_answer_match:
|
| 480 |
+
clean_answer = final_answer_match.group(1)
|
| 481 |
+
return clean_answer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 482 |
|
| 483 |
# If no final_answer found, try to extract the last meaningful line
|
| 484 |
lines = result.strip().split('\n')
|