Skip to content

JsonInstructions

Namespace: Vercel.AI.ProviderUtils

public static class JsonInstructions

Appends a JSON schema instruction to a prompt or to the first system message.

Inheritance: object

View source

Inject(string?, JsonNode?, string?, string?, bool, bool)

Section titled “Inject(string?, JsonNode?, string?, string?, bool, bool)”
public static string Inject(string? prompt, JsonNode? schema, string? schemaPrefix = null, string? schemaSuffix = null, bool prefixSpecified = false, bool suffixSpecified = false)

Joins an optional prompt with a JSON schema instruction.

Parameters

Name Type Description
prompt string
schema JsonNode
schemaPrefix string
schemaSuffix string
prefixSpecified bool
suffixSpecified bool

Returns: string

View source

InjectIntoMessages(IReadOnlyList<ModelMessage>, JsonNode?, string?, string?, bool, bool)

Section titled “InjectIntoMessages(IReadOnlyList<ModelMessage>, JsonNode?, string?, string?, bool, bool)”
public static IReadOnlyList<ModelMessage> InjectIntoMessages(IReadOnlyList<ModelMessage> messages, JsonNode? schema = null, string? schemaPrefix = null, string? schemaSuffix = null, bool prefixSpecified = false, bool suffixSpecified = false)

Writes the instruction into the first system message, or inserts one.

Parameters

Name Type Description
messages IReadOnlyList<ModelMessage>
schema JsonNode
schemaPrefix string
schemaSuffix string
prefixSpecified bool
suffixSpecified bool

Returns: IReadOnlyList<ModelMessage>

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product