(->json-schema {:keys [name schema]})
(->open-ai-message {:keys [system user ai tool-calls tool tool-call-id]
:as msg})
Convert the message to the OpenAI format.
Convert the message to the OpenAI format.
(apply-fn {:keys [args func] :as tool} function)
Apply the tool function to the arguments.
Apply the tool function to the arguments.
(ask-open-ai question
{:keys [model tools as max-tokens temperature top-p
response-format]}
{:keys [api-key api-endpoint organization]})
Send the request to OpenAI and if tools are provided, apply them to the response.
Send the request to OpenAI and if tools are provided, apply them to the response.
(ask-openai {:keys [question vars images model api-key api-endpoint organization
response-format max-tokens temperature top-p tools as]})
Send request to OpenAI chat completions. Args:
(ask-openai {:question "What programming language was created by Rich Hickey?"
:api-key api-token})
Send request to OpenAI chat completions. Args: - question: The question to ask. - vars: A map of variables to use in the question. - images: A list of image URLs or input streams. - model: The model to use. - api-key: The API key. - api-endpoint: The API endpoint. - organization: The organization. - response-format: The response format. - max-tokens: The maximum number of tokens. - temperature: The temperature. - top-p: The top-p. - tools: A list of tools. - as: The output format. Example: ```clojure (ask-openai {:question "What programming language was created by Rich Hickey?" :api-key api-token}) ```
(chat-completion {:keys [model msgs tools max-tokens top-p temperature
response-format]}
{:keys [api-key api-endpoint organization]})
Send a request to OpenAI chat completions.
Send a request to OpenAI chat completions.
(parse-arguments result)
Parse the arguments of the tool calls.
Parse the arguments of the tool calls.
(prompt s ctx)
Python-like f-string Example:
(f-string "Hello, {name}!" {:name "world"})
;; => "Hello, world!"
Python-like f-string Example: ```clojure (f-string "Hello, {name}!" {:name "world"}) ;; => "Hello, world!" ```
(question->msgs question)
Convert the question to a list of messages.
Convert the question to a list of messages.
(select-tool-by-name tools function)
Select the tool by name.
Select the tool by name.
(tool->function tool-spec)
Convert the tool to a function object for the OpenAI API.
Convert the tool to a function object for the OpenAI API.
(with-images text images)
Return a message with an image. Args:
(with-images "What are in these images? Is there any difference between them?"
"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
(io/input-stream "/tmp/sample.png"))
Return a message with an image. Args: - text: The prompt to ask the user. - images: A list of image URLs or input streams. Example: ```clojure (with-images "What are in these images? Is there any difference between them?" "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg" (io/input-stream "/tmp/sample.png")) ```
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close