LamiaYT commited on
Commit
adda9fb
·
1 Parent(s): cd4ed8b
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -12,13 +12,9 @@ class BasicAgent:
12
  def __init__(self):
13
  from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel
14
 
15
- # Initialize the search tool
16
  search_tool = DuckDuckGoSearchTool()
17
-
18
- # Initialize the model
19
  model = InferenceClientModel()
20
 
21
- # Create the agent
22
  self.agent = CodeAgent(
23
  model=model,
24
  tools=[search_tool],
@@ -26,9 +22,13 @@ class BasicAgent:
26
 
27
  def __call__(self, question: str) -> str:
28
  print(f"Agent received question (first 50 chars): {question[:50]}...")
29
- fixed_answer = "This is a default answer."
30
- print(f"Agent returning fixed answer: {fixed_answer}")
31
- return fixed_answer
 
 
 
 
32
 
33
 
34
  def run_and_submit_all(profile: gr.OAuthProfile | None):
 
12
  def __init__(self):
13
  from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel
14
 
 
15
  search_tool = DuckDuckGoSearchTool()
 
 
16
  model = InferenceClientModel()
17
 
 
18
  self.agent = CodeAgent(
19
  model=model,
20
  tools=[search_tool],
 
22
 
23
  def __call__(self, question: str) -> str:
24
  print(f"Agent received question (first 50 chars): {question[:50]}...")
25
+ try:
26
+ answer = self.agent.run(question)
27
+ print(f"Agent returned answer: {answer}")
28
+ return answer
29
+ except Exception as e:
30
+ print(f"Error running agent: {e}")
31
+ return f"AGENT ERROR: {e}"
32
 
33
 
34
  def run_and_submit_all(profile: gr.OAuthProfile | None):