Skip to content

Commit 0bf1baf

Browse files
Add SearchApi plugin
1 parent bf5b87e commit 0bf1baf

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

.env.example

+4
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ AZURE_AI_SEARCH_SEARCH_OPTION_SELECT=
253253
GOOGLE_SEARCH_API_KEY=
254254
GOOGLE_CSE_ID=
255255

256+
# SearchApi
257+
#-----------------
258+
SEARCHAPI_API_KEY=
259+
256260
# SerpAPI
257261
#-----------------
258262
SERPAPI_API_KEY=

api/app/clients/tools/manifest.json

+13
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,19 @@
8282
}
8383
]
8484
},
85+
{
86+
"name": "SearchApi",
87+
"pluginKey": "searchapi",
88+
"description": "SearchApi is a robust real-time SERP API delivering structured data from a collection of search engines.",
89+
"icon": "https://www.searchapi.io/press/searchapi-logo-symbol-screen.png",
90+
"authConfig": [
91+
{
92+
"authField": "SEARCHAPI_API_KEY",
93+
"label": "SearchApi Private API Key",
94+
"description": "Private Key for SearchApi. Register at <a href='https://www.searchapi.io/'>SearchApi</a> to obtain a private key."
95+
}
96+
]
97+
},
8598
{
8699
"name": "Serpapi",
87100
"pluginKey": "serpapi",

api/app/clients/tools/util/handleTools.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { Tools } = require('librechat-data-provider');
22
const { ZapierToolKit } = require('langchain/agents');
33
const { Calculator } = require('langchain/tools/calculator');
4-
const { SerpAPI, ZapierNLAWrapper } = require('langchain/tools');
4+
const { SerpAPI, ZapierNLAWrapper, SearchApi } = require('langchain/tools');
55
const { createCodeExecutionTool, EnvVar } = require('@librechat/agents');
66
const { getUserPluginAuthValue } = require('~/server/services/PluginService');
77
const {
@@ -197,6 +197,16 @@ const loadTools = async ({
197197
options,
198198
});
199199
},
200+
searchapi: async () => {
201+
let apiKey = process.env.SEARCHAPI_API_KEY;
202+
if (!apiKey) {
203+
apiKey = await getUserPluginAuthValue(user, 'SEARCHAPI_API_KEY');
204+
}
205+
return new SearchApi(apiKey, {
206+
hl: 'en',
207+
gl: 'us',
208+
});
209+
},
200210
serpapi: async () => {
201211
let apiKey = process.env.SERPAPI_API_KEY;
202212
if (!apiKey) {

0 commit comments

Comments
 (0)