refac
This commit is contained in:
1 parent
37d45fdee3
commit
3319b6410e
1 file changed
+30
-8
@@ -1156,12 +1156,7 @@ export const getChatAccessGrants = async (token: string, id: string) => {
|
|||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateChatById = async (
|
export const updateChatById = async (token: string, id: string, chat: object) => {
|
||||||
token: string,
|
|
||||||
id: string,
|
|
||||||
chat: object,
|
|
||||||
deletedMessageIds: string[] = []
|
|
||||||
) => {
|
|
||||||
let error = null;
|
let error = null;
|
||||||
|
|
||||||
const res = await fetch(`${WEBUI_API_BASE_URL}/chats/${id}`, {
|
const res = await fetch(`${WEBUI_API_BASE_URL}/chats/${id}`, {
|
||||||
@@ -1172,8 +1167,7 @@ export const updateChatById = async (
|
|||||||
...(token && { authorization: `Bearer ${token}` })
|
...(token && { authorization: `Bearer ${token}` })
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
chat: chat,
|
chat: chat
|
||||||
...(deletedMessageIds.length && { deleted_message_ids: deletedMessageIds })
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
@@ -1197,6 +1191,34 @@ export const updateChatById = async (
|
|||||||
return res;
|
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) => {
|
export const deleteChatById = async (token: string, id: string) => {
|
||||||
let error = null;
|
let error = null;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user