Fields as Context

Use fields as placeholders in user prompts.

Fields as Placeholders in User Prompts

Context is key to a good user prompt. The more context you can provide, the better the AI can understand the user's intent.

Kirby Copilot provides all fields from the same Kirby model as placeholders in user prompts. This allows you to include additional information in the prompt.

Wrap the field name in curly braces to use it as a placeholder: {field}. For example, given the Kirby model contains the following date field:

    label: Date
    type: date
    default: 2024-01-16

And your Kirby Copilot section contains the following user prompt:

type: copilot
field: blocks
userPrompt: What is the current date? (Hint, it is {date}!)
Kirby Copilot section preview

Before the user prompt above is sent to the AI model, the placeholder {date} is replaced with the actual field value 2024-01-16, resulting in the following prompt:

What is the current date? (Hint, it is 2024-01-16!)

Encoding Field Values

If the field value is not a primitive (e.g. a String, Number, or Boolean), it will be encoded as JSON before being used as a placeholder. GPT models are pretty good at understanding structured data like JSON.