HomeMAL' // MANUFACTORUM
datacrypt
AICastle
AICastle · python · js
Mock AI Dungeon running on local LLMs.
⬇ download aicastle.zip

files

readme.md

AICastle

Mock AI Dungeon. Stories are generated by locally run models; no external services.

Features

  • Do / Say / Story actions — the classic AI Dungeon input modes, with

streamed responses and a visual distinction between your inputs and the AI's narration

  • Edit / Retry / Undo — rewrite any paragraph (hover → edit), regenerate

the last response, or step back one entry at a time (undo removes the AI response first, then your input)

  • Story cards (world info) — persistent facts about characters, places

and factions. All cards are always in the model's context; that's what they're for

  • Auto-Cards — the AI periodically scans the story for new named

entities and proposes new cards or updates to existing ones. Every proposal is shown to you for review (Accept / Regenerate / Reject) before it is saved. Card previews generate in parallel

  • Rolling summary — actions that scroll out of the history window are

summarized in the background, so hundred-turn stories keep their past without blowing up the context

  • Memory & Author's Note — persistent context and style guidance,

same semantics as AI Dungeon

  • AI Dungeon import/export — round-trips AI Dungeon's backup zip format

(metadata.json + actions-NNN.json), including story cards, memory and the author's note

  • Per-adventure model tuning — temperature, top-p/k, repeat penalty,

max tokens, context window and history length, all with explanatory tooltips

  • Model switching mid-story — pick any installed Ollama model from the

top bar at any time

Requirements

  • Python 3.10+ (pip install -r requirements.txt)
  • Ollama running locally with at least one model:
ollama pull dolphin-llama3:8b   # good uncensored storyteller
ollama pull llama3.2:3b         # small & fast

Setup

python3 -m venv .venv
.venv/bin/pip install -r requirements.txt

Run

.venv/bin/python3 server.py

Then open http://localhost:8421.

If Ollama runs elsewhere, point the server at it:

OLLAMA_URL=http://192.168.1.50:11434 .venv/bin/python3 server.py

Usage notes

  • New Adventure — pick a model, optionally write a starting prompt,

memory and author's note.

  • Import from AI Dungeon — in AI Dungeon, export an adventure backup;

upload the resulting .zip here (or its extracted .json files).

  • Export — Settings → Plot → Export Adventure produces a zip in the

same format, importable back into AI Dungeon.

  • Auto-Cards — configured under Settings → Auto-Cards. Detection runs

every Cooldown turns turns; proposed cards appear in a review dialog.

  • Speed — response speed is dominated by model size. On Apple Silicon,

Ollama already uses the GPU. If generation is too slow, switch to a smaller model (the dropdown lists everything installed in Ollama).

Project layout

server.py          FastAPI backend: streaming, persistence, auto-cards,
                   summarization, AI Dungeon import/export
index.html         entire frontend (single file, no build step)
requirements.txt   Python dependencies
data/saves/        one JSON file per adventure (created at runtime)

API sketch

Method & pathPurpose
GET /api/modelsinstalled Ollama models
GET /api/games · POST /api/games/newlist / create adventures
POST /api/actionplayer action → streamed narration (SSE)
POST /api/action/retry · /undo · /edittranscript manipulation
POST /api/settingspartial update of any adventure settings
POST /api/world-info/add · /edit · /removestory card CRUD
POST /api/auto-cards/detect · /preview-batchentity detection & card previews
GET /api/game/{id}/exportAI Dungeon-compatible backup zip
POST /api/import/aidungeonimport an AI Dungeon backup

All state lives in data/saves/*.json; deleting a file deletes the adventure. There is no database and no authentication — this is a single-user local app.

++ last updated 2026-07-09 ++