Overview

File attachments enable you to include images and other files in your prompts. This is useful for tasks like image analysis, document processing, or any scenario where you need to work with external files.

Components

ImageAttachment

The <ImageAttachment> component allows you to attach images to your prompt:

<ImageAttachment image={props.imageLink} />

Parameters:

  • image: URL to the image file
  • mimeType (optional): MIME type of the image (e.g., “image/jpeg”, “image/png”)

FileAttachment

The <FileAttachment> component allows you to attach any type of file:

<FileAttachment data="https://example.com/document.pdf" mimeType={props.fileMimeType} />

Parameters:

  • data: URL to the file
  • mimeType: MIME type of the file (e.g., “application/pdf”, “text/plain”)

Example

Here’s a complete example showing how to use file attachments:

math.prompt.mdx
---
name: math
text_config:
  model_name: test-model
  temperature: 0.5
---

<System>
You are an observer that comments on images and files.
</System>

<User>
  {props.userMessage}
  <ImageAttachment image={props.imageLink} />
  <FileAttachment data="https://example.com/document.pdf" mimeType={props.fileMimeType} />
</User>

Have Questions?

We’re here to help! Choose the best way to reach us: