Compare commits
10
Commits
7538c391aa
...
4fa778563f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4fa778563f | ||
|
|
60dd85d80a | ||
|
|
b1d4d13f71 | ||
|
|
f3c7f33d88 | ||
|
|
e1c7ff3da5 | ||
|
|
2b97d5393b | ||
|
|
5592b6d9d3 | ||
|
|
0e401c15d8 | ||
|
|
b53e625d60 | ||
|
|
806369e498 |
+2
-2
@@ -4,13 +4,13 @@
|
||||
/dist
|
||||
/.vscode
|
||||
/__pycache__
|
||||
__pycache__/
|
||||
*.pyc
|
||||
/markdown
|
||||
/vectorstore
|
||||
/example
|
||||
config.json
|
||||
config_test.json
|
||||
/novel_generator/__pycache__
|
||||
/ui/__pycache__
|
||||
.idea/
|
||||
/novel
|
||||
app.log
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 📖 自动小说生成工具
|
||||
|
||||
>- 目前开学了,没什么时间维护该项目,后续更新可能得等长假才能继续
|
||||
>- 当前没有什么精力维护该项目,本身该项目并无任何收益,以及临近毕业,有很多内容要忙,如果后面有时间的话,再考虑基于更新的技术去重构吧。——2025/9/24
|
||||
|
||||
<div align="center">
|
||||
|
||||
@@ -20,15 +20,6 @@
|
||||
|
||||
> 一款基于大语言模型的多功能小说生成器,助您高效创作逻辑严谨、设定统一的长篇故事
|
||||
|
||||
2025-03-05 添加角色库功能
|
||||
|
||||
2025-03-09 添加字数显示
|
||||
|
||||
2025-03-13
|
||||
1、新增闲云修改;
|
||||
2、把本章指导改成内容指导;
|
||||
3、在生成架构中的: 2. 角色动力学设定(角色弧光模型)、 3. 世界构建矩阵(三维度交织法)、 4. 情节架构(三幕式悬念)与生成目录的:5. 章节目录生成(悬念节奏曲线)加入引导词内容指导,以方便生成角色动力学时只以核心种子生成,导致生成的内容与实际需求不符。
|
||||
4、在终端加回被删除的LLM提示词与LLM返回内容显示,以便复盘,参考修改提示词。
|
||||
---
|
||||
|
||||
## 📑 目录导航
|
||||
@@ -87,8 +78,6 @@
|
||||
```
|
||||
novel-generator/
|
||||
├── main.py # 入口文件, 运行 GUI
|
||||
├── ui.py # 图形界面
|
||||
├── novel_generator.py # 章节生成核心逻辑
|
||||
├── consistency_checker.py # 一致性检查, 防止剧情冲突
|
||||
|—— chapter_directory_parser.py # 目录解析
|
||||
|—— embedding_adapters.py # Embedding 接口封装
|
||||
@@ -97,6 +86,8 @@ novel-generator/
|
||||
├── utils.py # 常用工具函数, 文件操作
|
||||
├── config_manager.py # 管理配置 (API Key, Base URL)
|
||||
├── config.json # 用户配置文件 (可选)
|
||||
├── novel_generator/ # 章节生成核心逻辑
|
||||
├── ui/ # 图形界面
|
||||
└── vectorstore/ # (可选) 本地向量数据库存储
|
||||
```
|
||||
|
||||
|
||||
+231
@@ -0,0 +1,231 @@
|
||||
# 📖 Automatic Novel Generation Tool
|
||||
|
||||
>- Currently I don't have much energy to maintain this project. The project brings no revenue, and with graduation approaching I have many other priorities. If time permits in the future I may consider a refactor using newer technologies. — 2025/09/24
|
||||
|
||||
<div align="center">
|
||||
|
||||
✨ **Core Features** ✨
|
||||
|
||||
| Module | Key Capabilities |
|
||||
|-----------------------|-----------------------------------------|
|
||||
| 🎨 Novel Setting Workshop | Worldbuilding / Character Design / Plot Blueprint |
|
||||
| 📖 Intelligent Chapter Generation | Multi-stage generation to ensure plot coherence |
|
||||
| 🧠 State Tracking System | Character development trajectory / Foreshadowing management |
|
||||
| 🔍 Semantic Search Engine | Vector-based long-term context consistency |
|
||||
| 📚 Knowledge Base Integration | Supports local document references |
|
||||
| ✅ Automatic Proofreading | Detects plot contradictions and logical conflicts |
|
||||
| 🖥 Visual Workbench | Full-process GUI for configuration / generation / proofreading |
|
||||
|
||||
</div>
|
||||
|
||||
> A multifunctional novel generator built on large language models. Helps you efficiently create long-form stories with consistent settings and rigorous logic.
|
||||
|
||||
---
|
||||
|
||||
## 📑 Table of Contents
|
||||
1. [Environment Preparation](#-environment-preparation)
|
||||
2. [Project Structure](#-project-structure)
|
||||
3. [Configuration Guide](#⚙️-configuration-guide)
|
||||
4. [Run Instructions](#🚀-run-instructions)
|
||||
5. [User Guide](#📘-user-guide)
|
||||
6. [FAQ](#❓-faq)
|
||||
|
||||
---
|
||||
|
||||
## 🛠 Environment Preparation
|
||||
Ensure the environment meets the following requirements:
|
||||
- **Python 3.9+** (recommended 3.10–3.12)
|
||||
- **pip** package manager
|
||||
- Valid API keys:
|
||||
- Cloud services: OpenAI / DeepSeek, etc.
|
||||
- Local services: Ollama or other OpenAI-compatible interfaces
|
||||
|
||||
---
|
||||
|
||||
## 📥 Installation
|
||||
1. **Download the project**
|
||||
- Download the project ZIP from [GitHub](https://github.com) or clone the repository:
|
||||
```bash
|
||||
git clone https://github.com/YILING0013/AI_NovelGenerator
|
||||
```
|
||||
|
||||
|
||||
2. **Install build tools (optional)**
|
||||
- If some packages fail to install, visit [Visual Studio Build Tools](https://visualstudio.microsoft.com/zh-hans/visual-cpp-build-tools/) to download and install C++ build tools required by some modules.
|
||||
- By default the installer includes MSBuild only; make sure to select **C++ Desktop Development** from the workload list.
|
||||
|
||||
3. **Install dependencies and run**
|
||||
- Open a terminal and change to the project directory:
|
||||
```bash
|
||||
cd AI_NovelGenerator
|
||||
```
|
||||
- Install project dependencies:
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
- After installation run the main program:
|
||||
```bash
|
||||
python main.py
|
||||
```
|
||||
|
||||
If some dependencies are still missing, manually run:
|
||||
```bash
|
||||
pip install <package-name>
|
||||
```
|
||||
to install them.
|
||||
|
||||
|
||||
## 🗂 Project Structure
|
||||
```
|
||||
novel-generator/
|
||||
├── main.py # Entry file, runs the GUI
|
||||
├── consistency_checker.py # Consistency checks to prevent plot conflicts
|
||||
|—— chapter_directory_parser.py # Directory parsing
|
||||
|—— embedding_adapters.py # Embedding interface wrappers
|
||||
|—— llm_adapters.py # LLM interface wrappers
|
||||
├── prompt_definitions.py # AI prompt templates
|
||||
├── utils.py # Utility functions and file operations
|
||||
├── config_manager.py # Configuration manager (API keys, base URL)
|
||||
├── config.json # User configuration (optional)
|
||||
├── novel_generator/ # Core chapter generation logic
|
||||
├── ui/ # Graphical user interface
|
||||
└── vectorstore/ # (Optional) Local vector DB storage
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ⚙️ Configuration Guide
|
||||
### 📌 Basic configuration (`config.json`)
|
||||
```json
|
||||
{
|
||||
"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 protagonist of Star Rail travels to Genshin Impact's Teyvat continent, saves it, and develops complex relationships with its characters.",
|
||||
"genre": "Fantasy",
|
||||
"num_chapters": 120,
|
||||
"word_number": 4000,
|
||||
"filepath": "D:/AI_NovelGenerator/filepath"
|
||||
}
|
||||
```
|
||||
|
||||
### 🔧 Explanation
|
||||
1. **Generation model configuration**
|
||||
- `api_key`: API key for the LLM service
|
||||
- `base_url`: API endpoint (for local services use the Ollama address)
|
||||
- `interface_format`: Interface mode
|
||||
- `model_name`: Main generation model (e.g., gpt-4, claude-3)
|
||||
- `temperature`: Creativity parameter (0–1, higher is more creative)
|
||||
- `max_tokens`: Maximum model response length
|
||||
|
||||
2. **Embedding model configuration**
|
||||
- `embedding_model_name`: Embedding model name (e.g., Ollama's nomic-embed-text)
|
||||
- `embedding_url`: Service endpoint
|
||||
- `embedding_retrieval_k`: Number of nearest neighbors to retrieve
|
||||
|
||||
3. **Novel parameters**
|
||||
- `topic`: Core story theme
|
||||
- `genre`: Genre
|
||||
- `num_chapters`: Total number of chapters
|
||||
- `word_number`: Target words per chapter
|
||||
- `filepath`: Path to save generated files
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Run Instructions
|
||||
### Method 1 — Run with Python
|
||||
```bash
|
||||
python main.py
|
||||
```
|
||||
This launches the GUI for interactive use.
|
||||
|
||||
### Method 2 — Build an executable
|
||||
If you want to run the tool on machines without Python, package it with **PyInstaller**:
|
||||
```bash
|
||||
pip install pyinstaller
|
||||
pyinstaller main.spec
|
||||
```
|
||||
After packaging an executable (e.g., `main.exe` on Windows) will appear in the `dist/` folder.
|
||||
|
||||
---
|
||||
|
||||
## 📘 User Guide
|
||||
1. **After launching the app, fill in the basic parameters:**
|
||||
- **API Key & Base URL** (e.g., `https://api.openai.com/v1`)
|
||||
- **Model name** (e.g., `gpt-3.5-turbo`, `gpt-4o`)
|
||||
- **Temperature** (0–1, controls creative variance)
|
||||
- **Topic** (e.g., "AI uprising in a post-apocalyptic world")
|
||||
- **Genre** (e.g., "Sci-fi" / "Fantasy" / "Urban Fantasy")
|
||||
- **Number of chapters** and **words per chapter** (e.g., 10 chapters × ~3000 words)
|
||||
- **Save path** (create a new output folder for results)
|
||||
|
||||
2. **Click "Step1. Generate Settings"**
|
||||
- The system will generate, based on topic/genre/chapter count:
|
||||
- `Novel_setting.txt`: Worldbuilding, characters, trigger points and foreshadowing.
|
||||
- You can view or edit these settings after generation.
|
||||
|
||||
3. **Click "Step2. Generate Directory"**
|
||||
- The system will use `Novel_setting.txt` to produce:
|
||||
- `Novel_directory.txt`: Chapter titles and short prompts.
|
||||
- You can review and modify chapter titles and descriptions.
|
||||
|
||||
4. **Click "Step3. Generate Chapter Draft"**
|
||||
- Before generating a chapter you can:
|
||||
- Set the chapter number (e.g., `1`)
|
||||
- Provide chapter-specific guidance in the "This chapter guidance" box
|
||||
- When you generate a chapter the system will:
|
||||
- Read prior settings, `Novel_directory.txt`, and finalized chapters
|
||||
- Use vector retrieval to recall relevant context for coherence
|
||||
- Produce an outline (`outline_X.txt`) and chapter text (`chapter_X.txt`)
|
||||
- You can view and edit the draft in the editor pane.
|
||||
|
||||
5. **Click "Step4. Finalize Current Chapter"**
|
||||
- The system will:
|
||||
- Update the global summary (`global_summary.txt`)
|
||||
- Update character states (`character_state.txt`)
|
||||
- Update the vector store (so future chapters can use the latest info)
|
||||
- Update major plot points (e.g., `plot_arcs.txt`)
|
||||
- After finalizing you will see the finalized text in `chapter_X.txt`.
|
||||
|
||||
6. **Consistency check (optional)**
|
||||
- Click the "[Optional] Consistency Proofread" button to scan the latest chapter for conflicts (character logic, plot contradictions, etc.).
|
||||
- If conflicts are detected, detailed messages will appear in the log area.
|
||||
|
||||
7. **Repeat steps 4–6** until all chapters are generated and finalized.
|
||||
|
||||
> Vector retrieval tips:
|
||||
> 1. Explicitly set the embedding interface and model name.
|
||||
> 2. For local Ollama embeddings start the Ollama service first:
|
||||
> ```bash
|
||||
> ollama serve # Start the service
|
||||
> ollama pull nomic-embed-text # Download/enable the model
|
||||
> ```
|
||||
> 3. Clear the `vectorstore` directory after switching embedding models.
|
||||
> 4. For cloud embeddings ensure the API permissions are enabled.
|
||||
|
||||
---
|
||||
|
||||
## ❓ FAQ
|
||||
### Q1: Expecting value: line 1 column 1 (char 0)
|
||||
|
||||
This error usually indicates the API did not return valid JSON—sometimes an HTML error page or other unexpected content was returned.
|
||||
|
||||
### Q2: HTTP/1.1 504 Gateway Timeout?
|
||||
|
||||
Check the stability of the API endpoint and network connectivity.
|
||||
|
||||
### Q3: How do I switch Embedding providers?
|
||||
|
||||
Enter the new provider settings in the GUI fields for embedding configuration.
|
||||
|
||||
---
|
||||
|
||||
If you have further questions or feature requests, please open an issue on the project repository.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+3
-3
@@ -21,7 +21,7 @@ darkdetect==0.8.0
|
||||
dataclasses-json==0.6.7
|
||||
distro==1.9.0
|
||||
durationpy==0.10
|
||||
filelock==3.19.1
|
||||
filelock==3.20.1
|
||||
flatbuffers==25.2.10
|
||||
frozenlist==1.7.0
|
||||
fsspec==2025.9.0
|
||||
@@ -59,7 +59,7 @@ kubernetes==33.1.0
|
||||
langchain==0.3.27
|
||||
langchain-chroma==0.2.5
|
||||
langchain-community==0.3.29
|
||||
langchain-core==0.3.75
|
||||
langchain-core==0.3.80
|
||||
langchain-openai==0.3.32
|
||||
langchain-text-splitters==0.3.11
|
||||
langsmith==0.4.25
|
||||
@@ -135,7 +135,7 @@ typing-inspect==0.9.0
|
||||
typing-inspection==0.4.1
|
||||
typing_extensions==4.15.0
|
||||
uritemplate==4.2.0
|
||||
urllib3==2.5.0
|
||||
urllib3==2.6.0
|
||||
uvicorn==0.35.0
|
||||
watchfiles==1.1.0
|
||||
websocket-client==1.8.0
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user