Files
PlantAI-rag-new/sdk/app/services/docgen/settings.py
T
jerryandClaude Fable 5 4749f77544 fix(docgen): 两批手工测试修复——上传/预览/检索 + 护栏/导出/命名/编辑还原/二次预览
第一批:上传去限制+进度展示、模板HTML预览+按需导出、检索TAB实时更新
第二批:edit护栏移除、导出按钮纯化+file_name落库、编辑失焦还原、
       二次预览白底根治(防竞态+渲染兜底)
模板体系:7套公文模板(templates/)+templating渲染器、websearch联网

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-09-05 15:49:54 +08:00

57 lines
1.7 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.
"""services/docgen/settings.py —— docgen 服务层配置(dataclass,不引 pydantic)。
- 上传不设大小/数量/字符门槛;MATERIAL_BUDGET_CHARS 只是注入 prompt 的预算
- 路径:DOCGEN_ROOT(制品目录,默认 data/docgen)
- LLM 键:DOCGEN_LLM_BASE_URL / DOCGEN_LLM_API_KEY / DOCGEN_LLM_MODEL /
DOCGEN_LLM_TIMEOUT(默认 300s)
"""
from __future__ import annotations
import os
from dataclasses import dataclass, field
from pathlib import Path
# ---- 生成参数(2026-09-04 手工测试:上传不再设大小/数量/字符门槛)----
MAX_SECTIONS = 12 # 模版大纲裁剪上限(节数)
MAX_OUTLINE_CHUNKS = 3
MATERIAL_BUDGET_CHARS = 60_000 # 全部资料注入 prompt 的总字符预算(非上传限制)
# ---- 生成参数 ----
GENERATION_TEMPERATURE = 0.3
GENERATION_MAX_TOKENS = 8000
SECTION_MAX_CHARS = 4000 # 单节生成建议长度上限(prompt 约束)
CHUNK_EDIT_CHARS = 12000 # 长文档分段编辑阈值
@dataclass
class DocgenPaths:
"""docgen 制品目录(md/docx/pdf 落盘)。"""
root: str = field(default_factory=lambda: os.environ.get("DOCGEN_ROOT", "data/docgen"))
def __post_init__(self) -> None:
Path(self.root).mkdir(parents=True, exist_ok=True)
_paths: DocgenPaths | None = None
def get_paths() -> DocgenPaths:
"""取全局路径配置(首次调用构造)。"""
global _paths
if _paths is None:
_paths = DocgenPaths()
return _paths
def set_paths(paths: DocgenPaths) -> None:
"""注入配置(测试用)。"""
global _paths
_paths = paths
def artifacts_dir() -> Path:
"""制品目录(md/docx/pdf 落盘根)。"""
return Path(get_paths().root) / "artifacts"