Spaces:
Sleeping
Sleeping
do not modify system_prompt
Browse files- agent.py +0 -2
- app.py +3 -1
- prompts.py +2 -32
agent.py
CHANGED
|
@@ -5,7 +5,6 @@ from smolagents import (
|
|
| 5 |
#WebSearchTool,
|
| 6 |
OpenAIServerModel,
|
| 7 |
)
|
| 8 |
-
from prompts import prompt_templates
|
| 9 |
import os
|
| 10 |
from tools import tools
|
| 11 |
#model = InferenceClientModel(
|
|
@@ -36,7 +35,6 @@ manager_agent = CodeAgent(
|
|
| 36 |
max_steps=6,
|
| 37 |
verbosity_level=1,
|
| 38 |
additional_authorized_imports=["time", "numpy", "pandas", "wikipedia", "xlrd"],
|
| 39 |
-
prompt_templates=prompt_templates,
|
| 40 |
name="manager_agent",
|
| 41 |
description="Manages the web search agent. This is a code agent, it can return code blocks.",
|
| 42 |
)
|
|
|
|
| 5 |
#WebSearchTool,
|
| 6 |
OpenAIServerModel,
|
| 7 |
)
|
|
|
|
| 8 |
import os
|
| 9 |
from tools import tools
|
| 10 |
#model = InferenceClientModel(
|
|
|
|
| 35 |
max_steps=6,
|
| 36 |
verbosity_level=1,
|
| 37 |
additional_authorized_imports=["time", "numpy", "pandas", "wikipedia", "xlrd"],
|
|
|
|
| 38 |
name="manager_agent",
|
| 39 |
description="Manages the web search agent. This is a code agent, it can return code blocks.",
|
| 40 |
)
|
app.py
CHANGED
|
@@ -5,6 +5,7 @@ import inspect
|
|
| 5 |
import pandas as pd
|
| 6 |
from agent import manager_agent
|
| 7 |
from time import sleep
|
|
|
|
| 8 |
# --- Constants ---
|
| 9 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 10 |
|
|
@@ -15,7 +16,8 @@ class BasicAgent:
|
|
| 15 |
self.agent = manager_agent
|
| 16 |
def __call__(self, question: str) -> str:
|
| 17 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 18 |
-
|
|
|
|
| 19 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 20 |
return fixed_answer
|
| 21 |
|
|
|
|
| 5 |
import pandas as pd
|
| 6 |
from agent import manager_agent
|
| 7 |
from time import sleep
|
| 8 |
+
from prompts import prompt
|
| 9 |
# --- Constants ---
|
| 10 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 11 |
|
|
|
|
| 16 |
self.agent = manager_agent
|
| 17 |
def __call__(self, question: str) -> str:
|
| 18 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 19 |
+
prompt_question = f"{prompt}\nQuestion: {question}"
|
| 20 |
+
fixed_answer = self.agent.run(prompt_question)
|
| 21 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 22 |
return fixed_answer
|
| 23 |
|
prompts.py
CHANGED
|
@@ -1,37 +1,7 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
prompt_templates = PromptTemplates(
|
| 4 |
-
system_prompt = """You are a general AI assistant. You will be asked a question.
|
| 5 |
Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
|
| 6 |
YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
|
| 7 |
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.
|
| 8 |
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.
|
| 9 |
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.
|
| 10 |
-
|
| 11 |
-
Other rules you should always follow to solve your task:
|
| 12 |
-
- Use only variables that you have defined!
|
| 13 |
-
- Always use the right arguments for the tools.
|
| 14 |
-
- Take care to not chain too many sequential tool calls in the same code block, especially when the output format is unpredictable. For instance, a call to search has an unpredictable return format, so do not have another tool call that depends on its output in the same block: rather output results with print() to use them in the next block.
|
| 15 |
-
- Call a tool only when needed, and never re-do a tool call that you previously did with the exact same parameters.
|
| 16 |
-
- Never create any notional variables in our code, as having these in your logs will derail you from the true variables.
|
| 17 |
-
- You can use imports in your code, but only from the following list of modules: {{authorized_imports}}
|
| 18 |
-
- The state persists between code executions: so if in one step you've created variables or imported modules, these will all persist.
|
| 19 |
-
- Don't give up! You're in charge of solving the task, not providing directions to solve it.
|
| 20 |
-
""",
|
| 21 |
-
|
| 22 |
-
managed_agent = ManagedAgentPromptTemplate(
|
| 23 |
-
task = "You are a general AI assistant. You will be asked a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. ",
|
| 24 |
-
report = "FINAL ANSWER: [YOUR FINAL ANSWER].",
|
| 25 |
-
),
|
| 26 |
-
|
| 27 |
-
planning = PlanningPromptTemplate(
|
| 28 |
-
initial_plan = "Think step by step. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. ",
|
| 29 |
-
update_plan_pre_messages = "",
|
| 30 |
-
update_plan_post_messages = "",
|
| 31 |
-
),
|
| 32 |
-
|
| 33 |
-
final_answer = FinalAnswerPromptTemplate(
|
| 34 |
-
pre_messages = "",
|
| 35 |
-
post_messages = "",
|
| 36 |
-
)
|
| 37 |
-
)
|
|
|
|
| 1 |
+
prompt = """You are a general AI assistant. You will be asked a question.
|
|
|
|
|
|
|
|
|
|
| 2 |
Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
|
| 3 |
YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
|
| 4 |
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.
|
| 5 |
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.
|
| 6 |
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.
|
| 7 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|