Skip to content

Commit e1b83de

Browse files
Add SearchApi plugin
1 parent 9ec665d commit e1b83de

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ AZURE_AI_SEARCH_SEARCH_OPTION_SELECT=
233233
GOOGLE_SEARCH_API_KEY=
234234
GOOGLE_CSE_ID=
235235

236+
# SearchApi
237+
#-----------------
238+
SEARCHAPI_API_KEY=
239+
236240
# SerpAPI
237241
#-----------------
238242
SERPAPI_API_KEY=

api/app/clients/tools/manifest.json

Lines changed: 13 additions & 0 deletions
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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { ZapierToolKit } = require('langchain/agents');
22
const { Calculator } = require('langchain/tools/calculator');
33
const { WebBrowser } = require('langchain/tools/webbrowser');
4-
const { SerpAPI, ZapierNLAWrapper } = require('langchain/tools');
4+
const { SerpAPI, ZapierNLAWrapper, SearchApi } = require('langchain/tools');
55
const { OpenAIEmbeddings } = require('langchain/embeddings/openai');
66
const { getUserPluginAuthValue } = require('~/server/services/PluginService');
77
const {
@@ -208,6 +208,17 @@ const loadTools = async ({
208208
browser.description_for_model = browser.description;
209209
return browser;
210210
},
211+
searchapi: async () => {
212+
let apiKey = process.env.SEARCHAPI_API_KEY;
213+
if (!apiKey) {
214+
apiKey = await getUserPluginAuthValue(user, 'SEARCHAPI_API_KEY');
215+
}
216+
return new SearchApi(apiKey, {
217+
location: 'New York,United States',
218+
hl: 'en',
219+
gl: 'us',
220+
});
221+
},
211222
serpapi: async () => {
212223
let apiKey = process.env.SERPAPI_API_KEY;
213224
if (!apiKey) {

0 commit comments

Comments
 (0)