Mirrors com.openai.models.responses in openai-java
Mirrors com.openai.models.responses in openai-java
(chat-model x)
(chat-model x default)
Supports keywords and Java enums
Supports keywords and Java enums
(create-response & {:keys [raw?] :or {raw? false} :as m})
Creates a response using the Responses API. All keys map to builder methods in the java sdk. Some extra keys are supported for convenience
Options: :model - (optional) The model to use for responses. Can be a keyword from chat-models or a Java enum from the open ai sdk. Defaults to :gpt-4o :input-of-response - (optional) :input - (optional) :metadata - (optional, map) :max-output-tokens - (optional, int) :format - (optional) - A var pointing to a Malli Schema or a [schema format-name] tuple. Used for structured outputs :easy-input-messages - (optional) A vector of {:role, :content} maps. Will be converted to an ArrayList of EasyInputMessage and passed to .inputOfResponse on the java builder :input-items - (optional) A vector of {:role, :content} maps. Supports more content types than easy-input-messages. :content itself should be a vector of content maps - .ie [{:type :image :detail :auto} {:type :text :text "Describe this image."] :raw? - (optional, boolean) If true, the Java type will be returned instead of a Clojure map. Defaults to false
Creates a response using the Responses API. All keys map to builder methods in the java sdk. Some extra keys are supported for convenience Options: :model - (optional) The model to use for responses. Can be a keyword from chat-models or a Java enum from the open ai sdk. Defaults to :gpt-4o :input-of-response - (optional) :input - (optional) :metadata - (optional, map) :max-output-tokens - (optional, int) :format - (optional) - A var pointing to a Malli Schema or a [schema format-name] tuple. Used for structured outputs :easy-input-messages - (optional) A vector of {:role, :content} maps. Will be converted to an ArrayList of EasyInputMessage and passed to .inputOfResponse on the java builder :input-items - (optional) A vector of {:role, :content} maps. Supports more content types than easy-input-messages. :content itself should be a vector of content maps - .ie [{:type :image :detail :auto} {:type :text :text "Describe this image."] :raw? - (optional, boolean) If true, the Java type will be returned instead of a Clojure map. Defaults to false
(create-response-stream on-event & {:keys [on-complete on-error] :as m})
Nearly identical to create-response except it uses the async client. The first argument is a function that will receive events as they become available. All other options are the same as create-response with the addition of two new options:
Additional options: :on-complete - (optional) - Called when the underlying future completes :on-error - (optional) - Called with any exceptions generated in the underlying future
Nearly identical to create-response except it uses the async client. The first argument is a function that will receive events as they become available. All other options are the same as create-response with the addition of two new options: Additional options: :on-complete - (optional) - Called when the underlying future completes :on-error - (optional) - Called with any exceptions generated in the underlying future
(detect-mime-type-url url)
Guess the MIME type of the content at url
. Tries, in order:
Files.probeContentType
(for file:// URLs)URLConnection/guessContentTypeFromName
(by extension)URLConnection/guessContentTypeFromStream
(content‑sniffing).Guess the MIME type of the content at `url`. Tries, in order: 1. `Files.probeContentType` (for file:// URLs) 2. `URLConnection/guessContentTypeFromName` (by extension) 3. `URLConnection/guessContentTypeFromStream` (content‑sniffing).
(easy-input-messages entries)
Create a response with easy input - that is entries is expected to be a vector of maps containing :role and :content keys. Supported roles are :user, :assistant, and :system. :content should be anyhing supported by the EasyInputMessage.Builder class
Create a response with easy input - that is entries is expected to be a vector of maps containing :role and :content keys. Supported roles are :user, :assistant, and :system. :content should be anyhing supported by the EasyInputMessage.Builder class
(response-create-params' m)
Adds some defaults and support for Clojure only keys (like :easy-input-messages or :input-items)
Adds some defaults and support for Clojure only keys (like :easy-input-messages or :input-items)
(response-input-items entries)
Convert a vector into a valid builder call to inputOfResponse.
[{:role :user :content ["Describe this image."
{:type :image :detail :auto :image-url (io/resource "image.png")}]}
{:role :user :content [{:type :text :text "Describe this file"}
{:type :file :filename "notes.pdf" :file-data (io/resource "notes.pdf")]}]
Convert a vector into a valid builder call to inputOfResponse. ```clojure [{:role :user :content ["Describe this image." {:type :image :detail :auto :image-url (io/resource "image.png")}]} {:role :user :content [{:type :text :text "Describe this file"} {:type :file :filename "notes.pdf" :file-data (io/resource "notes.pdf")]}] ```
(response-text-config v)
(response-text-config s format-name)
Convert a malli schema to a response text config containing a format for structured outputs. If given a single var, the format name will be inferred from the var name. Otherwise a schema and name can be explicitly provided.
Convert a malli schema to a response text config containing a format for structured outputs. If given a single var, the format name will be inferred from the var name. Otherwise a schema and name can be explicitly provided.
(url->base64-data-url url)
Read all bytes from url
, Base64‑encode them, and return a
data URL of the form
"data:<mime-type>;base64,<base64‑data>".
Read all bytes from `url`, Base64‑encode them, and return a data URL of the form "data:<mime-type>;base64,<base64‑data>".
(with-url-support x)
Allows us to pass a java.net.URL to the :image-url property. Very convenient to be able to use (io/resource) as an input to openai-java
Allows us to pass a java.net.URL to the :image-url property. Very convenient to be able to use (io/resource) as an input to openai-java
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close