mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
refactor: 拆分职责、引入 dataclass 封装并增强缓存健壮性
- ErrorClassifier 副作用操作分离为 ErrorHandlerService(缓存失效、健康记录、RPM 调整) - chat_handler_base 提取 ProviderRequestResult dataclass 和 _prepare_provider_request 方法 - failover 提取 AttemptErrorOutcome dataclass 和辅助方法 - formula_engine 拆分 _resolve_mapping 为子方法,增加求值异常日志 - usage recording 引入 UsageCostInfo dataclass 封装成本参数 - 前端 types.ts 拆分为 types/ 子模块 - cache backend 工厂函数加锁防止并发重复创建,LocalCache 容量检查修正 - CacheSync 监听增加断线重连机制,publish 增加重试 - guide 页面修正 useSiteInfo() 调用顺序
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
from collections.abc import AsyncGenerator
|
||||
from contextlib import asynccontextmanager
|
||||
from typing import Any
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import pytest
|
||||
@@ -8,7 +10,7 @@ from src.services.request.executor import RequestExecutor
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def _noop_async_cm():
|
||||
async def _noop_async_cm() -> AsyncGenerator[None]:
|
||||
yield
|
||||
|
||||
|
||||
@@ -46,7 +48,9 @@ async def test_executor_records_health_by_provider_format() -> None:
|
||||
candidate.key = key
|
||||
candidate.is_cached = False
|
||||
|
||||
async def request_func(_provider, _endpoint, _key, _candidate): # noqa: ANN001
|
||||
async def request_func(
|
||||
_provider: Any, _endpoint: Any, _key: Any, _candidate: Any
|
||||
) -> dict[str, bool]:
|
||||
return {"ok": True}
|
||||
|
||||
with (
|
||||
@@ -96,7 +100,7 @@ async def test_error_classifier_records_failure_by_provider_format() -> None:
|
||||
key.id = "k1"
|
||||
|
||||
with patch(
|
||||
"src.services.orchestration.error_classifier.health_monitor.record_failure"
|
||||
"src.services.orchestration.error_handler.health_monitor.record_failure"
|
||||
) as record_failure:
|
||||
await classifier.handle_retriable_error(
|
||||
error=RuntimeError("boom"),
|
||||
|
||||
Reference in New Issue
Block a user