Liking cljdoc? Tell your friends :D

collet.actions.llm


->json-schemaclj

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

->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.
raw 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.
raw 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.
raw 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})
```
raw 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.
raw docstring

file->bytesclj

(file->bytes input-stream)

Read file into bytes.

Read file into bytes.
raw docstring

openai-params-specclj


parse-argumentsclj

(parse-arguments result)

Parse the arguments of the tool calls.

Parse the arguments of the tool calls.
raw 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!"
```
raw docstring

question->msgsclj

(question->msgs question)

Convert the question to a list of messages.

Convert the question to a list of messages.
raw docstring

select-tool-by-nameclj

(select-tool-by-name tools function)

Select the tool by name.

Select the tool by name.
raw 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.
raw docstring

tool-specclj


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"))
```
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close