|
Allegro CL version 11.0 |
Functionality described in this document are included in the :acl-llm
module. Load this module with
(require :acl-llm)
As described below, you should also load the :st-json
and :net.aserve
modules.
The two acl-llm packages documented here provide Lisp operators to interact with APIs of Large Languge Models.
Currently the packages support only the OpenAI GPT models. See OpenAI API docs for API details.
This document describes the package:
llm.gpt
(nickname gpt
): Lisp symbols naming operators/variables which access OpenAI Large Language Model APIs.Use this package to access the functions described below.
Code examples in the document assume that these packages are used.
Operators in the llm-gpt
module use operators/variables in the following modules, so they must be loaded when using this module:
:st-json
- This module (containing symbols in the st-json
package) supports building and parsing JSON objects.
See st-json.
:net.aserve
- Symbols in this module (mostly in the net.aserve
package) implement HTTP clients and servers. Specifically llm-gpt
package depends upon these two functions:
These forms will get you started:
(require :acl-llm)
(use-package :gpt)
(set-openai-api-key YOUR-API-KEY)
(ask-chat "Hello")
The call to set-openai-api-key requires a valid key. A valid key is a string formatted like this sample invalid key: "sk-U01ABc2defGHIJKlmnOpQ3RstvVWxyZABcD4eFG5jiJKlmno"
. See the description of that function for a link to instructions for getting a key.
The last form (ask-chat "Hello")
executes a simple chatbot function by building a JSON object to send to the OpenAI completions API and, if no errors occur, receives and parses the JSON object response. The sent object includes the input text "Hello"
and sets all parameters to their default values. The response object contains an array of response choices, and by default the ask-chat function extracts the top ranked response as a string.
The Large Language model API includes the following operators. Note that arguments to many of these operators are described in the OpenAI API Reference document and some searching in that document may be required to find the argument descriptions. This Allegro CL documentation assumes users are familiar with OpenAI and does not itself serve as a introduction to it.
*openai-api-key*: value changed to the key returned by set-openai-api-key when that function is called.
*default-vector-database-dir*: The default directory to store and retrieve vector databases.
*default-vector-database-name*: The default name for a vector database.
*openai-default-ask-chat-model*: The default value for the model used by ask-chat.
*openai-default-best-of*: The default value for the OpenAI API parameter best_of
.
*openai-default-chat-model*: The default value for the model used by chat.
*openai-default-echo*: The default value for the OpenAI API parameter echo
.
*openai-default-fine-tune-model*: The default value for the model used by (fine-tune)[gpt-ops.html#fine-tune].
*openai-default-frequency-penalty*: The default value for the OpenAI API parameter frequency_penalty
.
*openai-default-function-call*: The default value for the OpenAI API parameter function_call
.
*openai-default-functions*: The default value for the OpenAI API parameter functions
.
*openai-default-initial-delay*: The default value for the call-openai key parameter :initial-delay
.
*openai-default-logit-bias*: The default value for the OpenAI API parameter logit_bias
.
*openai-default-logprobs*: The default value for the OpenAI API parameter logprobs
.
*openai-default-max-tokens*: The default value for the OpenAI API parameter max_tokens
.
*openai-default-min-score*: The default value for the key parameter :min-score
of nn and ask-my-documents.
*openai-default-n*: The default value for the OpenAI API parameter n
.
*openai-default-output-format*: The default value for the OpenAI API parameter output_format
.
*openai-default-presence-penalty*: The default value for the OpenAI API parameter presence_penalty
.
*openai-default-retries*: The default value for the call-openai key parameter :retries
.
*openai-default-stop*: The default value for the OpenAI API parameter stop
.
*openai-default-suffix*: The default value for the OpenAI API parameter suffix
.
*openai-default-temperature*: The default value for the OpenAI API parameter temperature
.
*openai-default-timeout*: The default value for the :timeout
key parameter of call-openai.
*openai-default-top-n*: The default value for the key parameter :top-n
of nn and ask-my-documents.
*openai-default-top-p*: The default value for the OpenAI API parameter top_p
.
*openai-default-user*: The default value for the OpenAI API parameter user
.
Copyright (c) Franz Inc. Lafayette, CA., USA. All rights reserved.
|
Allegro CL version 11.0 |