https://github.com/pranav11024/genai-text-based-rpg-with-npcs
A text-based role-playing game with AI-powered NPC dialogue, built with Python and Mistral 7B via llama.cpp.
https://github.com/pranav11024/genai-text-based-rpg-with-npcs
ai-chat ai-npc interactive-story llama-cpp llm-integration local-ai mistral-7b npc python python-game role-playing-game rpg streamlit text-adventure text-rpg
Last synced: 3 months ago
JSON representation
A text-based role-playing game with AI-powered NPC dialogue, built with Python and Mistral 7B via llama.cpp.
- Host: GitHub
- URL: https://github.com/pranav11024/genai-text-based-rpg-with-npcs
- Owner: pranav11024
- Created: 2025-06-28T20:01:03.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-06-28T20:07:58.000Z (3 months ago)
- Last Synced: 2025-06-28T21:22:28.791Z (3 months ago)
- Topics: ai-chat, ai-npc, interactive-story, llama-cpp, llm-integration, local-ai, mistral-7b, npc, python, python-game, role-playing-game, rpg, streamlit, text-adventure, text-rpg
- Language: Python
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GenAI Text-Based RPG with NPCs
A text-based role-playing game with AI-powered NPC dialogue, built with Python and Mistral 7B via llama.cpp.
## Features
- Interactive NPC conversations powered by Mistral 7B
- Multiple locations to explore
- Inventory and quest systems
- Save/load game functionality
- Two interface options: terminal or web-based (Streamlit)
- Rich character personalities and knowledge systems## Requirements
- Python 3.7+
- llama.cpp installed locally
- Mistral 7B model (specifically `mistral-7b-instruct-v0.2.Q3_K_L.gguf`)
- For web interface: `streamlit` (`pip install streamlit`)## Setup Instructions
### 1. Install llama.cpp
```bash
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
make
```2. Download Mistral 7B Model
Download mistral-7b-instruct-v0.2.Q3_K_L.gguf and place it in:
```
llama.cpp/models/mistral/
```
3. Install Python Dependencies
```bash
pip install streamlit requests
```
4. Configure Game Paths
Edit npc_dialogue.py to set correct paths:
```
llama_process = subprocess.Popen(
[
"path/to/llama.cpp/build/bin/Release/llama-cli.exe", # Update this path
"-m", "path/to/llama.cpp/models/mistral/mistral-7b-instruct-v0.2.Q3_K_L.gguf", # Update this path
# ... rest of configuration
]
)
```
How to Run
Terminal Version
```bash
python main.py
```
Web Version (Streamlit)
```bash
python main.py --web
```
Run Tests
```bash
python main.py --test
```
The game uses Mistral 7B via llama.cpp to generate dynamic NPC responses. Each NPC has:
-Unique personality traits
-Knowledge areas they can discuss
-Current mood that affects responses
-Backstory and dialogue styleThe game saves to savegame.json by default. Features include:
-Multiple save slots
-Save metadata tracking
-Backup system
-Validation checks