Class GoogleSearchAPIWrapper

java.lang.Object
com.hw.langchain.utilities.GoogleSearchAPIWrapper

public class GoogleSearchAPIWrapper extends Object
Wrapper for Google Search API.
  1. Create an API key
  2. Setup Custom Search Engine to search the entire web
  3. Enable the Custom Search API
Author:
HamaWhite
  • Method Details

    • run

      public String run(String query)
      Run a query through Google Search and parse the results.
      Parameters:
      query - The search query to be executed.
      Returns:
      A string containing snippets from the Google Search results, joined with spaces.
    • results

      public List<Map<String,String>> results(String query, int num)
      Run query through GoogleSearch and return metadata.
      Parameters:
      query - The query to search for.
      num - The number of results to return.
      Returns:
      A list of dictionaries with the following keys:
      • snippet - The description of the result.
      • title - The title of the result.
      • link - The link to the result.
    • builder

      public static GoogleSearchAPIWrapper.Builder builder()