Message
a single chat message in a conversation.
role: who the message is fromcontent: the text contenttool-calls: non-empty for assistant messages that invoke toolstool-call-id: non-empty for tool result messages (role =Tool)images: images to include (only meaningful for user messages)
Use the constructors in the Message module instead of Message.init
directly.
from-response
(Fn [(Ref LLMResponse a)] Message)
(from-response r)
converts an LLMResponse into an assistant message, preserving any tool calls for conversation history.
images
(Fn [(Ref Message a)] (Ref (Array ImageContent) a))
gets the images property of a Message.
init
(Fn [Role, String, (Array ToolCall), String, (Array ImageContent)] Message)
creates a Message.
set-content!
(Fn [(Ref Message a), String] ())
sets the content property of a Message in place.
set-images
(Fn [Message, (Array ImageContent)] Message)
sets the images property of a Message.
set-images!
(Fn [(Ref Message a), (Array ImageContent)] ())
sets the images property of a Message in place.
set-tool-call-id
(Fn [Message, String] Message)
sets the tool-call-id property of a Message.
set-tool-call-id!
(Fn [(Ref Message a), String] ())
sets the tool-call-id property of a Message in place.
set-tool-calls
(Fn [Message, (Array ToolCall)] Message)
sets the tool-calls property of a Message.
set-tool-calls!
(Fn [(Ref Message a), (Array ToolCall)] ())
sets the tool-calls property of a Message in place.
to-json
(Fn [(Ref Message a)] JSON)
(to-json m)
converts a message to a JSON object with role and content keys. Includes tool_calls for assistant tool call messages, and tool_call_id for tool result messages. When images are present, content is serialized as an array of content parts (OpenAI format).
tool-call-id
(Fn [(Ref Message a)] (Ref String a))
gets the tool-call-id property of a Message.
tool-calls
(Fn [(Ref Message a)] (Ref (Array ToolCall) a))
gets the tool-calls property of a Message.
tool-result
(Fn [(Ref String a), (Ref String b)] Message)
(tool-result call-id content)
creates a tool result message for the given tool call ID.
update-content
(Fn [Message, (Ref (Fn [String] String a) b)] Message)
updates the content property of a Message using a function f.
update-images
(Fn [Message, (Ref (Fn [(Array ImageContent)] (Array ImageContent) a) b)] Message)
updates the images property of a Message using a function f.
update-role
(Fn [Message, (Ref (Fn [Role] Role a) b)] Message)
updates the role property of a Message using a function f.
update-tool-call-id
(Fn [Message, (Ref (Fn [String] String a) b)] Message)
updates the tool-call-id property of a Message using a function f.
update-tool-calls
(Fn [Message, (Ref (Fn [(Array ToolCall)] (Array ToolCall) a) b)] Message)
updates the tool-calls property of a Message using a function f.
user-with-image
(Fn [(Ref String a), (Array ImageContent)] Message)
(user-with-image s images)
creates a user message with text and images.
Each image is an ImageContent with a MIME type and base64-encoded data.