This project integrates an LLM-powered NPC(Non Playable Character) system into a Godot-based game. It includes:
- A pre-built exported game under
Exported Game/ - A Colab-friendly notebook under
Python API Script/google_notebook_capstone.ipynbthat serves a Flask API backed by an LLM - Guidance for secure key management
- Godot game (exported binaries are included in
Exported Game/) - Python 3.10+ for running the API if running locally
- Internet access for model downloads
- For the notebook: a GPU-backed runtime (e.g., Google Colab GPU or a GPU VM)
- An ngrok account with a reserved static domain (required)
- The notebook
Python API Script/google_notebook_capstone.ipynbshould be run on a GPU-enabled instance (e.g., Colab Runtime → Change runtime type → Hardware accelerator: GPU). CPU instances will be too slow or may fail to load larger models.
Never hardcode secrets in source files or notebooks. This repo reads tokens from environment variables.
-
Hugging Face token (for the exact model used)
- Model used:
Gigax/NPC-LLM-7B(https://huggingface.co/Gigax/NPC-LLM-7B) - If access is gated, click “Access repository” or accept the license/terms on the model page.
- Create a Read token (Settings → Access Tokens) and ensure your account has access to this model.
- Environment variable:
HF_TOKEN - Colab: Add a secret named
HF_TOKENvia the left sidebar → Secrets. - Local: Create a
.envfile in the project root with a line likeHF_TOKEN=your_hf_token.
- Model used:
-
ngrok (required, for a public URL)
- You must reserve a static domain (Dashboard → Domains → Reserved Domains → “+ Reserve Domain”), e.g.,
your-name.ngrok-free.app. - Environment variables (all required except region default):
NGROK_AUTHTOKEN,NGROK_DOMAIN,NGROK_REGION(defaultus). - Colab: Add these as secrets in the sidebar.
- Local: Add them to
.env.
- You must reserve a static domain (Dashboard → Domains → Reserved Domains → “+ Reserve Domain”), e.g.,
The notebook automatically reads these values from environment variables. Do not commit .env files to version control.
- Go to the model page:
https://huggingface.co/Gigax/NPC-LLM-7B. - If prompted, click “Access repository” or accept the model’s license/terms to enable access for your account.
- In a separate tab, create a Read token:
https://huggingface.co/settings/tokens→ “New token” → role: Read. - Copy the token and set it as
HF_TOKEN:- Colab: Left sidebar → Secrets → Add secret → Name:
HF_TOKEN, Value: your token. - Local: Create
.envin the repo root:HF_TOKEN=hf_xxx_your_token_here
- Colab: Left sidebar → Secrets → Add secret → Name:
- Sign up at
https://dashboard.ngrok.com/signup(or sign in). - Copy your Authtoken (Dashboard → Your Authtoken).
- Reserve a domain (Dashboard → Domains → Reserved Domains → “+ Reserve Domain”), e.g.,
your-name.ngrok-free.app. - Configure your environment (all required):
- Colab Secrets: add
NGROK_AUTHTOKEN,NGROK_DOMAIN(your reserved domain),NGROK_REGION(e.g.,us). - Local
.env:NGROK_AUTHTOKEN=your_ngrok_authtoken NGROK_REGION=us NGROK_DOMAIN=your-name.ngrok-free.app
- Colab Secrets: add
- Open
Game_project_files/temp/Label.gd. - Replace the existing line with your reserved domain:
var url = 'https://your-name.ngrok-free.app/AcchaProject'
- Save the file.
- The notebook requires
HF_TOKEN,NGROK_AUTHTOKEN,NGROK_REGION, andNGROK_DOMAINto be set (via Colab Secrets or.env). - The final test cell posts to
https://$NGROK_DOMAIN/AcchaProject. EnsureNGROK_DOMAINis set to your reserved domain.
- Open and run
Python API Script/google_notebook_capstone.ipynbin a GPU runtime (Colab recommended).- Wait for:
Public URL: NgrokTunnel: "https://your-name.ngrok-free.app" -> "http://localhost:5001".
- Wait for:
- Verify you can POST to the API (the notebook’s last cell uses
NGROK_DOMAIN, or use curl):curl -X POST https://your-name.ngrok-free.app/AcchaProject \ -H "Content-Type: application/json" \ -d '{"input":"Hello","character":1}'
- Launch the exported game from
Exported Game/. - In-game, press the M key to interact with the NPC.
- Uses
transformers,gigax, and optionalbitsandbytesfor 8-bit loading. - If you see authentication warnings for Hugging Face Hub, ensure
HF_TOKENis present and your account has access toGigax/NPC-LLM-7B. - For local runs, a sample
.env:HF_TOKEN=your_hf_token NGROK_AUTHTOKEN=your_ngrok_token NGROK_REGION=us NGROK_DOMAIN=your-name.ngrok-free.app
- No tokens hardcoded in the notebook
- README documents secret handling, GPU requirement, and run order
-
.envis used locally and not committed
MIT License
Copyright (c) 2025 Tanishq216
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.