Skip to content

Commit

Permalink
feat: Add system instructions
Browse files Browse the repository at this point in the history
feat: Add tool_config
feat: Add file upload service
feat: Add file_data to part options
docs: A comment for field `candidate_count` in message `.google.ai.generativelanguage.v1beta.GenerationConfig` is changed

PiperOrigin-RevId: 620400522
  • Loading branch information
Google APIs authored and Copybara-Service committed Mar 30, 2024
1 parent a70aa2c commit 81cd9fe
Show file tree
Hide file tree
Showing 6 changed files with 286 additions and 11 deletions.
18 changes: 16 additions & 2 deletions google/ai/generativelanguage/v1beta/BUILD.bazel
Expand Up @@ -9,21 +9,26 @@
# * extra_protoc_file_parameters
# The complete list of preserved parameters can be found in the source code.

# buildifier: disable=load-on-top

# This is an API workspace, having public visibility by default makes perfect sense.
package(default_visibility = ["//visibility:public"])

##############################################################################
# Common
##############################################################################
load("@rules_proto//proto:defs.bzl", "proto_library")
# buildifier: disable=same-origin-load
load("@com_google_googleapis_imports//:imports.bzl", "proto_library_with_info")
load("@rules_proto//proto:defs.bzl", "proto_library")

proto_library(
name = "generativelanguage_proto",
srcs = [
"citation.proto",
"content.proto",
"discuss_service.proto",
"file.proto",
"file_service.proto",
"generative_service.proto",
"model.proto",
"model_service.proto",
Expand Down Expand Up @@ -59,6 +64,7 @@ proto_library_with_info(
##############################################################################
# Java
##############################################################################
# buildifier: disable=same-origin-load
load(
"@com_google_googleapis_imports//:imports.bzl",
"java_gapic_assembly_gradle_pkg",
Expand Down Expand Up @@ -101,6 +107,8 @@ java_gapic_test(
test_classes = [
"com.google.ai.generativelanguage.v1beta.DiscussServiceClientHttpJsonTest",
"com.google.ai.generativelanguage.v1beta.DiscussServiceClientTest",
"com.google.ai.generativelanguage.v1beta.FileServiceClientHttpJsonTest",
"com.google.ai.generativelanguage.v1beta.FileServiceClientTest",
"com.google.ai.generativelanguage.v1beta.GenerativeServiceClientHttpJsonTest",
"com.google.ai.generativelanguage.v1beta.GenerativeServiceClientTest",
"com.google.ai.generativelanguage.v1beta.ModelServiceClientHttpJsonTest",
Expand Down Expand Up @@ -131,6 +139,7 @@ java_gapic_assembly_gradle_pkg(
##############################################################################
# Go
##############################################################################
# buildifier: disable=same-origin-load
load(
"@com_google_googleapis_imports//:imports.bzl",
"go_gapic_assembly_pkg",
Expand Down Expand Up @@ -183,6 +192,7 @@ go_gapic_assembly_pkg(
##############################################################################
# Python
##############################################################################
# buildifier: disable=same-origin-load
load(
"@com_google_googleapis_imports//:imports.bzl",
"py_gapic_assembly_pkg",
Expand Down Expand Up @@ -222,6 +232,7 @@ py_gapic_assembly_pkg(
##############################################################################
# PHP
##############################################################################
# buildifier: disable=same-origin-load
load(
"@com_google_googleapis_imports//:imports.bzl",
"php_gapic_assembly_pkg",
Expand Down Expand Up @@ -259,6 +270,7 @@ php_gapic_assembly_pkg(
##############################################################################
# Node.js
##############################################################################
# buildifier: disable=same-origin-load
load(
"@com_google_googleapis_imports//:imports.bzl",
"nodejs_gapic_assembly_pkg",
Expand Down Expand Up @@ -289,6 +301,7 @@ nodejs_gapic_assembly_pkg(
##############################################################################
# Ruby
##############################################################################
# buildifier: disable=same-origin-load
load(
"@com_google_googleapis_imports//:imports.bzl",
"ruby_cloud_gapic_library",
Expand Down Expand Up @@ -335,6 +348,7 @@ ruby_gapic_assembly_pkg(
##############################################################################
# C#
##############################################################################
# buildifier: disable=same-origin-load
load(
"@com_google_googleapis_imports//:imports.bzl",
"csharp_gapic_assembly_pkg",
Expand All @@ -345,7 +359,6 @@ load(

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

Expand Down Expand Up @@ -382,6 +395,7 @@ csharp_gapic_assembly_pkg(
##############################################################################
# C++
##############################################################################
# buildifier: disable=same-origin-load
load(
"@com_google_googleapis_imports//:imports.bzl",
"cc_grpc_library",
Expand Down
57 changes: 57 additions & 0 deletions google/ai/generativelanguage/v1beta/content.proto
Expand Up @@ -91,6 +91,9 @@ message Part {
// object containing any output from the function is used as context to
// the model.
FunctionResponse function_response = 5;

// URI based data.
FileData file_data = 6;
}
}

Expand All @@ -107,6 +110,15 @@ message Blob {
bytes data = 2;
}

// URI based data.
message FileData {
// Optional. The IANA standard MIME type of the source data.
string mime_type = 1 [(google.api.field_behavior) = OPTIONAL];

// Required. URI.
string file_uri = 2 [(google.api.field_behavior) = REQUIRED];
}

// 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 @@ -129,6 +141,51 @@ message Tool {
[(google.api.field_behavior) = OPTIONAL];
}

// The Tool configuration containing parameters for specifying `Tool` use
// in the request.
message ToolConfig {
// Optional. Function calling config.
FunctionCallingConfig function_calling_config = 1
[(google.api.field_behavior) = OPTIONAL];
}

// Configuration for specifying function calling behavior.
message FunctionCallingConfig {
// Defines the execution behavior for function calling by defining the
// execution mode.
enum Mode {
// Unspecified function calling mode. This value should not be used.
MODE_UNSPECIFIED = 0;

// Default model behavior, model decides to predict either a function call
// or a natural language repspose.
AUTO = 1;

// Model is constrained to always predicting a function call only.
// If "allowed_function_names" are set, the predicted function call will be
// limited to any one of "allowed_function_names", else the predicted
// function call will be any one of the provided "function_declarations".
ANY = 2;

// Model will not predict any function call. Model behavior is same as when
// not passing any function declarations.
NONE = 3;
}

// Optional. Specifies the mode in which function calling should execute. If
// unspecified, the default value will be set to AUTO.
Mode mode = 1 [(google.api.field_behavior) = OPTIONAL];

// Optional. A set of function names that, when provided, limits the functions
// the model will call.
//
// This should only be set when the Mode is ANY. Function names
// should match [FunctionDeclaration.name]. With mode set to ANY, model will
// predict a function call from the set of function names provided.
repeated string allowed_function_names = 2
[(google.api.field_behavior) = OPTIONAL];
}

// Structured representation of a function declaration as defined by the
// [OpenAPI 3.03 specification](https://spec.openapis.org/oas/v3.0.3). Included
// in this declaration are the function name and parameters. This
Expand Down
76 changes: 76 additions & 0 deletions google/ai/generativelanguage/v1beta/file.proto
@@ -0,0 +1,76 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.ai.generativelanguage.v1beta;

import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/timestamp.proto";

option go_package = "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb;generativelanguagepb";
option java_multiple_files = true;
option java_outer_classname = "FileProto";
option java_package = "com.google.ai.generativelanguage.v1beta";

// A file uploaded to the API.
message File {
option (google.api.resource) = {
type: "generativelanguage.googleapis.com/File"
pattern: "files/{file}"
plural: "files"
singular: "file"
};

// 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
// name is empty on create, a unique name will be generated. Example:
// `files/123-456`
string name = 1 [
(google.api.field_behavior) = IDENTIFIER,
(google.api.field_behavior) = IMMUTABLE
];

// Optional. The human-readable display name for the `File`. The display name
// must be no more than 512 characters in length, including spaces. Example:
// "Welcome Image"
string display_name = 2 [(google.api.field_behavior) = OPTIONAL];

// Output only. MIME type of the file.
string mime_type = 3 [(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. Size of the file in bytes.
int64 size_bytes = 4 [(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. The timestamp of when the `File` was created.
google.protobuf.Timestamp create_time = 5
[(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. The timestamp of when the `File` was last updated.
google.protobuf.Timestamp update_time = 6
[(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. The timestamp of when the `File` will be deleted. Only set if
// the `File` is scheduled to expire.
google.protobuf.Timestamp expiration_time = 7
[(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. SHA-256 hash of the uploaded bytes.
bytes sha256_hash = 8 [(google.api.field_behavior) = OUTPUT_ONLY];

// Output only. The uri of the `File`.
string uri = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
}
121 changes: 121 additions & 0 deletions google/ai/generativelanguage/v1beta/file_service.proto
@@ -0,0 +1,121 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.ai.generativelanguage.v1beta;

import "google/ai/generativelanguage/v1beta/file.proto";
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/empty.proto";

option go_package = "cloud.google.com/go/ai/generativelanguage/apiv1beta/generativelanguagepb;generativelanguagepb";
option java_multiple_files = true;
option java_outer_classname = "FileServiceProto";
option java_package = "com.google.ai.generativelanguage.v1beta";

// An API for uploading and managing files.
service FileService {
option (google.api.default_host) = "generativelanguage.googleapis.com";

// Creates a `File`.
rpc CreateFile(CreateFileRequest) returns (CreateFileResponse) {
option (google.api.http) = {
post: "/v1beta/files"
body: "*"
};
}

// Lists the metadata for `File`s owned by the requesting project.
rpc ListFiles(ListFilesRequest) returns (ListFilesResponse) {
option (google.api.http) = {
get: "/v1beta/files"
};
}

// Gets the metadata for the given `File`.
rpc GetFile(GetFileRequest) returns (File) {
option (google.api.http) = {
get: "/v1beta/{name=files/*}"
};
option (google.api.method_signature) = "name";
}

// Deletes the `File`.
rpc DeleteFile(DeleteFileRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete: "/v1beta/{name=files/*}"
};
option (google.api.method_signature) = "name";
}
}

// Request for `CreateFile`.
message CreateFileRequest {
// Optional. Metadata for the file to create.
File file = 1 [(google.api.field_behavior) = OPTIONAL];
}

// Response for `CreateFile`.
message CreateFileResponse {
// Metadata for the created file.
File file = 1;
}

// Request for `ListFiles`.
message ListFilesRequest {
// Optional. Maximum number of `File`s to return per page.
// If unspecified, defaults to 10. Maximum `page_size` is 100.
int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL];

// Optional. A page token from a previous `ListFiles` call.
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Response for `ListFiles`.
message ListFilesResponse {
// The list of `File`s.
repeated File files = 1;

// A token that can be sent as a `page_token` into a subsequent `ListFiles`
// call.
string next_page_token = 2;
}

// Request for `GetFile`.
message GetFileRequest {
// Required. The name of the `File` to get.
// Example: `files/abc-123`
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "generativelanguage.googleapis.com/File"
}
];
}

// Request for `DeleteFile`.
message DeleteFileRequest {
// Required. The name of the `File` to delete.
// Example: `files/abc-123`
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "generativelanguage.googleapis.com/File"
}
];
}

0 comments on commit 81cd9fe

Please sign in to comment.