more_agent/app/main.py

72 lines
1.9 KiB
Python
Raw Permalink Normal View History

2026-05-12 05:13:49 +00:00
"""
MACP 主应用入口模块
2026-05-12 05:03:18 +00:00
2026-05-12 05:13:49 +00:00
创建 FastAPI 应用实例注册路由提供健康检查接口
2026-05-12 05:03:18 +00:00
"""
2026-05-12 05:13:49 +00:00
from __future__ import annotations
2026-05-12 05:03:18 +00:00
2026-05-12 05:13:49 +00:00
import uvicorn
from fastapi import FastAPI
2026-05-12 05:03:18 +00:00
2026-05-12 05:13:49 +00:00
from app.routes import router
2026-05-12 05:03:18 +00:00
2026-05-12 05:13:49 +00:00
# 创建 FastAPI 应用
2026-05-12 05:03:18 +00:00
app = FastAPI(
2026-05-12 05:13:49 +00:00
title="MACP - 军工智能化文档编制与辅助研发平台",
description="面向军工领域的智能化文档编制与辅助研发平台集成文档模板管理、GJB合规验证、"
"在线编辑、MCP工具接入、Skills流程编排、智能体记忆管理、安全沙箱执行、"
"知识库交互、统一大模型接入、多模态输入处理等模块。",
2026-05-12 05:03:18 +00:00
version="1.0.0",
)
2026-05-12 05:13:49 +00:00
# =============================================================================
# 全局路由注册
# =============================================================================
2026-05-12 05:03:18 +00:00
2026-05-12 05:13:49 +00:00
app.include_router(router)
# =============================================================================
# 健康检查接口
# =============================================================================
2026-05-12 05:03:18 +00:00
2026-05-12 05:13:49 +00:00
@app.get("/api/health", tags=["系统"], summary="健康检查")
async def health_check():
"""系统健康检查接口"""
2026-05-12 05:03:18 +00:00
return {
"status": "ok",
2026-05-12 05:13:49 +00:00
"service": "MACP Platform",
2026-05-12 05:03:18 +00:00
"version": "1.0.0",
}
2026-05-12 05:13:49 +00:00
@app.get("/", tags=["系统"], summary="根路径")
async def root():
"""根路径重定向到文档"""
return {
"message": "欢迎使用MACP - 军工智能化文档编制与辅助研发平台",
"docs": "/docs",
"redoc": "/redoc",
}
2026-05-12 05:03:18 +00:00
2026-05-12 05:13:49 +00:00
# =============================================================================
# 主入口
# =============================================================================
2026-05-12 05:03:18 +00:00
def main():
2026-05-12 05:13:49 +00:00
"""启动 MACP 服务"""
2026-05-12 05:03:18 +00:00
uvicorn.run(
"app.main:app",
host="0.0.0.0",
port=8000,
2026-05-12 05:13:49 +00:00
reload=False,
log_level="info",
2026-05-12 05:03:18 +00:00
)
if __name__ == "__main__":
main()