Liking cljdoc? Tell your friends :D

dscloj.core


module->promptclj

(module->prompt {:keys [inputs outputs instructions]})

Convert a module signature/schema into a prompt template.

A module is a map with:

  • :inputs - A vector of field definitions with :name, :type, :description keys
  • :outputs - A vector of field definitions with :name, :type, :description keys
  • :instructions - Optional string describing the task instructions, rules, and examples

Example: (module->prompt example-module)

Returns a formatted prompt string.

Convert a module signature/schema into a prompt template.

A module is a map with:
- :inputs - A vector of field definitions with :name, :type, :description keys
- :outputs - A vector of field definitions with :name, :type, :description keys
- :instructions - Optional string describing the task instructions, rules, and examples

Example:
  (module->prompt example-module)

Returns a formatted prompt string.
sourceraw docstring

parse-outputclj

(parse-output response {:keys [outputs]})

Parse LLM output based on module's output field definitions.

Parameters:

  • response: The LLM response string
  • module: The module definition with :outputs

Returns a map with field names as keys and parsed values.

Example: (parse-output llm-response {:outputs [{:name :answer :type "str"} {:name :confidence :type "bool"}]})

Parse LLM output based on module's output field definitions.

Parameters:
- response: The LLM response string
- module: The module definition with :outputs

Returns a map with field names as keys and parsed values.

Example:
  (parse-output llm-response {:outputs [{:name :answer :type "str"}
                                        {:name :confidence :type "bool"}]})
sourceraw docstring

predictclj

(predict module input-map & [options])

Make a prediction using an LLM.

Parameters:

  • module: The module definition with :inputs and :outputs
  • input-map: Map of input field names to values
  • options: Optional configuration map (e.g., :model, :temperature)

Returns parsed output as a map based on module's output fields.

Example: (predict qa-module {:question "What is 2+2?"} {:model "gpt-4"})

Make a prediction using an LLM.

Parameters:
- module: The module definition with :inputs and :outputs
- input-map: Map of input field names to values
- options: Optional configuration map (e.g., :model, :temperature)

Returns parsed output as a map based on module's output fields.

Example:
  (predict qa-module {:question "What is 2+2?"} {:model "gpt-4"})
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