@@ -38,6 +38,13 @@ option ruby_package = "Google::Cloud::AIPlatform::V1";
3838// one type of Tool (e.g FunctionDeclaration, Retrieval or
3939// GoogleSearchRetrieval).
4040message Tool {
41+ // Tool that executes code generated by the model, and automatically returns
42+ // the result to the model.
43+ //
44+ // See also [ExecutableCode]and [CodeExecutionResult] which are input and
45+ // output to this tool.
46+ message CodeExecution {}
47+
4148 // Optional. Function tool type.
4249 // One or more function declarations to be passed to the model along with the
4350 // current user query. Model may decide to call a subset of these functions
@@ -59,6 +66,11 @@ message Tool {
5966 // Specialized retrieval tool that is powered by Google search.
6067 GoogleSearchRetrieval google_search_retrieval = 3
6168 [(google.api.field_behavior ) = OPTIONAL ];
69+
70+ // Optional. CodeExecution tool type.
71+ // Enables the model to execute code as part of generation.
72+ // This field is only used by the Gemini Developer API services.
73+ CodeExecution code_execution = 4 [(google.api.field_behavior ) = OPTIONAL ];
6274}
6375
6476// Structured representation of a function declaration as defined by the
@@ -128,6 +140,57 @@ message FunctionResponse {
128140 google.protobuf.Struct response = 2 [(google.api.field_behavior ) = REQUIRED ];
129141}
130142
143+ // Code generated by the model that is meant to be executed, and the result
144+ // returned to the model.
145+ //
146+ // Generated when using the [FunctionDeclaration] tool and
147+ // [FunctionCallingConfig] mode is set to [Mode.CODE].
148+ message ExecutableCode {
149+ // Supported programming languages for the generated code.
150+ enum Language {
151+ // Unspecified language. This value should not be used.
152+ LANGUAGE_UNSPECIFIED = 0 ;
153+
154+ // Python >= 3.10, with numpy and simpy available.
155+ PYTHON = 1 ;
156+ }
157+
158+ // Required. Programming language of the `code`.
159+ Language language = 1 [(google.api.field_behavior ) = REQUIRED ];
160+
161+ // Required. The code to be executed.
162+ string code = 2 [(google.api.field_behavior ) = REQUIRED ];
163+ }
164+
165+ // Result of executing the [ExecutableCode].
166+ //
167+ // Always follows a `part` containing the [ExecutableCode].
168+ message CodeExecutionResult {
169+ // Enumeration of possible outcomes of the code execution.
170+ enum Outcome {
171+ // Unspecified status. This value should not be used.
172+ OUTCOME_UNSPECIFIED = 0 ;
173+
174+ // Code execution completed successfully.
175+ OUTCOME_OK = 1 ;
176+
177+ // Code execution finished but with a failure. `stderr` should contain the
178+ // reason.
179+ OUTCOME_FAILED = 2 ;
180+
181+ // Code execution ran for too long, and was cancelled. There may or may not
182+ // be a partial output present.
183+ OUTCOME_DEADLINE_EXCEEDED = 3 ;
184+ }
185+
186+ // Required. Outcome of the code execution.
187+ Outcome outcome = 1 [(google.api.field_behavior ) = REQUIRED ];
188+
189+ // Optional. Contains stdout when code execution is successful, stderr or
190+ // other description otherwise.
191+ string output = 2 [(google.api.field_behavior ) = OPTIONAL ];
192+ }
193+
131194// Defines a retrieval tool that model can call to access external knowledge.
132195message Retrieval {
133196 // The source of the retrieval.
0 commit comments