Liking cljdoc? Tell your friends :D

collet.actions.llm


->json-schemaclj

(->json-schema {:keys [name schema]})
source

->open-ai-messageclj

(->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.
sourceraw docstring

apply-fnclj

(apply-fn {:keys [args func] :as tool} function)

Apply the tool function to the arguments.

Apply the tool function to the arguments.
sourceraw docstring

ask-open-aiclj

(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.
sourceraw docstring

ask-openaiclj

(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:

  • 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:
(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})
```
sourceraw docstring

chat-completionclj

(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.
sourceraw docstring

file->bytesclj

(file->bytes input-stream)

Read file into bytes.

Read file into bytes.
sourceraw docstring

openai-params-specclj

source

parse-argumentsclj

(parse-arguments result)

Parse the arguments of the tool calls.

Parse the arguments of the tool calls.
sourceraw docstring

promptclj

(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!"
```
sourceraw docstring

question->msgsclj

(question->msgs question)

Convert the question to a list of messages.

Convert the question to a list of messages.
sourceraw docstring

select-tool-by-nameclj

(select-tool-by-name tools function)

Select the tool by name.

Select the tool by name.
sourceraw docstring

tool->functionclj

(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.
sourceraw docstring

tool-specclj

source

with-imagesclj

(with-images text images)

Return a message with an image. Args:

  • text: The prompt to ask the user.
  • images: A list of image URLs or input streams. Example:
(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"))
```
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close