Skip to content

Commit

Permalink
Add SearchApi plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastjanPrachovskij committed Oct 14, 2024
1 parent bf5b87e commit 0bf1baf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
13 changes: 13 additions & 0 deletions api/app/clients/tools/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href='https://www.searchapi.io/'>SearchApi</a> to obtain a private key."
}
]
},
{
"name": "Serpapi",
"pluginKey": "serpapi",
Expand Down
12 changes: 11 additions & 1 deletion api/app/clients/tools/util/handleTools.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 0bf1baf

Please sign in to comment.