Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -61,7 +61,7 @@ def media_tool(file_path: str) -> str:
|
|
| 61 |
def internet_search_tool(search_query: str) -> str:
|
| 62 |
"""Does a google search with using the input as the search query. Returns a long batch of textual information related to the query."""
|
| 63 |
search_tool = DuckDuckGoSearchTool()
|
| 64 |
-
result = search_tool(
|
| 65 |
return result
|
| 66 |
|
| 67 |
@tool
|
|
@@ -78,7 +78,7 @@ def webscraper_tool(url: str) -> str:
|
|
| 78 |
@tool
|
| 79 |
def read_excel_tool(file_path: str) -> str:
|
| 80 |
"""Returns the contents of an Excel file as a Pandas dataframe."""
|
| 81 |
-
df = pd.read_excel(
|
| 82 |
return df
|
| 83 |
|
| 84 |
def agent_node(state: OrderState) -> OrderState:
|
|
@@ -116,16 +116,20 @@ def interactive_tools_node(state: OrderState) -> OrderState:
|
|
| 116 |
tool_args = tool_call["args"]
|
| 117 |
|
| 118 |
if tool_name == "wikipedia_search_tool":
|
| 119 |
-
print(str(tool_args))
|
| 120 |
page = wikipedia.page(tool_args.get("title"), auto_suggest=False)
|
| 121 |
response = page.content[:3000]
|
| 122 |
elif tool_name == "media_tool":
|
| 123 |
-
print(str(tool_args))
|
| 124 |
response = "This tool hasn't been implemented yet. Please return 0 if the task cannot be solved without knowing the contents of this file."
|
| 125 |
elif tool_name == "internet_search_tool":
|
|
|
|
|
|
|
| 126 |
search_tool = DuckDuckGoSearchTool()
|
| 127 |
response = search_tool(question)[:3000]
|
| 128 |
elif tool_name == "webscraper_tool":
|
|
|
|
|
|
|
| 129 |
response = requests.get(url, stream=True)
|
| 130 |
if response.status_code == 200:
|
| 131 |
soup = BeautifulSoup(response.content, 'html.parser')
|
|
@@ -134,6 +138,8 @@ def interactive_tools_node(state: OrderState) -> OrderState:
|
|
| 134 |
else:
|
| 135 |
response = Exception(f"Failed to retrieve the webpage. Status code: {response.status_code}")
|
| 136 |
elif tool_name == "read_excel_tool":
|
|
|
|
|
|
|
| 137 |
df = pd.read_excel(path, engine = "openpyxl")
|
| 138 |
response = df
|
| 139 |
|
|
|
|
| 61 |
def internet_search_tool(search_query: str) -> str:
|
| 62 |
"""Does a google search with using the input as the search query. Returns a long batch of textual information related to the query."""
|
| 63 |
search_tool = DuckDuckGoSearchTool()
|
| 64 |
+
result = search_tool(search_query)
|
| 65 |
return result
|
| 66 |
|
| 67 |
@tool
|
|
|
|
| 78 |
@tool
|
| 79 |
def read_excel_tool(file_path: str) -> str:
|
| 80 |
"""Returns the contents of an Excel file as a Pandas dataframe."""
|
| 81 |
+
df = pd.read_excel(file_path, engine = "openpyxl")
|
| 82 |
return df
|
| 83 |
|
| 84 |
def agent_node(state: OrderState) -> OrderState:
|
|
|
|
| 116 |
tool_args = tool_call["args"]
|
| 117 |
|
| 118 |
if tool_name == "wikipedia_search_tool":
|
| 119 |
+
print(f"called wikipedia with {str(tool_args)}")
|
| 120 |
page = wikipedia.page(tool_args.get("title"), auto_suggest=False)
|
| 121 |
response = page.content[:3000]
|
| 122 |
elif tool_name == "media_tool":
|
| 123 |
+
print(f"called media with {str(tool_args)}")
|
| 124 |
response = "This tool hasn't been implemented yet. Please return 0 if the task cannot be solved without knowing the contents of this file."
|
| 125 |
elif tool_name == "internet_search_tool":
|
| 126 |
+
print(f"called internet with {str(tool_args)}")
|
| 127 |
+
question = tool_args.get("search_query")
|
| 128 |
search_tool = DuckDuckGoSearchTool()
|
| 129 |
response = search_tool(question)[:3000]
|
| 130 |
elif tool_name == "webscraper_tool":
|
| 131 |
+
print(f"called webscraper with {str(tool_args)}")
|
| 132 |
+
url = tool_args.get("url")
|
| 133 |
response = requests.get(url, stream=True)
|
| 134 |
if response.status_code == 200:
|
| 135 |
soup = BeautifulSoup(response.content, 'html.parser')
|
|
|
|
| 138 |
else:
|
| 139 |
response = Exception(f"Failed to retrieve the webpage. Status code: {response.status_code}")
|
| 140 |
elif tool_name == "read_excel_tool":
|
| 141 |
+
print(f"called excel with {str(tool_args)}")
|
| 142 |
+
path = tool_args.get("file_path")
|
| 143 |
df = pd.read_excel(path, engine = "openpyxl")
|
| 144 |
response = df
|
| 145 |
|