[
https://issues.apache.org/jira/browse/CAMEL-27736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18153263#comment-18153263
]
Gaelle Fournier edited comment on CAMEL-27736 at 12/1/26, 8:51 AM:
-------------------------------------------------------------------
_[~davsclaus] [~ramu11] Some feedback on this_
+Engine split, not move.+ {{Query}} in and
{{Content}}/{{TextSegment}}/{{Metadata}}/{{EmbeddingMatch}} out are
LangChain4j types.
The neutral module needs its own query (text + metadata map) and result (text,
metadata, score, document id) types; {{QueryMetadataMapper}} stays in the
LangChain4j adapter, and {{ContentConverter}} splits into
selection/limits/cleanup (engine) and body shaping (adapter). Preserve the
reviewed semantics: one item = one Content, typed metadata, reserved
{{camel_retrieval_*}} keys written last, header prefix, caps after conversion,
and body/resource cleanup on failure, timeout and stop.
{{CamelContentRetriever}} is released in 4.24.0, so the extraction must be
additive and behaviour-preserving.
+Description is a consumer-side concern.+ The router reads the description to
decide when a source is relevant; as an {{ai-retriever}} endpoint option it
becomes a property of the source, so two agents cannot describe the same route
differently. Prefer the description on the producer per tag/source, with a
route-level description only as a default.
+Identity travels in invocation parameters only.+ At {{retrieve(Query)}} time
there is no calling exchange: identity arrives as
{{Query.metadata().invocationParameters()}}, and a multi-source fan-out runs on
the augmentor's executor without request context, so a retrieval route cannot
use {{exchangeProperty.subject}} or an {{allowedRoles}}-style guard the way an
{{ai-tool}} route does. {{CamelLangChain4jRetrieverParams}} is the channel;
which sources a caller may see is a producer/catalog decision, not a route one.
If the agent path wants the caller's exchange properties, copy them
deliberately into the invocation parameters rather than assuming
{{AiToolExecutor.createToolExchange}} semantics transfer.
+Routing: all by default, model routing opt-in, fallback explicit.+
{{DefaultQueryRouter}}
covers every tagged source with no model call; {{LanguageModelQueryRouter}}
costs a call per query and, on error or an unparsable answer, falls back to
{{DO_NOT_ROUTE}} silently.
Default to all tagged sources, make model routing opt-in, and expose and log
the fallback ({{do-not-route}} / {{route-to-all}} / {{fail}}). Keep the
endpoint option's {{on-error}} default aligned with the class ({{fail}}).
+Lifecycle.+ Keep the engine a {{ServiceSupport}} the context can own
(today's {{addService}} model); the {{ai-retriever}} consumer is a second
owner for route-declared sources. A source stopped while a producer holds it
must follow {{onError}}, not throw.
+Catalog snapshot vs live registry.+ Tags are runtime state, so decide
whether the producer resolves sources per query or snapshots them at start: a
snapshot makes a route registered later invisible and a stopped route stale,
while per-query resolution matches how {{ai-tool}} tags behave.
{{AiRetrieverRegistryListener}} can rebuild a snapshot on change.
+Naming.+ 4.24.0 ships {{CamelLangChain4jRetrieverParams}} and the
{{camel_retrieval_*}} keys; keep them as the route contract and define a
neutral alias in the new module rather than renaming.
+Scope.+ The {{camel-openai}} integration is a separate deliverable enabled
by the neutral engine and should not gate this.
_Claude Code on behalf of gfournier_
was (Author: JIRAUSER304516):
_[~davsclaus] [~ramu11] Some feedback on this_
+Engine split, not move.+ {{Query}} in and
{{Content}}/{{TextSegment}}/{{Metadata}}/{{EmbeddingMatch}} out are
LangChain4j types.
The neutral module needs its own query (text + metadata map) and result (text,
metadata, score, document id) types; {{QueryMetadataMapper}} stays in the
LangChain4j adapter, and {{ContentConverter}} splits into
selection/limits/cleanup (engine) and body shaping (adapter). Preserve the
reviewed semantics: one item = one Content, typed metadata, reserved
{{camel_retrieval_*}} keys written last, header prefix, caps after conversion,
and body/resource cleanup on failure, timeout and stop.
{{CamelContentRetriever}} is released in 4.24.0, so the extraction must be
additive and behaviour-preserving.
+Description is a consumer-side concern.+ The router reads the description to
decide when a source is relevant; as an {{ai-retriever}} endpoint option it
becomes a property of the source, so two agents cannot describe the same route
differently. Prefer the description on the producer per tag/source, with a
route-level description only as a default.
+Identity travels in invocation parameters only.+ At {{retrieve(Query)}} time
there is no
calling exchange: identity arrives as
{{Query.metadata().invocationParameters()}}, and a
multi-source fan-out runs on the augmentor's executor without request
context, so a
retrieval route cannot use {{exchangeProperty.subject}} or an
{{allowedRoles}}-style
guard the way an {{ai-tool}} route does. {{CamelLangChain4jRetrieverParams}}
is the
channel; which sources a caller may see is a producer/catalog decision, not a
route one.
If the agent path wants the caller's exchange properties, copy them
deliberately into the
invocation parameters rather than assuming
{{AiToolExecutor.createToolExchange}}
semantics transfer.
+Routing: all by default, model routing opt-in, fallback explicit.+
{{DefaultQueryRouter}}
covers every tagged source with no model call; {{LanguageModelQueryRouter}}
costs a call per query and, on error or an unparsable answer, falls back to
{{DO_NOT_ROUTE}} silently.
Default to all tagged sources, make model routing opt-in, and expose and log
the fallback ({{do-not-route}} / {{route-to-all}} / {{fail}}). Keep the
endpoint option's {{on-error}} default aligned with the class ({{fail}}).
+Lifecycle.+ Keep the engine a {{ServiceSupport}} the context can own
(today's {{addService}} model); the {{ai-retriever}} consumer is a second
owner for route-declared sources. A source stopped while a producer holds it
must follow {{onError}}, not throw.
+Catalog snapshot vs live registry.+ Tags are runtime state, so decide
whether the producer resolves sources per query or snapshots them at start: a
snapshot makes a route registered later invisible and a stopped route stale,
while per-query resolution matches how {{ai-tool}} tags behave.
{{AiRetrieverRegistryListener}} can rebuild a snapshot on change.
+Naming.+ 4.24.0 ships {{CamelLangChain4jRetrieverParams}} and the
{{camel_retrieval_*}} keys; keep them as the route contract and define a
neutral alias in the new module rather than renaming.
+Scope.+ The {{camel-openai}} integration is a separate deliverable enabled
by the neutral engine and should not gate this.
_Claude Code on behalf of gfournier_
> camel-ai - ai-retriever: routes as RAG sources that AI producers pick by tag,
> usable from YAML/XML
> --------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27736
> URL: https://issues.apache.org/jira/browse/CAMEL-27736
> Project: Camel
> Issue Type: New Feature
> Components: camel-ai, camel-langchain4j
> Reporter: Claus Ibsen
> Assignee: Ramu
> Priority: Major
> Fix For: 4.25.0
>
>
> CAMEL-27544 adds {{CamelContentRetriever}} to camel-langchain4j-core: a
> LangChain4j {{ContentRetriever}} backed by a Camel endpoint, with a bounded
> pool, a timeout, an {{onError}} policy, failure counters, body conversion and
> citation metadata that matches camel-langchain4j-ingest. It is a good engine,
> but today it can only be used from Java: the user builds the retriever,
> registers it with {{addService}}, builds a {{RetrievalAugmentor}} and passes
> it to {{AgentConfiguration}}, which is Java-only as well. Users who build
> routes in YAML, XML or Kaoto cannot use RAG from routes.
> This ticket proposes a Camel-first way to do it. It reuses the pattern of
> {{ai-tool}}, where a route registers itself under tags and the AI producer
> picks the routes whose tags it names.
> h3. 1. A retrieval source is a route
> A new consumer endpoint {{ai-retriever}} (a new camel-ai module) registers
> the route in an {{AiRetrieverRegistry}}, as {{ai-tool}} and {{ai-resource}}
> do.
> {code:yaml}
> - route:
> from:
> uri: ai-retriever:orders
> parameters:
> tags: support
> description: The customer's recent orders
> timeout: 2s
> onError: EMPTY
> maxResults: 5
> documentIdKey: orderId
> steps:
> - setHeader:
> name: CamelHttpQuery
> simple:
> "customer=${exchangeProperty.CamelLangChain4jRetrieverParams[customerId]}"
> - to: https://orders.internal/api/search
> - unmarshal:
> json: {}
> - route:
> from:
> uri: ai-retriever:articles
> parameters:
> tags: support
> description: Support articles about orders and refunds
> steps:
> - to: langchain4j-embeddingstore:kb?action=SEARCH
> {code}
> The options that are Java setters of {{CamelContentRetriever}} today
> ({{timeout}}, {{onError}}, {{maxResults}}, {{maxChars}}, {{concurrency}},
> {{queueCapacity}}, {{documentIdKey}}) become endpoint options, so they are in
> the catalog, Kaoto and the Camel CLI.
> h3. 2. The AI producer picks the sources by tag
> {code:yaml}
> - route:
> from:
> uri: platform-http:/chat
> steps:
> - to:
> uri: langchain4j-agent:support
> parameters:
> provider: openai
> modelName: gpt-4.1
> tags: support # tools, as today
> retrieverTags: support # new: RAG sources
> {code}
> When it starts, the producer looks up the tagged retrievers and builds the
> RAG wiring:
> * one source: a {{DefaultRetrievalAugmentor}} with that source
> * several sources: a {{LanguageModelQueryRouter}} that picks the relevant
> ones from each route's {{description}}, or a {{DefaultQueryRouter}} (all
> sources) with {{retrieverRouting=all}}
> * a {{DefaultContentInjector}} that includes {{camel_retrieval_source}} and
> {{camel_retrieval_document_id}}, so answers can cite their sources without
> any setup
> * the caller identity goes in as invocation parameters, the same as for
> {{ai-tool}} and {{ai-resource}} routes, so a route scopes its search the same
> way everywhere
> {{agentConfiguration.retrievalAugmentor}} stays as the Java escape hatch;
> setting both is a startup error.
> h3. 3. What changes in CamelContentRetriever
> It stays as the engine underneath:
> * it calls the consumer route through an invoker (the registry entry, as
> {{AiToolExecutor}} does for tools) instead of an endpoint URI; the public
> constructor with an endpoint URI can stay for Java users
> * the bounded execution, timeout, {{onError}}, counters, body conversion and
> cleanup move into the framework-neutral {{ai-retriever}} module, and
> {{CamelContentRetriever}} becomes a thin LangChain4j adapter over it. Then
> {{camel-openai}} can use the same sources (retrieve before the chat call and
> inject the content) without LangChain4j, the way {{ai-tool}} serves
> langchain4j-agent, camel-openai and the MCP server today.
> h3. What it brings
> * RAG with no Java: YAML, XML and Kaoto users get it, and the retrieval
> routes show in the TUI, the route diagrams and {{camel get}} like any other
> route
> * one retrieval route serves every AI producer, and could later become an MCP
> resource template too
> * no new mental model: "tag your routes, name the tags on the producer" is
> how tools already work
> h3. Open points
> * the name: {{ai-retriever}} or {{ai-knowledge}}
> * reuse {{ai-resource}} instead? It is also a read-only route, but it has no
> query, its URIs are for MCP clients, and it lacks the result shaping; a
> separate endpoint is clearer
> * whether {{LanguageModelQueryRouter}} uses the agent's chat model or a
> separate, cheaper one ({{retrieverRoutingModel}})
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)