RuaZhou commited on
Commit
3067aee
·
verified ·
1 Parent(s): 01e5355

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -31
app.py CHANGED
@@ -310,37 +310,25 @@ def assistant(state: AgentState, llm_with_tools):
310
  # Do not ask the user to upload files."""
311
  previous_message = state["messages"]
312
  sys_msg = SystemMessage(content=f"""
313
- You are a helpful assistant tasked with answering questions using a set of tools.
314
- 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.
315
- You need to provide a step-by-step explanation of how you arrived at the answer.
316
- INSTRUCTIONS:
317
- 1. Read the question carefully.
318
- 2. Identify the tools available to you.
319
- 3. Use the tools to find the answer.
320
- 4. If the answer is not found using the tools, search online.
321
- 5. Provide a step-by-step explanation of your process.
322
- 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: [YOUR FINAL ANSWER].
323
- 7. Then you must return the content of [YOUR FINAL ANSWER] without brackets, conclude, and keep it as brief as possible, to a few words, as the previous line #6 said.
324
-
325
- ==========================
326
- Here is a few examples showing you how to answer the question step by step.
327
-
328
- 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?"
329
- Steps:
330
- 1. Searched '"Can Hiccup Supply Enough Fish to Maintain a Dragon’s Diet?"' on Google.
331
- 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.
332
- 3. Clicked "PDF".
333
- 4. Found the calculations for the volume of the fish bag and noted them.
334
- Tools:
335
- 1. GoogleSearchAPIWrapper(k=10).run
336
- 2. PDF access
337
- 3. web_search
338
-
339
- - FINAL ANSWER: 0.1777
340
-
341
- ==========================
342
-
343
- Now, please answer the following question step by step.""")
344
 
345
  return {"messages": [llm_with_tools.invoke([sys_msg] + state["messages"])], "input_file": state["input_file"]}
346
 
 
310
  # Do not ask the user to upload files."""
311
  previous_message = state["messages"]
312
  sys_msg = SystemMessage(content=f"""
313
+ You are a helpful assistant tasked with answering questions using a set of tools.
314
+
315
+ Instructions:
316
+ 1. Read the question carefully.
317
+ 2. Use any available tools first.
318
+ 3. If tools do not help, search online.
319
+ 4. Use your own knowledge if all else fails.
320
+ 5. Think step-by-step and explain your reasoning.
321
+ 6. Extract the final answer from your reasoning and put it in the following format:
322
+
323
+ FINAL ANSWER: <your answer here> ← use this line exactly
324
+
325
+ Rules for FINAL ANSWER:
326
+ - If it's a number, write the digits without commas or units unless specified.
327
+ - If it's a string, do not repeat it, do not include articles or abbreviations, write digits in words if requested. If it is a string of number, use the number first.
328
+ - If it's a list, separate items with commas, and follow the above rules per item.
329
+ - DO NOT include square brackets around the answer.
330
+
331
+ Finally, in a new line, ONLY print the FINAL ANSWER, nothing else.""")
 
 
 
 
 
 
 
 
 
 
 
 
332
 
333
  return {"messages": [llm_with_tools.invoke([sys_msg] + state["messages"])], "input_file": state["input_file"]}
334