Spaces:
Sleeping
Sleeping
EtienneB
commited on
Commit
·
6ae13c3
1
Parent(s):
de96b54
updated tools
Browse files- old-tools.py +25 -0
- tools.py +2 -28
old-tools.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
@tool
|
3 |
+
def web_search(query: str) -> str:
|
4 |
+
"""Performs a DuckDuckGo search for the given query and returns the results.
|
5 |
+
|
6 |
+
Args:
|
7 |
+
query: The search query.
|
8 |
+
|
9 |
+
Returns:
|
10 |
+
The top search results as a string.
|
11 |
+
"""
|
12 |
+
try:
|
13 |
+
if not query or not query.strip():
|
14 |
+
return "Error: Search query cannot be empty"
|
15 |
+
|
16 |
+
search_tool = DuckDuckGoSearchRun()
|
17 |
+
results = search_tool.invoke(query.strip())
|
18 |
+
|
19 |
+
# Clean up the results a bit
|
20 |
+
if len(results) > 2000: # Truncate very long results
|
21 |
+
results = results[:2000] + "... (truncated)"
|
22 |
+
|
23 |
+
return results
|
24 |
+
except Exception as e:
|
25 |
+
return f"Error performing web search: {str(e)}"
|
tools.py
CHANGED
@@ -9,6 +9,7 @@ import cv2
|
|
9 |
import pandas
|
10 |
import pytz
|
11 |
import torch
|
|
|
12 |
from langchain.schema import HumanMessage
|
13 |
from langchain_community.document_loaders import (
|
14 |
ArxivLoader, AssemblyAIAudioTranscriptLoader, WikipediaLoader)
|
@@ -17,9 +18,8 @@ from langchain_community.document_loaders.parsers import LanguageParser
|
|
17 |
from langchain_community.tools import DuckDuckGoSearchRun
|
18 |
from langchain_core.tools import tool
|
19 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
20 |
-
from pytube import YouTube
|
21 |
from langchain_tavily import TavilySearch
|
22 |
-
from
|
23 |
|
24 |
|
25 |
@tool
|
@@ -230,32 +230,6 @@ def exponential(x: Union[int, float]) -> Union[float, str]:
|
|
230 |
except Exception as e:
|
231 |
return f"Error in exponential calculation: {str(e)}"
|
232 |
|
233 |
-
"""
|
234 |
-
@tool
|
235 |
-
def web_search(query: str) -> str:
|
236 |
-
"""Performs a DuckDuckGo search for the given query and returns the results.
|
237 |
-
|
238 |
-
Args:
|
239 |
-
query: The search query.
|
240 |
-
|
241 |
-
Returns:
|
242 |
-
The top search results as a string.
|
243 |
-
"""
|
244 |
-
try:
|
245 |
-
if not query or not query.strip():
|
246 |
-
return "Error: Search query cannot be empty"
|
247 |
-
|
248 |
-
search_tool = DuckDuckGoSearchRun()
|
249 |
-
results = search_tool.invoke(query.strip())
|
250 |
-
|
251 |
-
# Clean up the results a bit
|
252 |
-
if len(results) > 2000: # Truncate very long results
|
253 |
-
results = results[:2000] + "... (truncated)"
|
254 |
-
|
255 |
-
return results
|
256 |
-
except Exception as e:
|
257 |
-
return f"Error performing web search: {str(e)}"
|
258 |
-
"""
|
259 |
|
260 |
@tool
|
261 |
def roman_calculator_converter(value1: int, value2: int, oper: str) -> str:
|
|
|
9 |
import pandas
|
10 |
import pytz
|
11 |
import torch
|
12 |
+
from bs4 import BeautifulSoup
|
13 |
from langchain.schema import HumanMessage
|
14 |
from langchain_community.document_loaders import (
|
15 |
ArxivLoader, AssemblyAIAudioTranscriptLoader, WikipediaLoader)
|
|
|
18 |
from langchain_community.tools import DuckDuckGoSearchRun
|
19 |
from langchain_core.tools import tool
|
20 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
|
|
21 |
from langchain_tavily import TavilySearch
|
22 |
+
from pytube import YouTube
|
23 |
|
24 |
|
25 |
@tool
|
|
|
230 |
except Exception as e:
|
231 |
return f"Error in exponential calculation: {str(e)}"
|
232 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
|
234 |
@tool
|
235 |
def roman_calculator_converter(value1: int, value2: int, oper: str) -> str:
|