feat: 删除聊天记录接口

This commit is contained in:
martsforever
2025-09-04 16:22:34 +08:00
parent 6428e6658e
commit 4a307c4551
+10 -2
View File
@@ -12,6 +12,8 @@ from langgraph.types import interrupt, Command
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
from starlette.responses import StreamingResponse 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.llm_utils import create_llm
from app.utils.postgres_checkpointer import PostgresCheckpointerManager, AsyncPostgresSaverDep from app.utils.postgres_checkpointer import PostgresCheckpointerManager, AsyncPostgresSaverDep
@@ -30,7 +32,6 @@ def tool_get_datetime():
} }
@tool( @tool(
name_or_callable="tool_multiply", name_or_callable="tool_multiply",
description="一个乘法工具,用于计算两个数字相乘" description="一个乘法工具,用于计算两个数字相乘"
@@ -238,4 +239,11 @@ def add_langgraph_chat_route(app: FastAPI):
# 查询聊天记录 # 查询聊天记录
@app.get("/langgraph/chat_state/{thread_id}") @app.get("/langgraph/chat_state/{thread_id}")
async def langgraph_chat(thread_id: str): 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"}