79271835

Date: 2024-12-11 13:16:05
Score: 0.5
Natty:
Report link

You can customise how/when/why TavilySearchResults calls search tool by setting the description param.

The default description used to determine whether to call search tool is:

description: str = 'A search engine optimized for comprehensive, accurate, and trusted results. Useful for when you need to answer questions about current events. Input should be a search query.'

Obviously not so great, you can change it to what you need like:

custom_description = """
Only use the search tool if:
1. The question requires current information
2. The information cannot be derived from common knowledge
3. The question indicated that the answer must be a comprehensive, accurate, and trusted result
"""

search = TavilySearchResults(
    max_results=2, 
    description=custom_description
)

You'll then notice that TavilySearchResults won't make query tool calls easily anymore unless input question meets the newly customised conditions.

API reference: https://python.langchain.com/api_reference/community/tools/langchain_community.tools.tavily_search.tool.TavilySearchResults.html#langchain_community.tools.tavily_search.tool.TavilySearchResults.description

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Licong