Spaces:
Sleeping
Sleeping
prompt improvements
Browse files
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
|
| 356 |
-
2. If a file is mentioned in the user's question (
|
| 357 |
|
| 358 |
CRITICAL FORMATTING INSTRUCTION:
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
-
|
| 364 |
-
-
|
| 365 |
-
-
|
| 366 |
-
|
| 367 |
-
Failure to follow
|
| 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 |
-
|
| 384 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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}"
|