MariaFilipkowska commited on
Commit
782fdf6
·
verified ·
1 Parent(s): 426f453

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -26,12 +26,18 @@ if "Mistral" not in os.environ:
26
  os.environ["Mistral"] = getpass.getpass("Enter your Mistral API key: ")
27
 
28
  print("Loading LLM...")
29
- chat2 = ChatMistralAI(
30
  model="pixtral-large-2411",
31
  temperature=0.01,
32
  max_retries=6,
33
  mistral_api_key = os.getenv("Mistral")
34
  )
 
 
 
 
 
 
35
  print(f"Model {chat2.model} downloaded!")
36
  chat1 = ChatMistralAI(
37
  model="mistral-medium-2505",
@@ -207,6 +213,9 @@ class BasicAgent:
207
  except Exception as e:
208
  alfred = build_agent(chat2)
209
  answer = alfred.invoke(input={"messages": [system_prompt, message]},config={"recursion_limit": 6})['messages'][-1].content
 
 
 
210
  if answer:
211
  answer = "".join(re.findall(r'(FINAL ANSWER.*)', answer, flags=re.M))
212
  answer = answer.replace('FINAL ANSWER:', '')
 
26
  os.environ["Mistral"] = getpass.getpass("Enter your Mistral API key: ")
27
 
28
  print("Loading LLM...")
29
+ chat3 = ChatMistralAI(
30
  model="pixtral-large-2411",
31
  temperature=0.01,
32
  max_retries=6,
33
  mistral_api_key = os.getenv("Mistral")
34
  )
35
+ chat2 = ChatMistralAI(
36
+ model="mistral-ocr-2505",
37
+ temperature=0.01,
38
+ max_retries=6,
39
+ mistral_api_key = os.getenv("Mistral")
40
+ )
41
  print(f"Model {chat2.model} downloaded!")
42
  chat1 = ChatMistralAI(
43
  model="mistral-medium-2505",
 
213
  except Exception as e:
214
  alfred = build_agent(chat2)
215
  answer = alfred.invoke(input={"messages": [system_prompt, message]},config={"recursion_limit": 6})['messages'][-1].content
216
+ finally:
217
+ alfred = build_agent(chat3)
218
+ answer = alfred.invoke(input={"messages": [system_prompt, message]},config={"recursion_limit": 6})['messages'][-1].content
219
  if answer:
220
  answer = "".join(re.findall(r'(FINAL ANSWER.*)', answer, flags=re.M))
221
  answer = answer.replace('FINAL ANSWER:', '')