naman1102 commited on
Commit
1a8a299
·
1 Parent(s): aec3e3b
Files changed (2) hide show
  1. agent.py +2 -1
  2. app.py +31 -40
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
- messages.append(HumanMessage(content="Observation: No valid action. Please clarify."))
 
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 general AI assistant using the ReAct (Reasoning and Acting) approach. I will ask you a question, and you should think step by step and use tools when needed.
18
-
19
- FORMAT:
20
- For each step, use this exact format:
21
- Thought: [your reasoning about what to do next]
22
- Action: [tool name]
23
- Action Input: [input to the tool]
24
-
25
- After using a tool, you'll receive:
26
- Observation: [tool result]
27
-
28
- Continue this cycle until you have enough information, then provide:
29
- FINAL ANSWER: [YOUR FINAL ANSWER]
30
-
31
- ANSWER FORMAT:
32
- YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise.
33
-
34
- IMPORTANT: When using tools that require file access (such as audio_transcriber_tool, excel_tool, analyze_code_tool, or image_tool), ALWAYS use the task_id parameter only. Do NOT use any file names mentioned by the user.
35
-
36
- AVAILABLE TOOLS:
37
- - wikipedia_search_tool: For historical, biographical, scientific facts
38
- - arxiv_search_tool: For academic research papers
39
- - audio_transcriber_tool: For transcribing audio files
40
- - excel_tool: For analyzing spreadsheet data
41
- - analyze_code_tool: For understanding code files
42
- - image_tool: For describing images
43
- - add_tool: For adding numbers
44
- - subtract_tool: For subtracting numbers
45
- - multiply_tool: For multiplying numbers
46
- - divide_tool: For dividing numbers
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