Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,9 @@ 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"
|
@@ -12,12 +15,28 @@ 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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."
|
19 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
20 |
-
|
|
|
21 |
|
22 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
23 |
"""
|
|
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
|
7 |
+
from smolagents import DuckDuckGoSearchTool, CodeAgent, WikipediaSearchTool, GoogleSearchTool, FinalAnswerTool, InferenceClientModel
|
8 |
+
|
9 |
+
|
10 |
# (Keep Constants as is)
|
11 |
# --- Constants ---
|
12 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
|
15 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
16 |
class BasicAgent:
|
17 |
def __init__(self):
|
18 |
+
with open("prompts.yaml", 'r') as stream:
|
19 |
+
prompt_templates = yaml.safe_load(stream)
|
20 |
+
|
21 |
+
model = InferenceClientModel(
|
22 |
+
max_tokens=200,
|
23 |
+
temperature=0,
|
24 |
+
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
|
25 |
+
)
|
26 |
+
self.agent = CodeAgent(
|
27 |
+
model=model,
|
28 |
+
tools=[DuckDuckGoSearchTool(), WikipediaSearchTool(),FinalAnswerTool()],
|
29 |
+
prompt_templates=prompt_templates,
|
30 |
+
additional_authorized_imports=['datetime','numpy','pandas'],
|
31 |
+
max_steps=3
|
32 |
+
)
|
33 |
+
print("Agent initialized.")
|
34 |
def __call__(self, question: str) -> str:
|
35 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
36 |
fixed_answer = "This is a default answer."
|
37 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
38 |
+
agent_answer=self.agent(question)
|
39 |
+
return agent_answer
|
40 |
|
41 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
42 |
"""
|