Skip to content

Commit

Permalink
docs: update readme for deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
jschang19 committed Dec 19, 2023
1 parent 7a346cc commit 5ded457
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@

# ChatGPT-Cpp
A header-only version of ChatGPT Official API written in C++
A C++ text game features [ChatGPT API](https://platform.openai.com/docs/guides/text-generation) intergration. The options and the ending of the game are generated by ChatGPT randomly.

![image](/images/screenshot.png)

## Introduction
This project is a C++ text game that uses [ChatGPT API](https://platform.openai.com/docs/guides/text-generation) to generate the options and the ending of the game.

The game is a simple text adventure game that takes place in National Taiwan University. You can choose options based on the situation happened in the game. The game will give you the ending based on your choices. The options and the ending are generated by ChatGPT randomly.

## Table of Contents
* [Run with Docker](#run-with-docker)
* [Development](#development)
* [Update Vcpkg](#update-vcpkg)
* [Reminder](#reminder)
* [References](#references)

## Run with Docker

Expand All @@ -13,22 +24,22 @@ You can run this project with Docker. This is the easiest way to get started.

1. Clone this repository:
```bash
git clone https://github.com/jschang19/ntu-im-final-project.git
cd ntu-im-final-project
git clone https://github.com/jschang19/chatcpp.git
cd chatcpp
```

2. Get your OpenAI token from [here](https://platform.openai.com/) and set it as the `ENV` in the `Dockerfile` file.
2. Get your OpenAI token from [here](https://platform.openai.com/) and set it as the `ENV` in the `Dockerfile` file ( or pass it as an argument to `docker run` command later).

3. Install [Docker](https://www.docker.com/products/docker-desktop/), then run the following commands:

```bash
docker build -t chatcpp . # this will take a while
docker run -it --env OPENAI_API_KEY=<YOUR_OPENAI_API_KEY> chatcpp
docker run -it --env=OPENAI_API_KEY=<YOUR_OPENAI_API_KEY> chatcpp:latest # run with interactive mode
```

## Development

To develop this project, you need to install [CMake](https://cmake.org/download/) and [Vcpkg](https://github.com/microsoft/vcpkg).
To develop this project, you need to install [CMake](https://cmake.org/download/) and [Vcpkg](https://github.com/microsoft/vcpkg) first.

1. Export your OpenAI token to environment variable
```bash
Expand All @@ -39,10 +50,12 @@ export OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>
```bash
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg

# Windows
./bootstrap-vcpkg.bat
# Mac/Linux
./bootstrap-vcpkg.sh

./vcpkg install nlohmann-json
./vcpkg install cpr
./vcpkg integrate install
Expand All @@ -56,28 +69,35 @@ cmake -B build/ -S . -DCMAKE_TOOLCHAIN_FILE=<YOUR_VCPKG_PATH/scripts/buildsystem
cd build
cmake --build .
```

xcvv/c/
4. Run the project
```bash
./ChatGPT
```

Every time you want to rebuild the project, you need to run `cmake --build .` in the build directory.
5. Everytime you make changes to the code, you need to run `cmake --build .` in the `build` folder again to rebuild the project.
```bash
cd build
cmake --build .
```

## Update Vcpkg
Run this command to update vcpkg:
If getting error when running `cmake --build .` in the `build` folder, you need to update the vcpkg:
```bash
cd ~/vcpkg
cd ~/vcpkg # or where you install vcpkg
git pull
rm -rf installed
./bootstrap-vcpkg.sh
./vcpkg install nlohmann-json
./vcpkg install cpr
./vcpkg integrate install
```

Then run the cmake command again. You need to `rm -rf build/` and build again.

## Reminder
- This project is still under developmentm and ChatGPT might return invalid json sometimes.
- This project uses gpt3.5 model with `json` formatted response. Check the [official API](https://platform.openai.com/docs/guides/text-generation/json-mode) for more details.
- The reply generation is not very stable. You may see unrelevant options sometimes.

## References
- This repository is based on [deni2312/ChatGPT-Cpp](https://github.com/deni2312/ChatGPT-Cpp)
- Dockerize this C++ project with this [article](https://medium.com/codex/a-practical-guide-to-containerize-your-c-application-with-docker-50abb197f6d4)
Binary file added images/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5ded457

Please sign in to comment.