Skip to content

Commit 215fb4a

Browse files
Google APIscopybara-github
authored andcommitted
feat: add json schema support to structured output and function declaration
PiperOrigin-RevId: 766041719
1 parent da24f94 commit 215fb4a

2 files changed

Lines changed: 68 additions & 0 deletions

File tree

google/cloud/aiplatform/v1beta1/content.proto

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import "google/cloud/aiplatform/v1beta1/openapi.proto";
2222
import "google/cloud/aiplatform/v1beta1/tool.proto";
2323
import "google/cloud/aiplatform/v1beta1/vertex_rag_data.proto";
2424
import "google/protobuf/duration.proto";
25+
import "google/protobuf/struct.proto";
2526
import "google/type/date.proto";
2627

2728
option csharp_namespace = "Google.Cloud.AIPlatform.V1Beta1";
@@ -355,6 +356,45 @@ message GenerationConfig {
355356
// `application/json`: Schema for JSON response.
356357
optional Schema response_schema = 16 [(google.api.field_behavior) = OPTIONAL];
357358

359+
// Optional. Output schema of the generated response. This is an alternative
360+
// to `response_schema` that accepts [JSON Schema](https://json-schema.org/).
361+
//
362+
// If set, `response_schema` must be omitted, but `response_mime_type` is
363+
// required.
364+
//
365+
// While the full JSON Schema may be sent, not all features are supported.
366+
// Specifically, only the following properties are supported:
367+
//
368+
// - `$id`
369+
// - `$defs`
370+
// - `$ref`
371+
// - `$anchor`
372+
// - `type`
373+
// - `format`
374+
// - `title`
375+
// - `description`
376+
// - `enum` (for strings and numbers)
377+
// - `items`
378+
// - `prefixItems`
379+
// - `minItems`
380+
// - `maxItems`
381+
// - `minimum`
382+
// - `maximum`
383+
// - `anyOf`
384+
// - `oneOf` (interpreted the same as `anyOf`)
385+
// - `properties`
386+
// - `additionalProperties`
387+
// - `required`
388+
//
389+
// The non-standard `propertyOrdering` property may also be set.
390+
//
391+
// Cyclic references are unrolled to a limited degree and, as such, may only
392+
// be used within non-required properties. (Nullable properties are not
393+
// sufficient.) If `$ref` is set on a sub-schema, no other properties, except
394+
// for than those starting as a `$`, may be set.
395+
optional google.protobuf.Value response_json_schema = 28
396+
[(google.api.field_behavior) = OPTIONAL];
397+
358398
// Optional. Routing configuration.
359399
optional RoutingConfig routing_config = 17
360400
[(google.api.field_behavior) = OPTIONAL];

google/cloud/aiplatform/v1beta1/tool.proto

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,38 @@ message FunctionDeclaration {
163163
// - param1
164164
Schema parameters = 3 [(google.api.field_behavior) = OPTIONAL];
165165

166+
// Optional. Describes the parameters to the function in JSON Schema format.
167+
// The schema must describe an object where the properties are the parameters
168+
// to the function. For example:
169+
//
170+
// ```
171+
// {
172+
// "type": "object",
173+
// "properties": {
174+
// "name": { "type": "string" },
175+
// "age": { "type": "integer" }
176+
// },
177+
// "additionalProperties": false,
178+
// "required": ["name", "age"],
179+
// "propertyOrdering": ["name", "age"]
180+
// }
181+
// ```
182+
//
183+
// This field is mutually exclusive with `parameters`.
184+
google.protobuf.Value parameters_json_schema = 5
185+
[(google.api.field_behavior) = OPTIONAL];
186+
166187
// Optional. Describes the output from this function in JSON Schema format.
167188
// Reflects the Open API 3.03 Response Object. The Schema defines the type
168189
// used for the response value of the function.
169190
Schema response = 4 [(google.api.field_behavior) = OPTIONAL];
191+
192+
// Optional. Describes the output from this function in JSON Schema format.
193+
// The value specified by the schema is the response value of the function.
194+
//
195+
// This field is mutually exclusive with `response`.
196+
google.protobuf.Value response_json_schema = 6
197+
[(google.api.field_behavior) = OPTIONAL];
170198
}
171199

172200
// A predicted [FunctionCall] returned from the model that contains a string

0 commit comments

Comments
 (0)