jamesnetherton commented on code in PR #580: URL: https://github.com/apache/camel-quarkus-examples/pull/580#discussion_r4091139401
########## langchain4j-ingest-rag/src/main/java/org/acme/langchain4j/ingest/rag/SearchResource.java: ########## @@ -0,0 +1,60 @@ +/* + * 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.acme.langchain4j.ingest.rag; + +import java.util.List; +import java.util.Map; + +import dev.langchain4j.data.segment.TextSegment; +import dev.langchain4j.model.embedding.EmbeddingModel; +import dev.langchain4j.store.embedding.EmbeddingSearchRequest; +import dev.langchain4j.store.embedding.EmbeddingStore; +import jakarta.inject.Inject; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.MediaType; + +@Path("/search") +public class SearchResource { + + /** Written on every segment by the pipeline: the file the segment came from. */ + private static final String DOCUMENT_ID_METADATA = "camel_ingest_document_id"; Review Comment: The extension already exposes this key as a public constant, `org.apache.camel.quarkus.component.langchain4j.ingest.core.IngestService.METADATA_DOCUMENT_ID`. Could we reference that instead of repeating the string literal, so the two can't drift apart? _Claude Code on behalf of James Netherton_ ########## langchain4j-ingest-rag/src/main/java/org/acme/langchain4j/ingest/rag/EmbeddingModelProducer.java: ########## @@ -0,0 +1,38 @@ +/* + * 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.acme.langchain4j.ingest.rag; + +import dev.langchain4j.model.embedding.EmbeddingModel; +import dev.langchain4j.model.embedding.onnx.allminilml6v2.AllMiniLmL6V2EmbeddingModel; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Produces; +import jakarta.inject.Singleton; + +@ApplicationScoped +public class EmbeddingModelProducer { Review Comment: I don't think this producer is needed. When `langchain4j-embeddings-all-minilm-l6-v2` is on the classpath, Quarkus LangChain4j (`InProcessEmbeddingProcessor`) already registers an `@ApplicationScoped` default `EmbeddingModel` bean for `AllMiniLmL6V2EmbeddingModel`. I ran the tests locally with this class deleted, and both still pass. Removing it would drop a class and fit the example's 'no wiring' story. It also keeps the example on Quarkus LangChain4j's supported path for in-process models, which is probably safer for native mode. _Claude Code on behalf of James Netherton_ -- 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]
