Skip to content

Commit

Permalink
feat: Expose code execution tool API to v1
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 719423496

Source-Link: googleapis/googleapis@d8b31b6

Source-Link: googleapis/googleapis-gen@8a130cd
Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWFpcGxhdGZvcm0vLk93bEJvdC55YW1sIiwiaCI6IjhhMTMwY2Q4Mzc3NjEyMjJmNDUwYWE4MDNhNDNlMTlmNjU1ZTBjZjYifQ==
  • Loading branch information
gcf-owl-bot[bot] committed Jan 25, 2025
1 parent 5e9db41 commit 603386c
Show file tree
Hide file tree
Showing 5 changed files with 1,301 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ message Part {
// the model.
FunctionResponse function_response = 6
[(google.api.field_behavior) = OPTIONAL];

// Optional. Code generated by the model that is meant to be executed.
ExecutableCode executable_code = 8 [(google.api.field_behavior) = OPTIONAL];

// Optional. Result of executing the [ExecutableCode].
CodeExecutionResult code_execution_result = 9
[(google.api.field_behavior) = OPTIONAL];
}

oneof metadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ option ruby_package = "Google::Cloud::AIPlatform::V1";
// one type of Tool (e.g FunctionDeclaration, Retrieval or
// GoogleSearchRetrieval).
message Tool {
// Tool that executes code generated by the model, and automatically returns
// the result to the model.
//
// See also [ExecutableCode]and [CodeExecutionResult] which are input and
// output to this tool.
message CodeExecution {}

// Optional. Function tool type.
// One or more function declarations to be passed to the model along with the
// current user query. Model may decide to call a subset of these functions
Expand All @@ -59,6 +66,11 @@ message Tool {
// Specialized retrieval tool that is powered by Google search.
GoogleSearchRetrieval google_search_retrieval = 3
[(google.api.field_behavior) = OPTIONAL];

// Optional. CodeExecution tool type.
// Enables the model to execute code as part of generation.
// This field is only used by the Gemini Developer API services.
CodeExecution code_execution = 4 [(google.api.field_behavior) = OPTIONAL];
}

// Structured representation of a function declaration as defined by the
Expand Down Expand Up @@ -128,6 +140,57 @@ message FunctionResponse {
google.protobuf.Struct response = 2 [(google.api.field_behavior) = REQUIRED];
}

// Code generated by the model that is meant to be executed, and the result
// returned to the model.
//
// Generated when using the [FunctionDeclaration] tool and
// [FunctionCallingConfig] mode is set to [Mode.CODE].
message ExecutableCode {
// Supported programming languages for the generated code.
enum Language {
// Unspecified language. This value should not be used.
LANGUAGE_UNSPECIFIED = 0;

// Python >= 3.10, with numpy and simpy available.
PYTHON = 1;
}

// Required. Programming language of the `code`.
Language language = 1 [(google.api.field_behavior) = REQUIRED];

// Required. The code to be executed.
string code = 2 [(google.api.field_behavior) = REQUIRED];
}

// Result of executing the [ExecutableCode].
//
// Always follows a `part` containing the [ExecutableCode].
message CodeExecutionResult {
// Enumeration of possible outcomes of the code execution.
enum Outcome {
// Unspecified status. This value should not be used.
OUTCOME_UNSPECIFIED = 0;

// Code execution completed successfully.
OUTCOME_OK = 1;

// Code execution finished but with a failure. `stderr` should contain the
// reason.
OUTCOME_FAILED = 2;

// Code execution ran for too long, and was cancelled. There may or may not
// be a partial output present.
OUTCOME_DEADLINE_EXCEEDED = 3;
}

// Required. Outcome of the code execution.
Outcome outcome = 1 [(google.api.field_behavior) = REQUIRED];

// Optional. Contains stdout when code execution is successful, stderr or
// other description otherwise.
string output = 2 [(google.api.field_behavior) = OPTIONAL];
}

// Defines a retrieval tool that model can call to access external knowledge.
message Retrieval {
// The source of the retrieval.
Expand Down
Loading

0 comments on commit 603386c

Please sign in to comment.