jamesnetherton commented on code in PR #9229:
URL: https://github.com/apache/camel-quarkus/pull/9229#discussion_r4083791638


##########
extensions/langchain4j-embeddingstore/runtime/src/main/java/org/apache/camel/quarkus/component/langchain4j/embeddingstore/Langchain4jEmbeddingstoreRecorder.java:
##########
@@ -83,4 +84,24 @@ public Supplier<RetrievalAugmentor> 
createRetrievalAugmentorSupplier(
             String embeddingStoreName, String embeddingModelName, String 
augmentorName) {
         return new DefaultRetrievalAugmentorSupplier(embeddingStoreName, 
embeddingModelName, augmentorName);
     }
+
+    /**
+     * The auto-produced default augmentor resolves the {@code @Default} store 
and model on first use. The
+     * build detected at least one bean of each type, but a bean it detected 
may be named rather than default,
+     * which would fail that late; so the beans are verified at startup, once 
the synthetic ones exist.
+     */
+    public void verifyDefaultRetrievalAugmentorBeans() {

Review Comment:
   `Arc.container().instance(...)` creates the bean immediately, and 
`isAvailable()` just returns `get() != null`. The handle is also never closed. 
Side effects:
   
   - `@Singleton` stores or models (like the `@Produces @Singleton 
EmbeddingStore` in the rag-bridge IT) are now built at startup instead of on 
first use. If building one fails, for example because a database isn't 
reachable yet, startup fails.
   - `@Dependent` store or model instances are never destroyed, so their 
`@PreDestroy` or disposer methods never run.
   
   Something like `Arc.container().select(EMBEDDING_STORE_TYPE).isResolvable()` 
would check that a bean resolves without creating it.



##########
extensions/langchain4j-embeddingstore/runtime/src/main/java/org/apache/camel/quarkus/component/langchain4j/embeddingstore/Langchain4jEmbeddingstoreRecorder.java:
##########
@@ -83,4 +84,24 @@ public Supplier<RetrievalAugmentor> 
createRetrievalAugmentorSupplier(
             String embeddingStoreName, String embeddingModelName, String 
augmentorName) {
         return new DefaultRetrievalAugmentorSupplier(embeddingStoreName, 
embeddingModelName, augmentorName);
     }
+
+    /**
+     * The auto-produced default augmentor resolves the {@code @Default} store 
and model on first use. The
+     * build detected at least one bean of each type, but a bean it detected 
may be named rather than default,
+     * which would fail that late; so the beans are verified at startup, once 
the synthetic ones exist.
+     */
+    public void verifyDefaultRetrievalAugmentorBeans() {
+        boolean store = 
Arc.container().instance(EMBEDDING_STORE_TYPE).isAvailable();
+        boolean model = 
Arc.container().instance(EmbeddingModel.class).isAvailable();
+        if (store && model) {
+            return;
+        }
+        throw new IllegalStateException("The default RetrievalAugmentor was 
produced because an EmbeddingStore and"

Review Comment:
   This can make apps fail to start that started fine before, even if they 
never use the augmentor.
   
   The discovered-bean census in `Langchain4jEmbeddingstoreRagProcessor` 
(~L336) still counts every store bean, qualified ones included. Only the newly 
announced synthetic beans skip named beans. So take an app with:
   
   - a class-based `@ApplicationScoped @EmbeddingStoreName("products")` store
   - an `EmbeddingModel`
   - no `quarkus.camel.langchain4j.rag.augmentors.*` config
   
   The build still registers the default augmentor, and this check then throws 
`IllegalStateException` during RUNTIME_INIT. Previously the augmentor was 
resolved lazily, so an ingestion-only app (no `@RegisterAiService`, or AI 
services that opt out) was unaffected. The same applies to Quarkus LangChain4j 
apps with only named stores, e.g. pgvector with `default-store-enabled=false`.
   
   The migration guide mentions the Quarkus LangChain4j named-only case, but 
not the class-based `@EmbeddingStoreName` one.
   
   Possible options: have the discovered census count only `@Default` beans 
too, or log a warning here instead of failing startup.



-- 
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]

Reply via email to