Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -82,9 +82,15 @@ class BasicAgent:
|
|
82 |
self.tool_chain = build_tool_graph(self.agent_prompt)
|
83 |
|
84 |
def format_final_answer(self, answer: str) -> str:
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
def query_groq(self, question: str) -> str:
|
90 |
full_prompt = f"{self.agent_prompt}\n\nQuestion: {question}"
|
|
|
82 |
self.tool_chain = build_tool_graph(self.agent_prompt)
|
83 |
|
84 |
def format_final_answer(self, answer: str) -> str:
|
85 |
+
# Clean up whitespace
|
86 |
+
cleaned = " ".join(answer.strip().split())
|
87 |
+
# Extract only the final answer after the last occurrence of 'FINAL ANSWER:'
|
88 |
+
if "FINAL ANSWER:" in cleaned.upper():
|
89 |
+
final = re.split(r"FINAL ANSWER:\s*", cleaned, flags=re.IGNORECASE)[-1]
|
90 |
+
else:
|
91 |
+
final = cleaned
|
92 |
+
return f"FINAL ANSWER: {final.strip()}"
|
93 |
+
|
94 |
|
95 |
def query_groq(self, question: str) -> str:
|
96 |
full_prompt = f"{self.agent_prompt}\n\nQuestion: {question}"
|