1// Copyright 2023 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15syntax = "proto3"; 16 17package google.ai.generativelanguage.v1beta3; 18 19import "google/ai/generativelanguage/v1beta3/model.proto"; 20import "google/ai/generativelanguage/v1beta3/tuned_model.proto"; 21import "google/api/annotations.proto"; 22import "google/api/client.proto"; 23import "google/api/field_behavior.proto"; 24import "google/api/resource.proto"; 25import "google/longrunning/operations.proto"; 26import "google/protobuf/empty.proto"; 27import "google/protobuf/field_mask.proto"; 28 29option go_package = "cloud.google.com/go/ai/generativelanguage/apiv1beta3/generativelanguagepb;generativelanguagepb"; 30option java_multiple_files = true; 31option java_outer_classname = "ModelServiceProto"; 32option java_package = "com.google.ai.generativelanguage.v1beta3"; 33 34// Provides methods for getting metadata information about Generative Models. 35service ModelService { 36 option (google.api.default_host) = "generativelanguage.googleapis.com"; 37 38 // Gets information about a specific Model. 39 rpc GetModel(GetModelRequest) returns (Model) { 40 option (google.api.http) = { 41 get: "/v1beta3/{name=models/*}" 42 }; 43 option (google.api.method_signature) = "name"; 44 } 45 46 // Lists models available through the API. 47 rpc ListModels(ListModelsRequest) returns (ListModelsResponse) { 48 option (google.api.http) = { 49 get: "/v1beta3/models" 50 }; 51 option (google.api.method_signature) = "page_size,page_token"; 52 } 53 54 // Gets information about a specific TunedModel. 55 rpc GetTunedModel(GetTunedModelRequest) returns (TunedModel) { 56 option (google.api.http) = { 57 get: "/v1beta3/{name=tunedModels/*}" 58 }; 59 option (google.api.method_signature) = "name"; 60 } 61 62 // Lists tuned models owned by the user. 63 rpc ListTunedModels(ListTunedModelsRequest) 64 returns (ListTunedModelsResponse) { 65 option (google.api.http) = { 66 get: "/v1beta3/tunedModels" 67 }; 68 option (google.api.method_signature) = "page_size,page_token"; 69 } 70 71 // Creates a tuned model. 72 // Intermediate tuning progress (if any) is accessed through the 73 // [google.longrunning.Operations] service. 74 // 75 // Status and results can be accessed through the Operations service. 76 // Example: 77 // GET /v1/tunedModels/az2mb0bpw6i/operations/000-111-222 78 rpc CreateTunedModel(CreateTunedModelRequest) 79 returns (google.longrunning.Operation) { 80 option (google.api.http) = { 81 post: "/v1beta3/tunedModels" 82 body: "tuned_model" 83 }; 84 option (google.api.method_signature) = "tuned_model"; 85 option (google.api.method_signature) = "tuned_model_id,tuned_model"; 86 option (google.longrunning.operation_info) = { 87 response_type: "TunedModel" 88 metadata_type: "CreateTunedModelMetadata" 89 }; 90 } 91 92 // Updates a tuned model. 93 rpc UpdateTunedModel(UpdateTunedModelRequest) returns (TunedModel) { 94 option (google.api.http) = { 95 patch: "/v1beta3/{tuned_model.name=tunedModels/*}" 96 body: "tuned_model" 97 }; 98 option (google.api.method_signature) = "tuned_model,update_mask"; 99 } 100 101 // Deletes a tuned model. 102 rpc DeleteTunedModel(DeleteTunedModelRequest) 103 returns (google.protobuf.Empty) { 104 option (google.api.http) = { 105 delete: "/v1beta3/{name=tunedModels/*}" 106 }; 107 option (google.api.method_signature) = "name"; 108 } 109} 110 111// Request for getting information about a specific Model. 112message GetModelRequest { 113 // Required. The resource name of the model. 114 // 115 // This name should match a model name returned by the `ListModels` method. 116 // 117 // Format: `models/{model}` 118 string name = 1 [ 119 (google.api.field_behavior) = REQUIRED, 120 (google.api.resource_reference) = { 121 type: "generativelanguage.googleapis.com/Model" 122 } 123 ]; 124} 125 126// Request for listing all Models. 127message ListModelsRequest { 128 // The maximum number of `Models` to return (per page). 129 // 130 // The service may return fewer models. 131 // If unspecified, at most 50 models will be returned per page. 132 // This method returns at most 1000 models per page, even if you pass a larger 133 // page_size. 134 int32 page_size = 2; 135 136 // A page token, received from a previous `ListModels` call. 137 // 138 // Provide the `page_token` returned by one request as an argument to the next 139 // request to retrieve the next page. 140 // 141 // When paginating, all other parameters provided to `ListModels` must match 142 // the call that provided the page token. 143 string page_token = 3; 144} 145 146// Response from `ListModel` containing a paginated list of Models. 147message ListModelsResponse { 148 // The returned Models. 149 repeated Model models = 1; 150 151 // A token, which can be sent as `page_token` to retrieve the next page. 152 // 153 // If this field is omitted, there are no more pages. 154 string next_page_token = 2; 155} 156 157// Request for getting information about a specific Model. 158message GetTunedModelRequest { 159 // Required. The resource name of the model. 160 // 161 // Format: `tunedModels/my-model-id` 162 string name = 1 [ 163 (google.api.field_behavior) = REQUIRED, 164 (google.api.resource_reference) = { 165 type: "generativelanguage.googleapis.com/TunedModel" 166 } 167 ]; 168} 169 170// Request for listing TunedModels. 171message ListTunedModelsRequest { 172 // Optional. The maximum number of `TunedModels` to return (per page). 173 // The service may return fewer tuned models. 174 // 175 // If unspecified, at most 10 tuned models will be returned. 176 // This method returns at most 1000 models per page, even if you pass a larger 177 // page_size. 178 int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL]; 179 180 // Optional. A page token, received from a previous `ListTunedModels` call. 181 // 182 // Provide the `page_token` returned by one request as an argument to the next 183 // request to retrieve the next page. 184 // 185 // When paginating, all other parameters provided to `ListTunedModels` 186 // must match the call that provided the page token. 187 string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; 188} 189 190// Response from `ListTunedModels` containing a paginated list of Models. 191message ListTunedModelsResponse { 192 // The returned Models. 193 repeated TunedModel tuned_models = 1; 194 195 // A token, which can be sent as `page_token` to retrieve the next page. 196 // 197 // If this field is omitted, there are no more pages. 198 string next_page_token = 2; 199} 200 201// Request to create a TunedModel. 202message CreateTunedModelRequest { 203 // Optional. The unique id for the tuned model if specified. 204 // This value should be up to 40 characters, the first character must be a 205 // letter, the last could be a letter or a number. The id must match the 206 // regular expression: [a-z]([a-z0-9-]{0,38}[a-z0-9])?. 207 optional string tuned_model_id = 1 [(google.api.field_behavior) = OPTIONAL]; 208 209 // Required. The tuned model to create. 210 TunedModel tuned_model = 2 [(google.api.field_behavior) = REQUIRED]; 211} 212 213// Metadata about the state and progress of creating a tuned model returned from 214// the long-running operation 215message CreateTunedModelMetadata { 216 // Name of the tuned model associated with the tuning operation. 217 string tuned_model = 5 [(google.api.resource_reference) = { 218 type: "generativelanguage.googleapis.com/TunedModel" 219 }]; 220 221 // The total number of tuning steps. 222 int32 total_steps = 1; 223 224 // The number of steps completed. 225 int32 completed_steps = 2; 226 227 // The completed percentage for the tuning operation. 228 float completed_percent = 3; 229 230 // Metrics collected during tuning. 231 repeated TuningSnapshot snapshots = 4; 232} 233 234// Request to update a TunedModel. 235message UpdateTunedModelRequest { 236 // Required. The tuned model to update. 237 TunedModel tuned_model = 1 [(google.api.field_behavior) = REQUIRED]; 238 239 // Required. The list of fields to update. 240 google.protobuf.FieldMask update_mask = 2 241 [(google.api.field_behavior) = REQUIRED]; 242} 243 244// Request to delete a TunedModel. 245message DeleteTunedModelRequest { 246 // Required. The resource name of the model. 247 // Format: `tunedModels/my-model-id` 248 string name = 1 [ 249 (google.api.field_behavior) = REQUIRED, 250 (google.api.resource_reference) = { 251 type: "generativelanguage.googleapis.com/TunedModel" 252 } 253 ]; 254} 255