Skip to content

Commit

Permalink
Add embedding model setting
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
Royal-lobster committed Dec 16, 2024
1 parent 838475e commit bc7a92f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/components/Settings/Sections/ChatSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,31 @@ const ChatSettings = () => {
))}
</select>
</FieldWrapper>
<FieldWrapper
title="Embedding Model"
description="Choose between available embedding models"
row={true}
>
<select
value={chatSettings.embeddingModel || ''}
className="input cdx-w-44"
onChange={(e) => {
setSettings({
...settings,
chat: {
...chatSettings,
embeddingModel: e.target.value,
},
})
}}
>
{models.map((model) => (
<option key={model.id} value={model.id}>
{model.id}
</option>
))}
</select>
</FieldWrapper>
</div>
)
}
Expand Down
2 changes: 2 additions & 0 deletions src/config/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type Settings = {
model: string | null
mode: Mode
openAiBaseUrl: string | null
embeddingModel: string | null
}
general: {
theme: ThemeOptions
Expand All @@ -42,6 +43,7 @@ export const defaultSettings: Settings = {
model: null,
mode: Mode.BALANCED,
openAiBaseUrl: null,
embeddingModel: null,
},
general: {
theme: ThemeOptions.SYSTEM,
Expand Down
4 changes: 4 additions & 0 deletions src/lib/getMatchedContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
},
Expand Down

0 comments on commit bc7a92f

Please sign in to comment.