Attachment
A file that goes to a model with a message, such as the photo of a receipt or a contract as a PDF.
Create one from the bytes of the file with Attachment.of, or from an address that the model's API downloads itself with Attachment.url, and send it with a ChatMessage.User:
val question = ChatMessage.User(
"What does this letter ask me to do?",
attachments = listOf(Attachment.of(photo, "image/jpeg")),
)A tool returns one with attach.
The model classes send images (image/jpeg, image/png, image/gif and image/webp) and PDFs (application/pdf); each says which of them it takes from an address. A file of another type fails before the request, with a ChatModelException.
An attachment is part of its message, so a checkpoint of a state that holds the message holds the file too, after every step. For a large file, keep its path or its address in the state and attach it in the node that calls the model.
Inheritors
Types
The file itself.