Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zhudotexe/chatgpt-api-demo
Demo of how to use the ChatGPT API to create a chat application right in your terminal.
https://github.com/zhudotexe/chatgpt-api-demo
chatgpt chatgpt-api gpt-3 machine-learning natural-language-processing nlp openai openai-api
Last synced: 3 months ago
JSON representation
Demo of how to use the ChatGPT API to create a chat application right in your terminal.
- Host: GitHub
- URL: https://github.com/zhudotexe/chatgpt-api-demo
- Owner: zhudotexe
- License: mit
- Created: 2023-03-01T21:40:07.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-01T21:40:08.000Z (almost 2 years ago)
- Last Synced: 2024-10-11T19:13:34.661Z (3 months ago)
- Topics: chatgpt, chatgpt-api, gpt-3, machine-learning, natural-language-processing, nlp, openai, openai-api
- Language: Python
- Homepage:
- Size: 3.91 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ChatGPT API Demo
This repository demonstrates how to use the newly-released (as of March 1, 2023) ChatGPT API.
**TL;DR**: Run `python chat.py` to have a chat with ChatGPT right from your terminal!
It demonstrates these concepts:
- Passing instructions via the system prompt
- Building up the message history through a continued conversation
- Truncating long conversations to fit within the model context## Requirements
### Python
- Python 3.10+
To install Python dependencies, I recommend using a virtual environment. You can set one up by running:
```bash
$ python3 -m venv venv
$ source venv/bin/activate
```then, use the following command to install this project's dependencies:
```bash
$ pip install -r requirements.txt
```### OpenAI API
You will also need to set your OpenAI API key, which you can find [here](https://platform.openai.com/account/api-keys).
To pass this API key to the project, set the `OPENAI_API_KEY` environment variable by running:
```bash
$ export OPENAI_API_KEY=""
```(You could also add this to your shell profile so you don't have to do this every time.)
## Talking to ChatGPT
To chat with ChatGPT, simply run the following:
```bash
$ python chat.py
```More options and arguments will be added to this demo in the future.