Skip to content

Conversation

@SuminAndrew
Copy link
Contributor

Closes #2087

VertexAI's GenerationConfig natively uses a Schema object to configure response schema, which represents an OpenAPI schema. There's also a responseJsonSchema option, but it is only supported in Gemini 2.5 (see: https://ai.google.dev/gemini-api/docs/structured-output#json-schema).

To support this, I added a new String responseSchema property to VertexAiGeminiChatOptions. This allows users to provide an OpenAPI schema as a string, which is then converted into a Schema object internally. The same approach is already used for tool definitions via inputSchemas, so I extracted the conversion logic into a shared utility class. I also added corresponding unit tests.

@sobychacko
Copy link
Contributor

@SuminAndrew, could you sign your commit using DCO? https://spring.io/blog/2025/01/06/hello-dco-goodbye-cla-simplifying-contributions-to-spring

@SuminAndrew SuminAndrew force-pushed the support-gemini-response-schema branch 2 times, most recently from 931d6b6 to f8cc6d4 Compare July 8, 2025 15:57
@SuminAndrew
Copy link
Contributor Author

@SuminAndrew
Copy link
Contributor Author

Hey @sobychacko, I wonder what are the next steps for this PR? Should I tag someone to get this reviewed?

@SuminAndrew SuminAndrew force-pushed the support-gemini-response-schema branch 2 times, most recently from 42e331b to cfabfe0 Compare July 18, 2025 08:46
@SuminAndrew
Copy link
Contributor Author

Updated the branch to fix conflicts with the main branch

@SuminAndrew
Copy link
Contributor Author

Also tagging @ilayaperumalg
Would be great if this could make it into 1.1.0, this is one of the bits that we are currently missing compared to langchain4j

@SuminAndrew SuminAndrew reopened this Jul 18, 2025
@ilayaperumalg ilayaperumalg added this to the 1.1.x milestone Jul 18, 2025
@SuminAndrew SuminAndrew force-pushed the support-gemini-response-schema branch from cfabfe0 to 82a25f2 Compare August 7, 2025 07:12
@SuminAndrew
Copy link
Contributor Author

Rebased onto a fresh main branch to fix failing MCP Client tests (unrelated to the changeset).

@SuminAndrew SuminAndrew force-pushed the support-gemini-response-schema branch from 82a25f2 to fe7f34a Compare August 20, 2025 14:02
@SuminAndrew
Copy link
Contributor Author

Another rebase to stay up-to-date

@ilayaperumalg ilayaperumalg self-assigned this Sep 18, 2025
@ilayaperumalg ilayaperumalg modified the milestones: 1.1.0.M1, 1.1.0.M2 Sep 18, 2025
@ilayaperumalg
Copy link
Member

@SuminAndrew Sorry about the delay in response. The changes look good. Rebased, verified the tests and build locally, and merged as 31423e9.

@ilayaperumalg
Copy link
Member

@SuminAndrew Thank you for adding this feature!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Json Schema with Gemini

3 participants