gnodet-bot commented on code in PR #31038:
URL: https://github.com/apache/camel/pull/31038#discussion_r4721895715
##########
components/camel-ai/camel-langchain4j-core/src/main/docs/langchain4j-content-retriever.adoc:
##########
@@ -0,0 +1,245 @@
+= LangChain4j Content Retriever
+:doctitle: LangChain4j Content Retriever
+:shortname: langchain4j-content-retriever
+:artifactid: camel-langchain4j-core
+:description: Use Camel routes as LangChain4j content retrievers for
retrieval-augmented generation
+:since: 4.24
+:supportlevel: Preview
+:tabs-sync-option:
+
+*Since Camel {since}*
+
+The `CamelContentRetriever` turns a Camel endpoint — a route, a Kamelet or a
component — into a LangChain4j
+`ContentRetriever`, so that
https://docs.langchain4j.dev/tutorials/rag[retrieval-augmented generation] can
retrieve
+content from any system Camel can reach: a REST API, a database, a JMS queue,
an LDAP server, a legacy mainframe.
+
+Maven users will need to add the following dependency to their `pom.xml`
+for this component:
+
+[source,xml]
+----
+<dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-langchain4j-core</artifactId>
+ <version>x.x.x</version>
+ <!-- use the same version as your Camel core version -->
+</dependency>
+----
+
+== Usage
+
+Create one retriever per content source, register it with the `CamelContext`
and wire it into a LangChain4j
+`RetrievalAugmentor`:
+
+[source,java]
+----
+CamelContentRetriever orders = new CamelContentRetriever(camelContext,
"orders", "direct:orders")
+ .setTimeout(Duration.ofSeconds(2))
+ .setOnError(OnError.EMPTY)
+ .setMaxResults(5);
+camelContext.addService(orders);
+
+RetrievalAugmentor augmentor = DefaultRetrievalAugmentor.builder()
+ .queryRouter(new DefaultQueryRouter(orders, knowledgeBase))
+ .contentInjector(DefaultContentInjector.builder()
+ .metadataKeysToInclude(List.of("camel_retrieval_source",
"camel_retrieval_document_id"))
+ .build())
+ .build();
+----
+
+The first constructor argument is the source name, the second the endpoint
URI. The name identifies the source in
+logs and in the `camel_retrieval_source` segment metadata.
+
+IMPORTANT: Register every retriever with `CamelContext.addService(...)`, after
configuring it: the settings cannot
+change once it has started. A retriever that is only `start()`ed but not
registered still works, but is not stopped
+with the context: call `stop()` yourself. Registering a retriever that is
already started is allowed, as long as it
+was created with the same `CamelContext`.
+
+== What the Route Receives
+
+The retriever sends an InOut exchange to the endpoint: the query text is the
message body, and the query metadata
+is set as exchange properties:
+
+[width="100%",cols="3,3,4",options="header"]
+|===
+|Property |Source |Value
+
+|`CamelLangChain4jRetrieverUserMessage` |query metadata |text of the original
user message, when it has a single text
Review Comment:
💬 **Doc clarity (low):** `"when it has a single text"` is vague — a reader
won't know what "single text" means without reading the source. The
`QueryMetadataMapper` only maps the property when the `UserMessage` contains
exactly one `TextContent` element (not for multimodal messages that mix text
and image content).
Suggestion:
```suggestion
|`CamelLangChain4jRetrieverUserMessage` |query metadata |text of the
original user message; absent when the message has more than one content part
(multimodal messages)
```
--
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]