Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -223,10 +223,10 @@ def modulus(a: int, b: int) -> int:
|
|
| 223 |
|
| 224 |
@tool
|
| 225 |
def wiki_search(query: str) -> str:
|
| 226 |
-
"""Search Wikipedia for a query and return maximum
|
| 227 |
Args:
|
| 228 |
query: The search query."""
|
| 229 |
-
search_docs = WikipediaLoader(query=query, load_max_docs=
|
| 230 |
formatted_search_docs = "\n\n---\n\n".join(
|
| 231 |
[
|
| 232 |
f'<Document source="{doc.metadata["source"]}" page="{doc.metadata.get("page", "")}"/>\n{doc.page_content}\n</Document>'
|
|
@@ -252,7 +252,7 @@ tools = [
|
|
| 252 |
# analyze_python_code,
|
| 253 |
arvix_search,
|
| 254 |
wiki_search,
|
| 255 |
-
GoogleSearchAPIWrapper(k=
|
| 256 |
# DuckDuckGoSearchResults(),
|
| 257 |
]
|
| 258 |
###### state and behavior
|
|
@@ -285,15 +285,15 @@ def assistant(state: AgentState, llm_with_tools):
|
|
| 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
|
| 289 |
-
And you can use the relevant tools provided by the system. \n {file_info}\n. Make sure you try
|
| 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
|
| 297 |
|
| 298 |
return {"messages": [llm_with_tools.invoke([sys_msg] + state["messages"])], "input_file": state["input_file"]}
|
| 299 |
|
|
|
|
| 223 |
|
| 224 |
@tool
|
| 225 |
def wiki_search(query: str) -> str:
|
| 226 |
+
"""Search Wikipedia for a query and return maximum 10 results.
|
| 227 |
Args:
|
| 228 |
query: The search query."""
|
| 229 |
+
search_docs = WikipediaLoader(query=query, load_max_docs=10).load()
|
| 230 |
formatted_search_docs = "\n\n---\n\n".join(
|
| 231 |
[
|
| 232 |
f'<Document source="{doc.metadata["source"]}" page="{doc.metadata.get("page", "")}"/>\n{doc.page_content}\n</Document>'
|
|
|
|
| 252 |
# analyze_python_code,
|
| 253 |
arvix_search,
|
| 254 |
wiki_search,
|
| 255 |
+
GoogleSearchAPIWrapper(k=10).run,
|
| 256 |
# DuckDuckGoSearchResults(),
|
| 257 |
]
|
| 258 |
###### state and behavior
|
|
|
|
| 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 |
|