Skip to content

RareMojo/cc-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Repo stars CC Version Minecraft Version LICENSE


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:


Installation

To install, follow these steps:


  1. Clone the repository:

    git clone https://github.com/RareMojo/cc-ai.git


  1. 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"
    

  1. 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.

  1. 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.

  1. 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 <branch_name>
  3. Make your changes and commit them: git commit -m <commit_message>
  4. Push to the original branch: git push origin <project_name>/<location>
  5. Create the pull request.

License

Your project is completely open source, licensed under the MIT license. See LICENSE.md for more information.

About

This allows you to talk to ChatGPT from your Computer Craft terminal.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published