Project Description:
- Welcome to the Command Line ChatGPT Interface! This project allows you to have interactive conversations with ChatGPT through the command line.
-
Installation:
- To get started with the ChatGPT interface, follow these simple steps to install the required dependencies and set up the environment.
-
- Create an OpenAI API Key.
- Instructions can be found here or at https://platform.openai.com/docs/quickstart.
- Create an OpenAI API Key.
-
- Add API Key to your environment.
- Instructions can also be found here or at https://platform.openai.com/docs/quickstart#create-and-export-an-api-key.
- Add API Key to your environment.
-
- Create a python virtual environment.
- Create an environment by running
python -m venv path/to/venv/
- For example,
python -m venv .venv
would create an environment named '.venv'.
- Create an environment by running
- Create a python virtual environment.
-
- Activate virtual environment.
- Activate the environment by running
source path/to/venv/bin/activate
- For example,
source .venv/bin/activate
would activate the environment.
- Activate the environment by running
- Activate virtual environment.
-
- Add OpenAI to environment.
- With the virtual environment active, run
pip install openai
to install the OpenAI SDK to the environment. - Additional information on creating and using virtual environments can be found here.
- With the virtual environment active, run
- Add OpenAI to environment.
-
Usage:
- With the required dependencies installed and the virtual environment active, you can now run the command line chatgpt interface.
- Simply run
python3 chat_client.py
to start chatting with chatgpt! - Type
quit
orexit
to stop chatting.
-
Advanced Usage:
- Add the command line chatgpt as an alias in your terminal!
- In the same way you added the api key to your environment in 1b, create an alias in your environment for the command line chatgpt.
- In your .zshrc or .bashrc file, add
alias chat="python3 $HOME/path/to/your/file/chat_client.py"
where /path/to/your/file is the path needed to your file from your home directory. - For example,
alias chat="python3 $HOME/command_line_chat/chat_client.py
would work if chat_client.py was stored in a directory inside of your home directory. - For this to run properly, make sure your environment is active!
- For an even more advanced usage, create a bash script that activates the environment and then runs chat_client.py.
- Then, you would run the bash script as your alias. For example,
alias chat="sh $HOME/command_line_chat/chat.sh
where chat.sh runssource /path/to/venv/bin/activate
and thenpython3 $HOME/path/to/your/file/chat_client.py
-
Demo: