Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ import inspect
|
|
| 6 |
import pandas as pd
|
| 7 |
from io import BytesIO
|
| 8 |
|
| 9 |
-
from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool,
|
| 10 |
|
| 11 |
# --- Constants ---
|
| 12 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
@@ -38,16 +38,17 @@ class BasicAgent:
|
|
| 38 |
|
| 39 |
def __init__(self):
|
| 40 |
print("BasicAgent initialized.")
|
| 41 |
-
|
| 42 |
-
if not
|
| 43 |
-
|
| 44 |
-
"
|
| 45 |
-
"Add it as a Space secret (Settings > Variables and secrets) "
|
| 46 |
-
"
|
| 47 |
)
|
| 48 |
-
self.model =
|
| 49 |
-
model_id="
|
| 50 |
-
|
|
|
|
| 51 |
)
|
| 52 |
self.agent = CodeAgent(
|
| 53 |
tools=[DuckDuckGoSearchTool(), VisitWebpageTool()],
|
|
|
|
| 6 |
import pandas as pd
|
| 7 |
from io import BytesIO
|
| 8 |
|
| 9 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool, OpenAIServerModel
|
| 10 |
|
| 11 |
# --- Constants ---
|
| 12 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
|
|
| 38 |
|
| 39 |
def __init__(self):
|
| 40 |
print("BasicAgent initialized.")
|
| 41 |
+
groq_key = os.getenv("GROQ_API_KEY")
|
| 42 |
+
if not groq_key:
|
| 43 |
+
raise ValueError(
|
| 44 |
+
"GROQ_API_KEY not found in environment. "
|
| 45 |
+
"Add it as a Space secret (Settings > Variables and secrets). "
|
| 46 |
+
"Get a free key at https://console.groq.com"
|
| 47 |
)
|
| 48 |
+
self.model = OpenAIServerModel(
|
| 49 |
+
model_id="llama-3.3-70b-versatile",
|
| 50 |
+
api_base="https://api.groq.com/openai/v1",
|
| 51 |
+
api_key=groq_key,
|
| 52 |
)
|
| 53 |
self.agent = CodeAgent(
|
| 54 |
tools=[DuckDuckGoSearchTool(), VisitWebpageTool()],
|