Merge pull request #8286 from srajangarg/sg

feat: functionality to clone shared chats
This commit is contained in:
Timothy Jaeryang Baek
2025-01-05 00:45:55 -08:00
committed by GitHub
5 changed files with 111 additions and 17 deletions

View File

@@ -618,6 +618,44 @@ export const cloneChatById = async (token: string, id: string) => {
return res;
};
export const cloneSharedChatById = async (token: string, id: string) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/chats/${id}/clone/shared`, {
method: 'POST',
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;

View File

@@ -16,6 +16,8 @@
const i18n = getContext('i18n');
export let className = 'h-full flex pt-8';
export let chatId = '';
export let user = $_user;
@@ -333,7 +335,7 @@
};
</script>
<div class="h-full flex pt-8">
<div class={className}>
{#if Object.keys(history?.messages ?? {}).length == 0}
<ChatPlaceholder
modelIds={selectedModels}