mirror of
https://github.com/jihe520/MathModelAgent.git
synced 2026-10-30 07:24:14 +08:00
82 lines
2.3 KiB
Python
82 lines
2.3 KiB
Python
from fastapi import APIRouter
|
|
from app.config.setting import settings
|
|
from app.utils.common_utils import get_config_template
|
|
from app.schemas.enums import CompTemplate
|
|
from app.services.redis_manager import redis_manager
|
|
from app.services.sandbox_manager import sandbox_manager
|
|
from app.utils.log_util import logger
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/")
|
|
async def root():
|
|
return {"message": "Hello World"}
|
|
|
|
|
|
@router.get("/config")
|
|
async def config():
|
|
return {
|
|
"environment": settings.ENV,
|
|
"deepseek_model": settings.DEEPSEEK_MODEL,
|
|
"deepseek_base_url": settings.DEEPSEEK_BASE_URL,
|
|
"max_chat_turns": settings.MAX_CHAT_TURNS,
|
|
"max_retries": settings.MAX_RETRIES,
|
|
"CORS_ALLOW_ORIGINS": settings.CORS_ALLOW_ORIGINS,
|
|
}
|
|
|
|
|
|
@router.get("/writer_seque")
|
|
async def get_writer_seque():
|
|
# 返回论文顺序
|
|
config_template: dict = get_config_template(CompTemplate.CHINA)
|
|
return list(config_template.keys())
|
|
|
|
|
|
@router.get("/track")
|
|
async def track(task_id: str):
|
|
# 获取任务的token使用情况
|
|
|
|
pass
|
|
|
|
|
|
@router.get("/status")
|
|
async def get_service_status():
|
|
"""获取各个服务的状态"""
|
|
status = {
|
|
"backend": {"status": "running", "message": "Backend service is running"},
|
|
"redis": {"status": "unknown", "message": "Redis connection status unknown"},
|
|
"sandbox": {
|
|
"status": "unknown",
|
|
"message": "Sandbox connection status unknown",
|
|
},
|
|
}
|
|
|
|
# 检查Redis连接状态
|
|
try:
|
|
redis_client = await redis_manager.get_client()
|
|
await redis_client.ping()
|
|
status["redis"] = {
|
|
"status": "running",
|
|
"message": "Redis connection is healthy",
|
|
}
|
|
except Exception as e:
|
|
logger.error(f"Redis connection failed: {str(e)}")
|
|
status["redis"] = {
|
|
"status": "error",
|
|
"message": f"Redis connection failed: {str(e)}",
|
|
}
|
|
|
|
# 检查Sandbox连接状态
|
|
try:
|
|
sandbox_status = await sandbox_manager.check_sandbox_status()
|
|
status["sandbox"] = sandbox_status
|
|
except Exception as e:
|
|
logger.error(f"Sandbox connection check failed: {str(e)}")
|
|
status["sandbox"] = {
|
|
"status": "error",
|
|
"message": f"Sandbox connection check failed: {str(e)}",
|
|
}
|
|
|
|
return status
|