Skip to content

Commit

Permalink
fix: Ollama is unable to create a knowledge base using a local embedd…
Browse files Browse the repository at this point in the history
…ing model CherryHQ#630
  • Loading branch information
kangfenmao committed Jan 6, 2025
1 parent bd9bdc5 commit d884269
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const PopupContainer: React.FC<Props> = ({ title, resolve }) => {
} catch (error) {
console.error('Error getting embedding dimensions:', error)
window.message.error(t('message.error.get_embedding_dimensions'))
setLoading(false)
return
}

Expand Down
8 changes: 2 additions & 6 deletions src/renderer/src/services/KnowledgeService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ExtractChunkData } from '@llm-tools/embedjs-interfaces'
import AiProvider from '@renderer/providers/AiProvider'
import { FileType, KnowledgeBase, KnowledgeBaseParams, Message } from '@renderer/types'
import { isEmpty, take } from 'lodash'
import { take } from 'lodash'

import { getProviderByModel } from './AssistantService'
import FileManager from './FileManager'
Expand All @@ -10,10 +10,6 @@ export const getKnowledgeBaseParams = (base: KnowledgeBase): KnowledgeBaseParams
const provider = getProviderByModel(base.model)
const aiProvider = new AiProvider(provider)

if (provider.id === 'ollama' && isEmpty(provider.apiKey)) {
provider.apiKey = 'empty'
}

let host = aiProvider.getBaseURL()

if (provider.type === 'gemini') {
Expand All @@ -24,7 +20,7 @@ export const getKnowledgeBaseParams = (base: KnowledgeBase): KnowledgeBaseParams
id: base.id,
model: base.model.id,
dimensions: base.dimensions,
apiKey: aiProvider.getApiKey(),
apiKey: aiProvider.getApiKey() || 'secret',
apiVersion: provider.apiVersion,
baseURL: host
}
Expand Down

0 comments on commit d884269

Please sign in to comment.