refac
This commit is contained in:
1 parent
6c203fc7df
commit
71ca25c8ac
4 files changed
+425
-197
No files matched your search
@@ -1210,19 +1210,46 @@ export const exportChatStats = async (token: string, page: number = 1, params: o
|
||||
return res;
|
||||
};
|
||||
|
||||
export const exportSingleChatStats = async (token: string, chatId: string) => {
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${WEBUI_API_BASE_URL}/chats/stats/export/${chatId}`, {
|
||||
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;
|
||||
console.error(err);
|
||||
return null;
|
||||
});
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
export const downloadChatStats = async (
|
||||
token: string = '',
|
||||
chat_id: string | null = null,
|
||||
start_time: number | null = null,
|
||||
end_time: number | null = null
|
||||
updated_at: 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}`;
|
||||
if (updated_at) url += `&updated_at=${updated_at}`;
|
||||
|
||||
const res = await fetch(url, {
|
||||
signal: controller.signal,
|
||||
|
||||
Reference in new issue
Block a user