Support Gemini code execution in GoogleGenAiChatModel#6530
Open
subhashpolisetti wants to merge 1 commit into
Open
Support Gemini code execution in GoogleGenAiChatModel#6530subhashpolisetti wants to merge 1 commit into
GoogleGenAiChatModel#6530subhashpolisetti wants to merge 1 commit into
Conversation
a1f693b to
94246f6
Compare
Add a `codeExecution` option to `GoogleGenAiChatOptions` that enables Gemini's built-in code execution tool, mirroring the existing `googleSearchRetrieval` option. The generated code and execution result are surfaced on the response message metadata. Closes spring-projects#6471 Signed-off-by: subhash polisetti <subhashr161347@gmail.com>
94246f6 to
8955358
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds support for Gemini's built-in code execution tool to
GoogleGenAiChatModel, mirroring the existinggoogleSearchRetrievaloption.When
codeExecution(true)is set, the request includes the Gemini code execution tool, allowing the model to generate and run Python code server-side and use the result in its response. The generated code and execution result returned by the model are surfaced on the response message metadata viaexecutableCode,executableCodeLanguage,codeExecutionResult, andcodeExecutionOutcome.The capability is supported on both the Gemini Developer API and Vertex AI, and uses types already provided by the Google Java SDK (
com.google.genai), so no new dependency is added.Testing
Added 8 unit tests and 1 integration test:
equals/hashCode, andmutateround-trip for the new option.GOOGLE_API_KEYenvironment variable, verified against the live Gemini API../mvnw -pl models/spring-ai-google-genai clean testpasses (191 tests, Checkstyle and formatting clean).Documentation
Reference documentation is updated with the new option, the response metadata keys, and notes on the multi-part response shape.
Closes #6471