Module Message.User

Messages sent by the user.

type content =
  1. | String of string
    (*

    Simple text message

    *)
  2. | Blocks of Content_block.t list
    (*

    Complex message with multiple content blocks

    *)

The content of a user message.

type t

The type of user messages.

val jsont : t Jsont.t

jsont is the Jsont codec for user messages.

val incoming_jsont : t Jsont.t

incoming_jsont is the codec for parsing incoming user messages from CLI. This parses the envelope format with "message" wrapper.

val outgoing_jsont : t Jsont.t

outgoing_jsont is the codec for encoding outgoing user messages to CLI. This produces the envelope format with "message" wrapper containing "role" and "content" fields.

val create_string : string -> t

create_string s creates a user message with simple text content.

val create_blocks : Content_block.t list -> t

create_blocks blocks creates a user message with content blocks.

val create_with_tool_result : tool_use_id:string -> content:Jsont.json -> ?is_error:bool -> unit -> t

create_with_tool_result ~tool_use_id ~content ?is_error () creates a user message containing a tool result. Content can be a string or array.

val content : t -> content

content t returns the content of the user message.

val unknown : t -> Unknown.t

unknown t returns the unknown fields preserved from JSON.