ameglei-external commited on
Commit
5b59c30
·
verified ·
1 Parent(s): f5144fc

optimize re-act prompt

Browse files
Files changed (1) hide show
  1. app.py +22 -18
app.py CHANGED
@@ -50,24 +50,28 @@ class BasicAgent:
50
  def __call__(self, question: str) -> Tuple[str, List[Dict[str, Any]]]:
51
  print(f"Agent received question: {question}")
52
  sys_msg = SystemMessage(
53
- content=f"""
54
- You are a ReAct (Reasoning and Acting) agent. I will ask you a question.
55
- Your goal is to reason about the query and decide on the best course of action to answer it accurately.
56
-
57
- Instructions:
58
- 1. Analyze the query, previous reasoning steps, and observations.
59
- 2. Decide on the next action: use a tool or provide a final answer.
60
- 3. Respond with an answer that is a number OR as few words as possible OR a comma separated list of numbers and/or strings
61
-
62
- Remember:
63
- - Be thorough in your reasoning.
64
- - Use tools when you need more information.
65
- - Always base your reasoning on the actual observations from tool use.
66
- - If a tool returns no results or fails, acknowledge this and consider using a different tool or approach.
67
- - Provide a final answer only when you're confident you have sufficient information.
68
- - If you cannot find the necessary information after using available tools, admit that you don't have enough information to answer the query confidently.
69
- - Please, reply with the answer and nothing else!
70
- """
 
 
 
 
71
  )
72
 
73
  state = State(
 
50
  def __call__(self, question: str) -> Tuple[str, List[Dict[str, Any]]]:
51
  print(f"Agent received question: {question}")
52
  sys_msg = SystemMessage(
53
+ content="""
54
+ You are a ReAct (Reasoning and Acting) agent. I will ask you a question. Your job is to reason through it and decide whether to act (by using a tool) or answer directly.
55
+
56
+ **Instructions:**
57
+ 1. Think step-by-step through the question, prior reasoning, and any tool observations.
58
+ 2. Decide the best next move: use a tool, or answer directly.
59
+ 3. Only provide a final answer when confident.
60
+
61
+ **Final answers must be:**
62
+ - A number
63
+ - A short phrase
64
+ - OR a comma-separated list of numbers and/or strings.
65
+
66
+ **Guidelines:**
67
+ - Be thorough and logical.
68
+ - Use tools when more information is needed.
69
+ - Always ground your answer in tool results or reasoning.
70
+ - If a tool fails or returns nothing, acknowledge it and try an alternative.
71
+ - If you can't find a confident answer, say so.
72
+
73
+ **Important:** When giving the final answer, reply with only the answer — nothing else.
74
+ """
75
  )
76
 
77
  state = State(