ChatGPT in command line with OpenAI API (gpt-3.5-turbo/gpt-4/gpt-4-32k)
Take chatGPT into command line.
demo_config.json
to config.json
config.json
$ ./gptcli.py -h
usage: gptcli.py [-h] [-c CONFIG]
options:
-h, --help show this help message and exit
-c CONFIG path to your config.json (default: config.json)
Sample config.json
:
{
"api_key": "sk-xxx",
"api_base": "https://chat.pppan.net/v1",
"model": "gpt-3.5-turbo",
"context": 2,
"stream": true,
"stream_render": true,
"showtokens": false,
"proxy": "socks5://localhost:1080",
"prompt": [
{ "role": "system", "content": "If your response contains code, show with syntax highlight, for example ```js\ncode\n```" }
]
}
gpt-3.5-turbo
; choices are:
api_base
;Console help (with tab-complete):
gptcli> .help -v
gptcli commands (use '.help -v' for verbose/'.help <topic>' for details):
======================================================================================================
.edit Run a text editor and optionally open a file with it
.help List available commands or provide detailed help for a specific command
.load Load conversation from Markdown/JSON file
.multiline input multiple lines, end with ctrl-d(Linux/macOS) or ctrl-z(Windows). Cancel
with ctrl-c
.prompt Load different prompts
.quit Exit this application
.reset Reset session, i.e. clear chat history
.save Save current conversation to Markdown/JSON file
.set Set a settable parameter or show current settings of parameters
.usage Tokens usage of current session / last N days, or print detail billing info
Run in Docker:
# build
$ docker build -t gptcli:latest .
# run
$ docker run -it --rm -v $PWD/.key:/gptcli/.key gptcli:latest -h
# for host proxy access:
$ docker run --rm -it -v $PWD/config.json:/gptcli/config.json --network host gptcli:latest -c /gptcli/config.json
.multiline
command).save
and .load
command)llama_index
to support chatting with documents