feat: Add option to enable chat with website by default

This commit is contained in:
n4ze3m
2025-01-18 22:04:39 +05:30
parent aacade6c84
commit 7443d0ab6b
19 changed files with 86 additions and 3 deletions

View File

@@ -31,6 +31,10 @@ export const GeneralSettings = () => {
"webUIResumeLastChat",
false
)
const [defaultChatWithWebsite, setDefaultChatWithWebsite] = useStorage(
"defaultChatWithWebsite",
false
)
const [restoreLastChatModel, setRestoreLastChatModel] = useStorage(
"restoreLastChatModel",
@@ -118,6 +122,17 @@ export const GeneralSettings = () => {
onChange={(checked) => setCopilotResumeLastChat(checked)}
/>
</div>
<div className="flex flex-row justify-between">
<div className="inline-flex items-center gap-2">
<span className="text-gray-700 dark:text-neutral-50">
{t("generalSettings.settings.turnOnChatWithWebsite.label")}
</span>
</div>
<Switch
checked={defaultChatWithWebsite}
onChange={(checked) => setDefaultChatWithWebsite(checked)}
/>
</div>
<div className="flex flex-row justify-between">
<div className="inline-flex items-center gap-2">
<span className="text-gray-700 dark:text-neutral-50">
@@ -220,7 +235,7 @@ export const GeneralSettings = () => {
</h2>
<div className="border border-b border-gray-200 dark:border-gray-600 mt-3"></div>
</div>
<div className="flex flex-row mb-3 justify-between">
<span className="text-gray-700 dark:text-neutral-50 ">
{t("generalSettings.system.export.label")}

View File

@@ -134,7 +134,8 @@ export const SidepanelForm = ({ dropedFile }: Props) => {
speechToTextLanguage,
useOCR,
setUseOCR,
defaultInternetSearchOn
defaultInternetSearchOn,
defaultChatWithWebsite
} = useMessage()
React.useEffect(() => {
@@ -200,6 +201,10 @@ export const SidepanelForm = ({ dropedFile }: Props) => {
setWebSearch(true)
}
if (defaultChatWithWebsite) {
setChatMode("rag")
}
return () => {
textareaRef.current?.removeEventListener("drop", handleDrop)
textareaRef.current?.removeEventListener("dragover", handleDragOver)
@@ -212,6 +217,12 @@ export const SidepanelForm = ({ dropedFile }: Props) => {
}
}, [defaultInternetSearchOn])
React.useEffect(() => {
if (defaultChatWithWebsite) {
setChatMode("rag")
}
}, [defaultChatWithWebsite])
return (
<div className="px-3 pt-3 md:px-6 md:pt-6 bg-white dark:bg-[#262626] border rounded-t-xl border-gray-300 dark:border-gray-600">
<div