Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
-
from smolagents import CodeAgent, HfApiModel
|
7 |
|
8 |
# (Keep Constants as is)
|
9 |
# --- Constants ---
|
@@ -14,11 +14,25 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
14 |
class BasicAgent:
|
15 |
def __init__(self):
|
16 |
print("BasicAgent initialized.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
def __call__(self, question: str) -> str:
|
18 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
19 |
-
|
20 |
-
print(f"Agent returning
|
21 |
-
return
|
22 |
|
23 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
24 |
"""
|
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool, HfApiModel
|
7 |
|
8 |
# (Keep Constants as is)
|
9 |
# --- Constants ---
|
|
|
14 |
class BasicAgent:
|
15 |
def __init__(self):
|
16 |
print("BasicAgent initialized.")
|
17 |
+
|
18 |
+
# Initialize the model
|
19 |
+
model = HfApiModel("Qwen/Qwen2.5-Coder-32B-Instruct")
|
20 |
+
|
21 |
+
# Initialize the tools other than the base tools
|
22 |
+
# See list of base tools in https://github.com/huggingface/smolagents/blob/main/src/smolagents/default_tools.py
|
23 |
+
|
24 |
+
# Initialize the agent
|
25 |
+
self.agent = CodeAgent(
|
26 |
+
model=model,
|
27 |
+
tool=[],
|
28 |
+
add_base_tools=True
|
29 |
+
)
|
30 |
+
|
31 |
def __call__(self, question: str) -> str:
|
32 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
33 |
+
response = self.agent.run(question)
|
34 |
+
print(f"Agent returning its generated answer: {response}")
|
35 |
+
return response
|
36 |
|
37 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
38 |
"""
|