From 5c02defbf98d59be846f2d67312948b711e421af Mon Sep 17 00:00:00 2001 From: ag5250 Date: Fri, 24 Jul 2026 08:15:30 +0000 Subject: [PATCH] Show a user-friendly error when no embedding model is configured Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../OpenAiCompatibleChatModelFactory.kt | 4 ++++ .../OpenAiCompatibleModelFactory.kt | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) 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, diff --git a/shared/src/main/kotlin/io/askimo/core/providers/openaicompatible/OpenAiCompatibleModelFactory.kt b/shared/src/main/kotlin/io/askimo/core/providers/openaicompatible/OpenAiCompatibleModelFactory.kt index 550b81316..7d8cd4d68 100644 --- a/shared/src/main/kotlin/io/askimo/core/providers/openaicompatible/OpenAiCompatibleModelFactory.kt +++ b/shared/src/main/kotlin/io/askimo/core/providers/openaicompatible/OpenAiCompatibleModelFactory.kt @@ -34,11 +34,18 @@ class OpenAiCompatibleModelFactory : OpenAiCompatibleChatModelFactory AI Provider and select an embedding model under the provider configuration card." + } + return OpenAiEmbeddingModelBuilder() + .baseUrl(settings.baseUrl) + .apiKey(resolveApiKey(settings)) + .modelName(modelName) + .build() + } override fun getEmbeddingTokenLimit(settings: OpenAiCompatibleSettings): Int { val modelName = AppConfig.models[ModelProvider.OPENAI_COMPATIBLE].embeddingModel.lowercase()