Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -53,7 +53,7 @@ def get_ref_content(path: str) -> str | object:
|
|
| 53 |
elif path.endswith('mp3'):
|
| 54 |
file = librosa.load(path)
|
| 55 |
elif path.endswith('xlsx') or path.endswith('xls'):
|
| 56 |
-
file = pd.read_excel(path)
|
| 57 |
else:
|
| 58 |
with open(path, "rb") as f:
|
| 59 |
file = f.read()
|
|
@@ -63,7 +63,7 @@ def search_web(topic: str) -> str:
|
|
| 63 |
"""Retrieves information about the topic."""
|
| 64 |
results = DuckDuckGoSearchRun().invoke(topic)
|
| 65 |
if results:
|
| 66 |
-
return "\n\n".join([doc.text for doc in results[:
|
| 67 |
else:
|
| 68 |
return "No matching content found."
|
| 69 |
|
|
@@ -110,7 +110,7 @@ extract_text_tool = Tool(
|
|
| 110 |
)
|
| 111 |
|
| 112 |
tools = [get_file_path_tool, get_content_tool, extract_text_tool, search_web_tool]
|
| 113 |
-
chat_with_tools = chat.bind_tools(tools, parallel_tool_calls=
|
| 114 |
|
| 115 |
|
| 116 |
# Generate the AgentState and Agent graph
|
|
@@ -148,7 +148,7 @@ system_prompt = SystemMessage(
|
|
| 148 |
YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. \
|
| 149 |
If you are asked for a number, use only digits in your final answer. Don't use comma nor brackets to write your number neither use units such as $ or percent sign unless specified otherwise. \
|
| 150 |
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. \
|
| 151 |
-
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
|
| 152 |
If the question refers to an external content and there is no reference file attached, perform a web search and retrieve relevant information from the internet. \
|
| 153 |
Make sure that each final answer is preceded with 'FINAL ANSWER:' and is short: it should contain a number (without full stop at the end), a string (without full stop at the end) or a comma-separated list (without full stops at the end), nothing else. "
|
| 154 |
)
|
|
|
|
| 53 |
elif path.endswith('mp3'):
|
| 54 |
file = librosa.load(path)
|
| 55 |
elif path.endswith('xlsx') or path.endswith('xls'):
|
| 56 |
+
file = pd.read_excel(path).to_json()
|
| 57 |
else:
|
| 58 |
with open(path, "rb") as f:
|
| 59 |
file = f.read()
|
|
|
|
| 63 |
"""Retrieves information about the topic."""
|
| 64 |
results = DuckDuckGoSearchRun().invoke(topic)
|
| 65 |
if results:
|
| 66 |
+
return "\n\n".join([doc.text for doc in results[:2]])
|
| 67 |
else:
|
| 68 |
return "No matching content found."
|
| 69 |
|
|
|
|
| 110 |
)
|
| 111 |
|
| 112 |
tools = [get_file_path_tool, get_content_tool, extract_text_tool, search_web_tool]
|
| 113 |
+
chat_with_tools = chat.bind_tools(tools, parallel_tool_calls=True)
|
| 114 |
|
| 115 |
|
| 116 |
# Generate the AgentState and Agent graph
|
|
|
|
| 148 |
YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. \
|
| 149 |
If you are asked for a number, use only digits in your final answer. Don't use comma nor brackets to write your number neither use units such as $ or percent sign unless specified otherwise. \
|
| 150 |
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. \
|
| 151 |
+
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.\
|
| 152 |
If the question refers to an external content and there is no reference file attached, perform a web search and retrieve relevant information from the internet. \
|
| 153 |
Make sure that each final answer is preceded with 'FINAL ANSWER:' and is short: it should contain a number (without full stop at the end), a string (without full stop at the end) or a comma-separated list (without full stops at the end), nothing else. "
|
| 154 |
)
|