CAMEL-23642: camel-langchain4j-agent - support jsonSchema endpoint pr…#23793
CAMEL-23642: camel-langchain4j-agent - support jsonSchema endpoint pr…#23793zbendhiba wants to merge 1 commit into
Conversation
…operty for structured outputs Add a jsonSchema URI property to the langchain4j-agent component that loads a JSON schema (classpath, file, or inline) and applies it as a ResponseFormat on the internal AIService. This works only in agentConfiguration mode where Camel creates the agent internally. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
All tested modules (12 modules)
|
| String resolved = endpoint.getCamelContext().resolvePropertyPlaceholders(jsonSchema); | ||
|
|
||
| String content = resolveResourceContent(resolved); | ||
| if (content != null) { |
There was a problem hiding this comment.
what happen if a non existent json file is passed? ala jsonSchema=non-existent.json.
Maybe overkill, what happen if the passed file is not a json?
There was a problem hiding this comment.
@Croway Good catch! I'll investigate proper error handling for those edge cases next Monday and address them in a follow-up. If one of the two concerns turns out to be overkill, I'll open a separate issue for it instead.
davsclaus
left a comment
There was a problem hiding this comment.
Well-structured feature that significantly simplifies structured output configuration — from manual ResponseFormat + ChatModel wiring to just &jsonSchema=classpath:person-schema.json. Resource resolution via ResourceHelper supports classpath, file, and inline (RAW(...)) consistently with camel-openai. The chatRequestTransformer workaround is documented with a CAMEL-23695 reference. Three integration tests cover all resolution modes with json-validator validation. CI is green.
This review does not replace specialized AI review tools (CodeRabbit, Sourcery) or static analysis (SonarCloud).
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
…operty for structured outputs
Add a jsonSchema URI property to the
langchain4j-agentcomponent that loads a JSON schema (classpath, file, or inline) and applies it as a ResponseFormat on the internal AIService. This works only in agentConfiguration mode where Camel creates the agent internally.Summary
jsonSchemaendpoint property to thecamel-langchain4j-agentcomponent for structured LLM outputscamel-openaiExample usage
Test plan