Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -209,22 +209,22 @@ class BasicAgent:
|
|
| 209 |
while not answer or answer in wrong_answers or answer.lower().startswith("error"):
|
| 210 |
try:
|
| 211 |
alfred = build_agent(chat1)
|
| 212 |
-
|
| 213 |
except Exception as e:
|
| 214 |
alfred = build_agent(chat3)
|
| 215 |
-
|
| 216 |
-
if
|
| 217 |
alfred_super = build_agent(chat1)
|
| 218 |
-
|
| 219 |
-
input={"messages": [f"Verify the answer to the following question. QUESTION: {message}, ANSWER: {
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
print(f"Agent returning fixed answer: {
|
| 226 |
|
| 227 |
-
|
| 228 |
|
| 229 |
|
| 230 |
def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
|
|
| 209 |
while not answer or answer in wrong_answers or answer.lower().startswith("error"):
|
| 210 |
try:
|
| 211 |
alfred = build_agent(chat1)
|
| 212 |
+
answer = alfred.invoke(input={"messages": [system_prompt, message]},config={"recursion_limit": 6})['messages'][-1].content
|
| 213 |
except Exception as e:
|
| 214 |
alfred = build_agent(chat3)
|
| 215 |
+
answer = alfred.invoke(input={"messages": [system_prompt, message]},config={"recursion_limit": 6})['messages'][-1].content
|
| 216 |
+
if answer:
|
| 217 |
alfred_super = build_agent(chat1)
|
| 218 |
+
answer_fin = alfred_super.invoke(
|
| 219 |
+
input={"messages": [f"Verify the answer to the following question. QUESTION: {message}, ANSWER: {answer}"]},config={"recursion_limit": 6})['messages'][-1].content
|
| 220 |
+
answer_fin = "".join(re.findall(r'(FINAL ANSWER.*)', answer_fin, flags=re.M))
|
| 221 |
+
answer_fin = answer_fin.replace('FINAL ANSWER:', '')
|
| 222 |
+
answer_fin = answer_fin.replace('FINAL ANSWER', '')
|
| 223 |
+
answer_fin = answer_fin.replace('YOUR ', '')
|
| 224 |
+
answer_fin = answer_fin.replace('*', '')
|
| 225 |
+
print(f"Agent returning fixed answer: {answer_fin}")
|
| 226 |
|
| 227 |
+
return answer_fin
|
| 228 |
|
| 229 |
|
| 230 |
def run_and_submit_all(profile: gr.OAuthProfile | None):
|