feat: refactor model API structure to support specific model types with dedicated API clients for Checkpoints, LoRAs, and Embeddings

refactor: consolidate model API client creation into a factory function for better maintainability
feat: implement move operations for LoRAs and handle unsupported operations for Checkpoints and Embeddings
This commit is contained in:
Will Miao
2025-08-04 19:37:53 +08:00
parent 65ec6aacb7
commit 342a722991
29 changed files with 341 additions and 213 deletions

View File

@@ -5,7 +5,7 @@ import { toggleShowcase } from './showcase/ShowcaseView.js';
import { bulkManager } from '../../managers/BulkManager.js';
import { modalManager } from '../../managers/ModalManager.js';
import { NSFW_LEVELS } from '../../utils/constants.js';
import { getModelApiClient } from '../../api/baseModelApi.js';
import { getModelApiClient } from '../../api/modelApiFactory.js';
import { showDeleteModal } from '../../utils/modalUtils.js';
// Add global event delegation handlers

View File

@@ -121,7 +121,7 @@ export function setupModelDescriptionEditing(filePath) {
}
try {
// Save to backend
const { getModelApiClient } = await import('../../api/baseModelApi.js');
const { getModelApiClient } = await import('../../api/modelApiFactory.js');
await getModelApiClient().saveModelMetadata(filePath, { modelDescription: newValue });
showToast('Model description updated', 'success');
} catch (err) {

View File

@@ -4,7 +4,7 @@
*/
import { showToast } from '../../utils/uiHelpers.js';
import { BASE_MODELS } from '../../utils/constants.js';
import { getModelApiClient } from '../../api/baseModelApi.js';
import { getModelApiClient } from '../../api/modelApiFactory.js';
/**
* Set up model name editing functionality

View File

@@ -13,7 +13,7 @@ import {
setupFileNameEditing
} from './ModelMetadata.js';
import { setupTagEditMode } from './ModelTags.js';
import { getModelApiClient } from '../../api/baseModelApi.js';
import { getModelApiClient } from '../../api/modelApiFactory.js';
import { renderCompactTags, setupTagTooltip, formatFileSize } from './utils.js';
import { renderTriggerWords, setupTriggerWordsEditMode } from './TriggerWords.js';
import { parsePresets, renderPresetTags } from './PresetTags.js';

View File

@@ -3,7 +3,7 @@
* Module for handling model tag editing functionality - 共享版本
*/
import { showToast } from '../../utils/uiHelpers.js';
import { getModelApiClient } from '../../api/baseModelApi.js';
import { getModelApiClient } from '../../api/modelApiFactory.js';
// Preset tag suggestions
const PRESET_TAGS = [

View File

@@ -2,7 +2,7 @@
* PresetTags.js
* Handles LoRA model preset parameter tags - Shared version
*/
import { getModelApiClient } from '../../api/baseModelApi.js';
import { getModelApiClient } from '../../api/modelApiFactory.js';
/**
* Parse preset parameters

View File

@@ -4,7 +4,7 @@
* Moved to shared directory for consistency
*/
import { showToast, copyToClipboard } from '../../utils/uiHelpers.js';
import { getModelApiClient } from '../../api/baseModelApi.js';
import { getModelApiClient } from '../../api/modelApiFactory.js';
/**
* Fetch trained words for a model

View File

@@ -5,7 +5,7 @@
*/
import { showToast, copyToClipboard } from '../../../utils/uiHelpers.js';
import { state } from '../../../state/index.js';
import { getModelApiClient } from '../../../api/baseModelApi.js';
import { getModelApiClient } from '../../../api/modelApiFactory.js';
/**
* Try to load local image first, fall back to remote if local fails