Spaces:
Configuration error
Configuration error
Commit
·
d3455e3
1
Parent(s):
5b5993d
Improve tool use order
Browse files- custom_tools.py +7 -6
custom_tools.py
CHANGED
|
@@ -141,10 +141,11 @@ def wiki_search(query: str) -> str:
|
|
| 141 |
def sum_excel_cols(file_name: str, column_names: List[str]) -> float:
|
| 142 |
"""
|
| 143 |
Sum the values of specified columns in a pandas DataFrame read from an Excel file.
|
|
|
|
| 144 |
|
| 145 |
Args:
|
| 146 |
file_name (str): The path to the Excel file.
|
| 147 |
-
column_names (List[str]): A list of column names to sum.
|
| 148 |
|
| 149 |
Returns:
|
| 150 |
float: The sum of the specified columns.
|
|
@@ -221,12 +222,12 @@ def read_file_content(file_name: str) -> str:
|
|
| 221 |
str: The content of the file, or a detailed error message.
|
| 222 |
"""
|
| 223 |
download_state = download_file(file_name)
|
| 224 |
-
if download_state == f"Success downloading {file_name}":
|
| 225 |
-
file_content = read_file(file_name)
|
| 226 |
-
|
| 227 |
-
return file_content
|
| 228 |
-
|
| 229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
@tool
|
| 231 |
def analyse_youtube_video(url: str, video_question: str):
|
| 232 |
"""
|
|
|
|
| 141 |
def sum_excel_cols(file_name: str, column_names: List[str]) -> float:
|
| 142 |
"""
|
| 143 |
Sum the values of specified columns in a pandas DataFrame read from an Excel file.
|
| 144 |
+
This tool should NEVER be called if you're not sure which columns to sum. If you need to retrieve column names, you must do so from the output of the read_file_content tool.
|
| 145 |
|
| 146 |
Args:
|
| 147 |
file_name (str): The path to the Excel file.
|
| 148 |
+
column_names (List[str]): A list of column names to sum. Column names must first be retrieved from the output of the read_file_content tool.
|
| 149 |
|
| 150 |
Returns:
|
| 151 |
float: The sum of the specified columns.
|
|
|
|
| 222 |
str: The content of the file, or a detailed error message.
|
| 223 |
"""
|
| 224 |
download_state = download_file(file_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
|
| 226 |
+
if download_state.startswith("Success") or "already exists" in download_state:
|
| 227 |
+
return read_file(file_name)
|
| 228 |
+
else:
|
| 229 |
+
return download_state # Return the error message from downloading
|
| 230 |
+
|
| 231 |
@tool
|
| 232 |
def analyse_youtube_video(url: str, video_question: str):
|
| 233 |
"""
|