Files
PlantAI-rag-new/backend/app/config.py
T
jerryandClaude Fable 5 1e94de7464 PlantAI-rag-new 首次提交:文献知识工作台
- BFF 薄适配层(FastAPI,8090):QA 代理/SSE 中继/Neo4j 直连/抽取代理/会话持久化
- Vue3 前端:五相位检索流水线、文献来源与证据链、知识图谱、提取任务四 tab
- 四档响应式(桌面/笔记本/平板/手机)、深浅主题
- 81 个 FR 全部实现,测试追溯矩阵 81/81,后端 121 测/前端 156 测
- 真实凭据已脱敏,运行时配置在 backend/.env(不入 git)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-25 20:47:52 +08:00

66 lines
2.3 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 —— 环境变量驱动的 BFF 配置(pydantic-settings)。
全部键见 backend/.env.example。凭据类键(Neo4j)只存在于本进程,
**绝不下发到浏览器**(不进入任何 API 响应)。
上游拓扑与默认值依据 docs/DISCOVERY.md:
- QA 7920:`/api/v1/qa-v1-1-73`(DISCOVERY §4)
- RAG 8000(Methodology API,DISCOVERY §3)/ ragAlt 7900(protected 容器,§3.7)
- Neo4j 候选顺序:18788(direct,首选)→ 19788(normalized)→ 17687(protected,空库)
凭据见 DISCOVERY §2.1,可由 BFF_NEO4J_* 环境变量覆盖(测试/部署)。
"""
from __future__ import annotations
from functools import lru_cache
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
extra="ignore",
)
# ---- 应用 ----
app_name: str = "plantai-rag-new-bff"
version: str = "0.1.0"
# ---- 上游地址(只读消费,见 ARCHITECTURE.md §2)----
qa_base_url: str = "http://127.0.0.1:7920"
qa_api_path: str = "/api/v1/qa-v1-1-73"
rag_base_url: str = "http://127.0.0.1:8000"
rag_alt_base_url: str = "http://127.0.0.1:7900"
# ---- Neo4j 候选(顺序即回退顺序,首选 18788;凭据见 DISCOVERY §2.1)----
neo4j_bolt_uris: str = (
"bolt://127.0.0.1:18788,bolt://127.0.0.1:19788,bolt://127.0.0.1:17687"
)
neo4j_user: str = "neo4j"
neo4j_passwords: str = (
"" # 真实凭据在 backend/.env(不入 git),见 backend/.env.example
)
# ---- 超时阶梯(秒)----
timeout_health: float = 1.0 # 健康探测
timeout_qa_chat: float = 300.0 # qa chat(读超时)
timeout_qa_search: float = 180.0 # qa search(读超时)
timeout_upload: float = 600.0 # 抽取 upload(读超时)
timeout_extraction: float = 15.0 # 抽取其余接口
# ---- 本地 ----
db_path: str = "backend/data/plantai.db"
health_cache_ttl: float = 5.0
# ---- 生产形态:BFF 静态托管 frontend/dist(ARCHITECTURE.md §3,M6 挂载)----
frontend_dist_dir: str = "frontend/dist"
@lru_cache(maxsize=1)
def get_settings() -> Settings:
return Settings()
settings = get_settings()