You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Zineb Bendhiba (Jira)" <ji...@apache.org> on 2026/06/10 08:48:00 UTC
[jira] [Assigned] (CAMEL-23695) Langchain4j-agent: improve structured output when Langchain4j 1.16.0 is out
[ https://issues.apache.org/jira/browse/CAMEL-23695?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Zineb Bendhiba reassigned CAMEL-23695:
--------------------------------------
Assignee: Zineb Bendhiba
> Langchain4j-agent: improve structured output when Langchain4j 1.16.0 is out
> ---------------------------------------------------------------------------
>
> Key: CAMEL-23695
> URL: https://issues.apache.org/jira/browse/CAMEL-23695
> Project: Camel
> Issue Type: Improvement
> Reporter: Zineb Bendhiba
> Assignee: Zineb Bendhiba
> Priority: Major
>
> I've implemented the {{{{}}{}}}chatRequestTransformer in Apache Camel's camel-langchain4j-agent component and hit a snag. The one-liner transformer doesn't work against DefaultAiServices:
> {code:java}
> // This throws: IllegalArgumentException: Cannot set both 'parameters' and 'responseFormat' on ChatRequest
> .chatRequestTransformer(chatRequest -> chatRequest.toBuilder().responseFormat(responseFormat).build()) {code}
>
> DefaultAiServices always sets a ChatRequestParameters object on the ChatRequest (even with no tools), and ChatRequest.validate() rejects having both parameters and a standalone responseFormat at the same time.
> I had to merge responseFormat into the existing ChatRequestParameters instead:
>
> {code:java}
> .chatRequestTransformer(req -> {
> ChatRequestParameters existing = req.parameters();
> ChatRequestParameters withFormat = existing != null
> ? existing.overrideWith(
> DefaultChatRequestParameters.builder().responseFormat(responseFormat).build())
> : DefaultChatRequestParameters.builder().responseFormat(responseFormat).build();
> return ChatRequest.builder().messages(req.messages()).parameters(withFormat).build();
> }){code}
> This was fixe in this [Langchain4j PR|https://github.com/langchain4j/langchain4j/pull/5325], and the fix will be available in LangChain4j 1.16.0.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)