Spaces:
Running
Running
Create src/search.py
Browse files- src/search.py +9 -0
src/search.py
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from tavily import TavilyClient
|
2 |
+
|
3 |
+
def perform_search(query):
|
4 |
+
try:
|
5 |
+
client = TavilyClient(api_key=os.environ.get("TAVILY_API_KEY"))
|
6 |
+
result = client.search(query, include_answer=True)
|
7 |
+
return result["answer"]
|
8 |
+
except Exception as e:
|
9 |
+
return f"Error: {str(e)}"
|