Spaces:
Sleeping
Sleeping
change
Browse files
app.py
CHANGED
|
@@ -3,7 +3,13 @@ import gradio as gr
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
# (Keep Constants as is)
|
| 8 |
# --- Constants ---
|
| 9 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
@@ -12,12 +18,30 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 12 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 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 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 23 |
"""
|
|
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
+
from smolagents import (
|
| 7 |
+
CodeAgent,
|
| 8 |
+
OpenAIModel,
|
| 9 |
+
WebSearchTool,
|
| 10 |
+
VisitWebpageTool,
|
| 11 |
+
FinalAnswerTool
|
| 12 |
+
)
|
| 13 |
# (Keep Constants as is)
|
| 14 |
# --- Constants ---
|
| 15 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
|
|
| 18 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 19 |
class BasicAgent:
|
| 20 |
def __init__(self):
|
| 21 |
+
self.model = OpenAIModel(
|
| 22 |
+
model_id = "openai/gpt-oss-20b",
|
| 23 |
+
api_base="https://api.groq.com/openai/v1",
|
| 24 |
+
api_key=os.environ["GROQ_API_KEY"]
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
self.tools = [
|
| 28 |
+
WebSearchTool(),
|
| 29 |
+
VisitWebpageTool()
|
| 30 |
+
]
|
| 31 |
+
|
| 32 |
+
self.agent = CodeAgent(
|
| 33 |
+
model = self.model,
|
| 34 |
+
tools = self.tools,
|
| 35 |
+
max_steps = 5
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
print("BasicAgent initialized.")
|
| 39 |
def __call__(self, question: str) -> str:
|
| 40 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 41 |
+
|
| 42 |
+
answer = self.agent.run(question)
|
| 43 |
+
|
| 44 |
+
return answer
|
| 45 |
|
| 46 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 47 |
"""
|