Spaces:
Sleeping
Sleeping
clean
Browse files
app.py
CHANGED
|
@@ -458,31 +458,29 @@ class SlpMultiAgent:
|
|
| 458 |
await asyncio.sleep(5) # Wait before general retry
|
| 459 |
else:
|
| 460 |
print(f"All attempts failed. Returning default answer.")
|
| 461 |
-
return "
|
| 462 |
|
| 463 |
# If we couldn't get a result after all retries
|
| 464 |
if result is None:
|
| 465 |
-
return "
|
| 466 |
|
| 467 |
|
| 468 |
# Extract clean answer from result
|
| 469 |
if result and isinstance(result, str):
|
| 470 |
# Look for final_answer pattern
|
| 471 |
import re
|
| 472 |
-
final_answer_match = re.search(r'final_answer\(["\']([^"\']*)["\'\)]', result)
|
| 473 |
if final_answer_match:
|
| 474 |
-
clean_answer = final_answer_match.group(1)
|
| 475 |
-
|
|
|
|
|
|
|
| 476 |
|
| 477 |
-
# If no final_answer found
|
| 478 |
-
|
| 479 |
-
for line in reversed(lines):
|
| 480 |
-
line = line.strip()
|
| 481 |
-
if line and not line.startswith('#') and not line.startswith('###') and len(line) < 200:
|
| 482 |
-
return line
|
| 483 |
|
| 484 |
-
# Return
|
| 485 |
-
return
|
| 486 |
|
| 487 |
def check_reasoning(final_answer, agent_memory):
|
| 488 |
# Skip expensive validation to save costs
|
|
|
|
| 458 |
await asyncio.sleep(5) # Wait before general retry
|
| 459 |
else:
|
| 460 |
print(f"All attempts failed. Returning default answer.")
|
| 461 |
+
return "Unable to process request."
|
| 462 |
|
| 463 |
# If we couldn't get a result after all retries
|
| 464 |
if result is None:
|
| 465 |
+
return "Unable to process request."
|
| 466 |
|
| 467 |
|
| 468 |
# Extract clean answer from result
|
| 469 |
if result and isinstance(result, str):
|
| 470 |
# Look for final_answer pattern
|
| 471 |
import re
|
| 472 |
+
final_answer_match = re.search(r'final_answer\(["\']([^"\']*)["\'\)]', result)
|
| 473 |
if final_answer_match:
|
| 474 |
+
clean_answer = final_answer_match.group(1).strip()
|
| 475 |
+
# Ensure we have a meaningful answer, not search results
|
| 476 |
+
if clean_answer and not clean_answer.startswith('•') and len(clean_answer) < 500:
|
| 477 |
+
return clean_answer
|
| 478 |
|
| 479 |
+
# If no final_answer found or it's malformed, return a simple fallback
|
| 480 |
+
return "Unable to determine specific answer from available information."
|
|
|
|
|
|
|
|
|
|
|
|
|
| 481 |
|
| 482 |
+
# Return fallback if no result
|
| 483 |
+
return "Unable to process question."
|
| 484 |
|
| 485 |
def check_reasoning(final_answer, agent_memory):
|
| 486 |
# Skip expensive validation to save costs
|