Download tools.py from cricketAIAgent/cricketQuestionAnswering: direct link, hf CLI and curl.
- Browser
- Download file 701 Bytes
-
https://huggingface.co/spaces/cricketAIAgent/cricketQuestionAnswering/resolve/main/tools.py
- Command line
-
hf download hf://spaces/cricketAIAgent/cricketQuestionAnswering/tools.py
-
curl -L -o tools.py https://huggingface.co/spaces/cricketAIAgent/cricketQuestionAnswering/resolve/main/tools.py
701 Bytes
| from tavily import TavilyClient | |
| from os import getenv | |
| from dotenv import load_dotenv | |
| import mysql.connector | |
| load_dotenv() | |
| conn = mysql.connector.connect( | |
| host=getenv('MYSQL_HOST'), | |
| user=getenv('MYSQL_USER'), | |
| password=getenv('MYSQL_PASSWORD'), | |
| database=getenv('MYSQL_DATABASE') | |
| ) | |
| load_dotenv() | |
| tavily_client = TavilyClient(api_key=getenv('TAVILY_API')) | |
| def searchTool(question:str) -> dict: | |
| response = tavily_client.search(question) | |
| return response | |
| def sqlQuery(query:str): | |
| cursor = conn.cursor() | |
| cursor.execute(query) | |
| result = cursor.fetchall() | |
| return result | |
| if __name__ == "__main__": | |
| print(searchTool("How to create a new branch in git?")) | |