Skip to content

About

An AI-powered novel writing assistant: multi-model support (OpenAI/Gemini/Claude), smart wizard, worldbuilding, character management, chapter editing, plot checks & foreshadowing tracking, book splitting, PostgreSQL + Docker deployment.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Β 
Β 

Repository files navigation

AIFictionForge (η΅εˆ›) πŸ“šβœ¨

δΈ­ζ–‡ | English

An AI-powered intelligent novel creation assistant

Features β€’ Model Requirements β€’ Quick Start β€’ Configuration β€’ Project Structure


This project is forked from xiamuceer-j/MuMuAINovel. It is a localized, de-upstreamed derivative built on the upstream source, not an original standalone project. Thanks to the original author and all contributors. The code is licensed under GPL-3.0, see LICENSE.


⚠️ Breaking change (after v1.5.5 / since v1.6.0): PostgreSQL and Docker deployments are no longer supported. SQLite is the only database, and the Docker / Docker Compose path has been removed. If you deployed with PostgreSQL or Docker, stay on v1.5.5 or export your data yourself before upgrading; new installs run locally or use the single-port build on port 8008.


🧠 Model Requirements

Context window Status
>= 900,000 tokens βœ… Supported
Measured below the floor ❌ Rejected on save, and on every request that would dispatch that model
Probe could not reach a verdict ❌ Also rejected: unknown counts as unqualified, until you declare context_window_tokens >= 900,000
  • Every AI feature requires a backing model with a context window of at least 900,000 tokens. Below that floor the model is refused when you save it and on every request that would dispatch it.
  • There is no implicit fallback model and no tiered "128K mode". A fresh install has no usable AI model until you add one in Settings, where its window is probed against your own endpoint.
  • DEFAULT_MODEL is retired and no longer read by the backend. Configure the model per account in the app.
  • For how the window is measured, and the blind spots the probe still has, see docs/model-requirements.md.

Blind spot 1: a silent-truncating gateway can pass. Compatibility relays often do not error on an oversized request, they just cut it down; such an endpoint answers the probe as if it accepted the scale and is recorded as qualified. The needle tier (tier 3) is not wired up in this iteration, so nothing separates "the endpoint accepted the request" from "the model really read the window". If output quality is worse than the reported window suggests, suspect the gateway, not the model name.

Blind spot 2: a stale verdict is never re-checked. Verdicts are cached per (provider, base URL, model name) triple and are not refreshed automatically β€” not on a UTC schedule, not on dispatch. Requests keep being admitted under the stale verdict, and a gateway-side downgrade stays invisible, until you change one of the three triple parts or run the manual Re-check.

What even a correct verdict cannot tell you: accepting the probe scale is not the same as using the window well. Long-range consistency in the middle of a novel stays a per-model property, so judge a new model on your own text before committing to it.

What this page does not claim: supporting an API protocol is not the same as meeting the window requirement β€” the SDKs listed under Tech Stack describe transport compatibility only. Nor is it true that the floor can never be bypassed: a silent-truncating relay or a stale verdict can still admit a smaller window, which is why the blind spots above are written down.


✨ Features

  • πŸ€– Multiple AI providers: OpenAI, Gemini, Claude, and any OpenAI-compatible endpoint (protocol compatibility only; the model you configure still needs a >=900,000 token window).
  • πŸ§™ Project creation wizard: AI generates the outline, characters, and world settings from a short brief, plus custom bookshelf cover uploads.
  • πŸ—‚οΈ Volume management: organize long-form outlines and chapters by volume, inject volume-level arcs, time spans, and boundary constraints into AI context, and prioritize current-volume memories in RAG retrieval.
  • πŸ“– Chapter workflow: create, edit, regenerate (whole chapter or partial), and polish chapters with configurable target length, draft checkpoints, reasoning-budget control, and ending-style continuation.
  • πŸ“š Book deconstruction: import an existing text and analyze it chapter by chapter, with on-demand career/rank extraction.
  • 🧡 Foreshadowing tracking: track plot threads, get reminders about unrecovered ones, and view a foreshadowing timeline.
  • πŸ‘₯ Characters and organizations: character and organization management, a relationship graph, and customizable careers/ranks (cultivation realms, magic levels, and so on).
  • 🌐 Worldbuilding: build out story backgrounds and settings.
  • πŸ’‘ Inspiration mode: generate creative ideas and directions.
  • ✍️ Custom writing styles: define and reuse your own AI writing styles with literary style anchors and de-slop refinement.
  • 🧩 Prompt template editing: visually edit prompt templates in the UI.
  • 🧠 Story memory and consistency: long-term story memories per project, plus a data-consistency check and repair.
  • πŸ› οΈ Skills and MCP plugins: bundled writing skills (scan, analyze, write, deslop) and MCP plugin management.
  • 🧭 Plan runner: approve a multi-step plan, then the server runs it. See plan runner semantics.
  • πŸ” Memory search: semantic search across a project's story memories.
  • 🌍 Internationalization: zh/en UI, with content_language controlling the language of AI output.
  • πŸ” Login: local account or LinuxDO OAuth (with automatic account creation).
  • πŸ“¦ Import / export: project data (including volumes) plus character and organization cards, for cross-project sharing.
  • πŸ’Ύ Deployment & versioning: a single-port build served by the backend on 8008 with SQLite as the only database; frontend/package.json acts as the single version source (see releasing guide).

πŸ“Έ Project Preview

Multiple images ahead
Login Main interface Project management
Login Main interface Project management
Login (alt) Main interface (dark) Project management (alt)

πŸ’» Hardware Requirements

Setup CPU Memory Storage Network
Minimum (personal / development) 2 cores 2 GB RAM 10 GB free Stable internet for AI API calls
Recommended (small team / production) 4 cores 8 GB RAM 20 GB SSD Stable internet
High concurrency (80-150 users) 8 cores 16 GB RAM 50 GB+ SSD High bandwidth

πŸ“Œ Notes

  • Embedding model: ONNX Runtime model (model.onnx + tokenizer.json), about 457 MB of disk space, loaded into memory at runtime.
  • No local GPU is required; the project depends on external AI APIs.

πŸš€ Quick Start

Prerequisites: Python 3.12 and Node.js (for the frontend), plus at least one AI service API key (OpenAI / Gemini / Claude / any OpenAI-compatible relay) for a model with a >=900,000 token context window. No external database is required: data lives in a local SQLite file.

Clone and Configure

git clone https://github.com/andyhsu6/AIFictionForge.git && cd AIFictionForge
cp backend/.env.example .env          # then fill in the required config

Data is stored in backend/data/mumuai_novel.db (SQLite, created on first startup) β€” there is no database server to install and no migration step to run by hand.

Shortest path from here: ./aistoryforge.sh start (backend on 8008, frontend dev server on 5173; also supports status / stop / restart / verify).

Local Development / Building from Source

Prepare the ONNX embedding model first (about 457 MB, stored under backend/embedding/onnx/paraphrase-multilingual-MiniLM-L12-v2/). It is downloaded automatically from Hugging Face on first startup, or you can fetch onnx/model.onnx and tokenizer.json manually from https://huggingface.co/sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 (and set ONNX_EMBEDDING_OFFLINE=1 when running offline).

# Backend β€” run from the repository root, so that `.env` and the SQLite file resolve there
python3.12 -m venv backend/.venv && source backend/.venv/bin/activate   # Windows: backend\.venv\Scripts\activate
pip install -r backend/requirements.txt
PYTHONPATH=backend python -m uvicorn app.main:app --host localhost --port 8008 --reload

# Frontend
cd frontend
npm install
npm run dev    # development mode
npm run build  # production build (outputs to backend/static/)

If you leave DATABASE_URL unset the backend uses backend/data/mumuai_novel.db; set it only to point at another SQLite file (sqlite+aiosqlite:///<path>).

πŸ“Œ Ports: the frontend dev server runs on 5173 (Vite, proxying /api and /generated-assets to http://localhost:8008); the backend listens on 8008. After npm run build, the built frontend is served by the backend as a single-port entry on 8008.

βš™οΈ Configuration

Required in .env (DATABASE_URL is optional β€” see above, the built-in SQLite default is used when it is unset):

OPENAI_API_KEY=your_openai_key
OPENAI_BASE_URL=https://api.openai.com/v1
DEFAULT_AI_PROVIDER=openai
LOCAL_AUTH_ENABLED=true
LOCAL_AUTH_USERNAME=admin
LOCAL_AUTH_PASSWORD=your_password
# DEFAULT_MODEL is retired: the backend no longer reads it and there is no system
# default. Configure a >=900,000 token model per account in the app (Settings).

Any OpenAI-compatible relay works: point OPENAI_BASE_URL at the relay and set its key as OPENAI_API_KEY. See backend/.env.example for the full list, including the Xiaomi MiMo adapter.

Useful optional keys:

LINUXDO_CLIENT_ID=your_client_id             # LinuxDO OAuth
LINUXDO_CLIENT_SECRET=your_client_secret
LINUXDO_REDIRECT_URI=http://localhost:8008/api/auth/callback
LINUXDO_PROXY_URL=http://127.0.0.1:7890      # OAuth-only proxy
SESSION_COOKIE_SECURE=true                   # set false for plain-HTTP login cookies
# ONNX_EMBEDDING_OFFLINE=1                   # skip Hugging Face download when model is pre-staged
# ALLOW_PRIVATE_AI_ENDPOINTS=true            # local / private-network LLM
# ALLOWED_AI_HOSTS=127.0.0.1,localhost

πŸ“Œ Notes: keep SESSION_COOKIE_SECURE=true on HTTPS (set false on HTTP if the browser does not persist the login cookie). If only LinuxDO login is unreachable, set LINUXDO_PROXY_URL rather than a global HTTP_PROXY / HTTPS_PROXY; it does not affect AI, SMTP, or database calls. Local and private-network LLM endpoints (e.g. Ollama, llama.cpp) are blocked by default (SSRF protection); enable them with ALLOW_PRIVATE_AI_ENDPOINTS=true or allowlist the host in ALLOWED_AI_HOSTS. Link-local addresses stay blocked.

πŸ“ Project Structure

AIFictionForge/
β”œβ”€β”€ backend/                 # FastAPI service
β”‚   β”œβ”€β”€ app/                # api/, models/, services/, skills/, middleware/
β”‚   β”œβ”€β”€ embedding/onnx/     # Local ONNX embedding model files
β”‚   └── requirements.txt
β”œβ”€β”€ frontend/               # React + TypeScript app
β”‚   β”œβ”€β”€ src/                # pages/, components/, services/, store/, locales/
β”‚   └── package.json        # Single source of truth for app version
β”œβ”€β”€ docs/                   # Contributor, model, plan-runner, and release guides
β”œβ”€β”€ scripts/                # Version consistency checker and release scripts
β”œβ”€β”€ aistoryforge.sh         # Local backend/frontend dev service manager
β”œβ”€β”€ CHANGELOG.md
└── README.md

πŸ› οΈ Tech Stack

Backend: FastAPI β€’ SQLite β€’ SQLAlchemy β€’ ChromaDB β€’ ONNX Runtime β€’ OpenAI / Anthropic / OpenAI-compatible SDK

Frontend: React 18 β€’ TypeScript β€’ Ant Design β€’ Zustand β€’ Vite

πŸ“– Usage Guide

  1. Sign in with a local account or a LinuxDO account.
  2. Create a project, using "Create with Wizard" to have the AI draft the outline, characters, and world settings (and optionally upload a custom cover).
  3. Refine the setting & volumes: manage characters, organizations, relationships, careers/ranks, worldbuilding, and narrative volumes.
  4. Generate and edit chapters, regenerate or polish them, set a target length, and customize writing styles.
  5. Analyze: run book deconstruction, chapter analysis, and consistency checks; track foreshadowing.
  6. Extend: install writing skills, connect MCP plugins, or approve a multi-step plan for the agent runner.

API Documentation

  • Swagger UI: http://localhost:8008/docs
  • ReDoc: http://localhost:8008/redoc

πŸ“ License

This project is licensed under the GNU General Public License v3.0.

What GPL v3 means: free to use, modify, and distribute; usable for commercial purposes; modified and derivative versions must stay open source under GPL v3 and preserve the original author's copyright.

πŸ™ Acknowledgments

πŸ“š More Docs

About

An AI-powered novel writing assistant: multi-model support (OpenAI/Gemini/Claude), smart wizard, worldbuilding, character management, chapter editing, plot checks & foreshadowing tracking, book splitting, PostgreSQL + Docker deployment.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages