JiriOndrusek commented on code in PR #9018: URL: https://github.com/apache/camel-quarkus/pull/9018#discussion_r3805293834
########## extensions/langchain4j-ingest/runtime/src/main/java/org/apache/camel/quarkus/component/langchain4j/ingest/IngestRoutes.java: ########## @@ -0,0 +1,276 @@ +/* + * 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.langchain4j.ingest; + +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; + +import dev.langchain4j.data.segment.TextSegment; +import dev.langchain4j.model.embedding.EmbeddingModel; +import dev.langchain4j.store.embedding.EmbeddingStore; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Any; +import jakarta.enterprise.inject.Instance; +import jakarta.inject.Inject; +import org.apache.camel.Exchange; +import org.apache.camel.Expression; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.quarkus.component.langchain4j.ingest.core.IngestService; +import org.apache.camel.support.builder.ExpressionBuilder; +import org.apache.camel.support.processor.idempotent.MemoryIdempotentRepository; +import org.apache.camel.util.URISupport; +import org.jboss.logging.Logger; + +import static org.apache.camel.builder.endpoint.StaticEndpointBuilders.file; + +/** + * Generates one Camel route per configured ingestion pipeline. Users never see these routes — + * they are the implementation of the configuration. + */ +@ApplicationScoped +public class IngestRoutes extends RouteBuilder { + + private static final Logger LOG = Logger.getLogger(IngestRoutes.class); + + @Inject + IngestBuildTimeConfig buildTimeConfig; + + @Inject + IngestRunTimeConfig runTimeConfig; + + @Inject + IngestBuilderPipelines builderPipelines; + + @Inject + @Any + Instance<EmbeddingStore<TextSegment>> storeCandidates; + + @Inject + @Any + Instance<EmbeddingModel> modelCandidates; + + @Override + public void configure() { + // a pipeline may be declared entirely through runtime properties - the documented + // minimum is a directory and nothing else - so the two config roots are unioned. Keying + // off the build-time map alone would make that configuration a silent no-op, since + // SmallRye only materialises a map key for the mapping whose structure a property matches + Set<String> builderDeclared = builderPipelines.entries().stream() Review Comment: Done — the startup-only validation of runtime-only pipelines is now called out in usage.adoc. -- 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]
