ContentBuilderWithAttachment
A builder class that extends TextContentBuilder to support both text and media attachments.
This class combines text content building capabilities with media attachment support, allowing users to create rich content that includes both textual information and media elements like images, audio files, and documents.
Example usage:
val contentBuilder = ContentBuilderWithAttachment()
contentBuilder.text("Here's my analysis:")
contentBuilder.attachments {
image("chart.png")
document("report.pdf")
}
val (text, attachments) = contentBuilder.buildWithAttachments()
This class is part of the new DSL structure for prompt construction, replacing the previous UserContentBuilder approach. It provides a more structured way to combine text and media attachments in a single builder.
See also
for text-only content building
for media attachment building
Functions
Configures media attachments for this content builder.
Builds and returns both the text content and media attachments.
Extension function for TextContentBuilder that adds line numbering to the content.
Adds padding to each line of the content produced by the provided builder block.
Adds the given text to the content. If the caret is not at the beginning of the line, a newline is added before appending the text.
Adds the given string as a new line of text to the content being built by the TextContentBuilder.