Spaces:
Sleeping
Sleeping
Update app.py
Browse filesAdded the HF_TOKEN
app.py
CHANGED
@@ -6,6 +6,10 @@ import pandas as pd
|
|
6 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel
|
7 |
from functionalities import suggest_outfit, define_coordinates, get_weather
|
8 |
|
|
|
|
|
|
|
|
|
9 |
# (Keep Constants as is)
|
10 |
# --- Constants ---
|
11 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
@@ -15,14 +19,10 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
15 |
class BasicAgent:
|
16 |
def __init__(self):
|
17 |
print("BasicAgent initialized.")
|
|
|
18 |
self.agent = CodeAgent(
|
19 |
-
tools=[
|
20 |
-
|
21 |
-
suggest_outfit,
|
22 |
-
define_coordinates,
|
23 |
-
get_weather
|
24 |
-
],
|
25 |
-
model=InferenceClientModel()
|
26 |
)
|
27 |
|
28 |
def __call__(self, question: str) -> str:
|
|
|
6 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel
|
7 |
from functionalities import suggest_outfit, define_coordinates, get_weather
|
8 |
|
9 |
+
hf_token = os.getenv("HF_TOKEN")
|
10 |
+
if not hf_token:
|
11 |
+
raise RuntimeError("HF_API_TOKEN not set")
|
12 |
+
|
13 |
# (Keep Constants as is)
|
14 |
# --- Constants ---
|
15 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
|
19 |
class BasicAgent:
|
20 |
def __init__(self):
|
21 |
print("BasicAgent initialized.")
|
22 |
+
model = InferenceClientModel(token=hf_token)
|
23 |
self.agent = CodeAgent(
|
24 |
+
tools=[DuckDuckGoSearchTool(), suggest_outfit, define_coordinates, get_weather],
|
25 |
+
model=model
|
|
|
|
|
|
|
|
|
|
|
26 |
)
|
27 |
|
28 |
def __call__(self, question: str) -> str:
|