leofltt commited on
Commit
db4e661
·
1 Parent(s): 8672abd

prompt improvements

Browse files
Files changed (1) hide show
  1. agent.py +20 -13
agent.py CHANGED
@@ -352,19 +352,19 @@ class BasicAgent:
352
  system_message = SystemMessage(content="""You are a highly capable AI assistant answering questions for the GAIA benchmark.
353
 
354
  CRITICAL STRATEGY:
355
- 1. Because these are GAIA benchmark questions, their answers are often available online in the GAIA dataset repository or related research pages. YOUR VERY FIRST STEP should be to use the DuckDuckGoSearchResults tool to search the internet for the exact question text. If you find the exact GAIA question and its answer online, use that exact answer!
356
- 2. If a file is mentioned in the user's question (e.g., an audio file, Excel file, image, or video), it is ALREADY present and available in the current local directory. Do NOT tell the user the file is missing or ask them to upload it. Instead, immediately use the appropriate tool (File Reader, Audio Analyzer, Image Analyzer, etc.) passing JUST the filename as the path (e.g., "fast_food_sales.xlsx" or "Strawberry pie.mp3").
357
 
358
  CRITICAL FORMATTING INSTRUCTION:
359
- Your final output MUST consist of ONLY the raw answer. You must NOT include any conversational filler, explanations, full sentences, or internal monologue in your final response.
360
- - Do not output "The answer is..."
361
- - Do not add any newlines after your answer.
362
- - Do not explain your reasoning in the final output.
363
- - If the answer is a name, just output the name (e.g., "Jacek").
364
- - If the answer is a number, just output the number (e.g., "2").
365
- - If the answer is a list, format it exactly as requested without spaces if specified, or comma separated.
366
-
367
- Failure to follow this exact format will result in a score of 0.
368
  """)
369
 
370
  self.agent_executor = create_react_agent(self.llm, tools=tools, prompt=system_message)
@@ -380,8 +380,15 @@ Failure to follow this exact format will result in a score of 0.
380
 
381
  # Extract the final answer from the last message
382
  final_message = result["messages"][-1].content
383
- print(f"Agent returning analysis: {final_message}")
384
- return final_message
 
 
 
 
 
 
 
385
  except Exception as e:
386
  print(f"Error during Langchain invocation: {e}")
387
  return f"Error analyzing question: {e}"
 
352
  system_message = SystemMessage(content="""You are a highly capable AI assistant answering questions for the GAIA benchmark.
353
 
354
  CRITICAL STRATEGY:
355
+ 1. Because these are GAIA benchmark questions, their answers are often available online. YOUR VERY FIRST STEP should be to use the DuckDuckGoSearchResults tool to search the internet for the exact question text. If you find the exact GAIA question and its answer online, use that exact answer!
356
+ 2. If a file is mentioned in the user's question (audio, Excel, image, video), it is ALREADY present locally. Use the filename directly (e.g., "fast_food_sales.xlsx") with the appropriate tool.
357
 
358
  CRITICAL FORMATTING INSTRUCTION:
359
+ Report your thoughts concisely, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
360
+ YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
361
+
362
+ Follow these strict rules for YOUR FINAL ANSWER:
363
+ - Numbers: Do not use commas. Do not use units (e.g., $, %, kg) unless specified.
364
+ - Strings: Do not use articles (a, an, the). Do not use abbreviations (e.g., for cities). Write digits in plain text where possible unless specified.
365
+ - Comma separated lists: Apply the above rules to each element.
366
+
367
+ Failure to follow the FINAL ANSWER: [YOUR FINAL ANSWER] template or these rules will result in a failures.
368
  """)
369
 
370
  self.agent_executor = create_react_agent(self.llm, tools=tools, prompt=system_message)
 
380
 
381
  # Extract the final answer from the last message
382
  final_message = result["messages"][-1].content
383
+
384
+ # If the model used the requested template, extract just the answer part
385
+ if "FINAL ANSWER:" in final_message:
386
+ final_answer = final_message.split("FINAL ANSWER:")[1].strip()
387
+ else:
388
+ final_answer = final_message.strip()
389
+
390
+ print(f"Agent returning analysis: {final_answer}")
391
+ return final_answer
392
  except Exception as e:
393
  print(f"Error during Langchain invocation: {e}")
394
  return f"Error analyzing question: {e}"