Switching to CodeAgent.
Browse files
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
|
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 =
|
18 |
|
19 |
def __call__(self, question: str) -> str:
|
20 |
-
print(f"Agent received question
|
21 |
|
22 |
-
# Perform a web search using smolagents
|
23 |
try:
|
24 |
-
search_result = self.agent.
|
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}"
|