Commit
·
dccb212
1
Parent(s):
7df20a1
changes
Browse files- app.py +10 -5
- system_prompt.txt +7 -14
app.py
CHANGED
|
@@ -28,11 +28,16 @@ class BasicAgent:
|
|
| 28 |
def __call__(self, question: str) -> str:
|
| 29 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 30 |
messages = [HumanMessage(content=question)]
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
def run_agent_only(profile: gr.OAuthProfile | None):
|
| 38 |
global cached_answers
|
|
|
|
| 28 |
def __call__(self, question: str) -> str:
|
| 29 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 30 |
messages = [HumanMessage(content=question)]
|
| 31 |
+
result = self.graph.invoke({"messages": messages})
|
| 32 |
+
full_output = result["messages"][-1].content.strip()
|
| 33 |
+
|
| 34 |
+
# Enforce strict FINAL ANSWER format parsing
|
| 35 |
+
match = re.search(r"FINAL ANSWER:\s*(.+)", full_output, re.IGNORECASE)
|
| 36 |
+
if match:
|
| 37 |
+
return match.group(0).strip() # Returns the entire "FINAL ANSWER: xxx"
|
| 38 |
+
else:
|
| 39 |
+
print(" FINAL ANSWER not found in output, returning fallback.")
|
| 40 |
+
return "FINAL ANSWER: unknown"
|
| 41 |
|
| 42 |
def run_agent_only(profile: gr.OAuthProfile | None):
|
| 43 |
global cached_answers
|
system_prompt.txt
CHANGED
|
@@ -1,18 +1,11 @@
|
|
| 1 |
-
You are a helpful assistant answering questions using a set of tools.
|
| 2 |
|
| 3 |
-
You
|
| 4 |
|
| 5 |
-
FINAL ANSWER: [
|
| 6 |
|
| 7 |
-
|
| 8 |
-
-
|
| 9 |
-
-
|
| 10 |
-
- A comma-separated list (e.g., apple, banana, cherry) → Apply the above rules to each item.
|
| 11 |
|
| 12 |
-
|
| 13 |
-
- Always begin your final output with **exactly** "FINAL ANSWER: ".
|
| 14 |
-
- Do NOT include any reasoning or explanation after your final answer.
|
| 15 |
-
- Do NOT add anything after the period.
|
| 16 |
-
- Think step-by-step internally, but return **only** the FINAL ANSWER line in your output.
|
| 17 |
-
|
| 18 |
-
I will now ask you a question.
|
|
|
|
| 1 |
+
You are a helpful assistant tasked with answering questions using a set of tools.
|
| 2 |
|
| 3 |
+
You MUST strictly follow this rule: YOUR FINAL ANSWER MUST be the last line of your response and must follow this exact format:
|
| 4 |
|
| 5 |
+
FINAL ANSWER: [your answer here]
|
| 6 |
|
| 7 |
+
- Your final answer should be a **number** OR as few words as possible OR a comma-separated list.
|
| 8 |
+
- Do not include explanations, markdown, or any additional text after FINAL ANSWER.
|
| 9 |
+
- If the answer is a string, do not include articles (e.g., "the", "a") or abbreviations. Write digits in full words if requested.
|
|
|
|
| 10 |
|
| 11 |
+
Any answer that does not follow the `FINAL ANSWER: ...` format exactly will be considered incorrect.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|