feat: Add option to enable internet search by default
This commit is contained in:
parent
84e123bf38
commit
48b7a2824a
@ -77,6 +77,9 @@
|
||||
},
|
||||
"googleDomain": {
|
||||
"label": "نطاق جوجل"
|
||||
},
|
||||
"searchOnByDefault": {
|
||||
"label": "تفعيل البحث على الإنترنت بشكل افتراضي"
|
||||
}
|
||||
},
|
||||
"system": {
|
||||
|
@ -74,6 +74,9 @@
|
||||
"braveApi": {
|
||||
"label": "Brave API Nøgle",
|
||||
"placeholder": "Indtast din Brave API nøgle"
|
||||
},
|
||||
"searchOnByDefault": {
|
||||
"label": "Internet Søgning TIL som standard"
|
||||
}
|
||||
},
|
||||
"system": {
|
||||
|
@ -74,6 +74,9 @@
|
||||
"braveApi": {
|
||||
"label": "Brave API-Schlüssel",
|
||||
"placeholder": "Geben Sie Ihren Brave API-Schlüssel ein"
|
||||
},
|
||||
"searchOnByDefault": {
|
||||
"label": "Internetsuche standardmäßig aktiviert"
|
||||
}
|
||||
},
|
||||
"system": {
|
||||
|
@ -77,6 +77,9 @@
|
||||
},
|
||||
"googleDomain": {
|
||||
"label": "Google Domain"
|
||||
},
|
||||
"searchOnByDefault": {
|
||||
"label": "Internet Search ON by default"
|
||||
}
|
||||
},
|
||||
"system": {
|
||||
|
@ -74,6 +74,9 @@
|
||||
"braveApi": {
|
||||
"label": "Clave API de Brave",
|
||||
"placeholder": "Ingrese su clave API de Brave"
|
||||
},
|
||||
"searchOnByDefault": {
|
||||
"label": "Búsqueda en Internet activada por defecto"
|
||||
}
|
||||
},
|
||||
"system": {
|
||||
|
@ -71,6 +71,9 @@
|
||||
"braveApi": {
|
||||
"label": "کلید API بریو",
|
||||
"placeholder": "کلید API بریو خود را وارد کنید"
|
||||
},
|
||||
"searchOnByDefault": {
|
||||
"label": "جستجوی اینترنتی به صورت پیشفرض فعال باشد"
|
||||
}
|
||||
},
|
||||
"system": {
|
||||
|
@ -74,6 +74,9 @@
|
||||
"braveApi": {
|
||||
"label": "Clé API Brave",
|
||||
"placeholder": "Entrez votre clé API Brave"
|
||||
},
|
||||
"searchOnByDefault": {
|
||||
"label": "Recherche Internet activée par défaut"
|
||||
}
|
||||
},
|
||||
"system": {
|
||||
|
@ -74,6 +74,9 @@
|
||||
"braveApi": {
|
||||
"label": "Chiave API Brave",
|
||||
"placeholder": "Inserisci la tua chiave API Brave"
|
||||
},
|
||||
"searchOnByDefault": {
|
||||
"label": "Ricerca Internet attiva per impostazione predefinita"
|
||||
}
|
||||
},
|
||||
"system": {
|
||||
|
@ -77,6 +77,9 @@
|
||||
"braveApi": {
|
||||
"label": "Brave APIキー",
|
||||
"placeholder": "Brave APIキーを入力してください"
|
||||
},
|
||||
"searchOnByDefault": {
|
||||
"label": "デフォルトでインターネット検索をオンにする"
|
||||
}
|
||||
},
|
||||
"system": {
|
||||
|
@ -77,6 +77,9 @@
|
||||
"braveApi": {
|
||||
"label": "Brave API 키",
|
||||
"placeholder": "Brave API 키를 입력하세요"
|
||||
},
|
||||
"searchOnByDefault": {
|
||||
"label": "기본적으로 인터넷 검색 켜기"
|
||||
}
|
||||
},
|
||||
"system": {
|
||||
|
@ -77,6 +77,9 @@
|
||||
"braveApi": {
|
||||
"label": "ബ്രേവ് API കീ",
|
||||
"placeholder": "നിങ്ങളുടെ ബ്രേവ് API കീ നൽകുക"
|
||||
},
|
||||
"searchOnByDefault": {
|
||||
"label": "സ്ഥിരസ്ഥിതിയായി ഇന്റർനെറ്റ് തിരച്ചിൽ പ്രവർത്തനക്ഷമമാക്കുക"
|
||||
}
|
||||
},
|
||||
"system": {
|
||||
|
@ -74,6 +74,9 @@
|
||||
"braveApi": {
|
||||
"label": "Brave API Nøkkel",
|
||||
"placeholder": "Skriv inn din Brave API nøkkel"
|
||||
},
|
||||
"searchOnByDefault": {
|
||||
"label": "Internett-søk PÅ som standard"
|
||||
}
|
||||
},
|
||||
"system": {
|
||||
|
@ -74,6 +74,9 @@
|
||||
"braveApi": {
|
||||
"label": "Chave da API do Brave",
|
||||
"placeholder": "Digite sua chave da API do Brave"
|
||||
},
|
||||
"searchOnByDefault": {
|
||||
"label": "Pesquisa na Internet ativada por padrão"
|
||||
}
|
||||
},
|
||||
"system": {
|
||||
|
@ -75,6 +75,9 @@
|
||||
"braveApi": {
|
||||
"label": "API-ключ Brave",
|
||||
"placeholder": "Введите ваш API-ключ Brave"
|
||||
},
|
||||
"searchOnByDefault": {
|
||||
"label": "Поиск в интернете включен по умолчанию"
|
||||
}
|
||||
},
|
||||
"system": {
|
||||
|
@ -74,6 +74,9 @@
|
||||
"braveApi": {
|
||||
"label": "Brave API-nyckel",
|
||||
"placeholder": "Ange din Brave API-nyckel"
|
||||
},
|
||||
"searchOnByDefault": {
|
||||
"label": "Internetsökning PÅ som standard"
|
||||
}
|
||||
},
|
||||
"system": {
|
||||
|
@ -74,6 +74,9 @@
|
||||
"braveApi": {
|
||||
"label": "Ключ API Brave",
|
||||
"placeholder": "Введіть ваш ключ API Brave"
|
||||
},
|
||||
"searchOnByDefault": {
|
||||
"label": "Пошук в Інтернеті увімкнено за замовчуванням"
|
||||
}
|
||||
},
|
||||
"system": {
|
||||
|
@ -77,6 +77,9 @@
|
||||
"braveApi": {
|
||||
"label": "Brave API 密钥",
|
||||
"placeholder": "输入您的 Brave API 密钥"
|
||||
},
|
||||
"searchOnByDefault": {
|
||||
"label": "默认开启网络搜索"
|
||||
}
|
||||
},
|
||||
"system": {
|
||||
|
@ -39,7 +39,8 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
|
||||
selectedKnowledge,
|
||||
temporaryChat,
|
||||
useOCR,
|
||||
setUseOCR
|
||||
setUseOCR,
|
||||
defaultInternetSearchOn
|
||||
} = useMessageOption()
|
||||
|
||||
const isMobile = () => {
|
||||
@ -71,8 +72,17 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
|
||||
|
||||
React.useEffect(() => {
|
||||
textAreaFocus()
|
||||
if (defaultInternetSearchOn) {
|
||||
setWebSearch(true)
|
||||
}
|
||||
}, [])
|
||||
|
||||
React.useEffect(() => {
|
||||
if (defaultInternetSearchOn) {
|
||||
setWebSearch(true)
|
||||
}
|
||||
}, [defaultInternetSearchOn])
|
||||
|
||||
const onInputChange = async (
|
||||
e: React.ChangeEvent<HTMLInputElement> | File
|
||||
) => {
|
||||
|
@ -19,7 +19,8 @@ export const SearchModeSettings = () => {
|
||||
searxngURL: "",
|
||||
searxngJSONMode: false,
|
||||
braveApiKey: "",
|
||||
googleDomain: ""
|
||||
googleDomain: "",
|
||||
defaultInternetSearchOn: false
|
||||
}
|
||||
})
|
||||
|
||||
@ -171,6 +172,19 @@ export const SearchModeSettings = () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex sm:flex-row flex-col space-y-4 sm:space-y-0 sm:justify-between">
|
||||
<span className="text-gray-700 dark:text-neutral-50 ">
|
||||
{t("generalSettings.webSearch.searchOnByDefault.label")}
|
||||
</span>
|
||||
<div>
|
||||
<Switch
|
||||
className="mt-4 sm:mt-0"
|
||||
{...form.getInputProps("defaultInternetSearchOn", {
|
||||
type: "checkbox"
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex justify-end">
|
||||
<SaveButton btnType="submit" />
|
||||
</div>
|
||||
|
@ -133,7 +133,8 @@ export const SidepanelForm = ({ dropedFile }: Props) => {
|
||||
setSelectedQuickPrompt,
|
||||
speechToTextLanguage,
|
||||
useOCR,
|
||||
setUseOCR
|
||||
setUseOCR,
|
||||
defaultInternetSearchOn
|
||||
} = useMessage()
|
||||
|
||||
React.useEffect(() => {
|
||||
@ -194,12 +195,23 @@ export const SidepanelForm = ({ dropedFile }: Props) => {
|
||||
}
|
||||
textareaRef.current?.addEventListener("drop", handleDrop)
|
||||
textareaRef.current?.addEventListener("dragover", handleDragOver)
|
||||
|
||||
if (defaultInternetSearchOn) {
|
||||
setWebSearch(true)
|
||||
}
|
||||
|
||||
return () => {
|
||||
textareaRef.current?.removeEventListener("drop", handleDrop)
|
||||
textareaRef.current?.removeEventListener("dragover", handleDragOver)
|
||||
}
|
||||
}, [])
|
||||
|
||||
React.useEffect(() => {
|
||||
if (defaultInternetSearchOn) {
|
||||
setWebSearch(true)
|
||||
}
|
||||
}, [defaultInternetSearchOn])
|
||||
|
||||
return (
|
||||
<div className="px-3 pt-3 md:px-6 md:pt-6 bg-gray-50 dark:bg-[#262626] border rounded-t-xl border-black/10 dark:border-gray-600">
|
||||
<div
|
||||
@ -302,7 +314,7 @@ export const SidepanelForm = ({ dropedFile }: Props) => {
|
||||
chatMode === "rag" ? "hidden" : "block"
|
||||
}`}>
|
||||
{webSearch ? (
|
||||
<PiGlobe className="h-5 w-5 dark:text-gray-300" />
|
||||
<PiGlobe className="h-5 w-5 text-blue-600 dark:text-blue-400" />
|
||||
) : (
|
||||
<PiGlobeX className="h-5 w-5 text-gray-600 dark:text-gray-400" />
|
||||
)}
|
||||
|
@ -55,7 +55,10 @@ export const useMessage = () => {
|
||||
setWebSearch,
|
||||
isSearchingInternet
|
||||
} = useStoreMessageOption()
|
||||
|
||||
const [defaultInternetSearchOn, ] = useStorage(
|
||||
"defaultInternetSearchOn",
|
||||
false
|
||||
)
|
||||
const [chatWithWebsiteEmbedding] = useStorage(
|
||||
"chatWithWebsiteEmbedding",
|
||||
true
|
||||
@ -107,6 +110,9 @@ export const useMessage = () => {
|
||||
setIsProcessing(false)
|
||||
setStreaming(false)
|
||||
currentChatModelSettings.reset()
|
||||
if(defaultInternetSearchOn) {
|
||||
setWebSearch(true)
|
||||
}
|
||||
}
|
||||
|
||||
const chatWithWebsiteMode = async (
|
||||
@ -1714,6 +1720,7 @@ export const useMessage = () => {
|
||||
speechToTextLanguage,
|
||||
setSpeechToTextLanguage,
|
||||
useOCR,
|
||||
setUseOCR
|
||||
setUseOCR,
|
||||
defaultInternetSearchOn
|
||||
}
|
||||
}
|
||||
|
@ -76,6 +76,10 @@ export const useMessageOption = () => {
|
||||
} = useStoreMessageOption()
|
||||
const currentChatModelSettings = useStoreChatModelSettings()
|
||||
const [selectedModel, setSelectedModel] = useStorage("selectedModel")
|
||||
const [defaultInternetSearchOn, ] = useStorage(
|
||||
"defaultInternetSearchOn",
|
||||
false
|
||||
)
|
||||
const [speechToTextLanguage, setSpeechToTextLanguage] = useStorage(
|
||||
"speechToTextLanguage",
|
||||
"en-US"
|
||||
@ -98,6 +102,9 @@ export const useMessageOption = () => {
|
||||
setStreaming(false)
|
||||
currentChatModelSettings.reset()
|
||||
textareaRef?.current?.focus()
|
||||
if(defaultInternetSearchOn) {
|
||||
setWebSearch(true)
|
||||
}
|
||||
}
|
||||
|
||||
const searchChatMode = async (
|
||||
@ -1198,6 +1205,7 @@ export const useMessageOption = () => {
|
||||
temporaryChat,
|
||||
setTemporaryChat,
|
||||
useOCR,
|
||||
setUseOCR
|
||||
setUseOCR,
|
||||
defaultInternetSearchOn,
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ export const getIsVisitSpecificWebsite = async () => {
|
||||
return isVisitSpecificWebsite === "true"
|
||||
}
|
||||
|
||||
|
||||
export const setIsVisitSpecificWebsite = async (
|
||||
isVisitSpecificWebsite: boolean
|
||||
) => {
|
||||
@ -101,14 +100,29 @@ export const setGoogleDomain = async (domain: string) => {
|
||||
await storage2.set("searchGoogleDomain", domain)
|
||||
}
|
||||
|
||||
export const getInternetSearchOn = async () => {
|
||||
const defaultInternetSearchOn = await storage.get<boolean | undefined>(
|
||||
"defaultInternetSearchOn"
|
||||
)
|
||||
return defaultInternetSearchOn ?? false
|
||||
}
|
||||
|
||||
export const setInternetSearchOn = async (defaultInternetSearchOn: boolean) => {
|
||||
await storage.set("defaultInternetSearchOn", defaultInternetSearchOn)
|
||||
}
|
||||
|
||||
export const getSearchSettings = async () => {
|
||||
const [isSimpleInternetSearch, searchProvider, totalSearchResult, visitSpecificWebsite,
|
||||
const [
|
||||
isSimpleInternetSearch,
|
||||
searchProvider,
|
||||
totalSearchResult,
|
||||
visitSpecificWebsite,
|
||||
searxngURL,
|
||||
searxngJSONMode,
|
||||
braveApiKey,
|
||||
googleDomain
|
||||
] =
|
||||
await Promise.all([
|
||||
googleDomain,
|
||||
defaultInternetSearchOn
|
||||
] = await Promise.all([
|
||||
getIsSimpleInternetSearch(),
|
||||
getSearchProvider(),
|
||||
totalSearchResults(),
|
||||
@ -116,7 +130,8 @@ export const getSearchSettings = async () => {
|
||||
getSearxngURL(),
|
||||
isSearxngJSONMode(),
|
||||
getBraveApiKey(),
|
||||
getGoogleDomain()
|
||||
getGoogleDomain(),
|
||||
getInternetSearchOn()
|
||||
])
|
||||
|
||||
return {
|
||||
@ -127,7 +142,8 @@ export const getSearchSettings = async () => {
|
||||
searxngURL,
|
||||
searxngJSONMode,
|
||||
braveApiKey,
|
||||
googleDomain
|
||||
googleDomain,
|
||||
defaultInternetSearchOn
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,16 +155,18 @@ export const setSearchSettings = async ({
|
||||
searxngJSONMode,
|
||||
searxngURL,
|
||||
braveApiKey,
|
||||
googleDomain
|
||||
googleDomain,
|
||||
defaultInternetSearchOn
|
||||
}: {
|
||||
isSimpleInternetSearch: boolean
|
||||
searchProvider: string
|
||||
totalSearchResults: number
|
||||
visitSpecificWebsite: boolean
|
||||
searxngURL: string
|
||||
searxngJSONMode: boolean,
|
||||
braveApiKey: string,
|
||||
googleDomain: string
|
||||
searxngJSONMode: boolean
|
||||
braveApiKey: string
|
||||
googleDomain: string,
|
||||
defaultInternetSearchOn: boolean
|
||||
}) => {
|
||||
await Promise.all([
|
||||
setIsSimpleInternetSearch(isSimpleInternetSearch),
|
||||
@ -158,6 +176,7 @@ export const setSearchSettings = async ({
|
||||
setSearxngJSONMode(searxngJSONMode),
|
||||
setSearxngURL(searxngURL),
|
||||
setBraveApiKey(braveApiKey),
|
||||
setGoogleDomain(googleDomain)
|
||||
setGoogleDomain(googleDomain),
|
||||
setInternetSearchOn(defaultInternetSearchOn)
|
||||
])
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user