Spaces:
Sleeping
Sleeping
Update agent.py: refine final answer instructions and adjust BasicAgent model parameters
Browse files
agent.py
CHANGED
|
@@ -31,8 +31,9 @@ If you are asked for a number only answer with the number itself, without any ad
|
|
| 31 |
If you are asked for a string only answer with the string itself, without any additional text or formatting.
|
| 32 |
If you are asked for a list only answer with the list itself, without any additional text or formatting.
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
|
|
|
| 36 |
|
| 37 |
For example, if the question is "What is the capital of France?", you should answer:
|
| 38 |
FINAL ANSWER: Paris
|
|
@@ -43,8 +44,8 @@ FINAL ANSWER: 4
|
|
| 43 |
If the question is "What is 1 divided by 2, answer with 2 digits after the decimal point?", you should answer:
|
| 44 |
FINAL ANSWER: 0.50
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
"""
|
| 49 |
|
| 50 |
|
|
@@ -111,7 +112,7 @@ def wikipedia_page(title: str) -> str:
|
|
| 111 |
class BasicAgent:
|
| 112 |
def __init__(self):
|
| 113 |
model = OpenAIServerModel(
|
| 114 |
-
model_id="gpt-
|
| 115 |
api_key=os.getenv("OPENAI_API_KEY"),
|
| 116 |
temperature=0.0,
|
| 117 |
)
|
|
@@ -120,7 +121,7 @@ class BasicAgent:
|
|
| 120 |
visitor = VisitWebpageTool(max_output_length=4000)
|
| 121 |
wiki_search = WikipediaSearchTool()
|
| 122 |
self.agent = CodeAgent(
|
| 123 |
-
max_steps=
|
| 124 |
verbosity_level=0,
|
| 125 |
tools=[
|
| 126 |
search,
|
|
@@ -135,7 +136,6 @@ class BasicAgent:
|
|
| 135 |
additional_authorized_imports=["pandas", "numpy"],
|
| 136 |
use_structured_outputs_internally=True,
|
| 137 |
add_base_tools=True,
|
| 138 |
-
# final_answer_checks=[is_correct_format],
|
| 139 |
)
|
| 140 |
logging.info(
|
| 141 |
f"System prompt set for BasicAgent: {self.agent.memory.system_prompt}"
|
|
|
|
| 31 |
If you are asked for a string only answer with the string itself, without any additional text or formatting.
|
| 32 |
If you are asked for a list only answer with the list itself, without any additional text or formatting.
|
| 33 |
|
| 34 |
+
Think step by step. Report your thoughts.
|
| 35 |
+
Finish your answer with the following template:
|
| 36 |
+
FINAL ANSWER: [YOUR FINAL ANSWER].
|
| 37 |
|
| 38 |
For example, if the question is "What is the capital of France?", you should answer:
|
| 39 |
FINAL ANSWER: Paris
|
|
|
|
| 44 |
If the question is "What is 1 divided by 2, answer with 2 digits after the decimal point?", you should answer:
|
| 45 |
FINAL ANSWER: 0.50
|
| 46 |
|
| 47 |
+
If the quesion is "What is 10 * 10 with four digits after the decimal point?", you should answer:
|
| 48 |
+
FINAL ANSWER: 100.0000
|
| 49 |
"""
|
| 50 |
|
| 51 |
|
|
|
|
| 112 |
class BasicAgent:
|
| 113 |
def __init__(self):
|
| 114 |
model = OpenAIServerModel(
|
| 115 |
+
model_id="gpt-4o-mini",
|
| 116 |
api_key=os.getenv("OPENAI_API_KEY"),
|
| 117 |
temperature=0.0,
|
| 118 |
)
|
|
|
|
| 121 |
visitor = VisitWebpageTool(max_output_length=4000)
|
| 122 |
wiki_search = WikipediaSearchTool()
|
| 123 |
self.agent = CodeAgent(
|
| 124 |
+
max_steps=10,
|
| 125 |
verbosity_level=0,
|
| 126 |
tools=[
|
| 127 |
search,
|
|
|
|
| 136 |
additional_authorized_imports=["pandas", "numpy"],
|
| 137 |
use_structured_outputs_internally=True,
|
| 138 |
add_base_tools=True,
|
|
|
|
| 139 |
)
|
| 140 |
logging.info(
|
| 141 |
f"System prompt set for BasicAgent: {self.agent.memory.system_prompt}"
|