Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,17 +7,38 @@ import pandas as pd
|
|
| 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 |
print("BasicAgent initialized.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
def __call__(self, question: str) -> str:
|
| 17 |
-
print(f"Agent received question (first 50 chars): {question
|
| 18 |
-
|
| 19 |
-
print(f"Agent returning
|
| 20 |
-
return
|
| 21 |
|
| 22 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 23 |
"""
|
|
|
|
| 7 |
# (Keep Constants as is)
|
| 8 |
# --- Constants ---
|
| 9 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 10 |
+
agent_description = "You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string."
|
| 11 |
|
| 12 |
# --- Basic Agent Definition ---
|
| 13 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 14 |
class BasicAgent:
|
| 15 |
def __init__(self):
|
| 16 |
print("BasicAgent initialized.")
|
| 17 |
+
final_answer = FinalAnswerTool()
|
| 18 |
+
visit_webpage = VisitWebpageTool()
|
| 19 |
+
web_search = DuckDuckGoSearchTool()
|
| 20 |
+
model = HfApiModel(
|
| 21 |
+
max_tokens=2096,
|
| 22 |
+
temperature=0.5,
|
| 23 |
+
model_id='Qwen/Qwen2.5-Coder-32B-Instruct', custom_role_conversions=None,
|
| 24 |
+
)
|
| 25 |
+
self.agent = CodeAgent(
|
| 26 |
+
model=model,
|
| 27 |
+
tools=[visit_webpage, web_search, final_answer],
|
| 28 |
+
max_steps=10,
|
| 29 |
+
verbosity_level=1,
|
| 30 |
+
grammar=None,
|
| 31 |
+
planning_interval=None,
|
| 32 |
+
name=None,
|
| 33 |
+
description=agent_description,
|
| 34 |
+
add_base_tools=True,
|
| 35 |
+
prompt_templates=prompt_templates
|
| 36 |
+
)
|
| 37 |
def __call__(self, question: str) -> str:
|
| 38 |
+
print(f"Agent received question (first 50 chars): {question}")
|
| 39 |
+
answer = self.agent.run(question)
|
| 40 |
+
print(f"Agent returning answer: {answer}")
|
| 41 |
+
return answer
|
| 42 |
|
| 43 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 44 |
"""
|