This project showcases an implementation of ChatGPT clients with streaming support in a Command-Line Interface (CLI) environment, demonstrating its practicality and effectiveness.
- Interactive streaming mode for real-time interaction with the GPT model.
- Query mode for single input-output interactions with the GPT model.
- Context management across CLI calls, enabling seamless conversations with the GPT model by maintaining message history.
- Viper integration for robust configuration management.
To start developing, set the OPENAI_API_KEY
environment variable to
your ChatGPT secret key. Follow these steps for running tests and
building the application:
- Run the unit tests using the following script:
./scripts/unit.sh
- Build the app using the installation script:
./scripts/install.sh
- After a successful build, test the application with the following command:
./bin/chatgpt what type of dog is a Jack Russel?
- To enable history tracking across CLI calls, create a ~/.chatgpt-cli directory using the command:
mkdir ~/.chatgpt-cli
With this directory in place, the CLI will automatically manage message history for seamless conversations with the GPT model. The history acts as a sliding window, maintaining a maximum of 4096 tokens to ensure optimal performance and interaction quality.
For more options, see:
./bin/chatgpt --help