Class WebSearchTool

java.lang.Object
dev.langchain4j.adaptiverag.WebSearchTool
All Implemented Interfaces:
Function<String,List<dev.langchain4j.rag.content.Content>>

public class WebSearchTool extends Object implements Function<String,List<dev.langchain4j.rag.content.Content>>
The `WebSearchTool` class provides a solution for performing web searches based on user queries. It implements the Function<String, List<Content>> interface to define how queries are processed and results are returned. The class utilizes an API key from Tavily to authenticate requests to their search engine.
Since:
1.0
Author:
Your Name (if applicable)
  • Constructor Details

    • WebSearchTool

      public WebSearchTool()
  • Method Details

    • apply

      public List<dev.langchain4j.rag.content.Content> apply(String query)
      Applies the query to a search engine and retrieves up to 3 results.
      Specified by:
      apply in interface Function<String,List<dev.langchain4j.rag.content.Content>>
      Parameters:
      query - The search query to be executed.
      Returns:
      A list of content items retrieved from the searchengine.