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.v1beta1; 18 19import "google/api/annotations.proto"; 20import "google/api/client.proto"; 21import "google/api/field_behavior.proto"; 22import "google/api/resource.proto"; 23import "google/protobuf/struct.proto"; 24 25option csharp_namespace = "Google.Cloud.AIPlatform.V1Beta1"; 26option go_package = "cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb;aiplatformpb"; 27option java_multiple_files = true; 28option java_outer_classname = "LlmUtilityServiceProto"; 29option java_package = "com.google.cloud.aiplatform.v1beta1"; 30option php_namespace = "Google\\Cloud\\AIPlatform\\V1beta1"; 31option ruby_package = "Google::Cloud::AIPlatform::V1beta1"; 32 33// Service for LLM related utility functions. 34service LlmUtilityService { 35 option (google.api.default_host) = "aiplatform.googleapis.com"; 36 option (google.api.oauth_scopes) = 37 "https://www.googleapis.com/auth/cloud-platform"; 38 39 // Return a list of tokens based on the input text. 40 rpc ComputeTokens(ComputeTokensRequest) returns (ComputeTokensResponse) { 41 option (google.api.http) = { 42 post: "/v1beta1/{endpoint=projects/*/locations/*/endpoints/*}:computeTokens" 43 body: "*" 44 additional_bindings { 45 post: "/v1beta1/{endpoint=projects/*/locations/*/publishers/*/models/*}:computeTokens" 46 body: "*" 47 } 48 }; 49 option (google.api.method_signature) = "endpoint,instances"; 50 } 51} 52 53// Request message for ComputeTokens RPC call. 54message ComputeTokensRequest { 55 // Required. The name of the Endpoint requested to get lists of tokens and 56 // token ids. 57 string endpoint = 1 [ 58 (google.api.field_behavior) = REQUIRED, 59 (google.api.resource_reference) = { 60 type: "aiplatform.googleapis.com/Endpoint" 61 } 62 ]; 63 64 // Required. The instances that are the input to token computing API call. 65 // Schema is identical to the prediction schema of the text model, even for 66 // the non-text models, like chat models, or Codey models. 67 repeated google.protobuf.Value instances = 2 68 [(google.api.field_behavior) = REQUIRED]; 69} 70 71// Tokens info with a list of tokens and the corresponding list of token ids. 72message TokensInfo { 73 // A list of tokens from the input. 74 repeated bytes tokens = 1; 75 76 // A list of token ids from the input. 77 repeated int64 token_ids = 2; 78} 79 80// Response message for ComputeTokens RPC call. 81message ComputeTokensResponse { 82 // Lists of tokens info from the input. A ComputeTokensRequest could have 83 // multiple instances with a prompt in each instance. We also need to return 84 // lists of tokens info for the request with multiple instances. 85 repeated TokensInfo tokens_info = 1; 86} 87