θΏ™ζ˜―indexlocζδΎ›ηš„ζœεŠ‘οΌŒδΈθ¦θΎ“ε…₯任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docker/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,7 @@ GID='1000'
# AGENT_SERPER_DEV_KEY=

#------ Bing Search ----------- https://portal.azure.com/
# AGENT_BING_SEARCH_API_KEY=
# AGENT_BING_SEARCH_API_KEY=

#------ Serply.io ----------- https://serply.io/
# AGENT_SERPLY_API_KEY=
2 changes: 1 addition & 1 deletion docker/HOW_TO_USE_DOCKER.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ mintplexlabs/anythingllm;
<tr>
<td> Docker Compose</td>
<td>

version: '3.8'
services:
anythingllm:
Expand All @@ -116,6 +115,7 @@ mintplexlabs/anythingllm;
- TTS_PROVIDER=native
- PASSWORDMINCHAR=8
- AGENT_SERPER_DEV_KEY="SERPER DEV API KEY"
- AGENT_SERPLY_API_KEY="Serply.io API KEY"
volumes:
- anythingllm_storage:/app/server/storage
restart: always
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,38 @@ export function BingSearchOptions({ settings }) {
</>
);
}

export function SerplySearchOptions({ settings }) {
return (
<>
<p className="text-sm text-white/60 my-2">
You can get a free API key{" "}
<a
href="https://serply.io"
target="_blank"
rel="noreferrer"
className="text-blue-300 underline"
>
from Serply.io.
</a>
</p>
<div className="flex gap-x-4">
<div className="flex flex-col w-60">
<label className="text-white text-sm font-semibold block mb-4">
API Key
</label>
<input
type="password"
name="env::AgentSerplyApiKey"
className="border-none bg-zinc-900 text-white placeholder:text-white/20 text-sm rounded-lg focus:border-white block w-full p-2.5"
placeholder="Serply API Key"
defaultValue={settings?.AgentSerplyApiKey ? "*".repeat(20) : ""}
required={true}
autoComplete="off"
spellCheck={false}
/>
</div>
</div>
</>
);
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import AnythingLLMIcon from "@/media/logo/anything-llm-icon.png";
import GoogleSearchIcon from "./icons/google.png";
import SerperDotDevIcon from "./icons/serper.png";
import BingSearchIcon from "./icons/bing.png";
import SerplySearchIcon from "./icons/serply.png"
import { CaretUpDown, MagnifyingGlass, X } from "@phosphor-icons/react";
import SearchProviderItem from "./SearchProviderItem";
import {
SerperDotDevOptions,
GoogleSearchOptions,
BingSearchOptions,
SerplySearchOptions
} from "./SearchProviderOptions";

const SEARCH_PROVIDERS = [
Expand Down Expand Up @@ -44,6 +46,14 @@ const SEARCH_PROVIDERS = [
description:
"Web search powered by the Bing Search API. Free for 1000 queries per month.",
},
{
name: "Serply.io",
value: "serply-engine",
logo: SerplySearchIcon,
options: (settings) => <SerplySearchOptions settings={settings} />,
description:
"Serply.io web-search. Free account with a 100 calls/month forever.",
},
];

export default function AgentWebSearchSelection({
Expand Down
3 changes: 3 additions & 0 deletions server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,6 @@ TTS_PROVIDER="native"

#------ Bing Search ----------- https://portal.azure.com/
# AGENT_BING_SEARCH_API_KEY=

#------ Serply.io ----------- https://serply.io/
# AGENT_SERPLY_API_KEY=
3 changes: 2 additions & 1 deletion server/models/systemSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const SystemSettings = {
try {
if (update === "none") return null;
if (
!["google-search-engine", "serper-dot-dev", "bing-search"].includes(
!["google-search-engine", "serper-dot-dev", "bing-search", "serply-engine"].includes(
update
)
)
Expand Down Expand Up @@ -176,6 +176,7 @@ const SystemSettings = {
AgentGoogleSearchEngineKey: process.env.AGENT_GSE_KEY || null,
AgentSerperApiKey: process.env.AGENT_SERPER_DEV_KEY || null,
AgentBingSearchApiKey: process.env.AGENT_BING_SEARCH_API_KEY || null,
AgentSerplyApiKey: process.env.AGENT_SERPLY_API_KEY || null,
};
},

Expand Down
69 changes: 69 additions & 0 deletions server/utils/agents/aibitat/plugins/web-browsing.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ const webBrowsing = {
case "bing-search":
engine = "_bingWebSearch";
break;
case "serply-engine":
engine = "_serplyEngine";
break;
default:
engine = "_googleSearchEngine";
}
Expand Down Expand Up @@ -218,6 +221,72 @@ const webBrowsing = {
return `No information was found online for the search query.`;
return JSON.stringify(searchResponse);
},
_serplyEngine: async function (query, language = "en", hl = "us", limit = 100, device_type = "desktop", proxy_location = "US") {
// query (str): The query to search for
// hl (str): Host Language code to display results in (reference https://developers.google.com/custom-search/docs/xml_results?hl=en#wsInterfaceLanguages)
// limit (int): The maximum number of results to return [10-100, defaults to 100]
// device_type: get results based on desktop/mobile (defaults to desktop)

if (!process.env.AGENT_SERPLY_API_KEY) {
this.super.introspect(
`${this.caller}: I can't use Serply.io searching because the user has not defined the required API key.\nVisit: https://serply.io to create the API key for free.`
);
return `Search is disabled and no content was found. This functionality is disabled because the user has not set it up yet.`;
}

this.super.introspect(
`${this.caller}: Using Serply to search for "${
query.length > 100 ? `${query.slice(0, 100)}...` : query
}"`
);

const params = new URLSearchParams({
q: query,
language: language,
hl,
gl: proxy_location.toUpperCase()
})
const url = `https://api.serply.io/v1/search/${params.toString()}`
const { response, error } = await fetch(
url,
{
method: "GET",
headers: {
"X-API-KEY": process.env.AGENT_SERPLY_API_KEY,
"Content-Type": "application/json",
"User-Agent": "anything-llm",
"X-Proxy-Location": proxy_location,
"X-User-Agent": device_type
}
}
)
.then((res) => res.json())
.then((data) => {
if (data?.message === "Unauthorized"){
return { response: null, error: "Unauthorized. Please double check your AGENT_SERPLY_API_KEY" };
}
return { response: data, error: null}
})
.catch((e) => {
return { response: null, error: e.message };
});
if (error)
return `There was an error searching for content. ${error}`;

const data = [];
response.results?.forEach((searchResult) => {
const { title, link, description } = searchResult;
data.push({
title,
link,
snippet: description,
});
});

if (data.length === 0)
return `No information was found online for the search query.`;
return JSON.stringify(data);
},
});
},
};
Expand Down
5 changes: 5 additions & 0 deletions server/utils/helpers/updateENV.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,10 @@ const KEY_MAPPING = {
envKey: "AGENT_BING_SEARCH_API_KEY",
checks: [],
},
AgentSerplyApiKey: {
envKey: "AGENT_SERPLY_API_KEY",
checks: [],
},

// TTS/STT Integration ENVS
TextToSpeechProvider: {
Expand Down Expand Up @@ -769,6 +773,7 @@ async function dumpENV() {
"AGENT_GSE_KEY",
"AGENT_SERPER_DEV_KEY",
"AGENT_BING_SEARCH_API_KEY",
"AGENT_SERPLY_API_KEY"
];

// Simple sanitization of each value to prevent ENV injection via newline or quote escaping.
Expand Down