ChatResponseFormat.ForJsonSchema メソッド

定義

オーバーロード

名前 説明
ForJsonSchema(JsonElement, String, String)

指定したスキーマで構造化された JSON データを表す ChatResponseFormatJson を作成します。

ForJsonSchema(Type, JsonSerializerOptions, String, String)

schemaTypeに基づくスキーマを使用して、構造化された JSON データを表すChatResponseFormatJsonを作成します。

ForJsonSchema<T>(JsonSerializerOptions, String, String)

Tに基づくスキーマを使用して、構造化された JSON データを表すChatResponseFormatJsonを作成します。

ForJsonSchema(JsonElement, String, String)

ソース:
ChatResponseFormat.cs

指定したスキーマで構造化された JSON データを表す ChatResponseFormatJson を作成します。

public static Microsoft.Extensions.AI.ChatResponseFormatJson ForJsonSchema(System.Text.Json.JsonElement schema, string? schemaName = default, string? schemaDescription = default);
static member ForJsonSchema : System.Text.Json.JsonElement * string * string -> Microsoft.Extensions.AI.ChatResponseFormatJson
Public Shared Function ForJsonSchema (schema As JsonElement, Optional schemaName As String = Nothing, Optional schemaDescription As String = Nothing) As ChatResponseFormatJson

パラメーター

schema
JsonElement

JSON スキーマ。

schemaName
String

スキーマの省略可能な名前。 たとえば、スキーマが特定のクラスを表す場合は、クラスの名前を指定できます。

schemaDescription
String

スキーマの説明 (省略可能)。

返品

ChatResponseFormatJson のインスタンスです。

適用対象

ForJsonSchema(Type, JsonSerializerOptions, String, String)

ソース:
ChatResponseFormat.cs

schemaTypeに基づくスキーマを使用して、構造化された JSON データを表すChatResponseFormatJsonを作成します。

public static Microsoft.Extensions.AI.ChatResponseFormatJson ForJsonSchema(Type schemaType, System.Text.Json.JsonSerializerOptions? serializerOptions = default, string? schemaName = default, string? schemaDescription = default);
static member ForJsonSchema : Type * System.Text.Json.JsonSerializerOptions * string * string -> Microsoft.Extensions.AI.ChatResponseFormatJson
Public Shared Function ForJsonSchema (schemaType As Type, Optional serializerOptions As JsonSerializerOptions = Nothing, Optional schemaName As String = Nothing, Optional schemaDescription As String = Nothing) As ChatResponseFormatJson

パラメーター

schemaType
Type

スキーマをエクスポートして応答スキーマとして使用する必要がある Type

serializerOptions
JsonSerializerOptions

使用する JSON シリアル化オプション。

schemaName
String

スキーマの省略可能な名前。 既定では、これは schemaTypeから推論されます。

schemaDescription
String

スキーマの説明 (省略可能)。 既定では、これは schemaTypeから推論されます。

返品

ChatResponseFormatJson のインスタンスです。

例外

schemaTypenullです。

注釈

構造化された出力をサポートする多くの AI サービスでは、JSON スキーマに最上位レベルの 'type=object' が必要です。 schemaTypeStringInt32Booleanなどのプリミティブ型である場合、または JSON 配列としてシリアル化される型の場合、そのようなサービスで結果のスキーマを使用しようとすると失敗する可能性があります。 このような場合は、実際の型をクラスまたは構造体でラップする schemaType を使用して、元の型をそのオブジェクトのプロパティとして JSON オブジェクトとしてシリアル化することを検討してください。

適用対象

ForJsonSchema<T>(JsonSerializerOptions, String, String)

ソース:
ChatResponseFormat.cs

Tに基づくスキーマを使用して、構造化された JSON データを表すChatResponseFormatJsonを作成します。

public static Microsoft.Extensions.AI.ChatResponseFormatJson ForJsonSchema<T>(System.Text.Json.JsonSerializerOptions? serializerOptions = default, string? schemaName = default, string? schemaDescription = default);
static member ForJsonSchema : System.Text.Json.JsonSerializerOptions * string * string -> Microsoft.Extensions.AI.ChatResponseFormatJson
Public Shared Function ForJsonSchema(Of T) (Optional serializerOptions As JsonSerializerOptions = Nothing, Optional schemaName As String = Nothing, Optional schemaDescription As String = Nothing) As ChatResponseFormatJson

型パラメーター

T

スキーマをエクスポートし、応答スキーマとして使用する必要がある型。

パラメーター

serializerOptions
JsonSerializerOptions

使用する JSON シリアル化オプション。

schemaName
String

スキーマの省略可能な名前。 既定では、これは Tから推論されます。

schemaDescription
String

スキーマの説明 (省略可能)。 既定では、これは Tから推論されます。

返品

ChatResponseFormatJson のインスタンスです。

注釈

構造化された出力をサポートする多くの AI サービスでは、JSON スキーマに最上位レベルの 'type=object' が必要です。 TStringInt32Booleanなどのプリミティブ型である場合、または JSON 配列としてシリアル化される型の場合、そのようなサービスで結果のスキーマを使用しようとすると失敗する可能性があります。 このような場合は、実際の型をクラスまたは構造体でラップする T を使用して、元の型をそのオブジェクトのプロパティとして JSON オブジェクトとしてシリアル化することを検討してください。

適用対象