Spaces:
Sleeping
Sleeping
| import os | |
| from langchain.tools import tool | |
| def web_search(query: str, max_results: int = 3) -> str: | |
| """ | |
| Search the web for current information about a grocery or gourmet food product. | |
| Use this when the user asks about recent news, current pricing, availability, | |
| updated nutritional info, or anything unlikely to be in the product review corpus. | |
| Input should be a specific product name or question. | |
| """ | |
| from tavily import TavilyClient | |
| client = TavilyClient(api_key=os.getenv("TAVILY_API_KEY")) | |
| results = client.search(query, max_results=max_results) | |
| snippets = [r["content"] for r in results.get("results", [])] | |
| return "\n\n".join(snippets) if snippets else "No results found." |