feat: Add option to enable internet search by default

This commit is contained in:
n4ze3m
2025-01-12 00:19:39 +05:30
parent 84e123bf38
commit 48b7a2824a
23 changed files with 148 additions and 27 deletions

View File

@@ -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
) => {

View 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>

View File

@@ -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" />
)}