Take chatGPT into command line.
Setup
- clone this repo
- pip3 install -U -r requirements.txt
- get your apikey from https://platform.openai.com/account/api-keys and put it in
.key
Run
$ ./gptcli.py -h
usage: gptcli.py [-h] [-r] [-k KEY] [-p PROXY]
options:
-h, --help show this help message and exit
-s query openai in stream mode (default: False)
-r attach server response in request prompt, consume more tokens to get better results (default: False)
-k KEY path to api_key (default: .key)
-p PROXY http/https proxy to use (default: None)
Console help:
$ gptcli.py
Loading key from .key
Attach response in prompt: False
Input: help
options:
< input multiline
reset reset session, i.e. clear chat history
help show this help message
exit exit console
Example
Feature
- Session based
- Markdown support
- Syntax highlight
- Proxy support
- Multiline input
- Stream output
NOTE: openai's library use aiohttp for stream mode request, and
aiohttp
only supports http/https proxy, not socks5. see: aio-libs/aiohttp#2539 The workaround is to useaiohttp_socks
module for socks proxy in stream mode