feat: Add Civitai model version retrieval for Checkpoints and update error handling in download managers

This commit is contained in:
Will Miao
2025-04-13 20:36:19 +08:00
parent 8854334ab5
commit 9822f2c614
6 changed files with 84 additions and 9 deletions

View File

@@ -76,8 +76,12 @@ export class CheckpointDownloadManager {
throw new Error('Invalid Civitai URL format');
}
const response = await fetch(`/api/civitai/versions/${modelId}`);
const response = await fetch(`/api/checkpoints/civitai/versions/${modelId}`);
if (!response.ok) {
const errorData = await response.json().catch(() => ({}));
if (errorData && errorData.error && errorData.error.includes('Model type mismatch')) {
throw new Error('This model is not a Checkpoint. Please switch to the LoRAs page to download LoRA models.');
}
throw new Error('Failed to fetch model versions');
}

View File

@@ -80,6 +80,10 @@ export class DownloadManager {
const response = await fetch(`/api/civitai/versions/${modelId}`);
if (!response.ok) {
const errorData = await response.json().catch(() => ({}));
if (errorData && errorData.error && errorData.error.includes('Model type mismatch')) {
throw new Error('This model is not a LoRA. Please switch to the Checkpoints page to download checkpoint models.');
}
throw new Error('Failed to fetch model versions');
}