Field AI Config
Configure AI behavior for a field. Available for all Puck fields.
const config = {
components: {
HeadingBlock: {
fields: {
title: {
type: "text",
ai: {
instructions: "Always use caps",
},
},
},
render: ({ title }) => <h1>{title}</h1>,
},
},
};Params
| Param | Example | Type | Status |
|---|---|---|---|
instructions | "Always use caps" | String | - |
exclude | false | Boolean | - |
required | true | Boolean | - |
schema | {} | JSONSchema | - |
stream | true | Boolean | - |
Optional params
instructions
Instructions that must be taken into account when considering this field.
const config = {
components: {
HeadingBlock: {
fields: {
title: {
type: "text",
ai: {
instructions: "Always use caps",
},
},
},
// ...
},
},
};exclude
Exclude this field when generating a page. false by default.
const config = {
components: {
HeadingBlock: {
fields: {
title: {
type: "text",
ai: {
exclude: true,
},
},
},
// ...
},
},
};required
Explicitly mark this field as required (true) or optional (false). By default, any field with a default value in defaultProps is considered required.
const config = {
components: {
HeadingBlock: {
fields: {
title: {
type: "text",
ai: {
required: true,
},
},
},
// ...
},
},
};schema
A custom JSON Schema for custom, external, or user fields that Puck canāt infer. Puck will ignore this field for standard field types.
const config = {
components: {
HeadingBlock: {
fields: {
title: {
type: "custom",
render: () => <input />,
ai: {
schema: { type: "string" },
},
},
},
// ...
},
},
};Supported schemas
Field schemas support a subset of the JSON Schema language.
Supported types
The following types are supported in the schema definition:
Type constraints
You can constrain how schema types are generated using the following attributes.
stringĀ constraints
pattern: A regular expression that the string must match.format: Predefined formats for strings. Currently supported:
number constraints
multipleOf: The number must be a multiple of this value.maximum: The number must be less than or equal to this value.exclusiveMaximum: The number must be less than this value.minimum: The number must be greater than or equal to this value.exclusiveMinimum: The number must be greater than this value.
array constraints
minItems: The array must have at least this many items.maxItems: The array must have at most this many items.
stream
Control when a field value is streamed to the client when using the AI plugin. Use this for fields, like image URLs, that canāt be rendered until complete.
Accepts a boolean value, with the following behavior:
true: Stream the value to the client as soon as availablefalse: Wait for the value to finish generating before streaming the value to the client
const config = {
components: {
ImageBlock: {
fields: {
src: {
type: "text",
ai: {
stream: false, // Don't stream image URLs
},
},
},
// ...
},
},
};By default, the following field types are streamable by default:
arraycustomnumbertexttextarea