Update app.py
#266
by
Karim0111
- opened
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,20 @@ 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 DuckDuckSearchTool,HfApiModel,CodeAgent
|
| 7 |
+
|
| 8 |
|
| 9 |
# (Keep Constants as is)
|
| 10 |
# --- Constants ---
|
|
|
|
| 15 |
class BasicAgent:
|
| 16 |
def __init__(self):
|
| 17 |
print("BasicAgent initialized.")
|
| 18 |
+
self.model = HfApiModel(
|
| 19 |
+
model_id = HfApi(
|
| 20 |
+
model_id = "Qwen/Qwen2.5-Coder-32B-Instruct",
|
| 21 |
+
token = os.getenv("HF_TOKEN")
|
| 22 |
+
)
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
self.search_tool = DuckDuckSearchTool()
|
| 26 |
+
self.agent = CodeAgent(
|
| 27 |
+
tools = [self.search_tool, self.video_tool],
|
| 28 |
+
model = self.model,
|
| 29 |
+
max_steps = 15
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
def __call__(self, question: str) -> str:
|
| 33 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 34 |
fixed_answer = "This is a default answer."
|