mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-10 17:00:11 +01:00
linting
This commit is contained in:
parent
7693240e21
commit
394b5aafb6
@ -3,14 +3,14 @@ import AnythingLLMIcon from "@/media/logo/anything-llm-icon.png";
|
|||||||
import GoogleSearchIcon from "./icons/google.png";
|
import GoogleSearchIcon from "./icons/google.png";
|
||||||
import SerperDotDevIcon from "./icons/serper.png";
|
import SerperDotDevIcon from "./icons/serper.png";
|
||||||
import BingSearchIcon from "./icons/bing.png";
|
import BingSearchIcon from "./icons/bing.png";
|
||||||
import SerplySearchIcon from "./icons/serply.png"
|
import SerplySearchIcon from "./icons/serply.png";
|
||||||
import { CaretUpDown, MagnifyingGlass, X } from "@phosphor-icons/react";
|
import { CaretUpDown, MagnifyingGlass, X } from "@phosphor-icons/react";
|
||||||
import SearchProviderItem from "./SearchProviderItem";
|
import SearchProviderItem from "./SearchProviderItem";
|
||||||
import {
|
import {
|
||||||
SerperDotDevOptions,
|
SerperDotDevOptions,
|
||||||
GoogleSearchOptions,
|
GoogleSearchOptions,
|
||||||
BingSearchOptions,
|
BingSearchOptions,
|
||||||
SerplySearchOptions
|
SerplySearchOptions,
|
||||||
} from "./SearchProviderOptions";
|
} from "./SearchProviderOptions";
|
||||||
|
|
||||||
const SEARCH_PROVIDERS = [
|
const SEARCH_PROVIDERS = [
|
||||||
|
@ -71,9 +71,12 @@ const SystemSettings = {
|
|||||||
try {
|
try {
|
||||||
if (update === "none") return null;
|
if (update === "none") return null;
|
||||||
if (
|
if (
|
||||||
!["google-search-engine", "serper-dot-dev", "bing-search", "serply-engine"].includes(
|
![
|
||||||
update
|
"google-search-engine",
|
||||||
)
|
"serper-dot-dev",
|
||||||
|
"bing-search",
|
||||||
|
"serply-engine",
|
||||||
|
].includes(update)
|
||||||
)
|
)
|
||||||
throw new Error("Invalid SERP provider.");
|
throw new Error("Invalid SERP provider.");
|
||||||
return String(update);
|
return String(update);
|
||||||
|
@ -221,7 +221,14 @@ const webBrowsing = {
|
|||||||
return `No information was found online for the search query.`;
|
return `No information was found online for the search query.`;
|
||||||
return JSON.stringify(searchResponse);
|
return JSON.stringify(searchResponse);
|
||||||
},
|
},
|
||||||
_serplyEngine: async function (query, language = "en", hl = "us", limit = 100, device_type = "desktop", proxy_location = "US") {
|
_serplyEngine: async function (
|
||||||
|
query,
|
||||||
|
language = "en",
|
||||||
|
hl = "us",
|
||||||
|
limit = 100,
|
||||||
|
device_type = "desktop",
|
||||||
|
proxy_location = "US"
|
||||||
|
) {
|
||||||
// query (str): The query to search for
|
// 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)
|
// 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]
|
// limit (int): The maximum number of results to return [10-100, defaults to 100]
|
||||||
@ -244,28 +251,29 @@ const webBrowsing = {
|
|||||||
q: query,
|
q: query,
|
||||||
language: language,
|
language: language,
|
||||||
hl,
|
hl,
|
||||||
gl: proxy_location.toUpperCase()
|
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,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
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((res) => res.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data?.message === "Unauthorized"){
|
if (data?.message === "Unauthorized") {
|
||||||
return { response: null, error: "Unauthorized. Please double check your AGENT_SERPLY_API_KEY" };
|
return {
|
||||||
|
response: null,
|
||||||
|
error:
|
||||||
|
"Unauthorized. Please double check your AGENT_SERPLY_API_KEY",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return { response: data, error: null}
|
return { response: data, error: null };
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
return { response: null, error: e.message };
|
return { response: null, error: e.message };
|
||||||
|
@ -773,7 +773,7 @@ async function dumpENV() {
|
|||||||
"AGENT_GSE_KEY",
|
"AGENT_GSE_KEY",
|
||||||
"AGENT_SERPER_DEV_KEY",
|
"AGENT_SERPER_DEV_KEY",
|
||||||
"AGENT_BING_SEARCH_API_KEY",
|
"AGENT_BING_SEARCH_API_KEY",
|
||||||
"AGENT_SERPLY_API_KEY"
|
"AGENT_SERPLY_API_KEY",
|
||||||
];
|
];
|
||||||
|
|
||||||
// Simple sanitization of each value to prevent ENV injection via newline or quote escaping.
|
// Simple sanitization of each value to prevent ENV injection via newline or quote escaping.
|
||||||
|
Loading…
Reference in New Issue
Block a user