From 24e3937aa27ad24bc8566c1360d3a25946493334 Mon Sep 17 00:00:00 2001 From: Wenjie Zhang Date: Tue, 22 Jul 2025 04:10:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B0=86=E5=BD=93=E5=89=8D=E7=94=A8?= =?UTF-8?q?=E6=88=B7ID=E8=BD=AC=E6=8D=A2=E4=B8=BA=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E6=A0=BC=E5=BC=8F=EF=BC=8C=E4=BB=A5=E7=A1=AE=E4=BF=9D?= =?UTF-8?q?=E5=9C=A8=E6=95=B0=E6=8D=AE=E5=BA=93=E6=9F=A5=E8=AF=A2=E4=B8=AD?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/routers/chat_router.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/routers/chat_router.py b/server/routers/chat_router.py index 86626f98..e109685c 100644 --- a/server/routers/chat_router.py +++ b/server/routers/chat_router.py @@ -128,7 +128,7 @@ async def chat_agent(agent_name: str, messages = [{"role": "user", "content": query}] # 构造运行时配置,如果没有thread_id则生成一个 - config["user_id"] = current_user.id + config["user_id"] = str(current_user.id) if "thread_id" not in config or not config["thread_id"]: config["thread_id"] = str(uuid.uuid4()) logger.debug(f"没有thread_id,生成一个: {config['thread_id']=}") @@ -213,7 +213,7 @@ async def get_agent_history( raise HTTPException(status_code=404, detail=f"智能体 {agent_name} 不存在") # 获取历史消息 - history = await agent.get_history(user_id=current_user.id, thread_id=thread_id) + history = await agent.get_history(user_id=str(current_user.id), thread_id=thread_id) return {"history": history} except Exception as e: @@ -268,7 +268,7 @@ async def create_thread( new_thread = Thread( id=thread_id, - user_id=current_user.id, + user_id=str(current_user.id), agent_id=thread.agent_id, title=thread.title or "新对话", description=thread.description, @@ -297,7 +297,7 @@ async def list_threads( ): """获取用户的所有对话线程""" query = db.query(Thread).filter( - Thread.user_id == current_user.id, + Thread.user_id == str(current_user.id), Thread.status == 1 ) @@ -329,7 +329,7 @@ async def delete_thread( """删除对话线程""" thread = db.query(Thread).filter( Thread.id == thread_id, - Thread.user_id == current_user.id + Thread.user_id == str(current_user.id) ).first() if not thread: @@ -357,7 +357,7 @@ async def update_thread( """更新对话线程信息""" thread = db.query(Thread).filter( Thread.id == thread_id, - Thread.user_id == current_user.id, + Thread.user_id == str(current_user.id), Thread.status == 1 ).first()