report_generation/config.py
xxy aa98ea2623 @
Initial commit

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@
2026-06-05 18:45:29 +08:00

71 lines
2.4 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.

"""
config.py
全局配置项。可通过 .env 文件或环境变量覆盖。
本项目为「报告生成」独立服务,仅保留报告生成链路所需配置:
数据库(MySQL) / LLM / Embedding / Milvus / 文档存储路径。
"""
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
# 应用基本信息
APP_TITLE: str = "智能报告生成服务 API"
APP_VERSION: str = "0.1.0"
APP_DESCRIPTION: str = "后评价报告分章异步生成后端服务(独立抽取版)"
# 服务监听
HOST: str = "0.0.0.0"
PORT: int = 8099
RELOAD: bool = False
# CORS 允许的前端源(开发阶段放开,生产环境改为具体域名)
CORS_ORIGINS: list[str] = ["*"]
# 数据库MySQL
DATABASE_URL: str = "mysql+pymysql://root:123456@127.0.0.1:3306/post_eval_report?charset=utf8mb4"
DB_POOL_SIZE: int = 15
DB_MAX_OVERFLOW: int = 25
DB_POOL_TIMEOUT: int = 60
DB_POOL_PRE_PING: bool = True
# 文档存储根目录(附图提取时按 DOC_PAT/{project_uuid}/<相对路径> 定位 .docx
DOC_PAT: str = "./docpath"
# LLMOpenAI 兼容接口)
LLM_API_BASE: str = ""
LLM_API_KEY: str = ""
LLM_MODEL_NAME: str = ""
LLM_HTTP_TIMEOUT_SEC: int = 120
LLM_CONNECT_TIMEOUT_SEC: int = 30
LLM_RETRY_COUNT: int = 3
LLM_RETRY_BACKOFF_SEC: float = 1.0
LLM_RETRY_BACKOFF_MAX_SEC: float = 12.0
# 报告章节单次 chat 读超时。0 表示沿用 LLM_HTTP_TIMEOUT_SEC长章节建议 600+
REPORT_LLM_HTTP_TIMEOUT_SEC: int = 600
# 某章 LLM 仍失败时写入占位正文并继续后续章节,避免整份任务失败
REPORT_LLM_CONTINUE_ON_TIMEOUT: bool = True
# 表格抽取延迟补抽(首轮失败后进入队列,按轮次延迟重试)
LLM_TABLE_DELAY_RETRY_ROUNDS: int = 2
LLM_TABLE_DELAY_RETRY_SEC: float = 8.0
LLM_TABLE_DELAY_RETRY_BACKOFF: float = 2.0
LLM_TABLE_DELAY_RETRY_MAX_SEC: float = 60.0
# Embedding / Milvus向量检索证据 L2/L3
EMBEDDING_API_KEY: str = ""
EMBEDDING_API_BASE: str = ""
EMBEDDING_BATCH_MAX_DOCS: int = 4
EMBEDDING_BATCH_MAX_CHARS: int = 12000
EMBEDDING_MAX_CHUNK_CHARS: int = 4000
MILVUS_DB_URL: str = ""
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
extra="ignore",
)
settings = Settings()