feat: chat clone

This commit is contained in:
Timothy J. Baek
2024-05-31 10:30:42 -07:00
parent eb12d1e111
commit 7674229e3a
6 changed files with 125 additions and 26 deletions
+38
View File
@@ -325,6 +325,44 @@ export const getChatByShareId = async (token: string, share_id: string) => {
return res;
};
export const cloneChatById = async (token: string, id: string) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/chats/${id}/clone`, {
method: 'GET',
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();
})
.then((json) => {
return json;
})
.catch((err) => {
error = err;
if ('detail' in err) {
error = err.detail;
} else {
error = err;
}
console.log(err);
return null;
});
if (error) {
throw error;
}
return res;
};
export const shareChatById = async (token: string, id: string) => {
let error = null;