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/api/resource.proto"; 21import "google/cloud/aiplatform/v1/openapi.proto"; 22import "google/protobuf/struct.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 = "ToolProto"; 28option java_package = "com.google.cloud.aiplatform.v1"; 29option php_namespace = "Google\\Cloud\\AIPlatform\\V1"; 30option ruby_package = "Google::Cloud::AIPlatform::V1"; 31 32// Tool details that the model may use to generate response. 33// 34// A `Tool` is a piece of code that enables the system to interact with 35// external systems to perform an action, or set of actions, outside of 36// knowledge and scope of the model. A Tool object should contain exactly 37// one type of Tool (e.g FunctionDeclaration, Retrieval or 38// GoogleSearchRetrieval). 39message Tool { 40 // Optional. Function tool type. 41 // One or more function declarations to be passed to the model along with the 42 // current user query. Model may decide to call a subset of these functions 43 // by populating [FunctionCall][content.part.function_call] in the response. 44 // User should provide a [FunctionResponse][content.part.function_response] 45 // for each function call in the next turn. Based on the function responses, 46 // Model will generate the final response back to the user. 47 // Maximum 64 function declarations can be provided. 48 repeated FunctionDeclaration function_declarations = 1 49 [(google.api.field_behavior) = OPTIONAL]; 50 51 // Optional. Retrieval tool type. 52 // System will always execute the provided retrieval tool(s) to get external 53 // knowledge to answer the prompt. Retrieval results are presented to the 54 // model for generation. 55 Retrieval retrieval = 2 [(google.api.field_behavior) = OPTIONAL]; 56 57 // Optional. GoogleSearchRetrieval tool type. 58 // Specialized retrieval tool that is powered by Google search. 59 GoogleSearchRetrieval google_search_retrieval = 3 60 [(google.api.field_behavior) = OPTIONAL]; 61} 62 63// Structured representation of a function declaration as defined by the 64// [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3). Included 65// in this declaration are the function name and parameters. This 66// FunctionDeclaration is a representation of a block of code that can be used 67// as a `Tool` by the model and executed by the client. 68message FunctionDeclaration { 69 // Required. The name of the function to call. 70 // Must start with a letter or an underscore. 71 // Must be a-z, A-Z, 0-9, or contain underscores, dots and dashes, with a 72 // maximum length of 64. 73 string name = 1 [(google.api.field_behavior) = REQUIRED]; 74 75 // Optional. Description and purpose of the function. 76 // Model uses it to decide how and whether to call the function. 77 string description = 2 [(google.api.field_behavior) = OPTIONAL]; 78 79 // Optional. Describes the parameters to this function in JSON Schema Object 80 // format. Reflects the Open API 3.03 Parameter Object. string Key: the name 81 // of the parameter. Parameter names are case sensitive. Schema Value: the 82 // Schema defining the type used for the parameter. For function with no 83 // parameters, this can be left unset. Parameter names must start with a 84 // letter or an underscore and must only contain chars a-z, A-Z, 0-9, or 85 // underscores with a maximum length of 64. Example with 1 required and 1 86 // optional parameter: type: OBJECT properties: 87 // param1: 88 // type: STRING 89 // param2: 90 // type: INTEGER 91 // required: 92 // - param1 93 Schema parameters = 3 [(google.api.field_behavior) = OPTIONAL]; 94} 95 96// A predicted [FunctionCall] returned from the model that contains a string 97// representing the [FunctionDeclaration.name] and a structured JSON object 98// containing the parameters and their values. 99message FunctionCall { 100 // Required. The name of the function to call. 101 // Matches [FunctionDeclaration.name]. 102 string name = 1 [(google.api.field_behavior) = REQUIRED]; 103 104 // Optional. Required. The function parameters and values in JSON object 105 // format. See [FunctionDeclaration.parameters] for parameter details. 106 google.protobuf.Struct args = 2 [(google.api.field_behavior) = OPTIONAL]; 107} 108 109// The result output from a [FunctionCall] that contains a string representing 110// the [FunctionDeclaration.name] and a structured JSON object containing any 111// output from the function is used as context to the model. This should contain 112// the result of a [FunctionCall] made based on model prediction. 113message FunctionResponse { 114 // Required. The name of the function to call. 115 // Matches [FunctionDeclaration.name] and [FunctionCall.name]. 116 string name = 1 [(google.api.field_behavior) = REQUIRED]; 117 118 // Required. The function response in JSON object format. 119 google.protobuf.Struct response = 2 [(google.api.field_behavior) = REQUIRED]; 120} 121 122// Defines a retrieval tool that model can call to access external knowledge. 123message Retrieval { 124 oneof source { 125 // Set to use data source powered by Vertex AI Search. 126 VertexAISearch vertex_ai_search = 2; 127 } 128 129 // Optional. Disable using the result from this tool in detecting grounding 130 // attribution. This does not affect how the result is given to the model for 131 // generation. 132 bool disable_attribution = 3 [(google.api.field_behavior) = OPTIONAL]; 133} 134 135// Retrieve from Vertex AI Search datastore for grounding. 136// See https://cloud.google.com/vertex-ai-search-and-conversation 137message VertexAISearch { 138 // Required. Fully-qualified Vertex AI Search's datastore resource ID. 139 // Format: 140 // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}` 141 string datastore = 1 [(google.api.field_behavior) = REQUIRED]; 142} 143 144// Tool to retrieve public web data for grounding, powered by Google. 145message GoogleSearchRetrieval { 146 // Optional. Disable using the result from this tool in detecting grounding 147 // attribution. This does not affect how the result is given to the model for 148 // generation. 149 bool disable_attribution = 1 [(google.api.field_behavior) = OPTIONAL]; 150} 151