Kackle commited on
Commit
4958cc1
Β·
verified Β·
1 Parent(s): 5604ed9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -36
app.py CHANGED
@@ -418,34 +418,38 @@ class SlpMultiAgent:
418
  lambda: manager_agent.run(f"""
419
  Question: {short_question}
420
 
421
- CRITICAL: Read the question CAREFULLY and answer EXACTLY what is asked.
 
 
 
 
 
422
 
423
- STEP-BY-STEP APPROACH:
424
- 1. ANALYZE: What type of question is this?
425
- - Factual/Historical: Use google_search
426
- - Math/Calculation: Use math_calculator
427
- - List/Categorization: Use google_search for verification
428
- - File analysis: Use file_processor
429
 
430
- 2. SEARCH: Use the appropriate tool with SPECIFIC queries
431
- - For Olympics: "1928 Summer Olympics countries athletes least"
432
- - For vegetables: "botanical vegetables vs fruits classification"
433
- - For specific people: "[person name] [context] [year]"
434
 
435
- 3. EXTRACT: Get the EXACT answer from results
436
- - Look for specific numbers, names, codes
437
- - Pay attention to format requirements (IOC codes, last names only, etc.)
 
438
 
439
- 4. VERIFY: Double-check your answer matches the question format
440
 
441
- 5. ANSWER: Use final_answer("exact answer here")
442
-
443
- EXAMPLES:
444
- - Country question β†’ Search β†’ Find IOC code β†’ final_answer("IOC")
445
- - Vegetable list β†’ Search botanical classification β†’ List vegetables β†’ final_answer("item1, item2, item3")
446
- - Person question β†’ Search specific details β†’ Extract names β†’ final_answer("Name1, Name2")
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 with multiple formats
473
  import re
474
- patterns = [
475
- r'final_answer\(["\']([^"\']*)["\'\)]',
476
- r'final_answer\(([^)]+)\)',
477
- r'Final answer: ([^\n]+)',
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')