Attachments

Introduction

Sending attachments is particularly useful if you want your agent backend to send some images or any other files to your users.
AgentLabs SDK allows you to effortlessly send attachments along with your messages.
Some attachments like Images will be displayed with a lightbox preview, others like zip files will be displayed as simple downloadable files.
Example of 3 attachments sent in a message
Example of zip files

How to send an attachment

Sending attachments is super easy. You only have to instantiate an Attachment and then pass it to the send method as an argument.
Python
Typescript
from agentlabs.attachment import Attachment
attachment = Attachment.from_local_file("path-to-your-file")
agent.send(
conversation_id=message.conversation_id,
text="Here is your zip file",
attachments=[attachment],
)
import {Attachment} from "@agentlabs/node-sdk";
const attachment = Attachment.fromLocalFile('path-to-your-file')
await agent.send({
text: 'Here is an image for you...',
conversationId: '<your-conversation-id>',
attachments: [attachment],
});
You can pass as many attachments as you want. We also support all mime types as long as each file does not exceed 10MB.

Going further

If you want to go further with attachments, you can check this example where we show you how to create a basic midjourney clone.
Here's the result:
A basic midjourney clone