This project is base on AI_NovelGenerator
- Supports the generation of novels in multiple languages, and the interface also supports multiple languages. Currently, only Chinese and English are available, but other languages can be added easily.
- Automatically load the current chapter every time it starts
- The expansion function has been optimized. The original version can only be expanded once and the original content is rewrite each time. However, due to the limitations of the AI model, it is impossible to write too long content once. Therefore, my approach now is to continue writing on the original content and superimpose the new content every time. In this way, after many operations, a long enough content can be generated.
- English counting is also supported during expansion
- Add a button to each content page to facilitate the copying of the current content directly
- Support increase and decrease the font size in editor
The following is the official instructions (I made some changes based on this modified version):
✨ Core functions ✨
| Functional Modules | Key Capabilities |
|---|---|
| 🎨 Novel Setting Workshop | World View Architecture / Character Setting / Plot Blueprint |
| 📖 Intelligent chapter generation | Multi-stage generation to ensure plot consistency |
| 🧠 Status Tracking System | Role Development Trajectory / Foreshadowing Management System |
| 🔍 Semantic Retrieval Engine | Vector-based long-range context consistency maintenance |
| 📚 Knowledge Base Integration | Support local document reference |
| ✅ Automatic review mechanism | Detect plot conflicts and logical conflicts |
| 🖥 Visual Workbench | Full process GUI operation, configuration/generation/review integration |
A multi-functional novel generator based on a large language model, helping you to efficiently create long stories with rigorous logic and unified settings
- [Environmental Preparation] (#-Environmental Preparation)
- [Project Architecture] (#-Project Architecture)
- [Configuration Guide] (#⚙️-Configuration Guide)
- [Operation Instructions] (#🚀-Operation Instructions)
- [User Tutorial] (#📘-User Tutorial)
- [Troubleshooting] (#❓-Troubleshooting)
Ensure that the following operating conditions are met:
- Python 3.9+ Running Environment (recommended between 3.10-3.12)
- pip Package Management Tool
- Valid API key:
- Cloud services: OpenAI / DeepSeek, etc.
- Local services: Ollama and other OpenAI-compatible interfaces
-
Download Project
- Download the project ZIP file via GitHub, or clone the project using the following command:
git clone https://github.com/coderblog-winson/eBook_Generator
-
Installing the compilation tool (optional)
- If some packages cannot be installed normally, access Visual Studio Build Tools to download and install the C++ compilation tool for building some module packages;
- When installing, only the MSBuild tool is included by default. You need to manually check the **C++ desktop development option in the list bar in the upper left corner.
-
Installing dependencies and running
- Open the terminal and enter the project source file directory:
cd AI_NovelGenerator- Install project dependencies:
pip install -r requirements.txt
- After the installation is completed, run the main program:
python main.py
If partial dependencies are missing, follow-up ** manual execution**
pip install XXXJust install
novel-generator/
├── main.py # Entry file, run GUI
├── ui.py # Graphic interface
├── novel_generator.py # Chapter generation core logic
├── consistency_checker.py # Consistency check to prevent plot conflicts
|—— chapter_directory_parser.py # Directory analysis
|—— embedding_adapters.py # Embedding Interface Packaging
|—— llm_adapters.py # LLM Interface Packaging
├── prompt/[lang code].py # Definition AI prompt words with multiple language
├── utils.py # Commonly tool functions, file operations
├── config_manager.py # Manage configuration (API Key, Base URL)
├── config.json # User profile (optional)
└── vectorstore/ # (Optional) Local vector database storage
{
"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": "The star-distanced railway protagonist star travels to the Genshin Impact Continent, saves the Tivat continent, and develops love, hate and love with the characters in it",
"genre": "Fantasy",
"num_chapters": 120,
"word_number": 4000,
"filepath": "D:/AI_NovelGenerator/filepath"
}-
Generate model configuration
api_key: API key for big model servicebase_url: API terminal address (fill in Ollama and other addresses for local services)interface_format: Interface modemodel_name: Main Generative Model Name (such as gpt-4, claude-3, etc.)temperature: Creativity parameters (0-1, the higher the higher the creative)max_tokens: Maximum reply length of the model
-
EmbeddingModel configuration
embedding_model_name: Model name (such as Ollama's nomic-embed-text)embedding_url: Service addressembedding_retrieval_k:
-
Novel parameter configuration
topic: Core story themegenre: Type of worknum_chapters: Total chapter countword_number: Number of words in a single chapterfilepath: Generate file storage path
python main.pyAfter execution, the GUI will be launched, and you can perform various operations in the graphical interface.
If you want to use this tool on a machine without a Python environment, you can use PyInstaller to package it:
pip install pyinstaller
pyinstaller main.specAfter packaging, an executable file (such as main.exe under Windows) will be generated in the dist/ directory.
-
After starting, complete the basic parameter setting first:
- API Key & Base URL(such as
https://api.openai.com/v1) - Model name(Such as
gpt-3.5-turbo,gpt-4o, etc.) - Temperature (0~1, determines the level of creative writing)
- Topic (such as "AI Rebellion in Wasteland World")
- Genre (such as "Science Fiction"/"Magic"/"Urban Fantasy")
- Number of chapters, Number of words per chapter (such as 10 chapters, about 3000 words per chapter)
- Save path (It is recommended to create a new output folder)
- API Key & Base URL(such as
-
Click "Step1. Generate architecture"
- The system will generate:
Novel_setting.txt: Contains worldview, character information, thunder points and dark lines, etc.
- You can view or modify the architecture in the generated
Novel_setting.txt.
- The system will generate:
-
Click "Step2. Generate Outline"
- The system will generate all chapters based on the completed
Novel_setting.txtcontent:Novel_outline.txt:Includes titles and brief tips for each chapter.
- Chapter titles and descriptions can be viewed, modified, or supplemented in the generated file.
- The system will generate all chapters based on the completed
-
Click "Step3. Generate Draft"
- Before generating the chapter, you can:
- Set chapter number(If you generate Chapter 1, fill in
1) - Providing any expectations or tips for the plot of this chapter in the "Guide to this chapter" input box
- Set chapter number(If you generate Chapter 1, fill in
- After clicking the button, the system will:
- Automatically read the previous settings,
Novel_outline.txt, and finalized chapters - Call vector search and review the plot to ensure context coherence
- Outline of Generating the Chapter (
outline_X.txt) and Text (chapter_X.txt)
- Automatically read the previous settings,
- After the generation is completed, you can view and edit the draft content of this chapter in the text box on the left.
- Before generating the chapter, you can:
-
Click "Step4. Final chapter"
- The system will:
- Update global summary (write
global_summary.txt) - Update role status (write to
character_state.txt) - Update the vector search library (Make sure that subsequent chapters can call the latest information)
- Update plot points (such as
plot_arcs.txt)
- Update global summary (write
- After the finalization is completed, you can see the finalized text in
chapter_X.txt.
- The system will:
-
Consistency check (optional)
- Click the "[Optional] Consistency Review" button to detect conflicts on the latest chapters, such as character logic, plot inconsistencies, etc.
- If there is a conflict, a detailed prompt will be output in the log area.
-
Repeat steps 4-6 until all chapters are generated and finalized!
Vector search configuration tips
- The embedding model needs to display the specified interface and model name;
- When using the Embedding of local Ollama**, you need to start the Ollama service in advance:
ollama serve # Start the service ollama pull nomic-embed-text # Download/Enable the model- It is recommended to clear the vectorstore directory after switching different Embedding models.
- Cloud Embedding must ensure that the corresponding API permissions are enabled
-
Detail introduction
- You can find the detail introduction here.
This problem is most likely due to the API not responding correctly, maybe it responds to an html? Other contents lead to the error;
Confirm whether the interface is stable;
Just enter the corresponding input in the GUI interface.
If you have any more questions or needs, please feel free to ask in the Project Issues.