Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -208,16 +208,28 @@ class BasicAgent:
|
|
| 208 |
wrong_answers = ["Requests rate limit exceeded", "", " ", " ", "insufficient information"]
|
| 209 |
while not answer or answer in wrong_answers or answer.lower().startswith("error"):
|
| 210 |
try:
|
| 211 |
-
alfred = build_agent(
|
| 212 |
answer = alfred.invoke(input={"messages": [system_prompt, message]},config={"recursion_limit": 6})['messages'][-1].content
|
| 213 |
except Exception as e:
|
| 214 |
print(e)
|
| 215 |
-
alfred = build_agent(
|
| 216 |
answer = alfred.invoke(input={"messages": [system_prompt, message]},config={"recursion_limit": 6})['messages'][-1].content
|
| 217 |
if answer:
|
| 218 |
alfred_super = build_agent(chat1)
|
| 219 |
answer_fin = alfred_super.invoke(
|
| 220 |
-
input={"messages": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
answer_fin = "".join(re.findall(r'(FINAL ANSWER.*)', answer_fin, flags=re.M))
|
| 222 |
answer_fin = answer_fin.replace('FINAL ANSWER:', '')
|
| 223 |
answer_fin = answer_fin.replace('FINAL ANSWER', '')
|
|
|
|
| 208 |
wrong_answers = ["Requests rate limit exceeded", "", " ", " ", "insufficient information"]
|
| 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 |
print(e)
|
| 215 |
+
alfred = build_agent(chat3)
|
| 216 |
answer = alfred.invoke(input={"messages": [system_prompt, message]},config={"recursion_limit": 6})['messages'][-1].content
|
| 217 |
if answer:
|
| 218 |
alfred_super = build_agent(chat1)
|
| 219 |
answer_fin = alfred_super.invoke(
|
| 220 |
+
input={"messages": [
|
| 221 |
+
SystemMessage(
|
| 222 |
+
content="Verify the answer to the following question. If the answer is correct, return it.\
|
| 223 |
+
If it's incorrect, return just the corrected answer. \
|
| 224 |
+
Do not add any comments or characters, your should return just the answer: \
|
| 225 |
+
either a string, or a number, or a comma separated list."
|
| 226 |
+
),
|
| 227 |
+
HumanMessage(
|
| 228 |
+
content=f"{system_prompt}. QUESTION: {message.content}, ANSWER: {answer}"
|
| 229 |
+
)
|
| 230 |
+
]},
|
| 231 |
+
config={"recursion_limit": 6}
|
| 232 |
+
)['messages'][-1].content
|
| 233 |
answer_fin = "".join(re.findall(r'(FINAL ANSWER.*)', answer_fin, flags=re.M))
|
| 234 |
answer_fin = answer_fin.replace('FINAL ANSWER:', '')
|
| 235 |
answer_fin = answer_fin.replace('FINAL ANSWER', '')
|