From 3319b6410e1b600b7a885a5fb78573e9a2061c22 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 29 Jun 2026 13:14:42 -0500 Subject: [PATCH] refac --- src/lib/apis/chats/index.ts | 38 +++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/lib/apis/chats/index.ts b/src/lib/apis/chats/index.ts index 721800fbab..577b31cf49 100644 --- a/src/lib/apis/chats/index.ts +++ b/src/lib/apis/chats/index.ts @@ -1156,12 +1156,7 @@ export const getChatAccessGrants = async (token: string, id: string) => { return res; }; -export const updateChatById = async ( - token: string, - id: string, - chat: object, - deletedMessageIds: string[] = [] -) => { +export const updateChatById = async (token: string, id: string, chat: object) => { let error = null; const res = await fetch(`${WEBUI_API_BASE_URL}/chats/${id}`, { @@ -1172,8 +1167,7 @@ export const updateChatById = async ( ...(token && { authorization: `Bearer ${token}` }) }, body: JSON.stringify({ - chat: chat, - ...(deletedMessageIds.length && { deleted_message_ids: deletedMessageIds }) + chat: chat }) }) .then(async (res) => { @@ -1197,6 +1191,34 @@ export const updateChatById = async ( return res; }; +export const deleteChatMessageById = async (token: string, id: string, messageId: string) => { + let error = null; + + const res = await fetch(`${WEBUI_API_BASE_URL}/chats/${id}/messages/${messageId}`, { + method: 'DELETE', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + ...(token && { authorization: `Bearer ${token}` }) + } + }) + .then(async (res) => { + if (!res.ok) throw await res.json(); + return res.json(); + }) + .catch((err) => { + error = err; + console.error(err); + return null; + }); + + if (error) { + throw error; + } + + return res; +}; + export const deleteChatById = async (token: string, id: string) => { let error = null;