This commit is contained in:
Timothy Jaeryang Baek
2025-12-27 22:16:10 +04:00
parent a9609585af
commit 37b15604de
4 changed files with 374 additions and 160 deletions
+32
View File
@@ -1206,4 +1206,36 @@ export const exportChatStats = async (token: string, page: number = 1, params: o
return res;
};
export const downloadChatStats = async (
token: string = '',
chat_id: string | null = null,
start_time: number | null = null,
end_time: number | null = null
): Promise<[Response | null, AbortController]> => {
const controller = new AbortController();
let error = null;
let url = `${WEBUI_API_BASE_URL}/chats/stats/export?stream=true`;
if (chat_id) url += `&chat_id=${chat_id}`;
if (start_time) url += `&start_time=${start_time}`;
if (end_time) url += `&end_time=${end_time}`;
const res = await fetch(url, {
signal: controller.signal,
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
}
}).catch((err) => {
console.error(err);
error = err;
return null;
});
if (error) {
throw error;
}
return [res, controller];
};