AttachmentBuilder

A builder for constructing media attachments for prompt messages.

This builder provides a fluent DSL API for creating collections of media content that can be attached to user messages. It supports images, audio files, and documents, enabling rich multimedia content in prompt construction.

Example usage:

val attachments = AttachmentBuilder().apply {
image("screenshot.png")
audio(audioData, "mp3")
document("report.pdf")
}.build()

This class is part of the new DSL structure for prompt construction. It focuses specifically on building media attachments, while text content is handled by TextContentBuilder. For combining both text and attachments, use ContentBuilderWithAttachment.

See also

for the types of media content supported

for using this builder in prompt construction

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun audio(data: ByteArray, format: String)

Adds an audio attachment to the media content collection.

Link copied to clipboard

Constructs and returns the accumulated list of media content items.

Link copied to clipboard
fun document(source: String)

Adds a document attachment to the media content collection.

Link copied to clipboard
fun image(source: String)

Adds an image attachment to the media content collection.