AI.Message.Assistant (fnord v0.9.40)

View Source

Assistant reply message.

Internal shape (matches the chat-completions raw map shape that existing pattern matches expect):

%AI.Message.Assistant{role: "assistant", content: "<binary>"}

Wire shape (built on demand by to_map/1):

%{type: "message", role: "assistant",
  content: [%{type: "output_text", text: "..."}]}

See AI.Message.User for the rationale on storing content as a binary.

Summary

Functions

Hydrate from a Responses-shaped or legacy chat-completions-shaped map (atom or string keys). Collapses multi-part content lists to a single binary.

Build an assistant message from a binary.

Types

t()

@type t() :: %AI.Message.Assistant{content: binary(), role: binary()}

Functions

from_map(raw)

@spec from_map(map()) :: t()

Hydrate from a Responses-shaped or legacy chat-completions-shaped map (atom or string keys). Collapses multi-part content lists to a single binary.

new(text)

@spec new(binary()) :: t()

Build an assistant message from a binary.