Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -25,20 +25,22 @@ class BasicAgent:
|
|
25 |
weather_info_tool = WeatherInfoTool()
|
26 |
|
27 |
# Create agent
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
# planning_interval=3 # Enable planning every 3 steps
|
35 |
-
#)
|
36 |
|
37 |
def __call__(self, question: str) -> str:
|
|
|
|
|
|
|
|
|
38 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
39 |
-
answer = self.agent.
|
40 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
41 |
-
return answer
|
42 |
|
43 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
44 |
"""
|
|
|
25 |
weather_info_tool = WeatherInfoTool()
|
26 |
|
27 |
# Create agent
|
28 |
+
self.agent= CodeAgent(
|
29 |
+
tools=[weather_info_tool, search_tool],
|
30 |
+
model=model,
|
31 |
+
add_base_tools=True, # Add any additional base tools
|
32 |
+
planning_interval=3 # Enable planning every 3 steps
|
33 |
+
)
|
|
|
|
|
34 |
|
35 |
def __call__(self, question: str) -> str:
|
36 |
+
prompt = """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.
|
37 |
+
|
38 |
+
QUESTION:
|
39 |
+
"""
|
40 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
41 |
+
answer = self.agent.run(prompt + question)
|
42 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
43 |
+
return answer.replace("FINAL ANSWER:", "").strip()
|
44 |
|
45 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
46 |
"""
|