MariaFilipkowska commited on
Commit
7ecebea
·
verified ·
1 Parent(s): 4cc2870

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -3
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(chat3)
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(chat1)
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": [HumanMessage(f"Verify the answer to the following question. QUESTION: {system_prompt.content}: {message.content}, ANSWER: {answer}")]}, config={"recursion_limit": 6})['messages'][-1].content
 
 
 
 
 
 
 
 
 
 
 
 
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', '')