chore/ 删除无用文件

This commit is contained in:
Kevin
2026-03-19 14:36:14 +08:00
parent 2f60858c9c
commit c6e07ce5ca
135 changed files with 2111 additions and 4510 deletions

View File

@@ -2,6 +2,7 @@
Redis 客户端与会话/缓存能力:供应用生命周期、会话历史、任务追踪等使用。
配置从 app.core.config.settings 读取,禁止业务层散落 os.getenv。
"""
import json
from app.core.logging import get_logger
from datetime import datetime, timezone
@@ -47,7 +48,9 @@ class RedisService:
def _conversation_key(self, conversation_id: str) -> str:
return f"conversation:history:{conversation_id}"
async def get_conversation_history(self, conversation_id: str) -> List[Dict[str, Any]]:
async def get_conversation_history(
self, conversation_id: str
) -> List[Dict[str, Any]]:
try:
client = await self.get_client()
key = self._conversation_key(conversation_id)
@@ -81,7 +84,9 @@ class RedisService:
if voice_session_id:
item["voiceSessionId"] = voice_session_id
history.append(item)
await client.setex(key, self.session_ttl, json.dumps(history, ensure_ascii=False))
await client.setex(
key, self.session_ttl, json.dumps(history, ensure_ascii=False)
)
return True
except Exception as e:
logger.error("添加消息失败: %s", e)
@@ -110,7 +115,11 @@ class RedisService:
async def set_cache(self, key: str, value: Any, ttl: Optional[int] = None) -> bool:
try:
client = await self.get_client()
data = json.dumps(value, ensure_ascii=False) if not isinstance(value, str) else value
data = (
json.dumps(value, ensure_ascii=False)
if not isinstance(value, str)
else value
)
if ttl:
await client.setex(key, ttl, data)
else: