ToC DocOverview CGDoc RelNotes FAQ Index PermutedIndex
Allegro CL version 11.0

API for Large Language Models

API for Large Language Models

1.0 Large Language Model Introduction

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:

Use this package to access the functions described below.

Code examples in the document assume that these packages are used.


2.0 LLM Functional Dependencies

Operators in the llm-gpt module use operators/variables in the following modules, so they must be loaded when using this module:


3.0 LLM Quick Start

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.


4.0 LLM API operators

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.


5.0 LLM API variables


6.0 LLM Classes



Copyright (c) 2023, Franz Inc. Lafayette, CA., USA. All rights reserved.

ToC DocOverview CGDoc RelNotes FAQ Index PermutedIndex
Allegro CL version 11.0