Spaces:
Sleeping
Sleeping
Download server/src/tools/__init__.py from VashuTheGreat2/ML-Learner: direct link, hf CLI and curl.
- Browser
- Download file 745 Bytes
-
https://huggingface.co/spaces/VashuTheGreat2/ML-Learner/resolve/main/server/src/tools/__init__.py
- Command line
-
hf download hf://spaces/VashuTheGreat2/ML-Learner/server/src/tools/__init__.py
-
curl -L -o __init__.py https://huggingface.co/spaces/VashuTheGreat2/ML-Learner/resolve/main/server/src/tools/__init__.py
745 Bytes
| import logging | |
| from src.utils.asyncHandler import asyncHandler | |
| from langchain_tavily import TavilySearch | |
| from src.constants import SEARCH_MAX_RESULT, SEARCH_TOPIC | |
| from langchain.tools import tool | |
| from config.app_config import app_config | |
| async def web_search(query: str): | |
| """Use this tool to search the web for relevant information. Input should be a search query string.""" | |
| logging.info(f"Performing web search for query: {query}") | |
| tavily_client = TavilySearch( | |
| tavily_api_key=app_config.tavily_api_key, | |
| max_results=SEARCH_MAX_RESULT, | |
| topic=SEARCH_TOPIC | |
| ) | |
| results = await tavily_client.ainvoke(query) | |
| return results | |
| class WebSearch: | |
| def __init__(self): | |
| self.search = web_search |