Spaces:
Runtime error
Runtime error
fix
Browse files
app.py
CHANGED
@@ -3,16 +3,23 @@ import gradio as gr
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
|
|
|
|
|
|
6 |
|
7 |
# --- Constants ---
|
8 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
|
9 |
|
10 |
# --- Basic Agent Definition ---
|
11 |
class BasicAgent:
|
12 |
def __init__(self):
|
13 |
-
from smolagents import CodeAgent, DuckDuckGoSearchTool, InferenceClientModel
|
14 |
|
15 |
-
|
|
|
|
|
|
|
|
|
16 |
model = InferenceClientModel()
|
17 |
|
18 |
self.agent = CodeAgent(
|
@@ -31,6 +38,7 @@ class BasicAgent:
|
|
31 |
return f"AGENT ERROR: {e}"
|
32 |
|
33 |
|
|
|
34 |
def run_and_submit_all(profile: gr.OAuthProfile | None):
|
35 |
"""
|
36 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
+
from smolagents import CodeAgent, InferenceClientModel
|
7 |
+
from smolagents.tools.serper import SerperSearchTool # make sure this path is correct
|
8 |
+
|
9 |
|
10 |
# --- Constants ---
|
11 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
12 |
+
serper_api_key = os.getenv("SERPER_API_KEY")
|
13 |
|
14 |
# --- Basic Agent Definition ---
|
15 |
class BasicAgent:
|
16 |
def __init__(self):
|
|
|
17 |
|
18 |
+
serper_api_key = os.getenv("SERPER_API_KEY")
|
19 |
+
if not serper_api_key:
|
20 |
+
raise ValueError("Missing SERPER_API_KEY in environment variables.")
|
21 |
+
|
22 |
+
search_tool = SerperSearchTool(api_key=serper_api_key)
|
23 |
model = InferenceClientModel()
|
24 |
|
25 |
self.agent = CodeAgent(
|
|
|
38 |
return f"AGENT ERROR: {e}"
|
39 |
|
40 |
|
41 |
+
|
42 |
def run_and_submit_all(profile: gr.OAuthProfile | None):
|
43 |
"""
|
44 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|