From d5ab211a3fe92c6d906e08aae944c70c84260b50 Mon Sep 17 00:00:00 2001 From: w3lld1 <42353747+w3lld1@users.noreply.github.com> Date: Fri, 24 Jul 2026 07:08:45 +0200 Subject: [PATCH] fix(rag): explain missing embedding model setup Signed-off-by: w3lld1 <42353747+w3lld1@users.noreply.github.com> --- .../EmbeddingModelConfigurationTest.kt | 34 +++++++++++++++++++ .../OpenAiCompatibleChatModelFactory.kt | 4 +++ 2 files changed, 38 insertions(+) create mode 100644 cli/src/test/kotlin/io/askimo/core/providers/EmbeddingModelConfigurationTest.kt diff --git a/cli/src/test/kotlin/io/askimo/core/providers/EmbeddingModelConfigurationTest.kt b/cli/src/test/kotlin/io/askimo/core/providers/EmbeddingModelConfigurationTest.kt new file mode 100644 index 000000000..79e8916cc --- /dev/null +++ b/cli/src/test/kotlin/io/askimo/core/providers/EmbeddingModelConfigurationTest.kt @@ -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 { + 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, + ) + } +} diff --git a/shared/src/main/kotlin/io/askimo/core/providers/OpenAiCompatibleChatModelFactory.kt b/shared/src/main/kotlin/io/askimo/core/providers/OpenAiCompatibleChatModelFactory.kt index 75bb9517e..06a2fecc9 100644 --- a/shared/src/main/kotlin/io/askimo/core/providers/OpenAiCompatibleChatModelFactory.kt +++ b/shared/src/main/kotlin/io/askimo/core/providers/OpenAiCompatibleChatModelFactory.kt @@ -284,6 +284,10 @@ abstract class OpenAiCompatibleChatModelFactory : ChatModelFactory 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,