Skip to content

Commit 50febc7

Browse files
Google APIscopybara-github
authored andcommitted
feat: add json schema support to structured output and function declaration
PiperOrigin-RevId: 765394859
1 parent 2183b22 commit 50febc7

2 files changed

Lines changed: 68 additions & 0 deletions

File tree

google/cloud/aiplatform/v1/content.proto

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import "google/cloud/aiplatform/v1/openapi.proto";
2121
import "google/cloud/aiplatform/v1/tool.proto";
2222
import "google/cloud/aiplatform/v1/vertex_rag_data.proto";
2323
import "google/protobuf/duration.proto";
24+
import "google/protobuf/struct.proto";
2425
import "google/type/date.proto";
2526

2627
option csharp_namespace = "Google.Cloud.AIPlatform.V1";
@@ -281,6 +282,45 @@ message GenerationConfig {
281282
// `application/json`: Schema for JSON response.
282283
optional Schema response_schema = 16 [(google.api.field_behavior) = OPTIONAL];
283284

285+
// Optional. Output schema of the generated response. This is an alternative
286+
// to `response_schema` that accepts [JSON Schema](https://json-schema.org/).
287+
//
288+
// If set, `response_schema` must be omitted, but `response_mime_type` is
289+
// required.
290+
//
291+
// While the full JSON Schema may be sent, not all features are supported.
292+
// Specifically, only the following properties are supported:
293+
//
294+
// - `$id`
295+
// - `$defs`
296+
// - `$ref`
297+
// - `$anchor`
298+
// - `type`
299+
// - `format`
300+
// - `title`
301+
// - `description`
302+
// - `enum` (for strings and numbers)
303+
// - `items`
304+
// - `prefixItems`
305+
// - `minItems`
306+
// - `maxItems`
307+
// - `minimum`
308+
// - `maximum`
309+
// - `anyOf`
310+
// - `oneOf` (interpreted the same as `anyOf`)
311+
// - `properties`
312+
// - `additionalProperties`
313+
// - `required`
314+
//
315+
// The non-standard `propertyOrdering` property may also be set.
316+
//
317+
// Cyclic references are unrolled to a limited degree and, as such, may only
318+
// be used within non-required properties. (Nullable properties are not
319+
// sufficient.) If `$ref` is set on a sub-schema, no other properties, except
320+
// for than those starting as a `$`, may be set.
321+
optional google.protobuf.Value response_json_schema = 28
322+
[(google.api.field_behavior) = OPTIONAL];
323+
284324
// Optional. Routing configuration.
285325
optional RoutingConfig routing_config = 17
286326
[(google.api.field_behavior) = OPTIONAL];

google/cloud/aiplatform/v1/tool.proto

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

127+
// Optional. Describes the parameters to the function in JSON Schema format.
128+
// The schema must describe an object where the properties are the parameters
129+
// to the function. For example:
130+
//
131+
// ```
132+
// {
133+
// "type": "object",
134+
// "properties": {
135+
// "name": { "type": "string" },
136+
// "age": { "type": "integer" }
137+
// },
138+
// "additionalProperties": false,
139+
// "required": ["name", "age"],
140+
// "propertyOrdering": ["name", "age"]
141+
// }
142+
// ```
143+
//
144+
// This field is mutually exclusive with `parameters`.
145+
google.protobuf.Value parameters_json_schema = 5
146+
[(google.api.field_behavior) = OPTIONAL];
147+
127148
// Optional. Describes the output from this function in JSON Schema format.
128149
// Reflects the Open API 3.03 Response Object. The Schema defines the type
129150
// used for the response value of the function.
130151
Schema response = 4 [(google.api.field_behavior) = OPTIONAL];
152+
153+
// Optional. Describes the output from this function in JSON Schema format.
154+
// The value specified by the schema is the response value of the function.
155+
//
156+
// This field is mutually exclusive with `response`.
157+
google.protobuf.Value response_json_schema = 6
158+
[(google.api.field_behavior) = OPTIONAL];
131159
}
132160

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

0 commit comments

Comments
 (0)