Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* SPDX-License-Identifier: AGPLv3
*
* Copyright (c) 2026 Askimo
*/
package io.askimo.core.providers

import io.askimo.core.providers.ollama.OllamaModelFactory
import io.askimo.core.providers.ollama.OllamaSettings
import io.askimo.test.extensions.AskimoTestHome
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import kotlin.test.assertEquals

@AskimoTestHome
class EmbeddingModelConfigurationTest {

@Test
fun `missing embedding model explains how to configure one`() {
val exception = assertThrows<IllegalStateException> {
OllamaModelFactory().createEmbeddingModel(
OllamaSettings(
baseUrl = "http://localhost:11434/v1",
embeddingModel = "",
),
)
}

assertEquals(
"No embedding model is configured for OLLAMA. " +
"Go to Settings > AI Provider and select an embedding model under the provider configuration card.",
exception.message,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ abstract class OpenAiCompatibleChatModelFactory<T> : ChatModelFactory<T>
override fun createEmbeddingModel(settings: T): EmbeddingModel {
val baseUrl = settings.baseUrl.removeSuffix("/")
val modelName = settings.embeddingModel.ifBlank { AppConfig.models[getProvider()].embeddingModel }
check(modelName.isNotBlank()) {
"No embedding model is configured for ${getProvider().name}. " +
"Go to Settings > AI Provider and select an embedding model under the provider configuration card."
}
checkEmbeddingAvailability(baseUrl, modelName)
return customizeEmbeddingBuilder(
settings,
Expand Down