Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import requests
|
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, FinalAnswerTool, HfApiModel
|
| 7 |
-
|
| 8 |
|
| 9 |
model = HfApiModel(
|
| 10 |
model_id="Qwen/Qwen3-235B-A22B",
|
|
@@ -19,10 +19,28 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 19 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 20 |
class BasicAgent:
|
| 21 |
def __init__(self):
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
print("BasicAgent initialized.")
|
|
|
|
| 24 |
def __call__(self, question: str) -> str:
|
| 25 |
-
print(f"Agent received question (first 50 chars): {question
|
| 26 |
fixed_answer = self.agent.run(question)
|
| 27 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 28 |
return fixed_answer
|
|
|
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, FinalAnswerTool, HfApiModel
|
| 7 |
+
from smolagents import DuckDuckGoSearchTool, LiteLLMModel, PythonInterpreterTool, CodeAgent, SpeechToTextTool, WikipediaSearchTool, VisitWebpageTool
|
| 8 |
|
| 9 |
model = HfApiModel(
|
| 10 |
model_id="Qwen/Qwen3-235B-A22B",
|
|
|
|
| 19 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 20 |
class BasicAgent:
|
| 21 |
def __init__(self):
|
| 22 |
+
system_prompt = """
|
| 23 |
+
You are a general AI assistant.
|
| 24 |
+
I will ask you a question.
|
| 25 |
+
Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
|
| 26 |
+
YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
|
| 27 |
+
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.
|
| 28 |
+
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.
|
| 29 |
+
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.
|
| 30 |
+
"""
|
| 31 |
+
self.agent = CodeAgent(tools=[
|
| 32 |
+
DuckDuckGoSearchTool(),
|
| 33 |
+
PythonInterpreterTool(
|
| 34 |
+
authorized_imports=AUTHORIZED_IMPORTS,
|
| 35 |
+
),
|
| 36 |
+
SpeechToTextTool(),
|
| 37 |
+
WikipediaSearchTool(),
|
| 38 |
+
VisitWebpageTool()
|
| 39 |
+
], model=model)
|
| 40 |
print("BasicAgent initialized.")
|
| 41 |
+
self.agent.prompt_templates["system_prompt"] = self.agent.prompt_templates["system_prompt"] + system_prompt
|
| 42 |
def __call__(self, question: str) -> str:
|
| 43 |
+
print(f"Agent received question (first 50 chars): {question}...")
|
| 44 |
fixed_answer = self.agent.run(question)
|
| 45 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 46 |
return fixed_answer
|