CAMEL-24345: camel-google-vertexai - apply the streamOutputMode and jsonMode options - #25362
CAMEL-24345: camel-google-vertexai - apply the streamOutputMode and jsonMode options#25362oscerd wants to merge 1 commit into
Conversation
…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>
davsclaus
left a comment
There was a problem hiding this comment.
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
GoogleVertexAIConfigurationdeclares two options that no code ever read:They are documented and exposed in the catalog, so
streamOutputMode=chunkslooked configurablewhile
generateChatStreamingalways concatenated the whole response, andjsonModedid nothing atall. The
CamelGoogleVertexAIStreamOutputModeheader constant was equally unread.streamOutputMode=chunksnow produces aList<String>with one element per streamed chunk, readyfor a
split(). The defaultcompletekeeps returning the concatenatedString, so routes thatdo not set the option are unaffected. The header now works too and takes precedence over the
endpoint option.
jsonMode=truesets the request's response MIME type toapplication/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:
generateChatandgenerateCodedelegate verbatim togenerateTextwhile being advertised asdistinct operations. They are now documented as aliases in the enum javadoc — no behaviour change.
buildRawPredictRequestBodycalledbody.getClass()on its failure path, so a message with nobody failed with a
NullPointerExceptioninstead of the intended "must be a JSON String, Map, orplain text prompt" message.
Claude Code on behalf of oscerd
🤖 Generated with Claude Code