chore: lint 修复(TC001/TC003 类型导入优化)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-06 23:15:06 -04:00
parent dc6f8e047e
commit c2ba3ed591
7 changed files with 31 additions and 30 deletions
+2 -6
View File
@@ -47,9 +47,7 @@ class RedisResponseCache:
digest = hashlib.sha256(payload.encode("utf-8")).hexdigest()
return f"llm_cache:{digest}"
async def get(
self, model: str, messages: list[dict[str, str]]
) -> LLMResponse | None:
async def get(self, model: str, messages: list[dict[str, str]]) -> LLMResponse | None:
"""从缓存读取 LLM 响应。
Args:
@@ -87,9 +85,7 @@ class RedisResponseCache:
"""
try:
key = self._build_key(model, messages)
value = json.dumps(
dataclasses.asdict(response), ensure_ascii=False
)
value = json.dumps(dataclasses.asdict(response), ensure_ascii=False)
await self._redis.set(key, value, ex=self._ttl_s)
except Exception:
logger.warning("Redis 缓存写入失败,跳过缓存")
+5 -1
View File
@@ -3,11 +3,15 @@
通过 asyncio.to_thread 将 SQLite 同步写入桥接到异步接口,
确保事件循环不被阻塞。表在首次写入时懒初始化。
"""
from __future__ import annotations
import asyncio
import sqlite3
from pathlib import Path
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from pathlib import Path
class SQLiteTelemetryRecorder: