refactor : FastAPI 懒加载单例,消除模块级副作用

- import astrai.inference 不再在模块加载时创建 FastAPI 实例
- 路由移至 APIRouter;get_app() 首次调用时懒构造单例
- _create_engine 和 run_server 的 param_path 改为必填
- 更新测试改用 get_app() 替代模块级 app
This commit is contained in:
2026-06-04 15:52:27 +08:00
parent b36a78c612
commit dc7d2cfbca
5 changed files with 54 additions and 31 deletions
+2 -2
View File
@@ -17,7 +17,7 @@ from astrai.inference.api import (
MessagesRequest,
ProtocolHandler,
StopChecker,
app,
get_app,
run_server,
)
from astrai.inference.api.anthropic import AnthropicResponseBuilder
@@ -80,6 +80,6 @@ __all__ = [
"ChatCompletionRequest",
"AnthropicMessage",
"MessagesRequest",
"app",
"get_app",
"run_server",
]