From 92daadb92ce11dabd5c22d0dce092090b5952e62 Mon Sep 17 00:00:00 2001 From: Will Miao <13051207myq@gmail.com> Date: Mon, 4 Aug 2025 22:23:43 +0800 Subject: [PATCH] feat: add endpoints for retrieving checkpoints and unet roots in CheckpointApiClient --- static/js/api/apiConfig.js | 2 ++ static/js/api/checkpointApi.js | 36 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/static/js/api/apiConfig.js b/static/js/api/apiConfig.js index 14c9a04f..87704cd6 100644 --- a/static/js/api/apiConfig.js +++ b/static/js/api/apiConfig.js @@ -109,6 +109,8 @@ export const MODEL_SPECIFIC_ENDPOINTS = { }, [MODEL_TYPES.CHECKPOINT]: { info: `/api/${MODEL_TYPES.CHECKPOINT}/info`, + checkpoints_roots: `/api/${MODEL_TYPES.CHECKPOINT}/checkpoints_roots`, + unet_roots: `/api/${MODEL_TYPES.CHECKPOINT}/unet_roots`, }, [MODEL_TYPES.EMBEDDING]: { } diff --git a/static/js/api/checkpointApi.js b/static/js/api/checkpointApi.js index b7e32542..6fdf8b58 100644 --- a/static/js/api/checkpointApi.js +++ b/static/js/api/checkpointApi.js @@ -28,4 +28,40 @@ export class CheckpointApiClient extends BaseModelApiClient { throw error; } } + + /** + * Get checkpoint roots + */ + async getCheckpointsRoots() { + try { + const response = await fetch(this.apiConfig.endpoints.specific.checkpoints_roots, { + method: 'GET' + }); + if (!response.ok) { + throw new Error('Failed to fetch checkpoints roots'); + } + return await response.json(); + } catch (error) { + console.error('Error fetching checkpoints roots:', error); + throw error; + } + } + + /** + * Get unet roots + */ + async getUnetRoots() { + try { + const response = await fetch(this.apiConfig.endpoints.specific.unet_roots, { + method: 'GET' + }); + if (!response.ok) { + throw new Error('Failed to fetch unet roots'); + } + return await response.json(); + } catch (error) { + console.error('Error fetching unet roots:', error); + throw error; + } + } }