refac
This commit is contained in:
@@ -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];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user