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)
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.
set-content!
(Fn [(Ref Message a), String] ())
sets the content 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.
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-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.