ContentPart

org.llm4s.llmconnect.model.ContentPart
See theContentPart companion object
@Stable
sealed trait ContentPart extends Product, Serializable

One part of a user or tool message's content: text, an image, or a document.

Text is built directly. An image or a document is built with ContentPart.image or ContentPart.document, which check its source and return a Result:

  • '''Inline bytes are bounded''' by ContentPart.MaxInlineBytes (5 MiB), also when a part is read from JSON. An agent thread's every checkpoint is a full snapshot of its state, so each retained checkpoint keeps a copy of every inline part - base64-encoded, a third larger - for as long as the message stays in the thread. Larger media belongs at a org.llm4s.media.MediaSource.Url or in a org.llm4s.media.MediaSource.ProviderFile, which a message holds by reference.
  • '''A URL is absolute''', and not a data: URL: that is inline bytes by another name, and would escape the bound. Use org.llm4s.media.MediaSource.Inline.
  • '''A provider file''' names a provider and an id, neither blank.

Each provider sends the parts its API takes and fails the request with an org.llm4s.error.UnsupportedContentPartError for any other; nothing is dropped or turned into text. Which provider takes which parts is listed in docs/guide/multimodal.md.

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
class Document
class Image
class Text

Members list

Value members

Abstract methods

def kind: String

The part's kind, for errors and logs: text, or the category, source and media type of an image or document, e.g. image (url, image/png) or document (provider file openai, application/pdf).

The part's kind, for errors and logs: text, or the category, source and media type of an image or document, e.g. image (url, image/png) or document (provider file openai, application/pdf).

Attributes

Inherited methods

def productElementName(n: Int): String

Attributes

Inherited from:
Product
def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product
def productPrefix: String

Attributes

Inherited from:
Product

Inherited and Abstract methods

def canEqual(that: Any): Boolean

Attributes

Inherited from:
Equals
def productArity: Int

Attributes

Inherited from:
Product
def productElement(n: Int): Any

Attributes

Inherited from:
Product