JuyeopDang commited on
Commit
c74b14b
·
verified ·
1 Parent(s): 9795833

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -12
app.py CHANGED
@@ -17,21 +17,36 @@ GROQ_KEY = os.environ['GROQ_KEY']
17
  class BasicAgent:
18
  def __init__(self):
19
  print("BasicAgent initialized.")
20
- self.model = LiteLLMModel(
21
- "llama-3.3-70b-versatile",
22
- api_base="https://api.groq.com/openai/v1",
23
- api_key=GROQ_KEY,
24
- )
25
- self.model.flatten_messages_as_text = True
26
-
27
- self.agent = CodeAgent(
28
- tools=[DuckDuckGoSearchTool(), FinalAnswerTool(), VisitWebpageTool(), PythonInterpreterTool()],
29
- model=self.model,
30
- )
31
 
32
  def __call__(self, question: str) -> str:
33
  print(f"Agent received question (first 50 chars): {question[:50]}...")
34
- response = self.agent.run(question, max_steps=4)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  return response
36
 
37
  def run_and_submit_all( profile: gr.OAuthProfile | None):
 
17
  class BasicAgent:
18
  def __init__(self):
19
  print("BasicAgent initialized.")
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  def __call__(self, question: str) -> str:
22
  print(f"Agent received question (first 50 chars): {question[:50]}...")
23
+ try:
24
+ model = LiteLLMModel(
25
+ "llama-3.3-70b-versatile",
26
+ api_base="https://api.groq.com/openai/v1",
27
+ api_key=GROQ_KEY,
28
+ )
29
+ model.flatten_messages_as_text = True
30
+
31
+ agent = CodeAgent(
32
+ tools=[DuckDuckGoSearchTool(), FinalAnswerTool(), VisitWebpageTool(), PythonInterpreterTool()],
33
+ model=model,
34
+ )
35
+ response = self.agent.run(question)
36
+ except e:
37
+ model = LiteLLMModel(
38
+ "llama-3.1-8b-instant",
39
+ api_base="https://api.groq.com/openai/v1",
40
+ api_key=GROQ_KEY,
41
+ )
42
+ model.flatten_messages_as_text = True
43
+
44
+ agent = CodeAgent(
45
+ tools=[DuckDuckGoSearchTool(), FinalAnswerTool(), VisitWebpageTool(), PythonInterpreterTool()],
46
+ model=model,
47
+ )
48
+ response = self.agent.run(question)
49
+
50
  return response
51
 
52
  def run_and_submit_all( profile: gr.OAuthProfile | None):