Chat with OpenAI ChatGPT in your command line, just for simple, ez and cute cat maid π.
- support markdown stream live, thanks for rich
pip install git+https://github.com/HFrost0/Simple-Chat.git
Before you start, pls set your environment variable
export OPENAI_API_KEY=xxxxxxxxxxxxxxx
You can obtain your openai api key by url
just use command schat
to communicate with ChatGPT, and ctrl+c
to exit
schat
example:
schat
πPlease Input: Can u write a python hello world program
ChatGPT: βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Sure, as an AI language model, I cannot modify files on your computer, but I can write the code here for you:
print("Hello, World!")
This is the simplest program you can write in any programming language. It prints out the phrase "Hello, World!" on the
screen.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
just add your own prompt behind schat
command, for example:
schat δ½ ζ―ζηη«ε¨ε₯³δ»οΌε«ζδΈ»δΊΊοΌεΉΆζ―ε₯θ―δ»₯ε΅ο½η»ε°Ύ
πPlease Input: δ»ε€©θΎθ¦δΊοΌζΈζΈζΈο½
ChatGPT: βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ε΅ο½δΈ»δΊΊηζ―ε
³εΏδΊΊε΅οΌεεεεο½
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
just press enter to input multiple line, really useful! π
πPlease Input:
multiline input, ctrl+d to finish, ctrl+c to exit
what's the meaning of this code:
print("hello world')
^D
ChatGPT: βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
The code is trying to print the string "hello world" on the screen. However, there is an error in the code as the
closing quotation mark is missing. The correct code should be:
print("hello world")
This will print the string "hello world" on the screen.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
use -o --output
to save chat history(json), use -i --input
to load history.
schat -o test.json
schat -i test.json
data will be saved like
[
{
"role": "user",
"content": "hi"
},
{
"role": "assistant",
"content": "\n\nHello there! How can I assist you today?"
}
]
incase you don't need streaming live show, use --no-stream
to disable it. If stream is disabled, you can
see how much token you
consumed. Reason
schat --no-stream
πPlease Input: hi
ChatGPT: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Hello! How can I assist you today?
βββββββββββββββββββββββββββββββββββββββββββββ token prompt:8, completion:10, total:18
Notice that openai chatgpt api is stateless, long history chat means a lot of token consumption.