From bc7a92feafd97afd18b21438a97716e57b6dbea3 Mon Sep 17 00:00:00 2001 From: Srujan Gurram <52039218+Royal-lobster@users.noreply.github.com> Date: Mon, 16 Dec 2024 09:36:34 +0530 Subject: [PATCH] Add embedding model setting Related to #99 --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/Royal-lobster/Syncia/issues/99?shareId=XXXX-XXXX-XXXX-XXXX). --- .../Settings/Sections/ChatSettings.tsx | 25 +++++++++++++++++++ src/config/settings/index.ts | 2 ++ src/lib/getMatchedContent.ts | 4 +++ 3 files changed, 31 insertions(+) diff --git a/src/components/Settings/Sections/ChatSettings.tsx b/src/components/Settings/Sections/ChatSettings.tsx index 1e272ab0..c3178561 100644 --- a/src/components/Settings/Sections/ChatSettings.tsx +++ b/src/components/Settings/Sections/ChatSettings.tsx @@ -161,6 +161,31 @@ const ChatSettings = () => { ))} + + + ) } diff --git a/src/config/settings/index.ts b/src/config/settings/index.ts index 0066646c..e991ee03 100644 --- a/src/config/settings/index.ts +++ b/src/config/settings/index.ts @@ -24,6 +24,7 @@ export type Settings = { model: string | null mode: Mode openAiBaseUrl: string | null + embeddingModel: string | null } general: { theme: ThemeOptions @@ -42,6 +43,7 @@ export const defaultSettings: Settings = { model: null, mode: Mode.BALANCED, openAiBaseUrl: null, + embeddingModel: null, }, general: { theme: ThemeOptions.SYSTEM, diff --git a/src/lib/getMatchedContent.ts b/src/lib/getMatchedContent.ts index 81e86031..5ce3362a 100644 --- a/src/lib/getMatchedContent.ts +++ b/src/lib/getMatchedContent.ts @@ -3,6 +3,7 @@ import { RecursiveCharacterTextSplitter } from 'langchain/text_splitter' import { MemoryVectorStore } from 'langchain/vectorstores/memory' import { createSHA256Hash } from './createSHA256Hash' import { readStorage, setStorage } from '../hooks/useStorage' +import { useSettings } from '../hooks/useSettings' export const getMatchedContent = async ( query: string, @@ -21,8 +22,11 @@ const getContextVectorStore = async ( apiKey: string, baseURL: string, ) => { + const [settings] = useSettings() + const embeddingModel = settings.chat.embeddingModel || 'text-embedding-ada-002' const embeddings = new OpenAIEmbeddings({ openAIApiKey: apiKey, + modelName: embeddingModel, configuration: { baseURL: baseURL, },