feat: 优化飞书集成、知识库、Agent、工单管理及AI建议功能,统一前端对话字体样式并移除工单模板文件。
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -161,13 +161,36 @@ class CacheManager:
|
||||
"""淘汰最旧的缓存"""
|
||||
if not self.memory_cache:
|
||||
return
|
||||
|
||||
|
||||
oldest_key = min(
|
||||
self.memory_cache.keys(),
|
||||
key=lambda k: self.memory_cache[k]['created_at']
|
||||
)
|
||||
del self.memory_cache[oldest_key]
|
||||
|
||||
|
||||
def check_and_set_message_processed(self, message_id: str, ttl: int = 300) -> bool:
|
||||
"""
|
||||
检查消息是否已处理,如果未处理则标记为已处理
|
||||
|
||||
Args:
|
||||
message_id: 消息ID
|
||||
ttl: 过期时间(秒),默认5分钟
|
||||
|
||||
Returns:
|
||||
bool: True 表示已处理(重复消息),False 表示未处理(新消息)
|
||||
"""
|
||||
key = f"msg_processed:{message_id}"
|
||||
|
||||
# 使用锁确保原子性(针对内存缓存)
|
||||
with self.cache_lock:
|
||||
# 1. 检查是否存在
|
||||
if self.get(key):
|
||||
return True
|
||||
|
||||
# 2. 如果不存在,则标记为已处理
|
||||
self.set(key, 1, ttl)
|
||||
return False
|
||||
|
||||
def get_stats(self) -> Dict[str, Any]:
|
||||
"""获取缓存统计信息"""
|
||||
with self.cache_lock:
|
||||
@@ -218,11 +241,10 @@ class DatabaseCache:
|
||||
logger.debug(f"缓存未命中: {cache_key}")
|
||||
result = func(*args, **kwargs)
|
||||
self.cache_manager.set(cache_key, result, self.ttl)
|
||||
|
||||
|
||||
return result
|
||||
return wrapper
|
||||
|
||||
|
||||
# 全局缓存管理器实例
|
||||
cache_manager = CacheManager()
|
||||
|
||||
|
||||
@@ -92,7 +92,9 @@ class QueryOptimizer:
|
||||
'confidence_score': conv.confidence_score,
|
||||
'work_order_id': conv.work_order_id,
|
||||
'ip_address': conv.ip_address,
|
||||
'invocation_method': conv.invocation_method
|
||||
'invocation_method': conv.invocation_method,
|
||||
# 构造用户显示名称:如果有IP则显示IP,否则显示匿名
|
||||
'user_id': f"{conv.ip_address} ({conv.invocation_method})" if conv.ip_address else "匿名"
|
||||
})
|
||||
|
||||
# 记录查询时间
|
||||
|
||||
Reference in New Issue
Block a user