Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/raremojo/cc-ai
This allows you to talk to ChatGPT from your Computer Craft terminal.
https://github.com/raremojo/cc-ai
ai chatgpt computer-craft lua minecraft openai python
Last synced: 11 days ago
JSON representation
This allows you to talk to ChatGPT from your Computer Craft terminal.
- Host: GitHub
- URL: https://github.com/raremojo/cc-ai
- Owner: RareMojo
- License: mit
- Created: 2023-08-27T12:18:46.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2023-08-27T14:25:02.000Z (about 1 year ago)
- Last Synced: 2023-08-27T16:09:17.665Z (about 1 year ago)
- Topics: ai, chatgpt, computer-craft, lua, minecraft, openai, python
- Language: Lua
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
CC-AI
Bringing GPT to Modded Minecraft Computer Craft.
Check out GPT-Engineer! »
## About
This is a small Python Flask API server and ComputerCraft Lua client that allows you to use the OpenAI API from within Minecraft.
This should be compatible with any version of CC Tweaked for Minecraft 1.13+ I believe. This does cost money because it uses the OpenAI API.
Any CC Tweaked computers in the world that have the Lua client installed, a matching API token, and the correct IP address can use the API.
## Features
Lua Client features:
- Color choices: You can choose the color of various parts of the UI.
- Choose your AI's name: The AI will use this name when referring to itself.
- Choose your display name: The AI will use this name when referring to you.
- Summary threshold: The AI will summarize its response if it is over this many configurable characters.
- Monitor support: It will automatically detect and use a monitor if one is connected.
- Terminal Commands: Dedicated terminal commands for the client.AI Chat Server features:
- Per computer conversation memory buffer: The AI will remember the last 3 messages and use them to generate a response.
- System messages: The AI recieves hidden system messages such as in game time, the in game day, etc.
- Prompt injection: The AI is injected with configurable preprompts from the Flask API.
- And more!
## Prerequisites
Before you begin, ensure you have met the following requirements:
- [Python 3.x](https://www.python.org/downloads/)
- [ComputerCraft](https://tweaked.cc/)
- [OpenAI API Key](https://openai.com/blog/openai-api)
- [Mildly Better Shell](https://github.com/SquidDev-CC/mbs) * Optional, but recommended
## Installation
To install, follow these steps:
1. Clone the repository:
`git clone https://github.com/RareMojo/cc-ai.git`
2. Install the Lua client:
- Inside Computer Craft terminal:
`pastebin get KTMTw4hr cc-ai`
## Configuration
1. `.env`:
- You will need to provide some options for the Python API to function properly.
- Edit example_.env and rename it to `.env`
- Get your key from OpenAI's website.
- The API token is generated by the Lua client and saved in `cc-ai_config.txt`.
- Use `/token` to see your token, or `/token reset` to get a new one.
- Port is the port the API will run on. Choose something non-default.
- Model name is the name of the model you want to use. Default is `gpt-3.5-turbo`.
- Temperature is the randomness of the AI's responses. Default is `0.7`.
- Log level is the verbosity of the Python API's logs.
Open `.env` file in the root directory of the project, and add your keys:
OPENAI_API_KEY="KEY HERE"
API_TOKEN="TOKEN HERE"
PORT=PORT HERE
MODEL_NAME="gpt-3.5-turbo"
TEMPERATURE=0.7
LOG_LEVEL="INFO"
2. `cc-ai_config.txt`:
- This is held on the CC computer itself, and is used to configure the Lua client.
- You will be prompted to fill out the required parts of this during setup automatically.
- `Base URL` is the URL of the Python API. Example: `http://123.256.3.133:5000`
- You may have to configure your ports/firewall to allow the Python API to be accessed from the CC computer.
- Your API token is randomly generated and saved here. This is used to authenticate the Lua client with the Python API.
- You can use `/token` to see your token, or `/token reset` to get a new one in the Lua CC client.
- There are many more options you can edit with the client commands or by editing this file directly.
3. `preprompts/system`
- This is a file with a premade prompt that is injected into the AI before every response.
- You may edit this to your liking, or leave it as is.
- You will notice `{AINAME}` in the prompt. This is replaced with the AI and user names respectively.
- There is a method that passes config.data that you can use to replace more placeholder values like this. Look deeper into the API and Lua code for more info.
## Usage
The Python API server must be running for clients to connect.
However, clients do not need to be running for the API to start or be running.Here is a step-by-step guide on how to use:
1. **Python API Usage**:
- I recommend running this on a server or a computer that is always on.
- Consider security when choosing where to run this.
- From here you can run the `.\start.bat` or `sh start.sh` command to start the API.
- Leave this running for any Lua clients to connect to.
- All Lua clients will need to have the same API token as the one in the `.env` file.
- Thats it. You can `ctrl+c` to stop the API.
2. **Lua Client Usage**:
- From here you can run the `cc-ai` command to start the client.
- First you will be prompted to fill out the `cc-ai_config.txt` file.
- Then, simply type your prompt and press enter to get a response.
- Optionally you can connect a monitor. It was designed to work best with 5 wide setups.
## Disclaimer
It should be noted that:
- This project is not affiliated with OpenAI, ComputerCraft, or Minecraft in any way.
- I am not responsible for any damage this project may cause to your computer, Minecraft world, or anything else.
- I am not responsible for any security issues that may arise from using this project.
- I am not responsible for any charges you may incur from using the OpenAI API.Thank you for understanding.
## Contributing to Your Project
To contribute to the project, follow these steps:
1. Fork this repository.
2. Create a branch: `git checkout -b `
3. Make your changes and commit them: `git commit -m `
4. Push to the original branch: `git push origin /`
5. Create the pull request.
## License
Your project is completely open source, licensed under the [MIT](https://opensource.org/licenses/MIT) license.
See [LICENSE.md](https://github.com/RareMojo/cc-ai/blob/main/LICENSE.md) for more information.