Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -284,16 +284,37 @@ def assistant(state: AgentState, llm_with_tools):
|
|
| 284 |
# Use the appropriate loader tool (e.g., excel_loader_tool for Excel files, pdf_loader_tool for PDFs) to download and process it automatically.
|
| 285 |
# Do not ask the user to upload files."""
|
| 286 |
previous_message = state["messages"]
|
| 287 |
-
sys_msg = SystemMessage(content=f"""
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 297 |
|
| 298 |
return {"messages": [llm_with_tools.invoke([sys_msg] + state["messages"])], "input_file": state["input_file"]}
|
| 299 |
|
|
|
|
| 284 |
# Use the appropriate loader tool (e.g., excel_loader_tool for Excel files, pdf_loader_tool for PDFs) to download and process it automatically.
|
| 285 |
# Do not ask the user to upload files."""
|
| 286 |
previous_message = state["messages"]
|
| 287 |
+
sys_msg = SystemMessage(content=f"""
|
| 288 |
+
You are a helpful assistant tasked with answering questions using a set of tools.
|
| 289 |
+
If the tool is not available, you can try to find the information online. You can also use your own knowledge to answer the question.
|
| 290 |
+
You need to provide a step-by-step explanation of how you arrived at the answer.
|
| 291 |
+
INSTRUCTIONS:
|
| 292 |
+
1. Read the question carefully.
|
| 293 |
+
2. Identify the tools available to you.
|
| 294 |
+
3. Use the tools to find the answer.
|
| 295 |
+
4. If the answer is not found using the tools, search online.
|
| 296 |
+
5. Provide a step-by-step explanation of your process.
|
| 297 |
+
6. 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. Finish your answer with the following template:
|
| 298 |
+
- FINAL ANSWER: [YOUR FINAL ANSWER].
|
| 299 |
+
|
| 300 |
+
==========================
|
| 301 |
+
Here is a few examples showing you how to answer the question step by step.
|
| 302 |
+
|
| 303 |
+
Question 1: What was the volume in m^3 of the fish bag that was calculated in the University of Leicester paper "Can Hiccup Supply Enough Fish to Maintain a Dragon’s Diet?"
|
| 304 |
+
Steps:
|
| 305 |
+
1. Searched '"Can Hiccup Supply Enough Fish to Maintain a Dragon’s Diet?"' on Google.
|
| 306 |
+
2. Opened "Can Hiccup Supply Enough Fish to Maintain a Dragon’s Diet?" at https://journals.le.ac.uk/ojs1/index.php/jist/article/view/733.
|
| 307 |
+
3. Clicked "PDF".
|
| 308 |
+
4. Found the calculations for the volume of the fish bag and noted them.
|
| 309 |
+
Tools:
|
| 310 |
+
1. GoogleSearchAPIWrapper(k=10).run
|
| 311 |
+
2. PDF access
|
| 312 |
+
|
| 313 |
+
- FINAL ANSWER: 0.1777
|
| 314 |
+
|
| 315 |
+
==========================
|
| 316 |
+
|
| 317 |
+
Now, please answer the following question step by step.""")
|
| 318 |
|
| 319 |
return {"messages": [llm_with_tools.invoke([sys_msg] + state["messages"])], "input_file": state["input_file"]}
|
| 320 |
|