Unrestricted Open-source alternative to AI video platforms — Free AI image & video generation studio with 600+ models (Flux, Midjourney, Kling, Sora, Veo). No content filters. Self-hosted, MIT licensed.
JavaScript ai-art-generatorai-image-generationai-video-generationfal-ai-alternativegenerative-aiimage-to-videoinvideo-alternativekling-ailipsynclitellm-alternativemidjourney-alternativemuapiopen-sourceopenrouter-alternativeseedance2sora-alternativetext-to-imagetext-to-videouncensoredwan-video
fix(wan2gp): keep default endpoints available without metadata
NgoQuocViet2001607e6cd7c4d1
diff --git a/electron/lib/wan2gpModelAvailability.js b/electron/lib/wan2gpModelAvailability.jsnew file mode 100644index 00000000..295cd9a7--- /dev/null+++ b/electron/lib/wan2gpModelAvailability.js@@ -0,0 +1,33 @@+function withWan2gpAvailability(model, probeResult, cachedResolution) {+ if (!probeResult?.ok) {+ return {+ ...model,+ ready: false,+ unavailableReason: probeResult?.error || 'Wan2GP probe failed',+ };+ }++ const apiNames = Array.isArray(cachedResolution?.apiNames) ? cachedResolution.apiNames : [];+ const realFn = cachedResolution?.resolved?.get?.(model.id) || null;++ if (realFn) {+ return { ...model, ready: true, fn: realFn };+ }++ if (apiNames.length === 0) {+ return {+ ...model,+ ready: true,+ fn: model.fn,+ availabilityNote: 'Wan2GP did not expose endpoint metadata; using the default api_name.',+ };+ }++ return {+ ...model,+ ready: false,+ unavailableReason: `Wan2GP server has no api_name matching "${model.fn}". Check Wan2GP version or load this model in its UI.`,+ };+}++module.exports = { withWan2gpAvailability };diff --git a/electron/lib/wan2gpProvider.js b/electron/lib/wan2gpProvider.jsindex c5217008..68f6c83d 100644--- a/electron/lib/wan2gpProvider.js+++ b/electron/lib/wan2gpProvider.js@@ -9,6 +9,7 @@ const path = require('path');const fs = require('fs');const http = require('http');const https = require('https');+const { withWan2gpAvailability } = require('./wan2gpModelAvailability');const DATA_DIR = path.join(app.getPath('userData'), 'local-ai');const CONFIG_FILE = path.join(DATA_DIR, 'wan2gp.json');@@ -274,18 +275,7 @@ async function listModels() {const base = normalizeUrl(url);const probeRes = await probe(url); // populates fnResolutionCacheconst cached = fnResolutionCache.get(base);- return WAN2GP_CATALOG.map(m => {- if (!probeRes.ok) return { ...m, ready: false, unavailableReason: probeRes.error };- const realFn = cached?.resolved.get(m.id) || null;- if (!realFn) {- return {- ...m,- ready: false,- unavailableReason: `Wan2GP server has no api_name matching "${m.fn}". Check Wan2GP version or load this model in its UI.`,- };- }- return { ...m, ready: true, fn: realFn };- });+ return WAN2GP_CATALOG.map(m => withWan2gpAvailability(m, probeRes, cached));}// ─── Generate ─────────────────────────────────────────────────────────────────diff --git a/src/lib/i18n.js b/src/lib/i18n.jsindex 20260f0a..9efc63e4 100644--- a/src/lib/i18n.js+++ b/src/lib/i18n.js@@ -189,7 +189,7 @@ const translations = {'localModels.requiredComponents': 'Required components','localModels.ready': 'Ready','localModels.available': 'Available',- 'localModels.offline': 'Server offline',+ 'localModels.offline': 'Unavailable','localModels.starting': 'Starting...','localModels.complete': 'Complete!','localModels.preparing': 'Preparing...',@@ -379,7 +379,7 @@ const translations = {'localModels.requiredComponents': '所需组件','localModels.ready': '已就绪','localModels.available': '可用',- 'localModels.offline': '服务器离线',+ 'localModels.offline': '不可用','localModels.starting': '启动中...','localModels.complete': '完成!','localModels.preparing': '准备中...',diff --git a/tests/wan2gpModelAvailability.test.js b/tests/wan2gpModelAvailability.test.jsnew file mode 100644index 00000000..2d50810e--- /dev/null+++ b/tests/wan2gpModelAvailability.test.js@@ -0,0 +1,60 @@+const test = require('node:test');+const assert = require('node:assert/strict');++const { withWan2gpAvailability } = require('../electron/lib/wan2gpModelAvailability');++const fluxModel = {+ id: 'wan2gp:flux-dev',+ name: 'Flux.1 Dev (Wan2GP)',+ fn: 'flux',+};++test('withWan2gpAvailability marks models unavailable when the server probe fails', () => {+ const model = withWan2gpAvailability(fluxModel, { ok: false, error: 'Request timed out' });++ assert.equal(model.ready, false);+ assert.equal(model.unavailableReason, 'Request timed out');+});++test('withWan2gpAvailability uses resolved api_name when endpoint metadata matches', () => {+ const model = withWan2gpAvailability(+ fluxModel,+ { ok: true },+ {+ apiNames: ['flux_image'],+ resolved: new Map([['wan2gp:flux-dev', 'flux_image']]),+ }+ );++ assert.equal(model.ready, true);+ assert.equal(model.fn, 'flux_image');+});++test('withWan2gpAvailability keeps default api_name available when Gradio omits endpoint metadata', () => {+ const model = withWan2gpAvailability(+ fluxModel,+ { ok: true },+ {+ apiNames: [],+ resolved: new Map([['wan2gp:flux-dev', null]]),+ }+ );++ assert.equal(model.ready, true);+ assert.equal(model.fn, 'flux');+ assert.match(model.availabilityNote, /default api_name/);+});++test('withWan2gpAvailability rejects unmatched models when endpoint metadata is present', () => {+ const model = withWan2gpAvailability(+ fluxModel,+ { ok: true },+ {+ apiNames: ['qwen_image'],+ resolved: new Map([['wan2gp:flux-dev', null]]),+ }+ );++ assert.equal(model.ready, false);+ assert.match(model.unavailableReason, /no api_name matching "flux"/);+});