Spaces:
Running
Running
Update agent.py
Browse files
agent.py
CHANGED
@@ -15,47 +15,22 @@ class MonAgent(MultiStepAgent):
|
|
15 |
requises et optionnelles pour garantir un fonctionnement sans erreur
|
16 |
d'implémentation manquante.
|
17 |
"""
|
18 |
-
|
19 |
def initialize_system_prompt(self) -> str:
|
20 |
-
"""
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
If
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
"tool": "search_web",
|
36 |
-
"args": {
|
37 |
-
"query": "Who is the current president of France?"
|
38 |
-
}
|
39 |
-
}
|
40 |
-
]
|
41 |
-
}
|
42 |
-
|
43 |
-
If you have the final answer, respond with an empty plan and the answer in the 'final_answer' key:
|
44 |
-
{
|
45 |
-
"plan": [],
|
46 |
-
"final_answer": "The final answer is..."
|
47 |
-
}
|
48 |
-
|
49 |
-
**Your constraints are:**
|
50 |
-
1. **Analyze your plan:** Before executing, review your plan. Do not repeat actions that you have already performed. If you have already gathered the necessary information, move on to answering the question.
|
51 |
-
2. **Use tools effectively:** You have access to a variety of tools. Choose the best tool for each step.
|
52 |
-
3. **Final Answer Format:** When you have the final answer, you MUST respond with the answer and ONLY the answer. Do not include any extra text, explanations, or conversational phrases like "The answer is...". Your response should be an exact match to what is being asked.
|
53 |
-
|
54 |
-
**CRITICAL RULES:**
|
55 |
-
1. **NO LOOPS:** Before each step, review your action history. NEVER repeat a tool call with the same arguments. If a search did not yield the answer, do not repeat it. Instead, formulate a new, more specific query or use a different tool.
|
56 |
-
2. **THINK, THEN ACT:** After a search, analyze the results. If a source looks promising, your next step should be to SCRAPE it, not to search again.
|
57 |
-
3. **USE THE PYTHON TOOL:** For any task involving logic, data manipulation, sorting, strict filtering (like botanical classification), or calculations, your primary choice should be the `PythonInterpreterTool`. It is more reliable than your own reasoning for these tasks.
|
58 |
-
4. **FINAL ANSWER FORMAT:** Your final answer MUST be the answer and nothing else. No extra words, no "The answer is...", no explanations. Just the value. Example: for 'What is the capital of France?', the answer is 'Paris'.
|
59 |
"""
|
60 |
|
61 |
def _step_stream(self, memory_step):
|
|
|
15 |
requises et optionnelles pour garantir un fonctionnement sans erreur
|
16 |
d'implémentation manquante.
|
17 |
"""
|
|
|
18 |
def initialize_system_prompt(self) -> str:
|
19 |
+
return """You are a hyper-efficient autonomous agent. Your mission is to answer the user's question with surgical precision and no wasted steps.
|
20 |
+
|
21 |
+
**CRITICAL DIRECTIVES - YOU MUST OBEY:**
|
22 |
+
1. **NO LOOPS:** Before every action, you MUST review your previous steps. NEVER repeat a `search_web` call with similar keywords. If a search yields no result, formulate a COMPLETELY DIFFERENT query or use a different tool. Repeating actions is a critical failure.
|
23 |
+
2. **IMMEDIATE ACTION:** If a search result provides a promising URL, your IMMEDIATE next action MUST be to use `scrape_website` on that URL. DO NOT perform another web search.
|
24 |
+
3. **PYTHON FOR LOGIC:** For any task that involves logic, data processing, sorting, strict filtering (like botanical vs. culinary classification), or calculations, your FIRST AND ONLY choice is the `PythonInterpreterTool`. It is more reliable than your own reasoning for these tasks. You MUST use it for such problems.
|
25 |
+
4. **FINAL ANSWER IS ONLY THE ANSWER:** Your final answer must be ONLY the value requested. No "The answer is...", no explanations, no context.
|
26 |
+
- If asked "Who nominated the article?", the final answer is "Nimbus".
|
27 |
+
- If asked "What is the opposite of left?", the final answer is "right".
|
28 |
+
- If asked for a list, the final answer is "item1, item2, item3".
|
29 |
+
|
30 |
+
**RESPONSE FORMAT:**
|
31 |
+
You MUST respond with a valid JSON object.
|
32 |
+
- To act: {"plan": [{"tool": "tool_name", "args": {"arg_name": "value"}}]}
|
33 |
+
- To provide the final answer: {"plan": [], "final_answer": "TheExactFinalAnswer"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
"""
|
35 |
|
36 |
def _step_stream(self, memory_step):
|