From 0c48bfa1c013e3aee2b9848315116ec7acdbda75 Mon Sep 17 00:00:00 2001 From: n4ze3m Date: Sun, 26 Jan 2025 18:36:28 +0530 Subject: [PATCH] feat: Enhance embedding model validation by incorporating simple internet search check --- src/components/Option/Playground/PlaygroundForm.tsx | 4 +++- src/components/Sidepanel/Chat/form.tsx | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/Option/Playground/PlaygroundForm.tsx b/src/components/Option/Playground/PlaygroundForm.tsx index 42c2cc8..e8d4e32 100644 --- a/src/components/Option/Playground/PlaygroundForm.tsx +++ b/src/components/Option/Playground/PlaygroundForm.tsx @@ -15,6 +15,7 @@ import { KnowledgeSelect } from "../Knowledge/KnowledgeSelect" import { useSpeechRecognition } from "@/hooks/useSpeechRecognition" import { PiGlobe } from "react-icons/pi" import { handleChatInputKeyDown } from "@/utils/key-down" +import { getIsSimpleInternetSearch } from "@/services/search" type Props = { dropedFile: File | undefined @@ -181,7 +182,8 @@ export const PlaygroundForm = ({ dropedFile }: Props) => { } if (webSearch) { const defaultEM = await defaultEmbeddingModelForRag() - if (!defaultEM) { + const simpleSearch = await getIsSimpleInternetSearch() + if (!defaultEM && !simpleSearch) { form.setFieldError("message", t("formError.noEmbeddingModel")) return } diff --git a/src/components/Sidepanel/Chat/form.tsx b/src/components/Sidepanel/Chat/form.tsx index 7d0c376..5c6789f 100644 --- a/src/components/Sidepanel/Chat/form.tsx +++ b/src/components/Sidepanel/Chat/form.tsx @@ -20,6 +20,7 @@ import { ModelSelect } from "@/components/Common/ModelSelect" import { useSpeechRecognition } from "@/hooks/useSpeechRecognition" import { PiGlobeX, PiGlobe } from "react-icons/pi" import { handleChatInputKeyDown } from "@/utils/key-down" +import { getIsSimpleInternetSearch } from "@/services/search" type Props = { dropedFile: File | undefined @@ -99,7 +100,8 @@ export const SidepanelForm = ({ dropedFile }: Props) => { } if (webSearch) { const defaultEM = await defaultEmbeddingModelForRag() - if (!defaultEM) { + const simpleSearch = await getIsSimpleInternetSearch() + if (!defaultEM && !simpleSearch) { form.setFieldError("message", t("formError.noEmbeddingModel")) return }