feat(inference): LLM 客户端全异步化(T8 架构审查整改)

- Issue9: client.py 由同步 httpx.Client 全异步化
  - LLMClient Protocol / HttpLLMClient.chat → async;httpx.AsyncClient + asyncio.sleep 退避
  - __enter__/__exit__ → __aenter__/__aexit__(async with 生命周期闭环)
- engine.py chat/chat_structured/_call 全部 async + await
- FakeLLMClient.chat → async;测试用 anyio pytest 插件转换(engine 32 + client 10 用例)
- 同步 inference-engine spec 与 milestone3 review 的 httpx 描述
- 全量 182 passed / 100.00%(987 stmts/252 br)
This commit is contained in:
lhl
2026-08-12 09:50:37 +08:00
parent 1f931228e7
commit 8239a37a99
8 changed files with 161 additions and 111 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ class FakeLLMClient:
self.script = script or [("ok", "hello")]
self.calls: list[dict] = []
def chat(self, *, model, messages, temperature, max_tokens):
async def chat(self, *, model, messages, temperature, max_tokens):
# 与真实 HttpLLMClient 的 payload 结构一致:{role, content}T4 防护断言 role
self.calls.append({
"model": model,