refactor: 拆分大型模块为 mixin/子模块结构

- cli_handler_base.py 拆分为 7 个 mixin (event/monitor/prefetch/request/sse_helpers/stream/sync)
- usage/service.py 拆分为 6 个子模块 (types/active_requests/cache_analysis/lifecycle/pricing/query/recording)
- models/database 拆分为独立模型文件 (auth/misc/model/provider/stats/usage/user)
- DUMMY_THOUGHT_SIGNATURE 常量提升到 core/api_format/conversion/constants 统一管理
- task/service.py 内联导入提升为顶层导入
- 流处理函数签名移除冗余的 http_client 参数
This commit is contained in:
fawney19
2026-02-14 12:55:58 +08:00
parent f464f32e48
commit 26ede849e2
32 changed files with 10173 additions and 7218 deletions

View File

@@ -84,12 +84,7 @@ def test_process_line_handles_openai_usage_chunk_followed_by_done_without_blank_
class _DummyResponseCtx:
async def __aexit__(self, exc_type, exc, tb) -> None: # noqa: ANN001
return None
class _DummyHTTPClient:
async def aclose(self) -> None:
async def __aexit__(self, exc_type: type | None, exc: BaseException | None, tb: object) -> None:
return None
@@ -115,7 +110,6 @@ async def test_create_response_stream_flushes_usage_on_remote_protocol_error() -
ctx=ctx,
byte_iterator=_iter_bytes_then_remote_protocol_error(),
response_ctx=_DummyResponseCtx(),
http_client=_DummyHTTPClient(), # type: ignore[arg-type]
prefetched_chunks=[],
start_time=None,
):