Facelook commited on
Commit
49b7f52
·
1 Parent(s): 32df717

Switching to CodeAgent.

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
6
- from smolagents.agent import Agent
7
 
8
  # (Keep Constants as is)
9
  # --- Constants ---
@@ -14,14 +14,13 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
14
  class BasicAgent:
15
  def __init__(self):
16
  print("BasicAgent initialized with smolagents.")
17
- self.agent = Agent() # Initialize smolagents' Agent
18
 
19
  def __call__(self, question: str) -> str:
20
- print(f"Agent received question (first 50 chars): {question[:50]}...")
21
 
22
- # Perform a web search using smolagents
23
  try:
24
- search_result = self.agent.search(question) # Use smolagents' search capability [[1]]
25
  answer = f"Search result for '{question[:50]}...': {search_result}"
26
  except Exception as e:
27
  answer = f"Error during search: {e}"
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from smolagents import CodeAgent
7
 
8
  # (Keep Constants as is)
9
  # --- Constants ---
 
14
  class BasicAgent:
15
  def __init__(self):
16
  print("BasicAgent initialized with smolagents.")
17
+ self.agent = CodeAgent() # Initialize CodeAgent
18
 
19
  def __call__(self, question: str) -> str:
20
+ print(f"Agent received question: {question[:50]}...")
21
 
 
22
  try:
23
+ search_result = self.agent.run(question) # CodeAgent typically uses .run()
24
  answer = f"Search result for '{question[:50]}...': {search_result}"
25
  except Exception as e:
26
  answer = f"Error during search: {e}"