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.cloud.aiplatform.v1; 18 19import "google/api/field_behavior.proto"; 20import "google/cloud/aiplatform/v1/tool.proto"; 21import "google/protobuf/duration.proto"; 22import "google/type/date.proto"; 23 24option csharp_namespace = "Google.Cloud.AIPlatform.V1"; 25option go_package = "cloud.google.com/go/aiplatform/apiv1/aiplatformpb;aiplatformpb"; 26option java_multiple_files = true; 27option java_outer_classname = "ContentProto"; 28option java_package = "com.google.cloud.aiplatform.v1"; 29option php_namespace = "Google\\Cloud\\AIPlatform\\V1"; 30option ruby_package = "Google::Cloud::AIPlatform::V1"; 31 32// Harm categories that will block the content. 33enum HarmCategory { 34 // The harm category is unspecified. 35 HARM_CATEGORY_UNSPECIFIED = 0; 36 37 // The harm category is hate speech. 38 HARM_CATEGORY_HATE_SPEECH = 1; 39 40 // The harm category is dangerous content. 41 HARM_CATEGORY_DANGEROUS_CONTENT = 2; 42 43 // The harm category is harassment. 44 HARM_CATEGORY_HARASSMENT = 3; 45 46 // The harm category is sexually explicit content. 47 HARM_CATEGORY_SEXUALLY_EXPLICIT = 4; 48} 49 50// The base structured datatype containing multi-part content of a message. 51// 52// A `Content` includes a `role` field designating the producer of the `Content` 53// and a `parts` field containing multi-part data that contains the content of 54// the message turn. 55message Content { 56 // Optional. The producer of the content. Must be either 'user' or 'model'. 57 // 58 // Useful to set for multi-turn conversations, otherwise can be left blank 59 // or unset. 60 string role = 1 [(google.api.field_behavior) = OPTIONAL]; 61 62 // Required. Ordered `Parts` that constitute a single message. Parts may have 63 // different IANA MIME types. 64 repeated Part parts = 2 [(google.api.field_behavior) = REQUIRED]; 65} 66 67// A datatype containing media that is part of a multi-part `Content` message. 68// 69// A `Part` consists of data which has an associated datatype. A `Part` can only 70// contain one of the accepted types in `Part.data`. 71// 72// A `Part` must have a fixed IANA MIME type identifying the type and subtype 73// of the media if `inline_data` or `file_data` field is filled with raw bytes. 74message Part { 75 oneof data { 76 // Optional. Text part (can be code). 77 string text = 1 [(google.api.field_behavior) = OPTIONAL]; 78 79 // Optional. Inlined bytes data. 80 Blob inline_data = 2 [(google.api.field_behavior) = OPTIONAL]; 81 82 // Optional. URI based data. 83 FileData file_data = 3 [(google.api.field_behavior) = OPTIONAL]; 84 85 // Optional. A predicted [FunctionCall] returned from the model that 86 // contains a string representing the [FunctionDeclaration.name] with the 87 // parameters and their values. 88 FunctionCall function_call = 5 [(google.api.field_behavior) = OPTIONAL]; 89 90 // Optional. The result output of a [FunctionCall] that contains a string 91 // representing the [FunctionDeclaration.name] and a structured JSON object 92 // containing any output from the function call. It is used as context to 93 // the model. 94 FunctionResponse function_response = 6 95 [(google.api.field_behavior) = OPTIONAL]; 96 } 97 98 oneof metadata { 99 // Optional. Video metadata. The metadata should only be specified while the 100 // video data is presented in inline_data or file_data. 101 VideoMetadata video_metadata = 4 [(google.api.field_behavior) = OPTIONAL]; 102 } 103} 104 105// Content blob. 106// 107// It's preferred to send as [text][google.cloud.aiplatform.v1.Part.text] 108// directly rather than raw bytes. 109message Blob { 110 // Required. The IANA standard MIME type of the source data. 111 string mime_type = 1 [(google.api.field_behavior) = REQUIRED]; 112 113 // Required. Raw bytes. 114 bytes data = 2 [(google.api.field_behavior) = REQUIRED]; 115} 116 117// URI based data. 118message FileData { 119 // Required. The IANA standard MIME type of the source data. 120 string mime_type = 1 [(google.api.field_behavior) = REQUIRED]; 121 122 // Required. URI. 123 string file_uri = 2 [(google.api.field_behavior) = REQUIRED]; 124} 125 126// Metadata describes the input video content. 127message VideoMetadata { 128 // Optional. The start offset of the video. 129 google.protobuf.Duration start_offset = 1 130 [(google.api.field_behavior) = OPTIONAL]; 131 132 // Optional. The end offset of the video. 133 google.protobuf.Duration end_offset = 2 134 [(google.api.field_behavior) = OPTIONAL]; 135} 136 137// Generation config. 138message GenerationConfig { 139 // Optional. Controls the randomness of predictions. 140 optional float temperature = 1 [(google.api.field_behavior) = OPTIONAL]; 141 142 // Optional. If specified, nucleus sampling will be used. 143 optional float top_p = 2 [(google.api.field_behavior) = OPTIONAL]; 144 145 // Optional. If specified, top-k sampling will be used. 146 optional float top_k = 3 [(google.api.field_behavior) = OPTIONAL]; 147 148 // Optional. Number of candidates to generate. 149 optional int32 candidate_count = 4 [(google.api.field_behavior) = OPTIONAL]; 150 151 // Optional. The maximum number of output tokens to generate per message. 152 optional int32 max_output_tokens = 5 [(google.api.field_behavior) = OPTIONAL]; 153 154 // Optional. Stop sequences. 155 repeated string stop_sequences = 6 [(google.api.field_behavior) = OPTIONAL]; 156 157 // Optional. Positive penalties. 158 optional float presence_penalty = 8 [(google.api.field_behavior) = OPTIONAL]; 159 160 // Optional. Frequency penalties. 161 optional float frequency_penalty = 9 [(google.api.field_behavior) = OPTIONAL]; 162 163 // Optional. Output response mimetype of the generated candidate text. 164 // Supported mimetype: 165 // - `text/plain`: (default) Text output. 166 // - `application/json`: JSON response in the candidates. 167 // The model needs to be prompted to output the appropriate response type, 168 // otherwise the behavior is undefined. 169 // This is a preview feature. 170 string response_mime_type = 13 [(google.api.field_behavior) = OPTIONAL]; 171} 172 173// Safety settings. 174message SafetySetting { 175 // Probability based thresholds levels for blocking. 176 enum HarmBlockThreshold { 177 // Unspecified harm block threshold. 178 HARM_BLOCK_THRESHOLD_UNSPECIFIED = 0; 179 180 // Block low threshold and above (i.e. block more). 181 BLOCK_LOW_AND_ABOVE = 1; 182 183 // Block medium threshold and above. 184 BLOCK_MEDIUM_AND_ABOVE = 2; 185 186 // Block only high threshold (i.e. block less). 187 BLOCK_ONLY_HIGH = 3; 188 189 // Block none. 190 BLOCK_NONE = 4; 191 } 192 193 // Probability vs severity. 194 enum HarmBlockMethod { 195 // The harm block method is unspecified. 196 HARM_BLOCK_METHOD_UNSPECIFIED = 0; 197 198 // The harm block method uses both probability and severity scores. 199 SEVERITY = 1; 200 201 // The harm block method uses the probability score. 202 PROBABILITY = 2; 203 } 204 205 // Required. Harm category. 206 HarmCategory category = 1 [(google.api.field_behavior) = REQUIRED]; 207 208 // Required. The harm block threshold. 209 HarmBlockThreshold threshold = 2 [(google.api.field_behavior) = REQUIRED]; 210 211 // Optional. Specify if the threshold is used for probability or severity 212 // score. If not specified, the threshold is used for probability score. 213 HarmBlockMethod method = 4 [(google.api.field_behavior) = OPTIONAL]; 214} 215 216// Safety rating corresponding to the generated content. 217message SafetyRating { 218 // Harm probability levels in the content. 219 enum HarmProbability { 220 // Harm probability unspecified. 221 HARM_PROBABILITY_UNSPECIFIED = 0; 222 223 // Negligible level of harm. 224 NEGLIGIBLE = 1; 225 226 // Low level of harm. 227 LOW = 2; 228 229 // Medium level of harm. 230 MEDIUM = 3; 231 232 // High level of harm. 233 HIGH = 4; 234 } 235 236 // Harm severity levels. 237 enum HarmSeverity { 238 // Harm severity unspecified. 239 HARM_SEVERITY_UNSPECIFIED = 0; 240 241 // Negligible level of harm severity. 242 HARM_SEVERITY_NEGLIGIBLE = 1; 243 244 // Low level of harm severity. 245 HARM_SEVERITY_LOW = 2; 246 247 // Medium level of harm severity. 248 HARM_SEVERITY_MEDIUM = 3; 249 250 // High level of harm severity. 251 HARM_SEVERITY_HIGH = 4; 252 } 253 254 // Output only. Harm category. 255 HarmCategory category = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; 256 257 // Output only. Harm probability levels in the content. 258 HarmProbability probability = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; 259 260 // Output only. Harm probability score. 261 float probability_score = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; 262 263 // Output only. Harm severity levels in the content. 264 HarmSeverity severity = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; 265 266 // Output only. Harm severity score. 267 float severity_score = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; 268 269 // Output only. Indicates whether the content was filtered out because of this 270 // rating. 271 bool blocked = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; 272} 273 274// A collection of source attributions for a piece of content. 275message CitationMetadata { 276 // Output only. List of citations. 277 repeated Citation citations = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; 278} 279 280// Source attributions for content. 281message Citation { 282 // Output only. Start index into the content. 283 int32 start_index = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; 284 285 // Output only. End index into the content. 286 int32 end_index = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; 287 288 // Output only. Url reference of the attribution. 289 string uri = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; 290 291 // Output only. Title of the attribution. 292 string title = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; 293 294 // Output only. License of the attribution. 295 string license = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; 296 297 // Output only. Publication date of the attribution. 298 google.type.Date publication_date = 6 299 [(google.api.field_behavior) = OUTPUT_ONLY]; 300} 301 302// A response candidate generated from the model. 303message Candidate { 304 // The reason why the model stopped generating tokens. 305 // If empty, the model has not stopped generating the tokens. 306 enum FinishReason { 307 // The finish reason is unspecified. 308 FINISH_REASON_UNSPECIFIED = 0; 309 310 // Natural stop point of the model or provided stop sequence. 311 STOP = 1; 312 313 // The maximum number of tokens as specified in the request was reached. 314 MAX_TOKENS = 2; 315 316 // The token generation was stopped as the response was flagged for safety 317 // reasons. NOTE: When streaming the Candidate.content will be empty if 318 // content filters blocked the output. 319 SAFETY = 3; 320 321 // The token generation was stopped as the response was flagged for 322 // unauthorized citations. 323 RECITATION = 4; 324 325 // All other reasons that stopped the token generation 326 OTHER = 5; 327 328 // The token generation was stopped as the response was flagged for the 329 // terms which are included from the terminology blocklist. 330 BLOCKLIST = 6; 331 332 // The token generation was stopped as the response was flagged for 333 // the prohibited contents. 334 PROHIBITED_CONTENT = 7; 335 336 // The token generation was stopped as the response was flagged for 337 // Sensitive Personally Identifiable Information (SPII) contents. 338 SPII = 8; 339 } 340 341 // Output only. Index of the candidate. 342 int32 index = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; 343 344 // Output only. Content parts of the candidate. 345 Content content = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; 346 347 // Output only. The reason why the model stopped generating tokens. 348 // If empty, the model has not stopped generating the tokens. 349 FinishReason finish_reason = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; 350 351 // Output only. List of ratings for the safety of a response candidate. 352 // 353 // There is at most one rating per category. 354 repeated SafetyRating safety_ratings = 4 355 [(google.api.field_behavior) = OUTPUT_ONLY]; 356 357 // Output only. Describes the reason the mode stopped generating tokens in 358 // more detail. This is only filled when `finish_reason` is set. 359 optional string finish_message = 5 360 [(google.api.field_behavior) = OUTPUT_ONLY]; 361 362 // Output only. Source attribution of the generated content. 363 CitationMetadata citation_metadata = 6 364 [(google.api.field_behavior) = OUTPUT_ONLY]; 365 366 // Output only. Metadata specifies sources used to ground generated content. 367 GroundingMetadata grounding_metadata = 7 368 [(google.api.field_behavior) = OUTPUT_ONLY]; 369} 370 371// Segment of the content. 372message Segment { 373 // Output only. The index of a Part object within its parent Content object. 374 int32 part_index = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; 375 376 // Output only. Start index in the given Part, measured in bytes. Offset from 377 // the start of the Part, inclusive, starting at zero. 378 int32 start_index = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; 379 380 // Output only. End index in the given Part, measured in bytes. Offset from 381 // the start of the Part, exclusive, starting at zero. 382 int32 end_index = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; 383} 384 385// Grounding attribution. 386message GroundingAttribution { 387 // Attribution from the web. 388 message Web { 389 // Output only. URI reference of the attribution. 390 string uri = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; 391 392 // Output only. Title of the attribution. 393 string title = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; 394 } 395 396 oneof reference { 397 // Optional. Attribution from the web. 398 Web web = 3 [(google.api.field_behavior) = OPTIONAL]; 399 } 400 401 // Output only. Segment of the content this attribution belongs to. 402 Segment segment = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; 403 404 // Optional. Output only. Confidence score of the attribution. Ranges from 0 405 // to 1. 1 is the most confident. 406 optional float confidence_score = 2 [ 407 (google.api.field_behavior) = OPTIONAL, 408 (google.api.field_behavior) = OUTPUT_ONLY 409 ]; 410} 411 412// Metadata returned to client when grounding is enabled. 413message GroundingMetadata { 414 // Optional. Web search queries for the following-up web search. 415 repeated string web_search_queries = 1 416 [(google.api.field_behavior) = OPTIONAL]; 417 418 // Optional. List of grounding attributions. 419 repeated GroundingAttribution grounding_attributions = 2 420 [(google.api.field_behavior) = OPTIONAL]; 421} 422