JiriOndrusek commented on code in PR #8970:
URL: https://github.com/apache/camel-quarkus/pull/8970#discussion_r3736348629
##########
extensions-support/langchain4j/deployment/src/main/java/org/apache/camel/quarkus/component/support/langchain4j/deployment/SupportQuarkusLangchain4jProcessor.java:
##########
@@ -256,4 +265,94 @@ void validateAndRegisterAiServices(
}
}
}
+
+ /**
+ * Produces {@link RetrievalAugmentor} CDI beans that bridge Camel
ingestion routes with
+ * {@code @RegisterAiService} RAG.
+ *
+ * <p>
+ * Two modes:
+ * <ul>
+ * <li><b>Explicit config</b> — each entry under {@code
quarkus.camel.langchain4j.rag.augmentors.<name>}
+ * produces a {@code @Named("<name>")} RetrievalAugmentor backed by the
configured store.
+ * If only one entry exists, it is also marked as {@code defaultBean()}
for auto-discovery.</li>
+ * <li><b>Auto-detection</b> — when no config entries exist, at least one
EmbeddingStore and one
+ * EmbeddingModel are present, and no RetrievalAugmentor exists yet, a
default one is produced
+ * backed by the {@code @Default} CDI bean.</li>
+ * </ul>
+ */
+ @BuildStep
+ @Record(ExecutionTime.RUNTIME_INIT)
+ void registerDefaultRetrievalAugmentor(
+ BeanDiscoveryFinishedBuildItem beanDiscovery,
+ RagBridgeConfig ragBridgeConfig,
+ QuarkusLangchain4jRecorder recorder,
+ BuildProducer<SyntheticBeanBuildItem> syntheticBeans) {
+
+ DotName embeddingStoreDN =
DotName.createSimple(EmbeddingStore.class.getName());
+ DotName embeddingModelDN =
DotName.createSimple(EmbeddingModel.class.getName());
+ DotName retrievalAugmentorDN =
DotName.createSimple(RetrievalAugmentor.class.getName());
+
+ int embeddingStoreCount = 0;
+ int embeddingModelCount = 0;
+ boolean hasRetrievalAugmentor = false;
+
+ for (BeanInfo bean :
beanDiscovery.beanStream().collect(Collectors.toList())) {
+ for (org.jboss.jandex.Type type : bean.getTypes()) {
Review Comment:
Done — added import, using `Type` directly.
##########
extensions-support/langchain4j/runtime/src/main/java/org/apache/camel/quarkus/component/support/langchain4j/RagBridgeConfig.java:
##########
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.support.langchain4j;
+
+import java.util.Map;
+import java.util.Optional;
+
+import io.quarkus.runtime.annotations.ConfigPhase;
+import io.quarkus.runtime.annotations.ConfigRoot;
+import io.smallrye.config.ConfigMapping;
+
+// BUILD_AND_RUN_TIME_FIXED: augmentor bean definitions are baked in at build
time and cannot change at runtime
+@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED)
+@ConfigMapping(prefix = "quarkus.camel.langchain4j.rag")
+public interface RagBridgeConfig {
+
+ /**
+ * Named RetrievalAugmentor beans, each backed by a specific
EmbeddingStore.
+ * The map key becomes the CDI bean name ({@code @Named("key")}).
+ *
+ * Example:
+ *
+ * <pre>
+ *
quarkus.camel.langchain4j.rag.augmentors.products.embedding-store-name=products
+ *
quarkus.camel.langchain4j.rag.augmentors.support.embedding-store-name=support-docs
+ * </pre>
+ */
+ Map<String, AugmentorConfig> augmentors();
+
+ interface AugmentorConfig {
+
+ /**
+ * CDI bean name of the {@code EmbeddingStore} to use.
+ * Matches beans annotated with {@code @Named("name")} or {@code
@EmbeddingStoreName("name")}.
+ */
Review Comment:
Fixed both:
- `DefaultRetrievalAugmentorSupplier` now tries `@EmbeddingStoreName` first,
falls back to `@Named`.
- Added `EasyRagPresent` classpath condition with `@BuildStep(onlyIfNot =
EasyRagPresent.class)` to avoid conflict with Easy-RAG.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]