Coool2 commited on
Commit
c0ddcb5
·
verified ·
1 Parent(s): 6c51afa

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +48 -48
agent.py CHANGED
@@ -550,54 +550,54 @@ class EnhancedGAIAAgent:
550
  )
551
 
552
  def format_gaia_answer(self, raw_response: str, original_question: str) -> str:
553
- """
554
- Post-process the agent response to extract the exact GAIA format answer
555
- """
556
- format_prompt = f"""Extract the exact answer from the response below. Follow GAIA formatting rules strictly.
557
-
558
- Examples:
559
-
560
- Question: "How many research papers were published by the university between 2010 and 2020?"
561
- Response: "Based on my analysis of the data, I found that the university published 156 research papers between 2010 and 2020."
562
- Answer: 156
563
-
564
- Question: "What is the last name of the software engineer mentioned in the report?"
565
- Response: "After reviewing the document, the software engineer mentioned is Dr. Martinez who developed the system."
566
- Answer: Martinez
567
-
568
- Question: "List the programming languages from this job description, alphabetized:"
569
- Response: "The job description mentions several programming languages including Python, Java, C++, and JavaScript. When alphabetized, these are: C++, Java, JavaScript, Python"
570
- Answer: C++, Java, JavaScript, Python
571
-
572
- Question: "Give only the first name of the developer who created the framework."
573
- Response: "The framework was created by Sarah Johnson, a senior developer at the company."
574
- Answer: Sarah
575
-
576
- Question: "Give the ISO country code as your answer."
577
- Response: "The country in question is France, which has the ISO code FRA."
578
- Answer: FRA
579
-
580
- Question: "Provide your response in standard notation."
581
- Response: "The calculated value is 314 million, which in standard notation is 3.14e+8"
582
- Answer: 3.14e+8
583
-
584
- Now extract the exact answer:
585
-
586
- Question: {original_question}
587
- Response: {raw_response}
588
- Answer:"""
589
-
590
- try:
591
- # Use a simple, fast LLM for formatting
592
- formatting_response = proj_llm.complete(format_prompt)
593
- answer = str(formatting_response).strip()
594
-
595
- return answer
596
-
597
- except Exception as e:
598
- print(f"Error in formatting: {e}")
599
- return self._extract_fallback_answer(raw_response)
600
-
601
 
602
  async def solve_gaia_question(self, question_data: Dict[str, Any]) -> str:
603
  question = question_data.get("Question", "")
 
550
  )
551
 
552
  def format_gaia_answer(self, raw_response: str, original_question: str) -> str:
553
+ """
554
+ Post-process the agent response to extract the exact GAIA format answer
555
+ """
556
+ format_prompt = f"""Extract the exact answer from the response below. Follow GAIA formatting rules strictly.
557
+
558
+ Examples:
559
+
560
+ Question: "How many research papers were published by the university between 2010 and 2020?"
561
+ Response: "Based on my analysis of the data, I found that the university published 156 research papers between 2010 and 2020."
562
+ Answer: 156
563
+
564
+ Question: "What is the last name of the software engineer mentioned in the report?"
565
+ Response: "After reviewing the document, the software engineer mentioned is Dr. Martinez who developed the system."
566
+ Answer: Martinez
567
+
568
+ Question: "List the programming languages from this job description, alphabetized:"
569
+ Response: "The job description mentions several programming languages including Python, Java, C++, and JavaScript. When alphabetized, these are: C++, Java, JavaScript, Python"
570
+ Answer: C++, Java, JavaScript, Python
571
+
572
+ Question: "Give only the first name of the developer who created the framework."
573
+ Response: "The framework was created by Sarah Johnson, a senior developer at the company."
574
+ Answer: Sarah
575
+
576
+ Question: "Give the ISO country code as your answer."
577
+ Response: "The country in question is France, which has the ISO code FRA."
578
+ Answer: FRA
579
+
580
+ Question: "Provide your response in standard notation."
581
+ Response: "The calculated value is 314 million, which in standard notation is 3.14e+8"
582
+ Answer: 3.14e+8
583
+
584
+ Now extract the exact answer:
585
+
586
+ Question: {original_question}
587
+ Response: {raw_response}
588
+ Answer:"""
589
+
590
+ try:
591
+ # Use a simple, fast LLM for formatting
592
+ formatting_response = proj_llm.complete(format_prompt)
593
+ answer = str(formatting_response).strip()
594
+
595
+ return answer
596
+
597
+ except Exception as e:
598
+ print(f"Error in formatting: {e}")
599
+ return self._extract_fallback_answer(raw_response)
600
+
601
 
602
  async def solve_gaia_question(self, question_data: Dict[str, Any]) -> str:
603
  question = question_data.get("Question", "")