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/field_behavior.proto"; 20import "google/api/resource.proto"; 21import "google/cloud/aiplatform/v1beta1/openapi.proto"; 22import "google/protobuf/struct.proto"; 23 24option csharp_namespace = "Google.Cloud.AIPlatform.V1Beta1"; 25option go_package = "cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb;aiplatformpb"; 26option java_multiple_files = true; 27option java_outer_classname = "ToolProto"; 28option java_package = "com.google.cloud.aiplatform.v1beta1"; 29option php_namespace = "Google\\Cloud\\AIPlatform\\V1beta1"; 30option ruby_package = "Google::Cloud::AIPlatform::V1beta1"; 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// A single example of the tool usage. 64message ToolUseExample { 65 // Identifies one operation of the extension. 66 message ExtensionOperation { 67 // Resource name of the extension. 68 string extension = 1 [(google.api.resource_reference) = { 69 type: "aiplatform.googleapis.com/Extension" 70 }]; 71 72 // Required. Operation ID of the extension. 73 string operation_id = 2 [(google.api.field_behavior) = REQUIRED]; 74 } 75 76 // Target tool to use. 77 oneof Target { 78 // Extension operation to call. 79 ExtensionOperation extension_operation = 10; 80 81 // Function name to call. 82 string function_name = 11; 83 } 84 85 // Required. The display name for example. 86 string display_name = 1 [(google.api.field_behavior) = REQUIRED]; 87 88 // Required. Query that should be routed to this tool. 89 string query = 2 [(google.api.field_behavior) = REQUIRED]; 90 91 // Request parameters used for executing this tool. 92 google.protobuf.Struct request_params = 3; 93 94 // Response parameters generated by this tool. 95 google.protobuf.Struct response_params = 4; 96 97 // Summary of the tool response to the user query. 98 string response_summary = 5; 99} 100 101// Structured representation of a function declaration as defined by the 102// [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3). Included 103// in this declaration are the function name and parameters. This 104// FunctionDeclaration is a representation of a block of code that can be used 105// as a `Tool` by the model and executed by the client. 106message FunctionDeclaration { 107 // Required. The name of the function to call. 108 // Must start with a letter or an underscore. 109 // Must be a-z, A-Z, 0-9, or contain underscores, dots and dashes, with a 110 // maximum length of 64. 111 string name = 1 [(google.api.field_behavior) = REQUIRED]; 112 113 // Optional. Description and purpose of the function. 114 // Model uses it to decide how and whether to call the function. 115 string description = 2 [(google.api.field_behavior) = OPTIONAL]; 116 117 // Optional. Describes the parameters to this function in JSON Schema Object 118 // format. Reflects the Open API 3.03 Parameter Object. string Key: the name 119 // of the parameter. Parameter names are case sensitive. Schema Value: the 120 // Schema defining the type used for the parameter. For function with no 121 // parameters, this can be left unset. Parameter names must start with a 122 // letter or an underscore and must only contain chars a-z, A-Z, 0-9, or 123 // underscores with a maximum length of 64. Example with 1 required and 1 124 // optional parameter: type: OBJECT properties: 125 // param1: 126 // type: STRING 127 // param2: 128 // type: INTEGER 129 // required: 130 // - param1 131 Schema parameters = 3 [(google.api.field_behavior) = OPTIONAL]; 132 133 // Optional. Describes the output from this function in JSON Schema format. 134 // Reflects the Open API 3.03 Response Object. The Schema defines the type 135 // used for the response value of the function. 136 Schema response = 4 [(google.api.field_behavior) = OPTIONAL]; 137} 138 139// A predicted [FunctionCall] returned from the model that contains a string 140// representing the [FunctionDeclaration.name] and a structured JSON object 141// containing the parameters and their values. 142message FunctionCall { 143 // Required. The name of the function to call. 144 // Matches [FunctionDeclaration.name]. 145 string name = 1 [(google.api.field_behavior) = REQUIRED]; 146 147 // Optional. Required. The function parameters and values in JSON object 148 // format. See [FunctionDeclaration.parameters] for parameter details. 149 google.protobuf.Struct args = 2 [(google.api.field_behavior) = OPTIONAL]; 150} 151 152// The result output from a [FunctionCall] that contains a string representing 153// the [FunctionDeclaration.name] and a structured JSON object containing any 154// output from the function is used as context to the model. This should contain 155// the result of a [FunctionCall] made based on model prediction. 156message FunctionResponse { 157 // Required. The name of the function to call. 158 // Matches [FunctionDeclaration.name] and [FunctionCall.name]. 159 string name = 1 [(google.api.field_behavior) = REQUIRED]; 160 161 // Required. The function response in JSON object format. 162 google.protobuf.Struct response = 2 [(google.api.field_behavior) = REQUIRED]; 163} 164 165// Defines a retrieval tool that model can call to access external knowledge. 166message Retrieval { 167 oneof source { 168 // Set to use data source powered by Vertex AI Search. 169 VertexAISearch vertex_ai_search = 2; 170 171 // Set to use data source powered by Vertex RAG store. 172 // User data is uploaded via the VertexRagDataService. 173 VertexRagStore vertex_rag_store = 4; 174 } 175 176 // Optional. Disable using the result from this tool in detecting grounding 177 // attribution. This does not affect how the result is given to the model for 178 // generation. 179 bool disable_attribution = 3 [(google.api.field_behavior) = OPTIONAL]; 180} 181 182// Retrieve from Vertex RAG Store for grounding. 183message VertexRagStore { 184 // Required. Vertex RAG Store corpus resource name: 185 // `projects/{project}/locations/{location}/ragCorpora/{ragCorpus}` 186 // Currently only one corpus is allowed. 187 // In the future we may open up multiple corpora support. However, they should 188 // be from the same project and location. 189 repeated string rag_corpora = 1 [ 190 (google.api.field_behavior) = REQUIRED, 191 (google.api.resource_reference) = { 192 type: "aiplatform.googleapis.com/RagCorpus" 193 } 194 ]; 195 196 // Optional. Number of top k results to return from the selected corpora. 197 optional int32 similarity_top_k = 2 [(google.api.field_behavior) = OPTIONAL]; 198} 199 200// Retrieve from Vertex AI Search datastore for grounding. 201// See https://cloud.google.com/vertex-ai-search-and-conversation 202message VertexAISearch { 203 // Required. Fully-qualified Vertex AI Search's datastore resource ID. 204 // Format: 205 // `projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}` 206 string datastore = 1 [(google.api.field_behavior) = REQUIRED]; 207} 208 209// Tool to retrieve public web data for grounding, powered by Google. 210message GoogleSearchRetrieval { 211 // Optional. Disable using the result from this tool in detecting grounding 212 // attribution. This does not affect how the result is given to the model for 213 // generation. 214 bool disable_attribution = 1 [(google.api.field_behavior) = OPTIONAL]; 215} 216 217// Tool config. This config is shared for all tools provided in the request. 218message ToolConfig { 219 // Optional. Function calling config. 220 FunctionCallingConfig function_calling_config = 1 221 [(google.api.field_behavior) = OPTIONAL]; 222} 223 224// Function calling config. 225message FunctionCallingConfig { 226 // Function calling mode. 227 enum Mode { 228 // Unspecified function calling mode. This value should not be used. 229 MODE_UNSPECIFIED = 0; 230 231 // Default model behavior, model decides to predict either a function call 232 // or a natural language repspose. 233 AUTO = 1; 234 235 // Model is constrained to always predicting a function call only. 236 // If "allowed_function_names" are set, the predicted function call will be 237 // limited to any one of "allowed_function_names", else the predicted 238 // function call will be any one of the provided "function_declarations". 239 ANY = 2; 240 241 // Model will not predict any function call. Model behavior is same as when 242 // not passing any function declarations. 243 NONE = 3; 244 } 245 246 // Optional. Function calling mode. 247 Mode mode = 1 [(google.api.field_behavior) = OPTIONAL]; 248 249 // Optional. Function names to call. Only set when the Mode is ANY. Function 250 // names should match [FunctionDeclaration.name]. With mode set to ANY, model 251 // will predict a function call from the set of function names provided. 252 repeated string allowed_function_names = 2 253 [(google.api.field_behavior) = OPTIONAL]; 254} 255