Update app.py
Browse files
app.py
CHANGED
@@ -3,16 +3,50 @@ 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"
|
|
|
|
|
|
|
10 |
|
11 |
# --- Basic Agent Definition ---
|
12 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
13 |
class BasicAgent:
|
14 |
def __init__(self):
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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."
|
@@ -41,6 +75,8 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
41 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
42 |
try:
|
43 |
agent = BasicAgent()
|
|
|
|
|
44 |
except Exception as e:
|
45 |
print(f"Error instantiating agent: {e}")
|
46 |
return f"Error initializing agent: {e}", None
|
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
+
#--SM
|
7 |
+
from smolagents import OpenAIServerModel,CodeAgent,DuckDuckGoSearchTool,VisitWebpageTool,HfApiModel,load_tool,tool
|
8 |
+
from smolagents.utils import encode_image_base64, make_image_url
|
9 |
+
import datetime
|
10 |
+
import requests
|
11 |
+
import pytz
|
12 |
+
import yaml
|
13 |
+
from tools.final_answer import FinalAnswerTool
|
14 |
+
|
15 |
+
|
16 |
|
17 |
# (Keep Constants as is)
|
18 |
# --- Constants ---
|
19 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
20 |
+
#--SM
|
21 |
+
#model = HfApiModel("Qwen/Qwen2.5-Coder-32B-Instruct", provider="together", max_tokens=8096)
|
22 |
+
model = HfApiModel("deepseek-ai/DeepSeek-R1", provider="together", max_tokens=8096),
|
23 |
|
24 |
# --- Basic Agent Definition ---
|
25 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
26 |
class BasicAgent:
|
27 |
def __init__(self):
|
28 |
+
agent = CodeAgent(
|
29 |
+
model,
|
30 |
+
tools=[
|
31 |
+
GoogleSearchTool(provider="serper"),
|
32 |
+
VisitWebpageTool(),
|
33 |
+
],
|
34 |
+
additional_authorized_imports=[
|
35 |
+
"geopandas",
|
36 |
+
"plotly",
|
37 |
+
"shapely",
|
38 |
+
"json",
|
39 |
+
"pandas",
|
40 |
+
"numpy",
|
41 |
+
],
|
42 |
+
name="agent",
|
43 |
+
description="agent desc",
|
44 |
+
planning_interval=5,
|
45 |
+
verbosity_level=2,
|
46 |
+
max_steps=15,
|
47 |
+
)
|
48 |
+
print("BasicAgent initialized.")
|
49 |
+
|
50 |
def __call__(self, question: str) -> str:
|
51 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
52 |
fixed_answer = "This is a default answer."
|
|
|
75 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
76 |
try:
|
77 |
agent = BasicAgent()
|
78 |
+
#--SM
|
79 |
+
|
80 |
except Exception as e:
|
81 |
print(f"Error instantiating agent: {e}")
|
82 |
return f"Error initializing agent: {e}", None
|