Skip to content

Commit

Permalink
feat: Add code execution
Browse files Browse the repository at this point in the history
feat: Add max_temperature
docs: Minor fixes

PiperOrigin-RevId: 646960455
  • Loading branch information
Google APIs authored and copybara-github committed Jun 26, 2024
1 parent 16c01b4 commit cb060cb
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 4 deletions.
1 change: 1 addition & 0 deletions google/ai/generativelanguage/v1beta/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ load(

csharp_proto_library(
name = "generativelanguage_csharp_proto",
extra_opts = [],
deps = [":generativelanguage_proto"],
)

Expand Down
69 changes: 69 additions & 0 deletions google/ai/generativelanguage/v1beta/content.proto
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ message Part {

// URI based data.
FileData file_data = 6;

// Code generated by the model that is meant to be executed.
ExecutableCode executable_code = 9;

// Result of executing the `ExecutableCode`.
CodeExecutionResult code_execution_result = 10;
}
}

Expand Down Expand Up @@ -123,6 +129,59 @@ message FileData {
string file_uri = 2 [(google.api.field_behavior) = REQUIRED];
}

// Code generated by the model that is meant to be executed, and the result
// returned to the model.
//
// Only generated when using the `CodeExecution` tool, in which the code will
// be automatically executed, and a corresponding `CodeExecutionResult` will
// also be generated.
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`.
//
// Only generated when using the `CodeExecution`, and 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];
}

// Tool details that the model may use to generate response.
//
// A `Tool` is a piece of code that enables the system to interact with
Expand All @@ -143,8 +202,18 @@ message Tool {
// turn.
repeated FunctionDeclaration function_declarations = 1
[(google.api.field_behavior) = OPTIONAL];

// Optional. Enables the model to execute code as part of generation.
CodeExecution code_execution = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Tool that executes code generated by the model, and automatically returns
// the result to the model.
//
// See also `ExecutableCode` and `CodeExecutionResult` which are only generated
// when using this tool.
message CodeExecution {}

// The Tool configuration containing parameters for specifying `Tool` use
// in the request.
message ToolConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ message GenerateContentResponse {
// `safety_ratings` to understand which safety category blocked it.
SAFETY = 1;

// Prompt was blocked due to unknown reaasons.
// Prompt was blocked due to unknown reasons.
OTHER = 2;
}

Expand Down
9 changes: 6 additions & 3 deletions google/ai/generativelanguage/v1beta/model.proto
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,16 @@ message Model {

// Controls the randomness of the output.
//
// Values can range over `[0.0,2.0]`, inclusive. A higher value will
// produce responses that are more varied, while a value closer to `0.0` will
// typically result in less surprising responses from the model.
// Values can range over `[0.0,max_temperature]`, inclusive. A higher value
// will produce responses that are more varied, while a value closer to `0.0`
// will typically result in less surprising responses from the model.
// This value specifies default to be used by the backend while making the
// call to the model.
optional float temperature = 9;

// The maximum temperature this model can use.
optional float max_temperature = 13;

// For Nucleus sampling.
//
// Nucleus sampling considers the smallest set of tokens whose probability
Expand Down

0 comments on commit cb060cb

Please sign in to comment.