
AI_NovelGenerator
使用ai生成多章节的长篇小说,自动衔接上下文、伏笔
Stars: 964

AI_NovelGenerator is a versatile novel generation tool based on large language models. It features a novel setting workshop for world-building, character development, and plot blueprinting, intelligent chapter generation for coherent storytelling, a status tracking system for character arcs and foreshadowing management, a semantic retrieval engine for maintaining long-range context consistency, integration with knowledge bases for local document references, an automatic proofreading mechanism for detecting plot contradictions and logic conflicts, and a visual workspace for GUI operations encompassing configuration, generation, and proofreading. The tool aims to assist users in efficiently creating logically rigorous and thematically consistent long-form stories.
README:
✨ 核心功能 ✨
功能模块 | 关键能力 |
---|---|
🎨 小说设定工坊 | 世界观架构 / 角色设定 / 剧情蓝图 |
📖 智能章节生成 | 多阶段生成保障剧情连贯性 |
🧠 状态追踪系统 | 角色发展轨迹 / 伏笔管理系统 |
🔍 语义检索引擎 | 基于向量的长程上下文一致性维护 |
📚 知识库集成 | 支持本地文档参考 |
✅ 自动审校机制 | 检测剧情矛盾与逻辑冲突 |
🖥 可视化工作台 | 全流程GUI操作,配置/生成/审校一体化 |
一款基于大语言模型的多功能小说生成器,助您高效创作逻辑严谨、设定统一的长篇故事
2025-03-05 添加角色库功能
2025-03-09 添加字数显示
2025-03-13 1、新增闲云修改; 2、把本章指导改成内容指导; 3、在生成架构中的: 2. 角色动力学设定(角色弧光模型)、 3. 世界构建矩阵(三维度交织法)、 4. 情节架构(三幕式悬念)与生成目录的:5. 章节目录生成(悬念节奏曲线)加入引导词内容指导,以方便生成角色动力学时只以核心种子生成,导致生成的内容与实际需求不符。 4、在终端加回被删除的LLM提示词与LLM返回内容显示,以便复盘,参考修改提示词。
确保满足以下运行条件:
- Python 3.9+ 运行环境(推荐3.10-3.12之间)
- pip 包管理工具
- 有效API密钥:
- 云端服务:OpenAI / DeepSeek 等
- 本地服务:Ollama 等兼容 OpenAI 的接口
-
下载项目
- 通过 GitHub 下载项目 ZIP 文件,或使用以下命令克隆本项目:
git clone https://github.com/YILING0013/AI_NovelGenerator
- 通过 GitHub 下载项目 ZIP 文件,或使用以下命令克隆本项目:
-
安装编译工具(可选)
- 如果对某些包无法正常安装,访问 Visual Studio Build Tools 下载并安装C++编译工具,用于构建部分模块包;
- 安装时,默认只包含 MSBuild 工具,需手动勾选左上角列表栏中的 C++ 桌面开发 选项。
-
安装依赖并运行
- 打开终端,进入项目源文件目录:
cd AI_NovelGenerator
- 安装项目依赖:
pip install -r requirements.txt
- 安装完成后,运行主程序:
python main.py
- 打开终端,进入项目源文件目录:
如果缺失部分依赖,后续手动执行
pip install XXX进行安装即可
novel-generator/
├── main.py # 入口文件, 运行 GUI
├── ui.py # 图形界面
├── novel_generator.py # 章节生成核心逻辑
├── consistency_checker.py # 一致性检查, 防止剧情冲突
|—— chapter_directory_parser.py # 目录解析
|—— embedding_adapters.py # Embedding 接口封装
|—— llm_adapters.py # LLM 接口封装
├── prompt_definitions.py # 定义 AI 提示词
├── utils.py # 常用工具函数, 文件操作
├── config_manager.py # 管理配置 (API Key, Base URL)
├── config.json # 用户配置文件 (可选)
└── vectorstore/ # (可选) 本地向量数据库存储
{
"api_key": "sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"base_url": "https://api.openai.com/v1",
"interface_format": "OpenAI",
"model_name": "gpt-4o-mini",
"temperature": 0.7,
"max_tokens": 4096,
"embedding_api_key": "sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"embedding_interface_format": "OpenAI",
"embedding_url": "https://api.openai.com/v1",
"embedding_model_name": "text-embedding-ada-002",
"embedding_retrieval_k": 4,
"topic": "星穹铁道主角星穿越到原神提瓦特大陆,拯救提瓦特大陆,并与其中的角色展开爱恨情仇的小说",
"genre": "玄幻",
"num_chapters": 120,
"word_number": 4000,
"filepath": "D:/AI_NovelGenerator/filepath"
}
-
生成模型配置
-
api_key
: 大模型服务的API密钥 -
base_url
: API终端地址(本地服务填Ollama等地址) -
interface_format
: 接口模式 -
model_name
: 主生成模型名称(如gpt-4, claude-3等) -
temperature
: 创意度参数(0-1,越高越有创造性) -
max_tokens
: 模型最大回复长度
-
-
Embedding模型配置
-
embedding_model_name
: 模型名称(如Ollama的nomic-embed-text) -
embedding_url
: 服务地址 -
embedding_retrieval_k
:
-
-
小说参数配置
-
topic
: 核心故事主题 -
genre
: 作品类型 -
num_chapters
: 总章节数 -
word_number
: 单章目标字数 -
filepath
: 生成文件存储路径
-
python main.py
执行后,GUI 将会启动,你可以在图形界面中进行各项操作。
如果你想在无 Python 环境的机器上使用本工具,可以使用 PyInstaller 进行打包:
pip install pyinstaller
pyinstaller main.spec
打包完成后,会在 dist/
目录下生成可执行文件(如 Windows 下的 main.exe
)。
-
启动后,先完成基本参数设置:
-
API Key & Base URL(如
https://api.openai.com/v1
) -
模型名称(如
gpt-3.5-turbo
、gpt-4o
等) - Temperature (0~1,决定文字创意程度)
- 主题(Topic)(如 “废土世界的 AI 叛乱”)
- 类型(Genre)(如 “科幻”/“魔幻”/“都市幻想”)
- 章节数、每章字数(如 10 章,每章约 3000 字)
- 保存路径(建议创建一个新的输出文件夹)
-
API Key & Base URL(如
-
点击「Step1. 生成设定」
- 系统将基于主题、类型、章节数等信息,生成:
-
Novel_setting.txt
:包含世界观、角色信息、雷点暗线等。
-
- 可以在生成后的
Novel_setting.txt
中查看或修改设定内容。
- 系统将基于主题、类型、章节数等信息,生成:
-
点击「Step2. 生成目录」
- 系统会根据已完成的
Novel_setting.txt
内容,为全部章节生成:-
Novel_directory.txt
:包括每章标题和简要提示。
-
- 可以在生成后的文件中查看、修改或补充章节标题和描述。
- 系统会根据已完成的
-
点击「Step3. 生成章节草稿」
- 在生成章节之前,你可以:
-
设置章节号(如写第 1 章,就填
1
) - 在“本章指导”输入框中提供对本章剧情的任何期望或提示
-
设置章节号(如写第 1 章,就填
- 点击按钮后,系统将:
- 自动读取前文设定、
Novel_directory.txt
、以及已定稿章节 - 调用向量检索回顾剧情,保证上下文连贯
- 生成本章大纲 (
outline_X.txt
) 及正文 (chapter_X.txt
)
- 自动读取前文设定、
- 生成完成后,你可在左侧的文本框查看、编辑本章草稿内容。
- 在生成章节之前,你可以:
-
点击「Step4. 定稿当前章节」
- 系统将:
-
更新全局摘要(写入
global_summary.txt
) -
更新角色状态(写入
character_state.txt
) - 更新向量检索库(保证后续章节可以调用最新信息)
-
更新剧情要点(如
plot_arcs.txt
)
-
更新全局摘要(写入
- 定稿完成后,你可以在
chapter_X.txt
中看到定稿后的文本。
- 系统将:
-
一致性检查(可选)
- 点击「[可选] 一致性审校」按钮,对最新章节进行冲突检测,如角色逻辑、剧情前后矛盾等。
- 若有冲突,会在日志区输出详细提示。
-
重复第 4-6 步 直到所有章节生成并定稿!
向量检索配置提示
- embedding模型需要显示指定接口和模型名称;
- 使用本地Ollama的Embedding时需提前启动Ollama服务:
ollama serve # 启动服务 ollama pull nomic-embed-text # 下载/启用模型- 切换不同Embedding模型后建议清空vectorstore目录
- 云端Embedding需确保对应API权限已开通
该问题大概率由于API未正确响应造成,也许响应了一个html?其它内容,导致出现该报错;
确认接口是否稳定;
在GUI界面中对应输入即可。
如有更多问题或需求,欢迎在项目 Issues 中提出。
For Tasks:
Click tags to check more tools for each tasksFor Jobs:
Alternative AI tools for AI_NovelGenerator
Similar Open Source Tools

AI_NovelGenerator
AI_NovelGenerator is a versatile novel generation tool based on large language models. It features a novel setting workshop for world-building, character development, and plot blueprinting, intelligent chapter generation for coherent storytelling, a status tracking system for character arcs and foreshadowing management, a semantic retrieval engine for maintaining long-range context consistency, integration with knowledge bases for local document references, an automatic proofreading mechanism for detecting plot contradictions and logic conflicts, and a visual workspace for GUI operations encompassing configuration, generation, and proofreading. The tool aims to assist users in efficiently creating logically rigorous and thematically consistent long-form stories.

ailab
The 'ailab' project is an experimental ground for code generation combining AI (especially coding agents) and Deno. It aims to manage configuration files defining coding rules and modes in Deno projects, enhancing the quality and efficiency of code generation by AI. The project focuses on defining clear rules and modes for AI coding agents, establishing best practices in Deno projects, providing mechanisms for type-safe code generation and validation, applying test-driven development (TDD) workflow to AI coding, and offering implementation examples utilizing design patterns like adapter pattern.

siteproxy
Siteproxy 2.0 is a web proxy tool that utilizes service worker for enhanced stability and increased website coverage. It replaces express with hono for a 4x speed boost and supports deployment on Cloudflare worker. It enables reverse proxying, allowing access to YouTube/Google without VPN, and supports login for GitHub and Telegram web. The tool also features DuckDuckGo AI Chat with free access to GPT3.5 and Claude3. It offers a pure web-based online proxy with no client configuration required, facilitating reverse proxying to the internet.

llm_note
LLM notes repository contains detailed analysis on transformer models, language model compression, inference and deployment, high-performance computing, and system optimization methods. It includes discussions on various algorithms, frameworks, and performance analysis related to large language models and high-performance computing. The repository serves as a comprehensive resource for understanding and optimizing language models and computing systems.

chatgpt-on-wechat
This project is a smart chatbot based on a large model, supporting WeChat, WeChat Official Account, Feishu, and DingTalk access. You can choose from GPT3.5/GPT4.0/Claude/Wenxin Yanyi/Xunfei Xinghuo/Tongyi Qianwen/Gemini/LinkAI/ZhipuAI, which can process text, voice, and images, and access external resources such as operating systems and the Internet through plugins, supporting the development of enterprise AI applications based on proprietary knowledge bases.

GitHubSentinel
GitHub Sentinel is an intelligent information retrieval and high-value content mining AI Agent designed for the era of large models (LLMs). It is aimed at users who need frequent and large-scale information retrieval, especially open source enthusiasts, individual developers, and investors. The main features include subscription management, update retrieval, notification system, report generation, multi-model support, scheduled tasks, graphical interface, containerization, continuous integration, and the ability to track and analyze the latest dynamics of GitHub open source projects and expand to other information channels like Hacker News for comprehensive information mining and analysis capabilities.

hugging-llm
HuggingLLM is a project that aims to introduce ChatGPT to a wider audience, particularly those interested in using the technology to create new products or applications. The project focuses on providing practical guidance on how to use ChatGPT-related APIs to create new features and applications. It also includes detailed background information and system design introductions for relevant tasks, as well as example code and implementation processes. The project is designed for individuals with some programming experience who are interested in using ChatGPT for practical applications, and it encourages users to experiment and create their own applications and demos.

Nano
Nano is a Transformer-based autoregressive language model for personal enjoyment, research, modification, and alchemy. It aims to implement a specific and lightweight Transformer language model based on PyTorch, without relying on Hugging Face. Nano provides pre-training and supervised fine-tuning processes for models with 56M and 168M parameters, along with LoRA plugins. It supports inference on various computing devices and explores the potential of Transformer models in various non-NLP tasks. The repository also includes instructions for experiencing inference effects, installing dependencies, downloading and preprocessing data, pre-training, supervised fine-tuning, model conversion, and various other experiments.

chatgpt-webui
ChatGPT WebUI is a user-friendly web graphical interface for various LLMs like ChatGPT, providing simplified features such as core ChatGPT conversation and document retrieval dialogues. It has been optimized for better RAG retrieval accuracy and supports various search engines. Users can deploy local language models easily and interact with different LLMs like GPT-4, Azure OpenAI, and more. The tool offers powerful functionalities like GPT4 API configuration, system prompt setup for role-playing, and basic conversation features. It also provides a history of conversations, customization options, and a seamless user experience with themes, dark mode, and PWA installation support.

MarkMap-OpenAi-ChatGpt
MarkMap-OpenAi-ChatGpt is a Vue.js-based mind map generation tool that allows users to generate mind maps by entering titles or content. The application integrates the markmap-lib and markmap-view libraries, supports visualizing mind maps, and provides functions for zooming and adapting the map to the screen. Users can also export the generated mind map in PNG, SVG, JPEG, and other formats. This project is suitable for quickly organizing ideas, study notes, project planning, etc. By simply entering content, users can get an intuitive mind map that can be continuously expanded, downloaded, and shared.

MINI_LLM
This project is a personal implementation and reproduction of a small-parameter Chinese LLM. It mainly refers to these two open source projects: https://github.com/charent/Phi2-mini-Chinese and https://github.com/DLLXW/baby-llama2-chinese. It includes the complete process of pre-training, SFT instruction fine-tuning, DPO, and PPO (to be done). I hope to share it with everyone and hope that everyone can work together to improve it!

Code-Interpreter-Api
Code Interpreter API is a project that combines a scheduling center with a sandbox environment, dedicated to creating the world's best code interpreter. It aims to provide a secure, reliable API interface for remotely running code and obtaining execution results, accelerating the development of various AI agents, and being a boon to many AI enthusiasts. The project innovatively combines Docker container technology to achieve secure isolation and execution of Python code. Additionally, the project supports storing generated image data in a PostgreSQL database and accessing it through API endpoints, providing rich data processing and storage capabilities.

MoneyPrinterTurbo
MoneyPrinterTurbo is a tool that can automatically generate video content based on a provided theme or keyword. It can create video scripts, materials, subtitles, and background music, and then compile them into a high-definition short video. The tool features a web interface and an API interface, supporting AI-generated video scripts, customizable scripts, multiple HD video sizes, batch video generation, customizable video segment duration, multilingual video scripts, multiple voice synthesis options, subtitle generation with font customization, background music selection, access to high-definition and copyright-free video materials, and integration with various AI models like OpenAI, moonshot, Azure, and more. The tool aims to simplify the video creation process and offers future plans to enhance voice synthesis, add video transition effects, provide more video material sources, offer video length options, include free network proxies, enable real-time voice and music previews, support additional voice synthesis services, and facilitate automatic uploads to YouTube platform.

AivisSpeech
AivisSpeech is a Japanese text-to-speech software based on the VOICEVOX editor UI. It incorporates the AivisSpeech Engine for generating emotionally rich voices easily. It supports AIVMX format voice synthesis model files and specific model architectures like Style-Bert-VITS2. Users can download AivisSpeech and AivisSpeech Engine for Windows and macOS PCs, with minimum memory requirements specified. The development follows the latest version of VOICEVOX, focusing on minimal modifications, rebranding only where necessary, and avoiding refactoring. The project does not update documentation, maintain test code, or refactor unused features to prevent conflicts with VOICEVOX.

Streamer-Sales
Streamer-Sales is a large model for live streamers that can explain products based on their characteristics and inspire users to make purchases. It is designed to enhance sales efficiency and user experience, whether for online live sales or offline store promotions. The model can deeply understand product features and create tailored explanations in vivid and precise language, sparking user's desire to purchase. It aims to revolutionize the shopping experience by providing detailed and unique product descriptions to engage users effectively.

sanic-web
Sanic-Web is a lightweight, end-to-end, and easily customizable large model application project built on technologies such as Dify, Ollama & Vllm, Sanic, and Text2SQL. It provides a one-stop solution for developing large model applications, supporting graphical data-driven Q&A using ECharts, handling table-based Q&A with CSV files, and integrating with third-party RAG systems for general knowledge Q&A. As a lightweight framework, Sanic-Web enables rapid iteration and extension to facilitate the quick implementation of large model projects.
For similar tasks

AI_NovelGenerator
AI_NovelGenerator is a versatile novel generation tool based on large language models. It features a novel setting workshop for world-building, character development, and plot blueprinting, intelligent chapter generation for coherent storytelling, a status tracking system for character arcs and foreshadowing management, a semantic retrieval engine for maintaining long-range context consistency, integration with knowledge bases for local document references, an automatic proofreading mechanism for detecting plot contradictions and logic conflicts, and a visual workspace for GUI operations encompassing configuration, generation, and proofreading. The tool aims to assist users in efficiently creating logically rigorous and thematically consistent long-form stories.
For similar jobs

LLMStack
LLMStack is a no-code platform for building generative AI agents, workflows, and chatbots. It allows users to connect their own data, internal tools, and GPT-powered models without any coding experience. LLMStack can be deployed to the cloud or on-premise and can be accessed via HTTP API or triggered from Slack or Discord.

daily-poetry-image
Daily Chinese ancient poetry and AI-generated images powered by Bing DALL-E-3. GitHub Action triggers the process automatically. Poetry is provided by Today's Poem API. The website is built with Astro.

exif-photo-blog
EXIF Photo Blog is a full-stack photo blog application built with Next.js, Vercel, and Postgres. It features built-in authentication, photo upload with EXIF extraction, photo organization by tag, infinite scroll, light/dark mode, automatic OG image generation, a CMD-K menu with photo search, experimental support for AI-generated descriptions, and support for Fujifilm simulations. The application is easy to deploy to Vercel with just a few clicks and can be customized with a variety of environment variables.

SillyTavern
SillyTavern is a user interface you can install on your computer (and Android phones) that allows you to interact with text generation AIs and chat/roleplay with characters you or the community create. SillyTavern is a fork of TavernAI 1.2.8 which is under more active development and has added many major features. At this point, they can be thought of as completely independent programs.

Twitter-Insight-LLM
This project enables you to fetch liked tweets from Twitter (using Selenium), save it to JSON and Excel files, and perform initial data analysis and image captions. This is part of the initial steps for a larger personal project involving Large Language Models (LLMs).

AISuperDomain
Aila Desktop Application is a powerful tool that integrates multiple leading AI models into a single desktop application. It allows users to interact with various AI models simultaneously, providing diverse responses and insights to their inquiries. With its user-friendly interface and customizable features, Aila empowers users to engage with AI seamlessly and efficiently. Whether you're a researcher, student, or professional, Aila can enhance your AI interactions and streamline your workflow.

ChatGPT-On-CS
This project is an intelligent dialogue customer service tool based on a large model, which supports access to platforms such as WeChat, Qianniu, Bilibili, Douyin Enterprise, Douyin, Doudian, Weibo chat, Xiaohongshu professional account operation, Xiaohongshu, Zhihu, etc. You can choose GPT3.5/GPT4.0/ Lazy Treasure Box (more platforms will be supported in the future), which can process text, voice and pictures, and access external resources such as operating systems and the Internet through plug-ins, and support enterprise AI applications customized based on their own knowledge base.

obs-localvocal
LocalVocal is a live-streaming AI assistant plugin for OBS that allows you to transcribe audio speech into text and perform various language processing functions on the text using AI / LLMs (Large Language Models). It's privacy-first, with all data staying on your machine, and requires no GPU, cloud costs, network, or downtime.