optimize re-act prompt
Browse files
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=
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 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(
|