ModelByNikhil commited on
Commit
c10f191
·
verified ·
1 Parent(s): 77c4b17

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -17,14 +17,14 @@ class BasicAgent:
17
  print("BasicAgent initialized.")
18
  groq_key = os.getenv("GROQ_API_KEY")
19
  model = OpenAIServerModel(
20
- model_id="openai/gpt-oss-120b",
21
  api_base="https://api.groq.com/openai/v1",
22
  api_key=groq_key,
23
  )
24
  self.agent = CodeAgent(
25
  tools=[DuckDuckGoSearchTool()],
26
  model=model,
27
- max_steps=6,
28
  additional_authorized_imports=["requests", "pandas", "numpy", "time", "bs4", "re"]
29
  )
30
 
@@ -43,13 +43,16 @@ class BasicAgent:
43
  """
44
 
45
  try:
46
- with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor:
47
- future = executor.submit(self.agent.run, prompt)
48
- result = future.result(timeout=90)
49
- return str(result).strip()
50
- except concurrent.futures.TimeoutError:
51
- print("Agent timed out after 90s")
52
- return "ERROR: Timeout"
 
 
 
53
  except BaseException as e:
54
  import traceback
55
  print(f"Agent failed to answer: {e}")
 
17
  print("BasicAgent initialized.")
18
  groq_key = os.getenv("GROQ_API_KEY")
19
  model = OpenAIServerModel(
20
+ model_id="llama-3.1-8b-instant",
21
  api_base="https://api.groq.com/openai/v1",
22
  api_key=groq_key,
23
  )
24
  self.agent = CodeAgent(
25
  tools=[DuckDuckGoSearchTool()],
26
  model=model,
27
+ max_steps=8,
28
  additional_authorized_imports=["requests", "pandas", "numpy", "time", "bs4", "re"]
29
  )
30
 
 
43
  """
44
 
45
  try:
46
+ executor = concurrent.futures.ThreadPoolExecutor(max_workers=1)
47
+ future = executor.submit(self.agent.run, prompt)
48
+ try:
49
+ result = future.result(timeout=120)
50
+ executor.shutdown(wait=False)
51
+ return str(result).strip()
52
+ except concurrent.futures.TimeoutError:
53
+ print("Agent timed out after 120s, moving on")
54
+ executor.shutdown(wait=False, cancel_futures=True)
55
+ return "ERROR: Timeout"
56
  except BaseException as e:
57
  import traceback
58
  print(f"Agent failed to answer: {e}")