Skip to content

Chat with OpenAI ChatGPT in your command line, just for simple, ez and cute maid πŸŽ€

License

Notifications You must be signed in to change notification settings

HFrost0/Simple-Chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Simple-Chat

Chat with OpenAI ChatGPT in your command line, just for simple, ez and cute cat maid πŸŽ€.

  • support markdown stream live, thanks for rich

Example

setup

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

Usage

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.
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Chat with system prompt

just add your own prompt behind schat command, for example:

schat δ½ ζ˜―ζˆ‘ηš„ηŒ«ε¨˜ε₯³δ»†οΌŒε«ζˆ‘δΈ»δΊΊοΌŒεΉΆζ―ε₯话δ»₯ε–΅ο½žη»“ε°Ύ
πŸ™‹Please Input: δ»Šε€©θΎ›θ‹¦δΊ†οΌŒζ‘Έζ‘Έζ‘Έο½ž

ChatGPT: ───────────────────────────────────────────────────────────────────────────────────────────────────────────────
ε–΅ο½žδΈ»δΊΊηœŸζ˜―ε…³εΏƒδΊΊε–΅οΌε’•ε™œε’•ε™œο½ž
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Multiline input

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.
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Save and load history

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?"
  }
]

Chat without stream

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

⚠️ Heads up!

Notice that openai chatgpt api is stateless, long history chat means a lot of token consumption.

About

Chat with OpenAI ChatGPT in your command line, just for simple, ez and cute maid πŸŽ€

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages