Update app.py
Browse files
app.py
CHANGED
@@ -7,18 +7,15 @@ from agno.agent import Agent
|
|
7 |
from agno.tools.duckduckgo import DuckDuckGoTools
|
8 |
from agno.models.nvidia import Nvidia
|
9 |
|
10 |
-
|
11 |
-
# (Keep Constants as is)
|
12 |
# --- Constants ---
|
13 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
14 |
|
15 |
# --- Basic Agent Definition ---
|
16 |
-
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
17 |
class BasicAgent:
|
18 |
def __init__(self):
|
19 |
agent=Agent(
|
20 |
-
model=Nvidia(id="meta/llama-3.3-70b-instruct")
|
21 |
-
|
22 |
## 🚀 Gaia Taskmaster: The Ultimate Agent Efficiency Prompt! 🌍
|
23 |
|
24 |
You are a high-performance AI agent with a laser focus on completing Gaia tasks with maximum efficiency and precision. Think of yourself as a blend of a master strategist and a productivity guru—always optimizing, always delivering.
|
@@ -44,24 +41,15 @@ class BasicAgent:
|
|
44 |
tools=[DuckDuckGoTools()])
|
45 |
print("BasicAgent initialized.")
|
46 |
|
47 |
-
def do_web_search(self,question:str)->str:
|
48 |
-
"""
|
49 |
-
this would call an API or perform a search.
|
50 |
-
"""
|
51 |
-
print(f"Performing web search for: {question}")
|
52 |
-
# Example usage
|
53 |
-
answer=agent.print_response(
|
54 |
-
"Tell me about a breaking news story happening in Times Square.", stream=True
|
55 |
-
)
|
56 |
-
return {answer}
|
57 |
-
|
58 |
def __call__(self, question: str) -> str:
|
59 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
60 |
-
fixed_answer =
|
|
|
|
|
61 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
62 |
return fixed_answer
|
63 |
|
64 |
-
def run_and_submit_all(
|
65 |
"""
|
66 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
67 |
and displays the results.
|
@@ -86,7 +74,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
86 |
except Exception as e:
|
87 |
print(f"Error instantiating agent: {e}")
|
88 |
return f"Error initializing agent: {e}", None
|
89 |
-
# In the case of an app running as a hugging Face space, this link points toward your codebase (
|
90 |
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
91 |
print(agent_code)
|
92 |
|
@@ -181,7 +169,6 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
181 |
results_df = pd.DataFrame(results_log)
|
182 |
return status_message, results_df
|
183 |
|
184 |
-
|
185 |
# --- Build Gradio Interface using Blocks ---
|
186 |
with gr.Blocks() as demo:
|
187 |
gr.Markdown("# Basic Agent Evaluation Runner")
|
@@ -203,7 +190,6 @@ with gr.Blocks() as demo:
|
|
203 |
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
204 |
|
205 |
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
206 |
-
# Removed max_rows=10 from DataFrame constructor
|
207 |
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
208 |
|
209 |
run_button.click(
|
@@ -232,4 +218,5 @@ if __name__ == "__main__":
|
|
232 |
|
233 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
234 |
|
235 |
-
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
|
|
|
7 |
from agno.tools.duckduckgo import DuckDuckGoTools
|
8 |
from agno.models.nvidia import Nvidia
|
9 |
|
|
|
|
|
10 |
# --- Constants ---
|
11 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
12 |
|
13 |
# --- Basic Agent Definition ---
|
|
|
14 |
class BasicAgent:
|
15 |
def __init__(self):
|
16 |
agent=Agent(
|
17 |
+
model=Nvidia(id="meta/llama-3.3-70b-instruct"),
|
18 |
+
instructions='''
|
19 |
## 🚀 Gaia Taskmaster: The Ultimate Agent Efficiency Prompt! 🌍
|
20 |
|
21 |
You are a high-performance AI agent with a laser focus on completing Gaia tasks with maximum efficiency and precision. Think of yourself as a blend of a master strategist and a productivity guru—always optimizing, always delivering.
|
|
|
41 |
tools=[DuckDuckGoTools()])
|
42 |
print("BasicAgent initialized.")
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
def __call__(self, question: str) -> str:
|
45 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
46 |
+
fixed_answer = agent.print_response(
|
47 |
+
question, stream=True
|
48 |
+
)
|
49 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
50 |
return fixed_answer
|
51 |
|
52 |
+
def run_and_submit_all(profile: gr.OAuthProfile | None):
|
53 |
"""
|
54 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
55 |
and displays the results.
|
|
|
74 |
except Exception as e:
|
75 |
print(f"Error instantiating agent: {e}")
|
76 |
return f"Error initializing agent: {e}", None
|
77 |
+
# In the case of an app running as a hugging Face space, this link points toward your codebase ( useful for others so please keep it public)
|
78 |
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
79 |
print(agent_code)
|
80 |
|
|
|
169 |
results_df = pd.DataFrame(results_log)
|
170 |
return status_message, results_df
|
171 |
|
|
|
172 |
# --- Build Gradio Interface using Blocks ---
|
173 |
with gr.Blocks() as demo:
|
174 |
gr.Markdown("# Basic Agent Evaluation Runner")
|
|
|
190 |
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
191 |
|
192 |
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
|
|
193 |
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
194 |
|
195 |
run_button.click(
|
|
|
218 |
|
219 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
220 |
|
221 |
+
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
222 |
+
demo.launch(debug=True, share=False)
|