批量生成网络小说章节。通过环境变量读取 API 密钥,调用外部 LLM API(ModelScope、Fyra、Ph8)生成中文内容。适用场景:用户提供大纲后批量生成章节、编写指定章节范围或后台静默写作。前置要求:需配置环境变量 NOVEL_MODELSCOPE_KEY 等。
pip install httpxbash
export NOVEL_MODELSCOPE_KEY="your_modelscope_key"
export NOVEL_FYRA_KEY="your_fyra_key"
export NOVEL_PH8_KEY="your_ph8_key"
服务URL环境变量ModelScopehttps://api-inference.modelscope.cn/v1/chat/completionsNOVEL_MODELSCOPE_KEYFyrahttps://Fyra.im/v1/chat/completionsNOVEL_FYRA_KEYPh8https://ph8.co/v1/chat/completionsNOVEL_PH8_KEY
用户文本会发送到以上 API 端点以生成小说内容。
references/api-config.md 获取 API 配置说明scripts/batch_generate.pytext
大纲 → 逐章prompt → 逐个调用外部 LLM API → 分段生成 → 保存文件
scripts/batch_generate.py:
references/api-config.mdreferences/prompt-template.md