From ddda5fa0e7c57d1b10aac3e49ca7903692f69db2 Mon Sep 17 00:00:00 2001 From: Jan Martiska Date: Tue, 3 Dec 2024 14:23:19 +0100 Subject: [PATCH] Don't register an embedding model for Easy RAG if the user explicitly chose a provider --- .../langchain4j/deployment/BeansProcessor.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/core/deployment/src/main/java/io/quarkiverse/langchain4j/deployment/BeansProcessor.java b/core/deployment/src/main/java/io/quarkiverse/langchain4j/deployment/BeansProcessor.java index 1dcd08508..cfdcc7409 100644 --- a/core/deployment/src/main/java/io/quarkiverse/langchain4j/deployment/BeansProcessor.java +++ b/core/deployment/src/main/java/io/quarkiverse/langchain4j/deployment/BeansProcessor.java @@ -261,11 +261,14 @@ public void handleProviders(BeanDiscoveryFinishedBuildItem beanDiscoveryFinished // in case multiple embedding model providers are available, // the user has to specify `quarkus.langchain4j.embedding-model.provider` to choose one Optional userSelectedProvider = buildConfig.defaultConfig().embeddingModel().provider(); - String provider = selectEmbeddingModelProvider(inProcessEmbeddingBuildItems, embeddingCandidateItems, - beanDiscoveryFinished.beanStream().withBeanType(EmbeddingModel.class), - userSelectedProvider, embeddingModelBeanType, embeddingModelConfigNamespace); - selectedEmbeddingProducer - .produce(new SelectedEmbeddingModelCandidateBuildItem(provider, NamedConfigUtil.DEFAULT_NAME)); + if (userSelectedProvider.isEmpty()) { + String provider = selectEmbeddingModelProvider(inProcessEmbeddingBuildItems, embeddingCandidateItems, + beanDiscoveryFinished.beanStream().withBeanType(EmbeddingModel.class), + userSelectedProvider, embeddingModelBeanType, embeddingModelConfigNamespace); + selectedEmbeddingProducer + .produce(new SelectedEmbeddingModelCandidateBuildItem(provider, NamedConfigUtil.DEFAULT_NAME)); + } + // else: if the user actually selected a provider, the model will be registered automatically below anyway } for (String modelName : requestedModerationModels) {