From 4a307c455198e0aee7c350462404e7a54c83193d Mon Sep 17 00:00:00 2001 From: martsforever Date: Thu, 4 Sep 2025 16:22:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=A0=E9=99=A4=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/add_langgraph_chat_route.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/controller/add_langgraph_chat_route.py b/app/controller/add_langgraph_chat_route.py index 2c94b5c..a2ec134 100644 --- a/app/controller/add_langgraph_chat_route.py +++ b/app/controller/add_langgraph_chat_route.py @@ -12,6 +12,8 @@ from langgraph.types import interrupt, Command from pydantic import BaseModel, Field from starlette.responses import StreamingResponse +from app.model.ConversationModel import ConversationService +from app.utils.db_utils import AsyncSessionDep from app.utils.llm_utils import create_llm from app.utils.postgres_checkpointer import PostgresCheckpointerManager, AsyncPostgresSaverDep @@ -30,7 +32,6 @@ def tool_get_datetime(): } - @tool( name_or_callable="tool_multiply", description="一个乘法工具,用于计算两个数字相乘" @@ -238,4 +239,11 @@ def add_langgraph_chat_route(app: FastAPI): # 查询聊天记录 @app.get("/langgraph/chat_state/{thread_id}") async def langgraph_chat(thread_id: str): - return await ChatAgent.get_chat_state(thread_id) + return await ChatAgent.get_chat_state(thread_id) # 查询聊天记录 + + # 删除聊天记录 + @app.post("/langgraph/chat_remove/{thread_id}") + async def langgraph_chat(thread_id: str, checkpointer: AsyncPostgresSaverDep, session=AsyncSessionDep): + await ConversationService.item_delete(session=session, row_dict={"id": thread_id}) + await checkpointer.adelete_thread(thread_id) + return {"result": "success"}