davsclaus commented on code in PR #25893:
URL: https://github.com/apache/camel/pull/25893#discussion_r3889935861


##########
components/camel-ai/camel-langchain4j-chat/src/main/docs/langchain4j-chat-component.adoc:
##########
@@ -367,6 +367,35 @@ from("direct:chat")
     .to("langchain4j-chat:my-chat");
 ----
 
+=== Structured error exchange properties
+
+When a LangChain4j chat call fails, Camel sets structured metadata on the 
exchange **before** the model exception propagates. This works even when GenAI 
observability is disabled.
+
+[cols="2,3"]
+|===
+| Exchange property | Meaning
+
+| `CamelAiErrorCategory` | Coarse category derived from the LangChain4j 
exception: `RATE_LIMIT`, `SERVER_ERROR`, `VALIDATION`, `AUTH`, or `UNKNOWN`
+| `CamelAiRetryAfterMillis` | Not populated for LangChain4j providers 
(OpenAI-only today)
+|===
+
+Category-based handling complements matching on `RetriableException` / 
`NonRetriableException` above:
+
+[source, java]
+----
+onException(Exception.class)
+    .process(exchange -> {
+        String category = exchange.getProperty("CamelAiErrorCategory", 
String.class);
+        if ("VALIDATION".equals(category)) {
+            exchange.getIn().setHeader("Rejected", true);
+        }
+    })
+    .handled(true)
+    .to("direct:rejected");
+----
+
+The same properties are set by 
xref:langchain4j-agent-component.adoc[LangChain4j Agent] and 
xref:langchain4j-embeddings-component.adoc[LangChain4j Embeddings] on their 
failure paths. See 
xref:ai-llm-integration-guide.adoc#_structured_error_exchange_properties[AI LLM 
integration guide] for a cross-component overview.

Review Comment:
   Doc gap: `LangChain4jAgentProducer`, `LangChain4jEmbeddingsProducer`, and 
`SpringAiChatProducer` were all changed to call `GenAiErrorSupport.apply()`, 
but only this file and `openai-component.adoc` got a "Structured error exchange 
properties" section. Doc pages already exist for the other three 
(`langchain4j-agent-component.adoc`, `langchain4j-embeddings-component.adoc`, 
`spring-ai-chat-component.adoc`) but were left untouched, so this line's claim 
("the same properties are set by ... on their failure paths") isn't backed by a 
section on those pages. Per the project's doc convention, new behavior should 
be documented on each affected component's own doc page.



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