feat!(ai): add support for anyOf schemas (#9042) · firebase/firebase-js-sdk@5200f7b (original) (raw)
14 files changed
lines changed
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| 1 | +--- | |
| 2 | +'firebase': major | |
| 3 | +'@firebase/ai': major | |
| 4 | +--- | |
| 5 | + | |
| 6 | +Add support for `anyOf` schemas |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -64,6 +64,17 @@ export interface AIOptions { | ||||||
| 64 | 64 | backend: Backend; | ||||
| 65 | 65 | } | ||||
| 66 | 66 | |||||
| 67 | +// @public | |||||
| 68 | +export class AnyOfSchema extends Schema { | |||||
| 69 | +constructor(schemaParams: SchemaParams & { | |||||
| 70 | + anyOf: TypedSchema[]; | |||||
| 71 | + }); | |||||
| 72 | +// (undocumented) | |||||
| 73 | + anyOf: TypedSchema[]; | |||||
| 74 | +// @internal (undocumented) | |||||
| 75 | + toJSON(): SchemaRequest; | |||||
| 76 | +} | |||||
| 77 | + | |||||
| 67 | 78 | // @public | ||||
| 68 | 79 | export class ArraySchema extends Schema { | ||||
| 69 | 80 | constructor(schemaParams: SchemaParams, items: TypedSchema); | ||||
| @@ -814,6 +825,10 @@ export abstract class Schema implements SchemaInterface { | ||||||
| 814 | 825 | constructor(schemaParams: SchemaInterface); | ||||
| 815 | 826 | [key: string]: unknown; | ||||
| 816 | 827 | // (undocumented) | ||||
| 828 | +static anyOf(anyOfParams: SchemaParams & { | |||||
| 829 | + anyOf: TypedSchema[]; | |||||
| 830 | + }): AnyOfSchema; | |||||
| 831 | +// (undocumented) | |||||
| 817 | 832 | static array(arrayParams: SchemaParams & { | ||||
| 818 | 833 | items: Schema; | ||||
| 819 | 834 | }): ArraySchema; | ||||
| @@ -845,12 +860,12 @@ export abstract class Schema implements SchemaInterface { | ||||||
| 845 | 860 | static string(stringParams?: SchemaParams): StringSchema; | ||||
| 846 | 861 | // @internal | ||||
| 847 | 862 | toJSON(): SchemaRequest; | ||||
| 848 | - type: SchemaType; | |||||
| 863 | + type?: SchemaType; | |||||
| 849 | 864 | } | ||||
| 850 | 865 | |||||
| 851 | 866 | // @public | ||||
| 852 | 867 | export interface SchemaInterface extends SchemaShared<SchemaInterface> { | ||||
| 853 | - type: SchemaType; | |||||
| 868 | + type?: SchemaType; | |||||
| 854 | 869 | } | ||||
| 855 | 870 | |||||
| 856 | 871 | // @public | ||||
| @@ -860,13 +875,14 @@ export interface SchemaParams extends SchemaShared { | ||||||
| 860 | 875 | // @public | ||||
| 861 | 876 | export interface SchemaRequest extends SchemaShared<SchemaRequest> { | ||||
| 862 | 877 | required?: string[]; | ||||
| 863 | - type: SchemaType; | |||||
| 878 | + type?: SchemaType; | |||||
| 864 | 879 | } | ||||
| 865 | 880 | |||||
| 866 | 881 | // @public | ||||
| 867 | 882 | export interface SchemaShared<T> { | ||||
| 868 | 883 | // (undocumented) | ||||
| 869 | 884 | [key: string]: unknown; | ||||
| 885 | + anyOf?: T[]; | |||||
| 870 | 886 | description?: string; | ||||
| 871 | 887 | enum?: string[]; | ||||
| 872 | 888 | example?: unknown; | ||||
| @@ -958,7 +974,7 @@ export interface ToolConfig { | ||||||
| 958 | 974 | } | ||||
| 959 | 975 | |||||
| 960 | 976 | // @public | ||||
| 961 | -export type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema; | |
| 977 | +export type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema | |
| 962 | 978 | |||||
| 963 | 979 | // @public | ||||
| 964 | 980 | export interface UsageMetadata { |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -12,6 +12,8 @@ toc: | ||
| 12 | 12 | path: /docs/reference/js/ai.aimodel.md |
| 13 | 13 | - title: AIOptions |
| 14 | 14 | path: /docs/reference/js/ai.aioptions.md |
| 15 | + - title: AnyOfSchema | |
| 16 | +path: /docs/reference/js/ai.anyofschema.md | |
| 15 | 17 | - title: ArraySchema |
| 16 | 18 | path: /docs/reference/js/ai.arrayschema.md |
| 17 | 19 | - title: Backend |
| Original file line number | Diff line number | Diff line change | | | |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | ----------- | |
| @@ -0,0 +1,58 @@ | | | | | |
| | 1 | +Project: /docs/reference/js/_project.yaml | | | | |
| | 2 | +Book: /docs/reference/_book.yaml | | | | |
| | 3 | +page_type: reference | | | | |
| | 4 | + | | | | |
| | 5 | +{% comment %} | | | | |
| | 6 | +DO NOT EDIT THIS FILE! | | | | |
| | 7 | +This is generated by the JS SDK team, and any local changes will be | | | | |
| | 8 | +overwritten. Changes should be made in the source code at | | | | |
| | 9 | +https://github.com/firebase/firebase-js-sdk | | | | |
| | 10 | +{% endcomment %} | | | | |
| | 11 | + | | | | |
| | 12 | +# AnyOfSchema class | | | | |
| | 13 | +Schema class representing a value that can conform to any of the provided sub-schemas. This is useful when a field can accept multiple distinct types or structures. | | | | |
| | 14 | + | | | | |
| | 15 | +<b>Signature:</b> | | | | |
| | 16 | + | | | | |
| | 17 | +```typescript | | | | |
| | 18 | +export declare class AnyOfSchema extends Schema | | | | |
| | 19 | +``` | | | | |
| | 20 | +Extends: [Schema](./ai.schema.md#schema_class) | | | | |
| | 21 | + | | | | |
| | 22 | +## Constructors | | | | |
| | 23 | + | | | | |
| | 24 | +| Constructor | Modifiers | Description | | |
| | 25 | +| --- | --- | --- | | |
| | 26 | +| [(constructor)(schemaParams)](./ai.anyofschema.md#anyofschemaconstructor) | | Constructs a new instance of the AnyOfSchema class | | |
| | 27 | + | | | | |
| | 28 | +## Properties | | | | |
| | 29 | + | | | | |
| | 30 | +| Property | Modifiers | Type | Description | |
| | 31 | +| --- | --- | --- | --- | |
| | 32 | +| [anyOf](./ai.anyofschema.md#anyofschemaanyof) | | [TypedSchema](./ai.md#typedschema)\[\] | | |
| | 33 | + | | | | |
| | 34 | +## AnyOfSchema.(constructor) | | | | |
| | 35 | + | | | | |
| | 36 | +Constructs a new instance of the `AnyOfSchema` class | | | | |
| | 37 | + | | | | |
| | 38 | +Signature: | | | | |
| | 39 | + | | | | |
| | 40 | +```typescript | | | | |
| | 41 | +constructor(schemaParams: SchemaParams & { | | | | |
| | 42 | + anyOf: TypedSchema[]; | | | | |
| | 43 | + }); | | | | |
| | 44 | +``` | | | | |
| | 45 | + | | | | |
| | 46 | +#### Parameters | | | | |
| | 47 | + | | | | |
| | 48 | +| Parameter | Type | Description | | |
| | 49 | +| --- | --- | --- | | |
| | 50 | +| schemaParams | [SchemaParams](./ai.schemaparams.md#schemaparams_interface) & { anyOf: [TypedSchema](./ai.md#typedschema)\[\]; } | | | |
| | 51 | + | | | | |
| | 52 | +## AnyOfSchema.anyOf | | | | |
| | 53 | + | | | | |
| | 54 | +Signature: | | | | |
| | 55 | + | | | | |
| | 56 | +```typescript | | | | |
| | 57 | +anyOf: TypedSchema[]; | | | | |
| | 58 | +``` | | | | |
| Original file line number | Diff line number | Diff line change | | | |
| ------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| @@ -28,7 +28,7 @@ export interface GenerationConfig | | | | | |
| 28 | 28 | | [presencePenalty](./ai.generationconfig.md#generationconfigpresencepenalty) | number | | |
| 29 | 29 | | [responseMimeType](./ai.generationconfig.md#generationconfigresponsemimetype) | string | Output response MIME type of the generated candidate text. Supported MIME types are <code>text/plain</code> (default, text output), <code>application/json</code> (JSON response in the candidates), and <code>text/x.enum</code>. | |
| 30 | 30 | | [responseModalities](./ai.generationconfig.md#generationconfigresponsemodalities) | [ResponseModality](./ai.md#responsemodality)\[\] | <b><i>(Public Preview)</i></b> Generation modalities to be returned in generation responses. | |
| 31 | | -| [responseSchema](./ai.generationconfig.md#generationconfigresponseschema) | [TypedSchema](./ai.md#typedschema) \| [SchemaRequest](./ai.schemarequest.md#schemarequest_interface) | Output response schema of the generated candidate text. This value can be a class generated with a [Schema](./ai.schema.md#schema_class) static method like <code>Schema.string()</code> or <code>Schema.object()</code> or it can be a plain JS object matching the [SchemaRequest](./ai.schemarequest.md#schemarequest_interface) interface.
Note: This only applies when the specified <code>responseMIMEType</code> supports a schema; currently this is limited to <code>application/json</code> and <code>text/x.enum</code>. | |
| | 31 | +| [responseSchema](./ai.generationconfig.md#generationconfigresponseschema) | [TypedSchema](./ai.md#typedschema) \| [SchemaRequest](./ai.schemarequest.md#schemarequest_interface) | Output response schema of the generated candidate text. This value can be a class generated with a [Schema](./ai.schema.md#schema_class) static method like <code>Schema.string()</code> or <code>Schema.object()</code> or it can be a plain JS object matching the [SchemaRequest](./ai.schemarequest.md#schemarequest_interface) interface.
Note: This only applies when the specified <code>responseMimeType</code> supports a schema; currently this is limited to <code>application/json</code> and <code>text/x.enum</code>. | | |
| 32 | 32 | | [stopSequences](./ai.generationconfig.md#generationconfigstopsequences) | string\[\] | | |
| 33 | 33 | | [temperature](./ai.generationconfig.md#generationconfigtemperature) | number | | |
| 34 | 34 | | [thinkingConfig](./ai.generationconfig.md#generationconfigthinkingconfig) | [ThinkingConfig](./ai.thinkingconfig.md#thinkingconfig_interface) | Configuration for "thinking" behavior of compatible Gemini models. | |
| @@ -94,7 +94,7 @@ responseModalities?: ResponseModality[]; | | | | | |
| 94 | 94 | | | | |
| 95 | 95 | ## GenerationConfig.responseSchema | | | |
| 96 | 96 | | | | |
| 97 | | -Output response schema of the generated candidate text. This value can be a class generated with a [Schema](./ai.schema.md#schema_class) static method like `Schema.string()` or `Schema.object()` or it can be a plain JS object matching the [SchemaRequest](./ai.schemarequest.md#schemarequest_interface) interface.
Note: This only applies when the specified `responseMIMEType` supports a schema; currently this is limited to `application/json` and `text/x.enum`. | | | |
| | 97 | +Output response schema of the generated candidate text. This value can be a class generated with a [Schema](./ai.schema.md#schema_class) static method like `Schema.string()` or `Schema.object()` or it can be a plain JS object matching the [SchemaRequest](./ai.schemarequest.md#schemarequest_interface) interface.
Note: This only applies when the specified `responseMimeType` supports a schema; currently this is limited to `application/json` and `text/x.enum`. | | | | |
| 98 | 98 | | | | |
| 99 | 99 | <b>Signature:</b> | | | |
| 100 | 100 | | | | |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -28,6 +28,7 @@ The Firebase AI Web SDK. | ||||||
| 28 | 28 | | --- | --- | |||
| 29 | 29 | | [AIError](./ai.aierror.md#aierror_class) | Error class for the Firebase AI SDK. | |||
| 30 | 30 | | [AIModel](./ai.aimodel.md#aimodel_class) | Base class for Firebase AI model APIs.Instances of this class are associated with a specific Firebase AI [Backend](./ai.backend.md#backend_class) and provide methods for interacting with the configured generative model. | |||
| 31 | +| [AnyOfSchema](./ai.anyofschema.md#anyofschema_class) | Schema class representing a value that can conform to any of the provided sub-schemas. This is useful when a field can accept multiple distinct types or structures. | ||||
| 31 | 32 | | [ArraySchema](./ai.arrayschema.md#arrayschema_class) | Schema class for "array" types. The <code>items</code> param should refer to the type of item that can be a member of the array. | |||
| 32 | 33 | | [Backend](./ai.backend.md#backend_class) | Abstract base class representing the configuration for an AI service backend. This class should not be instantiated directly. Use its subclasses; [GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class) for the Gemini Developer API (via [Google AI](https://ai.google/)), and [VertexAIBackend](./ai.vertexaibackend.md#vertexaibackend_class) for the Vertex AI Gemini API. | |||
| 33 | 34 | | [BooleanSchema](./ai.booleanschema.md#booleanschema_class) | Schema class for "boolean" types. | |||
| @@ -762,5 +763,5 @@ A type that includes all specific Schema types. | ||||||
| 762 | 763 | <b>Signature:</b> | ||||
| 763 | 764 | |||||
| 764 | 765 | ```typescript | ||||
| 765 | -export type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema; | |
| 766 | +export type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema | |
| 766 | 767 | ``` |
| Original file line number | Diff line number | Diff line change | | | | |
| ----------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | |
| @@ -36,12 +36,13 @@ export declare abstract class Schema implements SchemaInterface | | | | | | |
| 36 | 36 | | [maxItems](./ai.schema.md#schemamaxitems) | | number | The maximum number of items (elements) in a schema of [SchemaType](./ai.md#schematype) array. | |
| 37 | 37 | | [minItems](./ai.schema.md#schemaminitems) | | number | The minimum number of items (elements) in a schema of [SchemaType](./ai.md#schematype) array. | |
| 38 | 38 | | [nullable](./ai.schema.md#schemanullable) | | boolean | Optional. Whether the property is nullable. Defaults to false. | |
| 39 | | -| [type](./ai.schema.md#schematype) | | [SchemaType](./ai.md#schematype) | Optional. The type of the property. [SchemaType](./ai.md#schematype). | |
| | 39 | +| [type](./ai.schema.md#schematype) | | [SchemaType](./ai.md#schematype) | Optional. The type of the property. This can only be undefined when using anyOf schemas, which do not have an explicit type in the [OpenAPI specification](https://swagger.io/docs/specification/v3\_0/data-models/data-types/#any-type). | | |
| 40 | 40 | | | | | |
| 41 | 41 | ## Methods | | | | |
| 42 | 42 | | | | | |
| 43 | 43 | | Method | Modifiers | Description | | |
| 44 | 44 | | --- | --- | --- | | |
| | 45 | +| [anyOf(anyOfParams)](./ai.schema.md#schemaanyof) | static | | | | |
| 45 | 46 | | [array(arrayParams)](./ai.schema.md#schemaarray) | static | | | |
| 46 | 47 | | [boolean(booleanParams)](./ai.schema.md#schemaboolean) | static | | | |
| 47 | 48 | | [enumString(stringParams)](./ai.schema.md#schemaenumstring) | static | | | |
| @@ -138,14 +139,34 @@ nullable: boolean; | | | | | | |
| 138 | 139 | | | | | |
| 139 | 140 | ## Schema.type | | | | |
| 140 | 141 | | | | | |
| 141 | | -Optional. The type of the property. [SchemaType](./ai.md#schematype). | | | | |
| | 142 | +Optional. The type of the property. This can only be undefined when using `anyOf` schemas, which do not have an explicit type in the [OpenAPI specification](https://swagger.io/docs/specification/v3\_0/data-models/data-types/#any-type). | | | | | |
| 142 | 143 | | | | | |
| 143 | 144 | Signature: | | | | |
| 144 | 145 | | | | | |
| 145 | 146 | ```typescript | | | | |
| 146 | | -type: SchemaType; | | | | |
| | 147 | +type?: SchemaType; | | | | | |
| 147 | 148 | ``` | | | | |
| 148 | 149 | | | | | |
| | 150 | +## Schema.anyOf() | | | | | |
| | 151 | + | | | | | |
| | 152 | +Signature: | | | | | |
| | 153 | + | | | | | |
| | 154 | +```typescript | | | | | |
| | 155 | +static anyOf(anyOfParams: SchemaParams & { | | | | | |
| | 156 | + anyOf: TypedSchema[]; | | | | | |
| | 157 | + }): AnyOfSchema; | | | | | |
| | 158 | +``` | | | | | |
| | 159 | + | | | | | |
| | 160 | +#### Parameters | | | | | |
| | 161 | + | | | | | |
| | 162 | +| Parameter | Type | Description | | | |
| | 163 | +| --- | --- | --- | | | |
| | 164 | +| anyOfParams | [SchemaParams](./ai.schemaparams.md#schemaparams_interface) & { anyOf: [TypedSchema](./ai.md#typedschema)\[\]; } | | | | |
| | 165 | + | | | | | |
| | 166 | +Returns: | | | | | |
| | 167 | + | | | | | |
| | 168 | +[AnyOfSchema](./ai.anyofschema.md#anyofschema_class) | | | | | |
| | 169 | + | | | | | |
| 149 | 170 | ## Schema.array() | | | | |
| 150 | 171 | | | | | |
| 151 | 172 | Signature: | | | | |
| Original file line number | Diff line number | Diff line change | | | |
| ------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------- | |
| @@ -23,14 +23,14 @@ export interface SchemaInterface extends SchemaShared | | | | | |
| 23 | 23 | | | | |
| 24 | 24 | | Property | Type | Description | |
| 25 | 25 | | --- | --- | --- | |
| 26 | | -| [type](./ai.schemainterface.md#schemainterfacetype) | [SchemaType](./ai.md#schematype) | The type of the property. [SchemaType](./ai.md#schematype). | |
| | 26 | +| [type](./ai.schemainterface.md#schemainterfacetype) | [SchemaType](./ai.md#schematype) | The type of the property. this can only be undefined when using anyof schemas, which do not have an explicit type in the [OpenAPI Specification](https://swagger.io/docs/specification/v3\_0/data-models/data-types/#any-type). | | |
| 27 | 27 | | | | |
| 28 | 28 | ## SchemaInterface.type | | | |
| 29 | 29 | | | | |
| 30 | | -The type of the property. [SchemaType](./ai.md#schematype). | | | |
| | 30 | +The type of the property. this can only be undefined when using `anyof` schemas, which do not have an explicit type in the [OpenAPI Specification](https://swagger.io/docs/specification/v3\_0/data-models/data-types/#any-type). | | | | |
| 31 | 31 | | | | |
| 32 | 32 | Signature: | | | |
| 33 | 33 | | | | |
| 34 | 34 | ```typescript | | | |
| 35 | | -type: SchemaType; | | | |
| | 35 | +type?: SchemaType; | | | | |
| 36 | 36 | ``` | | | |
| Original file line number | Diff line number | Diff line change | | | |
| ------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------- | |
| @@ -24,7 +24,7 @@ export interface SchemaRequest extends SchemaShared | | | | | |
| 24 | 24 | | Property | Type | Description | |
| 25 | 25 | | --- | --- | --- | |
| 26 | 26 | | [required](./ai.schemarequest.md#schemarequestrequired) | string\[\] | Optional. Array of required property. | |
| 27 | | -| [type](./ai.schemarequest.md#schemarequesttype) | [SchemaType](./ai.md#schematype) | The type of the property. [SchemaType](./ai.md#schematype). | |
| | 27 | +| [type](./ai.schemarequest.md#schemarequesttype) | [SchemaType](./ai.md#schematype) | The type of the property. this can only be undefined when using anyOf schemas, which do not have an explicit type in the [OpenAPI specification](https://swagger.io/docs/specification/v3\_0/data-models/data-types/#any-type). | | |
| 28 | 28 | | | | |
| 29 | 29 | ## SchemaRequest.required | | | |
| 30 | 30 | | | | |
| @@ -38,10 +38,10 @@ required?: string[]; | | | | | |
| 38 | 38 | | | | |
| 39 | 39 | ## SchemaRequest.type | | | |
| 40 | 40 | | | | |
| 41 | | -The type of the property. [SchemaType](./ai.md#schematype). | | | |
| | 41 | +The type of the property. this can only be undefined when using `anyOf` schemas, which do not have an explicit type in the [OpenAPI specification](https://swagger.io/docs/specification/v3\_0/data-models/data-types/#any-type). | | | | |
| 42 | 42 | | | | |
| 43 | 43 | Signature: | | | |
| 44 | 44 | | | | |
| 45 | 45 | ```typescript | | | |
| 46 | | -type: SchemaType; | | | |
| | 46 | +type?: SchemaType; | | | | |
| 47 | 47 | ``` | | | |
| Original file line number | Diff line number | Diff line change | | | | | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | | @@ -22,6 +22,7 @@ export interface SchemaShared | | | | | | | 22 | 22 | | | | | | 23 | 23 | | Property | Type | Description | | | 24 | 24 | | --- | --- | --- | | | | 25 | +| [anyOf](./ai.schemashared.md#schemasharedanyof) | T\[\] | An array of [Schema](./ai.schema.md#schema_class). The generated data must be valid against any of the schemas listed in this array. This allows specifying multiple possible structures or types for a single field. | | | | 25 | 26 | | [description](./ai.schemashared.md#schemashareddescription) | string | Optional. The description of the property. | | | 26 | 27 | | [enum](./ai.schemashared.md#schemasharedenum) | string\[\] | Optional. The enum of the property. | | | 27 | 28 | | [example](./ai.schemashared.md#schemasharedexample) | unknown | Optional. The example of the property. | | | @@ -36,6 +37,16 @@ export interface SchemaShared | | | | | | | 36 | 37 | | [propertyOrdering](./ai.schemashared.md#schemasharedpropertyordering) | string\[\] | A hint suggesting the order in which the keys should appear in the generated JSON string. | | | 37 | 38 | | [title](./ai.schemashared.md#schemasharedtitle) | string | The title of the property. This helps document the schema's purpose but does not typically constrain the generated value. It can subtly guide the model by clarifying the intent of a field. | | | 38 | 39 | | | | | | | 40 | +## SchemaShared.anyOf | | | | | | | 41 | + | | | | | | | 42 | +An array of [Schema](./ai.schema.md#schema_class)<!-- -->. The generated data must be valid against any of the schemas listed in this array. This allows specifying multiple possible structures or types for a single field. | | | | | | | 43 | + | | | | | | | 44 | +<b>Signature:</b> | | | | | | | 45 | + | | | | | | | 46 | +```typescript | | | | | | | 47 | +anyOf?: T[]; | | | | | | | 48 | +``` | | | | | | | 49 | + | | | | | | 39 | 50 | ## SchemaShared.description | | | | | 40 | 51 | | | | | | 41 | 52 | Optional. The description of the property. | | | |