修改rag,实现混合检索
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 5m42s

This commit is contained in:
2026-05-04 04:28:32 +08:00
parent d0590240f9
commit 82dde7113e
15 changed files with 536 additions and 65 deletions

View File

@@ -12,18 +12,21 @@ class ThreadHistoryService:
def __init__(self, checkpointer):
self.checkpointer = checkpointer
async def get_user_threads(self, user_id: str, limit: int = 50) -> List[Dict[str, Any]]:
async def get_user_threads(self, user_id: str, limit: int = 4) -> List[Dict[str, Any]]:
"""
获取指定用户的所有线程摘要信息
Args:
user_id: 用户 ID
limit: 返回数量限制
limit: 返回数量限制强制最多4条
Returns:
线程列表,每个包含 thread_id, last_updated, summary, message_count
"""
try:
# 强制限制最多4条
actual_limit = min(limit, 4)
# 查询 checkpoints 表获取用户的线程列表
async with self.checkpointer.conn.cursor() as cur:
# 在较新的 LangGraph 版本中AsyncPostgresSaver 创建的 checkpoints 表
@@ -40,7 +43,7 @@ class ThreadHistoryService:
ORDER BY last_updated DESC
LIMIT %s
"""
await cur.execute(query, (user_id, limit))
await cur.execute(query, (user_id, actual_limit))
rows = await cur.fetchall()
threads = []