rtamaki commited on
Commit
d50e869
·
verified ·
1 Parent(s): 81917a3

Adding SmolAgent basic version

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -19,6 +19,21 @@ class BasicAgent:
19
  print(f"Agent returning fixed answer: {fixed_answer}")
20
  return fixed_answer
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  def run_and_submit_all( profile: gr.OAuthProfile | None):
23
  """
24
  Fetches all questions, runs the BasicAgent on them, submits all answers,
 
19
  print(f"Agent returning fixed answer: {fixed_answer}")
20
  return fixed_answer
21
 
22
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel
23
+ import time
24
+ import datetime
25
+ class SmolAgent:
26
+ def __init__(self):
27
+ print("SmolAgent initialized.")
28
+ self.agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=InferenceClientModel(), additional_authorized_imports=['datetime'])
29
+
30
+ def __call__(self, question: str) -> str:
31
+ print(f"Agent received question (first 50 chars): {question[:50]}...")
32
+ final_answer = self.agent.run(question)
33
+ print(f"Agent returning answer: {final_answer}")
34
+ return final_answer
35
+
36
+
37
  def run_and_submit_all( profile: gr.OAuthProfile | None):
38
  """
39
  Fetches all questions, runs the BasicAgent on them, submits all answers,