Add conversation deletion functionality and update HistoryPage
- Implement a new API endpoint for deleting conversations in the backend. - Enhance the HistoryPage component to include a dropdown menu for conversation actions, allowing users to delete conversations. - Update the pagination logic to handle conversation removal and improve user experience during deletion. - Adjust the loading state and error handling for the delete operation, ensuring smooth interaction.
This commit is contained in:
@@ -115,3 +115,16 @@ async def get_conversation(
|
||||
for message in messages
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@router.delete("/{conversation_id}")
|
||||
async def delete_conversation(
|
||||
conversation_id: str,
|
||||
session: AsyncSession = Depends(get_session),
|
||||
):
|
||||
conversation = await session.get(ConversationSession, conversation_id)
|
||||
if not conversation:
|
||||
raise HTTPException(404, "对话记录不存在")
|
||||
await session.delete(conversation)
|
||||
await session.commit()
|
||||
return {"ok": True}
|
||||
|
||||
Reference in New Issue
Block a user