PartEncoding

org.llm4s.llmconnect.provider.PartEncoding
@Stable
object PartEncoding

What every chat client needs to map ContentParts: a client describes the parts it sends as a partial function from part to its wire form, and a part it does not cover fails the request with an UnsupportedContentPartError - never dropped, never sent as text.

A provider module uses check to refuse a conversation before anything is sent and encodeAll to encode a message's parts.

Attributes

Source
PartEncoding.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def check(provider: String, messages: Seq[Message], user: PartialFunction[ContentPart, Any], tool: PartialFunction[ContentPart, Any]): Result[Unit]

Right when user covers every part of every user message in messages, and tool every part of every tool message; else the error for the first part one does not. For a client that builds its request in steps that cannot fail, so it checks the conversation first. It asks only isDefinedAt: nothing is encoded, so inline media is not base64-encoded twice per request.

Right when user covers every part of every user message in messages, and tool every part of every tool message; else the error for the first part one does not. For a client that builds its request in steps that cannot fail, so it checks the conversation first. It asks only isDefinedAt: nothing is encoded, so inline media is not base64-encoded twice per request.

Attributes

Source
PartEncoding.scala
def encodeAll[A](provider: String, role: MessageRole, parts: Seq[ContentPart])(encode: PartialFunction[ContentPart, A]): Result[Vector[A]]

parts, each encoded with encode; the first part encode does not cover fails the whole.

parts, each encoded with encode; the first part encode does not cover fails the whole.

Attributes

Source
PartEncoding.scala