Skip to content

serpapi/Auto-GPT-SerpApi-Plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auto-GPT SerpApi Search Plugin

This search plugin integrates SerpApi into Auto-GPT, allowing users to choose a broader range of search engines supported by SerpApi, and get much more information than the default search engine in Auto-GPT.

Key Features:

  • Perform search queries with engine of your choice supported by SerpApi, including Google, Bing, Baidu, Yahoo, DuckDuckGo, Yandex and so on.

Installation

  • Install Auto-GPT

    If you haven't done so, follow the installation instructions given by Auto-GPT to install it.

  • Download the plugins folder from the root of Auto-GPT directory

    To download it directly from your Auto-GPT directory, you can run this command on Linux or MacOS:

    curl -L -o ./plugins/Auto-GPT-SerpApi-Plugin.zip https://github.com/SerpApi/Auto-GPT-SerpApi-Plugin/archive/refs/heads/master.zip

    Or in PowerShell:

    Invoke-WebRequest -Uri "https://github.com/SerpApi/Auto-GPT-SerpApi-Plugin/archive/refs/heads/master.zip" -OutFile "./plugins/Auto-GPT-SerpApi-Plugin.zip"
  • Append the following configuration settings to the .env file within AutoGPT, see Configuration for details:

    ################################################################################
    ### SerpApi
    ################################################################################
    
    SERPAPI_API_KEY=
    SERPAPI_ENGINE=
    SERPAPI_NO_CACHE=
    SERPAPI_RESULT_FILTER=
  • In the .env file, search for ALLOWLISTED_PLUGINS and add this plugin:

    ################################################################################
    ### ALLOWLISTED PLUGINS
    ################################################################################
    
    #ALLOWLISTED_PLUGINS - Sets the listed plugins that are allowed (Example: plugin1,plugin2,plugin3)
    ALLOWLISTED_PLUGINS=AutoGPTSerpApiSearch

Configuration

Variable Required Description
SERPAPI_API_KEY Yes Your API key for the SerpApi. You can obtain a key by following the steps:
- Sign up for a free account at SerpApi.
- Navigate to the Dashboard page and find "Your Private API Key".
SERPAPI_ENGINE No The engine you want to use for web searches performed by Auto-GPT.
- You can find valid engine values from SerpApi Documentation.
- Typical values are: google, bing, baidu, yahoo, duckduckgo, yandex, ...
- The default value is google if not set.
SERPAPI_NO_CACHE No Set to true if you want to force SerpApi to fetch the results even if a cached version is already present. Defaulted to false.
SERPAPI_RESULT_FILTER No SerpApi can return JSON results that is too large for Auto-GPT to process. This variable allows you to pick certain fields from the returned JSON to reduce the size. Defaulted to organic_results(title,link,snippet). See Result Filter for details.

Result Filter

This plugin supports filtering fields up to a depth of 2. The syntax of the filter is <t>(<s>,<s>,...),<t>(<s>,<s>,...),..., where <t> is top level field, and <s> is second level field. <s> is optional. Set to <none> to disable filtering. Here are some examples:

  • <none>
    • Filter disabled. The whole JSON output will be the input of the current command.
  • organic_results:
    • Pick only organic_results from the top level fields of JSON output.
  • organic_results, knowledge_graph:
    • Pick only organic_results and knowledge_graph from the top level fields of JSON output.
  • organic_results(title, link, snippet):
    • Pick only organic_results from the top level fields of JSON output.
    • Pick only title, link and snippet from organic_results.
      • If organic_results is an object, applies to itself.
      • If organic_results is an array, applies to all its containing objects.
      • Otherwise, the second level filter is ignored.
  • organic_results(title,link,snippet), knowledge_graph(website, description):
    • Pick only organic_results and knowledge_graph from the top level fields of JSON output.
    • Pick only title, link and snippet from organic_results.
      • If organic_results is an object, applies to itself.
      • If organic_results is an array, applies to all its containing objects.
      • Otherwise, the second level filter is ignored.
    • Pick only website, and description from knowledge_graph.
      • If knowledge_graph is an object, applies to itself.
      • If knowledge_graph is an array, applies to all its containing objects.
      • Otherwise, the second level filter is ignored.

Filter Tuning

Sometimes too much input can make Auto-GPT confused, failing to extract the correct information. Other than organic_results, SerpApi extracts more fields such as answer_box, knowledge_graph and related_questions, which are more straightforward and easier to make sense of, but not always present. You can always check if those exist through the Dashboard and add/remove fields to the filter according to your needs.

Example

Here's an example to let Auto-GPT search on Google and get information from "Answer Box" and "Knowledge Graph"

SERPAPI_API_KEY=your_api_key
SERPAPI_ENGINE=google
SERPAPI_RESULT_FILTER=answer_box,knowledge_graph

How it works

When SERPAPI_API_KEY is set. The plugin will add a new command serpapi_search to Auto-GPT. The google command will be intercepted to use serpapi_search instead. Auto-GPT can also use serpapi_search command directly. Therefore, all web searches performed by Auto-GPT are routed to SerpApi.

About

An Auto-GPT Plugin that connects SerpApi to Auto-GPT

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages