Update app.py
Browse files
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 ---
|
@@ -10,14 +12,39 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
10 |
|
11 |
# --- Basic Agent Definition ---
|
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 DuckDuckGoSearchTool,HfApiModel,load_tool, CodeAgent
|
7 |
+
from smolagents import CodeAgent
|
8 |
|
9 |
# (Keep Constants as is)
|
10 |
# --- Constants ---
|
|
|
12 |
|
13 |
# --- Basic Agent Definition ---
|
14 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
15 |
+
|
16 |
+
|
17 |
+
web_search = DuckDuckGoSearchTool()
|
18 |
+
|
19 |
+
|
20 |
+
|
21 |
+
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
22 |
+
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
23 |
+
|
24 |
+
model = HfApiModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct")
|
25 |
+
|
26 |
+
|
27 |
class BasicAgent:
|
28 |
def __init__(self):
|
29 |
print("BasicAgent initialized.")
|
30 |
+
self.agent = CodeAgent(
|
31 |
+
model=model,
|
32 |
+
tools=[web_search],
|
33 |
+
max_steps=15,
|
34 |
+
verbosity_level=1,
|
35 |
+
grammar=None,
|
36 |
+
planning_interval=None,
|
37 |
+
name=None,
|
38 |
+
description=None,
|
39 |
+
)
|
40 |
+
|
41 |
def __call__(self, question: str) -> str:
|
42 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
43 |
+
answer = self.agent.run(question)
|
44 |
+
return answer
|
45 |
+
|
46 |
+
|
47 |
+
|
48 |
|
49 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
50 |
"""
|