Update agent.py
Browse files
agent.py
CHANGED
|
@@ -17,11 +17,14 @@ from smolagents import (
|
|
| 17 |
from tools import GetTaskFileTool, LoadXlsxFileTool, LoadTextFileTool
|
| 18 |
|
| 19 |
sys_instruction = (
|
| 20 |
-
"You are a general AI assistant.
|
| 21 |
-
"then
|
| 22 |
-
"
|
| 23 |
-
"
|
| 24 |
-
"
|
|
|
|
|
|
|
|
|
|
| 25 |
)
|
| 26 |
|
| 27 |
prompts = yaml.safe_load(
|
|
@@ -31,28 +34,34 @@ prompts["system_prompt"] = sys_instruction + prompts["system_prompt"]
|
|
| 31 |
|
| 32 |
# req_instruction = (
|
| 33 |
req_instruction = (
|
| 34 |
-
"You are
|
| 35 |
"A valued client has assigned you the following task:\n"
|
| 36 |
"---\n"
|
| 37 |
"Task:\n"
|
| 38 |
"{{task}}\n"
|
| 39 |
"---\n"
|
| 40 |
-
"
|
| 41 |
-
"
|
| 42 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
"Your final_answer MUST be:\n"
|
| 44 |
-
"- a number,\n"
|
| 45 |
-
"- a
|
| 46 |
-
"- or a comma-separated list of numbers or strings (no articles
|
| 47 |
-
"Only the content passed to the final_answer tool will be preserved
|
| 48 |
)
|
|
|
|
| 49 |
prompts['managed_agent']['task'] = req_instruction
|
| 50 |
prompts['managed_agent']['report'] = "{{final_answer}}"
|
| 51 |
|
| 52 |
-
# print(prompts["system_prompt"])
|
| 53 |
-
# print(prompts['planning'])
|
| 54 |
-
# print(prompts['managed_agent'])
|
| 55 |
-
# print(prompts['final_answer'])
|
| 56 |
|
| 57 |
def get_model(
|
| 58 |
model_id: str = "gpt-4.1-mini",
|
|
@@ -109,4 +118,9 @@ def get_agent(
|
|
| 109 |
additional_authorized_imports = ["pandas"],
|
| 110 |
name="GAIAAgent",
|
| 111 |
)
|
| 112 |
-
return agent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
from tools import GetTaskFileTool, LoadXlsxFileTool, LoadTextFileTool
|
| 18 |
|
| 19 |
sys_instruction = (
|
| 20 |
+
"You are a general-purpose AI assistant. For each question, first reason through your answer, "
|
| 21 |
+
"then use the 'final_answer' tool to submit ONLY the final output.\n"
|
| 22 |
+
"Your final answer MUST be one of the following:\n"
|
| 23 |
+
"- A number (without commas or units, unless explicitly instructed),\n"
|
| 24 |
+
"- A short phrase,\n"
|
| 25 |
+
"- A comma-separated list of numbers or strings.\n"
|
| 26 |
+
"For strings, avoid articles and abbreviations, and write digits fully unless told otherwise. "
|
| 27 |
+
"Apply these formatting rules consistently to each item in a list."
|
| 28 |
)
|
| 29 |
|
| 30 |
prompts = yaml.safe_load(
|
|
|
|
| 34 |
|
| 35 |
# req_instruction = (
|
| 36 |
req_instruction = (
|
| 37 |
+
"You are a highly capable and autonomous agent named {{name}}, designed to solve complex tasks efficiently.\n"
|
| 38 |
"A valued client has assigned you the following task:\n"
|
| 39 |
"---\n"
|
| 40 |
"Task:\n"
|
| 41 |
"{{task}}\n"
|
| 42 |
"---\n"
|
| 43 |
+
"To complete this task successfully, follow these steps carefully:\n"
|
| 44 |
+
" 1. Comprehend the task and identify the intended goal.\n"
|
| 45 |
+
" 2. Break the task into clear, logical steps.\n"
|
| 46 |
+
" 3. Select and prepare the tools or resources you need.\n"
|
| 47 |
+
" 4. Set up the required environment or context.\n"
|
| 48 |
+
" 5. Execute each step methodically.\n"
|
| 49 |
+
" 6. Monitor outcomes and identify any deviations.\n"
|
| 50 |
+
" 7. Revise your plan if necessary based on feedback.\n"
|
| 51 |
+
" 8. Maintain internal state and track progress.\n"
|
| 52 |
+
" 9. Verify that the goal has been fully achieved.\n"
|
| 53 |
+
" 10. Present the final result clearly and concisely.\n"
|
| 54 |
+
"If you succeed, you will be rewarded with a significant bonus.\n\n"
|
| 55 |
"Your final_answer MUST be:\n"
|
| 56 |
+
"- a number (retain its original type; do not include units),\n"
|
| 57 |
+
"- a concise phrase,\n"
|
| 58 |
+
"- or a comma-separated list of numbers or strings (no articles, no abbreviations).\n\n"
|
| 59 |
+
"Only the content passed to the final_answer tool will be preserved. Any other content will be discarded."
|
| 60 |
)
|
| 61 |
+
|
| 62 |
prompts['managed_agent']['task'] = req_instruction
|
| 63 |
prompts['managed_agent']['report'] = "{{final_answer}}"
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
def get_model(
|
| 67 |
model_id: str = "gpt-4.1-mini",
|
|
|
|
| 118 |
additional_authorized_imports = ["pandas"],
|
| 119 |
name="GAIAAgent",
|
| 120 |
)
|
| 121 |
+
return agent
|
| 122 |
+
|
| 123 |
+
def test():
|
| 124 |
+
"""test tests something. """
|
| 125 |
+
# Test the agent with a simple task
|
| 126 |
+
return True
|