Skip to content

Commit

Permalink
feat: Add FileState to File
Browse files Browse the repository at this point in the history
feat: Add response_schema to GenerationConfig
feat: Add UsageMetadata to GenerateContentResponse
feat: Add GenerateContentRequest to CountTokensRequest
docs: Various small fixes

PiperOrigin-RevId: 630516587
  • Loading branch information
Google APIs authored and Copybara-Service committed May 3, 2024
1 parent 5010f17 commit 79c1b13
Show file tree
Hide file tree
Showing 16 changed files with 79 additions and 21 deletions.
2 changes: 1 addition & 1 deletion google/ai/generativelanguage/v1beta/citation.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Google LLC
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
10 changes: 7 additions & 3 deletions google/ai/generativelanguage/v1beta/content.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Google LLC
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -102,8 +102,12 @@ message Part {
// Text should not be sent as raw bytes, use the 'text' field.
message Blob {
// The IANA standard MIME type of the source data.
// Accepted types include: "image/png", "image/jpeg", "image/heic",
// "image/heif", "image/webp".
// Examples:
// - image/png
// - image/jpeg
// If an unsupported MIME type is provided, an error will be returned. For a
// complete list of supported types, see [Supported file
// formats](https://ai.google.dev/gemini-api/docs/prompting_with_media#supported_file_formats).
string mime_type = 1;

// Raw bytes for media formats.
Expand Down
2 changes: 1 addition & 1 deletion google/ai/generativelanguage/v1beta/discuss_service.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Google LLC
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
20 changes: 19 additions & 1 deletion google/ai/generativelanguage/v1beta/file.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Google LLC
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,6 +34,21 @@ message File {
singular: "file"
};

// States for the lifecycle of a File.
enum State {
// The default value. This value is used if the state is omitted.
STATE_UNSPECIFIED = 0;

// File is being processed and cannot be used for inference yet.
PROCESSING = 1;

// File is processed and available for inference.
ACTIVE = 2;

// File failed processing.
FAILED = 10;
}

// Immutable. Identifier. The `File` resource name. The ID (name excluding the
// "files/" prefix) can contain up to 40 characters that are lowercase
// alphanumeric or dashes (-). The ID cannot start or end with a dash. If the
Expand Down Expand Up @@ -73,4 +88,7 @@ message File {

// Output only. The uri of the `File`.
string uri = 9 [(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. Processing state of the File.
State state = 10 [(google.api.field_behavior) = OUTPUT_ONLY];
}
2 changes: 1 addition & 1 deletion google/ai/generativelanguage/v1beta/file_service.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Google LLC
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
44 changes: 40 additions & 4 deletions google/ai/generativelanguage/v1beta/generative_service.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Google LLC
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,6 +37,11 @@ service GenerativeService {

// Generates a response from the model given an input
// `GenerateContentRequest`.
//
// Input capabilities differ between models, including tuned models. See the
// [model guide](https://ai.google.dev/models/gemini) and
// [tuning guide](https://ai.google.dev/docs/model_tuning_guidance) for
// details.
rpc GenerateContent(GenerateContentRequest)
returns (GenerateContentResponse) {
option (google.api.http) = {
Expand Down Expand Up @@ -245,6 +250,16 @@ message GenerationConfig {
// `text/plain`: (default) Text output.
// `application/json`: JSON response in the candidates.
string response_mime_type = 13 [(google.api.field_behavior) = OPTIONAL];

// Optional. Output response schema of the generated candidate text when
// response mime type can have schema. Schema can be objects, primitives or
// arrays and is a subset of [OpenAPI
// schema](https://spec.openapis.org/oas/v3.0.3#schema).
//
// If set, a compatible response_mime_type must also be set.
// Compatible mimetypes:
// `application/json`: Schema for JSON response.
Schema response_schema = 14 [(google.api.field_behavior) = OPTIONAL];
}

// Configuration for retrieving grounding content from a `Corpus` or
Expand Down Expand Up @@ -307,11 +322,26 @@ message GenerateContentResponse {
repeated SafetyRating safety_ratings = 2;
}

// Metadata on the generation request's token usage.
message UsageMetadata {
// Number of tokens in the prompt.
int32 prompt_token_count = 1;

// Total number of tokens across the generated candidates.
int32 candidates_token_count = 2;

// Total token count for the generation request (prompt + candidates).
int32 total_token_count = 3;
}

// Candidate responses from the model.
repeated Candidate candidates = 1;

// Returns the prompt's feedback related to the content filters.
PromptFeedback prompt_feedback = 2;

// Output only. Metadata on the generation requests' token usage.
UsageMetadata usage_metadata = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// A response candidate generated from the model.
Expand Down Expand Up @@ -593,7 +623,8 @@ message EmbedContentRequest {

// Optional. Optional reduced dimension for the output embedding. If set,
// excessive values in the output embedding are truncated from the end.
// Supported by `models/text-embedding-latest`.
// Supported by newer models since 2024, and the earlier model
// (`models/embedding-001`) cannot specify this value.
optional int32 output_dimensionality = 5
[(google.api.field_behavior) = OPTIONAL];
}
Expand Down Expand Up @@ -657,8 +688,13 @@ message CountTokensRequest {
}
];

// Required. The input given to the model as a prompt.
repeated Content contents = 2 [(google.api.field_behavior) = REQUIRED];
// Optional. The input given to the model as a prompt.
repeated Content contents = 2 [(google.api.field_behavior) = OPTIONAL];

// Optional. The overall input given to the model. CountTokens will count
// prompt, function calling, etc.
GenerateContentRequest generate_content_request = 3
[(google.api.field_behavior) = OPTIONAL];
}

// A response from `CountTokens`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ documentation:
The Gemini API allows developers to build generative AI applications using
Gemini models. Gemini is our most capable model, built from the ground up
to be multimodal. It can generalize and seamlessly understand, operate
across, and combine different types of information. including language,
across, and combine different types of information including language,
images, audio, video, and code. You can use the Gemini API for use cases
like reasoning across text and images, content generation, dialogue
agents, summarization and classification systems, and more.
Expand Down
2 changes: 1 addition & 1 deletion google/ai/generativelanguage/v1beta/model.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Google LLC
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion google/ai/generativelanguage/v1beta/model_service.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Google LLC
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion google/ai/generativelanguage/v1beta/permission.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Google LLC
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Google LLC
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion google/ai/generativelanguage/v1beta/retriever.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Google LLC
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Google LLC
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion google/ai/generativelanguage/v1beta/safety.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Google LLC
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion google/ai/generativelanguage/v1beta/text_service.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Google LLC
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion google/ai/generativelanguage/v1beta/tuned_model.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Google LLC
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down

0 comments on commit 79c1b13

Please sign in to comment.