Update app.py
Browse filesAt top, added dependencies. In __init__, added model, final_answers, and agent
app.py
CHANGED
@@ -3,6 +3,11 @@ import gradio as gr
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# (Keep Constants as is)
|
8 |
# --- Constants ---
|
@@ -12,6 +17,25 @@ 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]}...")
|
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
+
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
7 |
+
import datetime
|
8 |
+
import requests
|
9 |
+
import pytz
|
10 |
+
from tools.final_answer import FinalAnswerTool
|
11 |
|
12 |
# (Keep Constants as is)
|
13 |
# --- Constants ---
|
|
|
17 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
18 |
class BasicAgent:
|
19 |
def __init__(self):
|
20 |
+
model = HfApiModel(
|
21 |
+
max_tokens=2096,
|
22 |
+
temperature=0.5,
|
23 |
+
# model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
|
24 |
+
model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud',
|
25 |
+
custom_role_conversions=None,
|
26 |
+
)
|
27 |
+
final_answer = FinalAnswerTool()
|
28 |
+
agent = CodeAgent(
|
29 |
+
model=model,
|
30 |
+
tools=[final_answer, get_current_time_in_timezone, add_ints_to_str, image_generation_tool], ## add your tools here (don't remove final answer)
|
31 |
+
max_steps=6,
|
32 |
+
verbosity_level=1,
|
33 |
+
grammar=None,
|
34 |
+
planning_interval=None,
|
35 |
+
name=None,
|
36 |
+
description=None,
|
37 |
+
prompt_templates=prompt_templates
|
38 |
+
)
|
39 |
print("BasicAgent initialized.")
|
40 |
def __call__(self, question: str) -> str:
|
41 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|