TavilyWebSearch / src /search.py
hgdgng's picture
Update src/search.py
c9d3192 verified
raw
history blame contribute delete
302 Bytes
import os
from tavily import TavilyClient
def perform_search(query):
try:
client = TavilyClient(api_key=os.environ.get("TAVILY_API_KEY"))
result = client.search(query, include_answer=True)
return result["answer"]
except Exception as e:
return f"Error: {str(e)}"