File Attachments

Enrich prompts with visual and document context, including automatic image resizing and native PDF parsing.

Kirby Copilot lets you select files to enrich the user prompt with additional information. For example, you can select product images and ask the AI model to describe the product visually or select PDF files and let the AI model use these documents to generate summaries or extract key information.

Supported AI Models

In order to pass images or PDF files as input, you need an AI model that supports file processing. Currently, the following models support image and PDF input:

  • OpenAI's ChatGPT and other reasoning models
  • Anthropic's Claude models
  • Google's Gemini models
  • Mistral AI's Mistral models
If the configured model does not support file processing, the files will be ignored.

Images

Resizing

When the Panel user selects files, the plugin will automatically downscale all images to a maximum size of 2048px. On the one hand, this ensures that the AI model can process the images quickly, and on the other hand, it complies with the OpenAI image size limit of fitting into a 2048 pixel bounding box.

Image resizing happens on the fly, directly in the browser, before the image is sent to the AI provider.

Processing PDF Files

PDF files can be used to support user prompts with information that the AI model can incorporate to generate answers. For example, you can select a PDF with a product description and ask the AI model to summarize the product in a few sentences.

When selecting PDF files with the Select files button, the plugin sends them directly to the AI provider along with your prompt. The AI model reads the document's structure, formatting, and content natively.

The AI provider sets how large and how long the attached PDFs may be. Your web server's request size limit applies as well, since every request passes through Kirby.

File as Context Source

On a Kirby file page, you can set the value to auto to pre-select the current file as context for the user prompt. This is useful if you want to generate text for an image that has already been uploaded to the Panel, such as alternative text:

sections/copilot.yml
type: copilot
field: alt
# Use the uploaded file as context
files: auto
# Optional: Provide a predefined user prompt
userPrompt: Describe this image for alternative text. Include key features, colors, and context. Max 125 characters.
# Optional: Disable the editing of the user prompt
editable: false

The section above will use the current file of a Kirby file model as context for the user prompt:

Only images are attached this way – gif, jpeg, png, and webp. On a file of any other type, including PDF, the section shows a note that the type is not supported as context. Attach a PDF through the file picker instead, which files: true provides.