Skip to content

CAMEL-24345: camel-google-vertexai - apply the streamOutputMode and jsonMode options - #25362

Open
oscerd wants to merge 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-24345
Open

CAMEL-24345: camel-google-vertexai - apply the streamOutputMode and jsonMode options#25362
oscerd wants to merge 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-24345

Conversation

@oscerd

@oscerd oscerd commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

GoogleVertexAIConfiguration declares two options that no code ever read:

@UriParam(label = "producer", description = "Streaming output mode: complete (default) or chunks",
          defaultValue = "complete", enums = "complete,chunks")
private String streamOutputMode = "complete";

@UriParam(label = "producer", description = "Whether to use JSON request/response format", defaultValue = "false")
private boolean jsonMode;

They are documented and exposed in the catalog, so streamOutputMode=chunks looked configurable
while generateChatStreaming always concatenated the whole response, and jsonMode did nothing at
all. The CamelGoogleVertexAIStreamOutputMode header constant was equally unread.

  • streamOutputMode=chunks now produces a List<String> with one element per streamed chunk, ready
    for a split(). The default complete keeps returning the concatenated String, so routes that
    do not set the option are unaffected. The header now works too and takes precedence over the
    endpoint option.
  • jsonMode=true sets the request's response MIME type to application/json.

Both are covered by an upgrade-guide entry, since an option that starts being honoured is a
behaviour change for anyone who had set it.

Two smaller items from the same audit:

  • generateChat and generateCode delegate verbatim to generateText while being advertised as
    distinct operations. They are now documented as aliases in the enum javadoc — no behaviour change.
  • buildRawPredictRequestBody called body.getClass() on its failure path, so a message with no
    body failed with a NullPointerException instead of the intended "must be a JSON String, Map, or
    plain text prompt" message.

Claude Code on behalf of oscerd

🤖 Generated with Claude Code

…sonMode options

Both options were declared, documented and exposed in the catalog, but no code
ever read them, so streamOutputMode=chunks behaved like complete and jsonMode
did nothing at all.

generateChatStreaming now returns one list element per streamed chunk when the
mode is chunks, and the mode can also be set per message with the existing
CamelGoogleVertexAIStreamOutputMode header, which nothing read either. jsonMode
sets the response mime type of the request to application/json.

Also documents generateChat and generateCode as aliases of generateText, which
is what they have always been, and reports a missing body in rawPredict instead
of failing with a NullPointerException while building the error message.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@oscerd oscerd added the bug Something isn't working label Aug 5, 2026
@oscerd
oscerd requested review from Croway and davsclaus August 5, 2026 14:14

@davsclaus davsclaus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch wiring up the two declared-but-never-read options. The PR is clean, well-tested, and follows project conventions.

One minor observation (not blocking): the CHUNK_COUNT header now counts only chunks with actual text content (chunks.size()) whereas the old code counted all stream response objects including those with null text. The new semantics are arguably more useful, but it's a subtle behavioral change that isn't mentioned in the upgrade guide entry. Worth adding a note if you agree.

Everything else looks good — config resolution follows the standard header-overrides-config pattern, tests use AssertJ, upgrade guide entry is clear, and the NPE fix in buildRawPredictRequestBody is a nice bonus.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of davsclaus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants