Spaces:
Sleeping
Sleeping
something
Browse files
agent.py
CHANGED
@@ -89,7 +89,8 @@ class CustomReActAgent:
|
|
89 |
except Exception as e:
|
90 |
messages.append(HumanMessage(content=f"Observation: Tool execution failed: {str(e)}"))
|
91 |
else:
|
92 |
-
|
|
|
93 |
|
94 |
return "No FINAL ANSWER found within allowed steps."
|
95 |
|
|
|
89 |
except Exception as e:
|
90 |
messages.append(HumanMessage(content=f"Observation: Tool execution failed: {str(e)}"))
|
91 |
else:
|
92 |
+
# Instead of adding a confusing "observation"
|
93 |
+
messages.append(HumanMessage(content="Observation: No action detected. If you are done, write FINAL ANSWER."))
|
94 |
|
95 |
return "No FINAL ANSWER found within allowed steps."
|
96 |
|
app.py
CHANGED
@@ -13,47 +13,38 @@ from state import AgentState
|
|
13 |
# --- Constants ---
|
14 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
15 |
|
|
|
16 |
SYSTEM_PROMPT = """
|
17 |
-
You are a
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
Thought: [your reasoning
|
22 |
-
Action: [
|
23 |
-
Action Input: [input
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
-
|
38 |
-
-
|
39 |
-
-
|
40 |
-
-
|
41 |
-
|
42 |
-
|
43 |
-
-
|
44 |
-
-
|
45 |
-
-
|
46 |
-
-
|
47 |
-
|
48 |
-
SEARCH STRATEGY:
|
49 |
-
- If wikipedia_search_tool fails, try with broader queries or use arxiv_search_tool for academic topics
|
50 |
-
- When you see [END_OF_SEARCH] in results, stop searching and provide your final answer
|
51 |
-
- You MUST always provide a FINAL ANSWER, even if tools fail
|
52 |
-
|
53 |
-
Example:
|
54 |
-
Thought: I need to find information about quantum computing.
|
55 |
-
Action: wikipedia_search_tool
|
56 |
-
Action Input: quantum computing
|
57 |
"""
|
58 |
|
59 |
|
|
|
13 |
# --- Constants ---
|
14 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
15 |
|
16 |
+
|
17 |
SYSTEM_PROMPT = """
|
18 |
+
You are a helpful AI assistant using a ReAct pattern. You will answer questions by thinking step-by-step, taking actions using tools when necessary, and finishing with a final answer.
|
19 |
+
|
20 |
+
When you want to use a tool, respond *exactly* in the following format:
|
21 |
+
|
22 |
+
Thought: [your reasoning]
|
23 |
+
Action: [tool_name]
|
24 |
+
Action Input: [input]
|
25 |
+
|
26 |
+
When you receive an observation, continue reasoning. When you are confident in your answer, write:
|
27 |
+
|
28 |
+
Thought: [final reasoning]
|
29 |
+
FINAL ANSWER: [your answer]
|
30 |
+
|
31 |
+
Use only the available tools:
|
32 |
+
- wikipedia_search_tool
|
33 |
+
- arxiv_search_tool
|
34 |
+
- audio_transcriber_tool
|
35 |
+
- excel_tool
|
36 |
+
- analyze_code_tool
|
37 |
+
- image_tool
|
38 |
+
- add_tool
|
39 |
+
- subtract_tool
|
40 |
+
- multiply_tool
|
41 |
+
- divide_tool
|
42 |
+
|
43 |
+
IMPORTANT:
|
44 |
+
- If using tools that require a `task_id`, only use the value provided.
|
45 |
+
- Do not make up tool names.
|
46 |
+
- Do not loop unnecessarily.
|
47 |
+
- Provide FINAL ANSWER as soon as you are confident.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
"""
|
49 |
|
50 |
|