Class GoogleSchemaHelper
- Namespace
- GenerativeAI.Types
- Assembly
- GenerativeAI.dll
Provides helper methods for converting JSON schemas to Google-compatible formats.
public static class GoogleSchemaHelper
- Inheritance
-
GoogleSchemaHelper
- Inherited Members
Methods
ConvertToCompatibleSchemaSubset(JsonDocument)
Converts a JSON document that contains valid json schema https://json-schema.org/specification as e.g. generated by
Microsoft.Extensions.AI.AIJsonUtilities.CreateJsonSchema
or
JsonSchema.Net
's JsonSchemaBuilder to a subset that is compatible with Google's APIs.
public static Schema? ConvertToCompatibleSchemaSubset(JsonDocument constructedSchema)
Parameters
constructedSchemaJsonDocumentGenerated, valid json schema.
Returns
- Schema
Subset of the given json schema in a google-comaptible format.
ConvertToCompatibleSchemaSubset(JsonNode)
Converts a JSON document that contains valid json schema https://json-schema.org/specification as e.g. generated by
Microsoft.Extensions.AI.AIJsonUtilities.CreateJsonSchema
or
JsonSchema.Net
's JsonSchemaBuilder to a subset that is compatible with Google's APIs.
public static Schema ConvertToCompatibleSchemaSubset(JsonNode node)
Parameters
nodeJsonNodeGenerated, valid json schema as a JsonNode.
Returns
- Schema
Subset of the given json schema in a google-comaptible format.
ConvertToSchema(Type, JsonSerializerOptions?, Dictionary<string, string>?)
Converts a .NET type to a Google-compatible schema.
public static Schema ConvertToSchema(Type type, JsonSerializerOptions? jsonOptions = null, Dictionary<string, string>? descriptionTable = null)
Parameters
typeTypeThe type to convert to a schema.
jsonOptionsJsonSerializerOptionsOptional JSON serializer options to use during conversion.
descriptionTableDictionary<string, string>Optional dictionary containing custom descriptions for properties.
Returns
- Schema
A Google-compatible schema representing the specified type.
ConvertToSchema<T>(JsonSerializerOptions?)
Converts a .NET type to a Google-compatible schema.
public static Schema ConvertToSchema<T>(JsonSerializerOptions? jsonOptions = null)
Parameters
jsonOptionsJsonSerializerOptionsOptional JSON serializer options to use during conversion.
Returns
- Schema
A Google-compatible schema representing the specified type.
Type Parameters
TThe type to convert to a schema.