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.

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.

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],
)

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:

Last updated