ResponseContent

@Serializable(with = ResponseContentSerializer::class)
sealed interface ResponseContent

The two shapes a content or output field takes on the wire: a bare string, or an array of ResponseContentParts.

Reading one is a when over the two cases:

when (val content = message.content) {
is ResponseContent.Text -> println(content.text)
is ResponseContent.Parts -> content.parts.forEach(::println)
null -> println("no content")
}

Writing one is usually implicit: the item constructors take a String or a List<ResponseContentPart> and wrap it for you.

Inheritors

Types

Link copied to clipboard

Multimodal content, sent and received as a JSON array of parts.

Link copied to clipboard
class Text(val text: String) : ResponseContent

Plain text, sent and received as a bare JSON string.