Using additional search parameters as keywords arguments from Langchain

I’m using the Tavily Search Langchain integration to use Tavily as a tool (function) to be called by an agent.

I want (the agent to be able) to provide additional search parameters such as “topic” and “days” as keyword arguments as is described in Github for TavilyClient:

"Methods:

  • search(query, **kwargs)
    • Performs a Tavily Search query and returns the response as a well-structured dict.
    • Additional parameters** can be provided as keyword arguments (detailed below). The keyword arguments supported by this method are: search_depth, topic, days, max_results, include_domains, exclude_domains, include_answer, include_raw_content, include_images, include_image_descriptions.
      … "

However, it seems that the tool function exposed to the agent only takes a query string as argument. Is it possible to also pass additional search parameters somehow?

1 Like

I ended up modifying the Tavily LangChain integration code to include the additional parameters.

Hi James,

Thank you for reaching out!

The Tavily Search tool in LangChain does indeed support additional parameters beyond just the query string. These parameters can be passed as keyword arguments when invoking the search method, as described in the TavilyClient documentation.

Refer to the LangChain Tavily Search integration documentation for detailed information about passing additional parameters like topic, days, and max_results.

Best,
May