Files
novel-app/config.py
2026-08-17 17:11:30 +08:00

26 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""novel-app 中央配置。
所有值均可通过环境变量覆盖NOVEL_APP_* 前缀SECRET_KEY 例外,
沿用惯例的 FLASK_SECRET_KEY。上下文组装预算字符数
services/context.py 与 routes/ 共享。
"""
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
DB_PATH = os.environ.get("NOVEL_APP_DB_PATH", os.path.join(BASE_DIR, "novel.db"))
LLM_URL = os.environ.get("NOVEL_APP_LLM_URL", "http://127.0.0.1:4000/v1")
LLM_MODEL = os.environ.get("NOVEL_APP_LLM_MODEL", "default")
LLM_TIMEOUT = int(os.environ.get("NOVEL_APP_LLM_TIMEOUT", "600"))
PORT = int(os.environ.get("NOVEL_APP_PORT", "8091"))
# 上下文组装预算(字符数)
CTX_PREV_CHAPTERS = int(os.environ.get("NOVEL_APP_CTX_PREV_CHAPTERS", "2")) # 最近 N 章全文
CTX_SUMMARY_CHAPTERS = int(os.environ.get("NOVEL_APP_CTX_SUMMARY_CHAPTERS", "20")) # 结构化摘要窗口
CTX_BUDGET_MIN = int(os.environ.get("NOVEL_APP_CTX_BUDGET_MIN", "8000"))
CTX_BUDGET_MAX = int(os.environ.get("NOVEL_APP_CTX_BUDGET_MAX", "120000"))
SECRET_KEY = os.environ.get("FLASK_SECRET_KEY", "dev-novel-secret-change-me")