Kackle commited on
Commit
6773149
·
verified ·
1 Parent(s): 9d3ccd7
Files changed (1) hide show
  1. app.py +11 -13
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 "I apologize, but I'm currently experiencing technical difficulties. Please try again later."
462
 
463
  # If we couldn't get a result after all retries
464
  if result is None:
465
- return "I apologize, but I'm currently experiencing technical difficulties. Please try again later."
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) # Fixed regex
473
  if final_answer_match:
474
- clean_answer = final_answer_match.group(1)
475
- return clean_answer
 
 
476
 
477
- # If no final_answer found, try to extract the last meaningful line
478
- lines = result.strip().split('\n')
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 the result from the agent
485
- return result if result else "Unable to determine answer."
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