2.0.1 • Published 2 years ago
completion-cli v2.0.1
completion-cli
npx completion-cli --helpAnswers questions. This tool was done for personal use, but feel free to use it.
Requirements
- NodeJS v19+
Api
- Define
OPENAI_API_KEYenvironment variable with your OpenAI key.
- Simplest one. Request creative reply of 2000 tokens long.
npx completion-cli -t 2000 -T 1 -p "Explain me the world:"- Send the text from
blogpost.txtusing supported option in the config file.
I tend to use this option almost exclusively.
npx completion-cli -j ./path/to/config.json -f ./path/to/blogpost.txtExample of a json config here
Options
Pass either cli flags or a JSON-config path. The CLI and JSON options are combined, CLI overwrites JSON. But only one of --prompt or --filePath or json.prompt is allowed.
--help--filePathor-f, the relative path to the text file. Example:completion-cli -f ./path/to/blogpost.txt--jsonConfigor-j, path to a json file with any of the Open AI Supported Options(#supported-onot both, and any of these overwrites ptions). Example:completion-cli -j ./path/to/config.json
The CLI only supports a small subset of OpenAI options
--promptor-p: one way to pass text. Example:completion-cli -p Explain me the world:. The length limit is 15000 bytes (ascii characters.)--modelor-m, the default model used is text-davinci-003. Other flavours are: text-curie-001, text-babbage-001. Defaulttext-davinci-003--tokensor-tthe expected response length in tokens (max is 4096, about 1700 english words.)`--temperatureor-T(capital T). How creative the model is. Float between 0 and 1. Default 0.--echoor-e. Explicitboolean. Indicates whether to concatenate the response to the prompt or not. You need to specify--echo [true, false]
All the values in the object are optional. For explanations and default values check the schema file.
{
"model": string;
"prompt": string;
"suffix": string;
"max_tokens": number;
"temperature": number;
"top_p": number;
"echo": boolean;
"stop": string | string[];
"presence_penalty": number;
"frequency_penalty": number;
"prePromptString": string;
"postPromptString": string;
}ToDos
- Support different text encoding for filePath (streams have option for this)
- Improve boolean flags (atm you have to specify
--flagName true/false). - Support multiple completions from json configuration using the option
n. - Support for
streamoption. - Support pdf.
- Support both from urls as well.
The code is being thought such that it is not too difficult to adapt it to the browser.
License
There are no restrictions and you can do with the code what you prefer.