Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,8 @@ import gradio as gr
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
|
|
|
|
6 |
|
7 |
# (Keep Constants as is)
|
8 |
# --- Constants ---
|
@@ -13,6 +15,16 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
13 |
class BasicAgent:
|
14 |
def __init__(self):
|
15 |
print("BasicAgent initialized.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
def __call__(self, question: str) -> str:
|
17 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
18 |
fixed_answer = "This is a default answer."
|
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
|
7 |
+
from smolagents.agents import ToolCallingAgent
|
8 |
|
9 |
# (Keep Constants as is)
|
10 |
# --- Constants ---
|
|
|
15 |
class BasicAgent:
|
16 |
def __init__(self):
|
17 |
print("BasicAgent initialized.")
|
18 |
+
model = HfApiModel()
|
19 |
+
|
20 |
+
search_tool = DuckDuckGoSearchTool()
|
21 |
+
|
22 |
+
agent = CodeAgent(
|
23 |
+
tools=[search_tool],
|
24 |
+
model=model,
|
25 |
+
additional_authorized_imports=["yfinance"] # Move this parameter here
|
26 |
+
)
|
27 |
+
|
28 |
def __call__(self, question: str) -> str:
|
29 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
30 |
fixed_answer = "This is a default answer."
|