aps-agent/server/main.py

19 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.

# ============================================================
# 后端入口(moduleId: server-main, 可重生 ✅)
# 用法:python -m uvicorn server.main:app --reload --port 8000
# 职责:加载 .env → 构建应用 →(首次启动时)确保世界已播种
# ============================================================
from dotenv import load_dotenv # .env 加载器
# 先于一切导入加载环境变量(ModelProvider 构造依赖 LLM_* 变量)
load_dotenv() # 仓库根 .env(不存在则静默跳过)
from server.gateway.app import create_app # 应用工厂(置于 load_dotenv 之后)
from server.state.store import get_store # 世界状态单例
# 触发世界状态加载(无文件时自动播种落盘,保证首个请求即有数据)
get_store() # 副作用:加载或播种
# ASGI 应用实例(uvicorn 入口点)
app = create_app() # 构建 FastAPI 应用