diff --git a/.env.example b/.env.example index 0b56317ff318..97d07e122ff0 100644 --- a/.env.example +++ b/.env.example @@ -253,6 +253,10 @@ AZURE_AI_SEARCH_SEARCH_OPTION_SELECT= GOOGLE_SEARCH_API_KEY= GOOGLE_CSE_ID= +# SearchApi +#----------------- +SEARCHAPI_API_KEY= + # SerpAPI #----------------- SERPAPI_API_KEY= diff --git a/api/app/clients/tools/manifest.json b/api/app/clients/tools/manifest.json index c8beed976fe8..22b79a7cb983 100644 --- a/api/app/clients/tools/manifest.json +++ b/api/app/clients/tools/manifest.json @@ -82,6 +82,19 @@ } ] }, + { + "name": "SearchApi", + "pluginKey": "searchapi", + "description": "SearchApi is a robust real-time SERP API delivering structured data from a collection of search engines.", + "icon": "https://www.searchapi.io/press/searchapi-logo-symbol-screen.png", + "authConfig": [ + { + "authField": "SEARCHAPI_API_KEY", + "label": "SearchApi Private API Key", + "description": "Private Key for SearchApi. Register at SearchApi to obtain a private key." + } + ] + }, { "name": "Serpapi", "pluginKey": "serpapi", diff --git a/api/app/clients/tools/util/handleTools.js b/api/app/clients/tools/util/handleTools.js index 7a7be797d56e..5acf82cbe6eb 100644 --- a/api/app/clients/tools/util/handleTools.js +++ b/api/app/clients/tools/util/handleTools.js @@ -1,7 +1,7 @@ const { Tools } = require('librechat-data-provider'); const { ZapierToolKit } = require('langchain/agents'); const { Calculator } = require('langchain/tools/calculator'); -const { SerpAPI, ZapierNLAWrapper } = require('langchain/tools'); +const { SerpAPI, ZapierNLAWrapper, SearchApi } = require('langchain/tools'); const { createCodeExecutionTool, EnvVar } = require('@librechat/agents'); const { getUserPluginAuthValue } = require('~/server/services/PluginService'); const { @@ -197,6 +197,16 @@ const loadTools = async ({ options, }); }, + searchapi: async () => { + let apiKey = process.env.SEARCHAPI_API_KEY; + if (!apiKey) { + apiKey = await getUserPluginAuthValue(user, 'SEARCHAPI_API_KEY'); + } + return new SearchApi(apiKey, { + hl: 'en', + gl: 'us', + }); + }, serpapi: async () => { let apiKey = process.env.SERPAPI_API_KEY; if (!apiKey) {