RuaZhou commited on
Commit
5d5d5f6
·
verified ·
1 Parent(s): 77437e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -10
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"""You are an agent that must use tools for computations or unknown info. Think step-by-step: 1. Analyze question. 2. Call tools if needed. 3. Summarize.
288
- Please make sure you call GoogleSearchAPIWrapper tool or wiki_search tool multiple times if needed for verification or depth.
289
- And you can use the relevant tools provided by the system. \n {file_info}\n. Make sure you try each tools at least six times with different searching strategy and conclude the answer.
290
- I will ask you a question. Please return your answer with the following template: [YOUR FINAL ANSWER] without brackets.
291
- YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
292
- 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.
293
- 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.
294
- 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.
295
- Please return YOUR FINAL ANSWER only, without explanation, keep it brief within a single word or several words.
296
- If you infer a result, you should also conclude result YOUR FINAL ANSWER within a single word or several words""")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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