Pure functions over messages and request bodies: reading a reply, building the next request, and making the content blocks that are tedious to write by hand. Everything here takes and returns the API's own shapes, so each function is optional: the maps can always be read and built directly.
(text message) ; the reply's text (-> body (reply message) (say "Say more.")) ; the next request body
Pure functions over messages and request bodies: reading a reply, building the next request, and making the content blocks that are tedious to write by hand. Everything here takes and returns the API's own shapes, so each function is optional: the maps can always be read and built directly. (text message) ; the reply's text (-> body (reply message) (say "Say more.")) ; the next request body
(data message)The text of a message read as JSON, with keyword keys: the value of a reply made with a structured output format. Throws if the text is not JSON, as it is not after a refusal or when max_tokens cut it short, so check :stop_reason first.
The text of a message read as JSON, with keyword keys: the value of a reply made with a structured output format. Throws if the text is not JSON, as it is not after a refusal or when max_tokens cut it short, so check :stop_reason first.
(document bytes)A document content block from a PDF's bytes. An :title, :context, :citations or :cache_control is an assoc away.
A document content block from a PDF's bytes. An :title, :context, :citations or :cache_control is an assoc away.
(image bytes media-type)An image content block from the image's bytes and its media type, such as "image/png" or "image/jpeg".
{:role "user" :content [(image bytes "image/png") {:type "text" :text "What is this?"}]}
An image content block from the image's bytes and its media type, such
as "image/png" or "image/jpeg".
{:role "user" :content [(image bytes "image/png")
{:type "text" :text "What is this?"}]}(reply body message)body with a message from the API appended as an assistant turn, its :content unchanged, which is how the API must get it back.
(-> body (reply message) (say "And in French?"))
body with a message from the API appended as an assistant turn, its :content unchanged, which is how the API must get it back. (-> body (reply message) (say "And in French?"))
(say body content)body with a user turn appended. content is whatever the API accepts as a message's :content: a string or a vector of blocks.
body with a user turn appended. content is whatever the API accepts as a message's :content: a string or a vector of blocks.
(text message)The text of a message: its text blocks joined, with thinking, tool and other blocks left out. "" when there is none.
The text of a message: its text blocks joined, with thinking, tool and other blocks left out. "" when there is none.
(tool-uses message)The tool_use blocks of a message, in order, as a vector. These are the calls the caller must answer; server tool blocks are not among them.
The tool_use blocks of a message, in order, as a vector. These are the calls the caller must answer; server tool blocks are not among them.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |