Fix web interface model select to filter by mode

- In T2I mode, only show image models in the main model select
- In other modes (T2V, I2V, etc.), show video models
- Repopulate model select when switching modes
- Image model select for I2V mode always shows image models
parent e1a47955
...@@ -53,6 +53,16 @@ async function loadModels() { ...@@ -53,6 +53,16 @@ async function loadModels() {
const response = await fetch('/api/models'); const response = await fetch('/api/models');
models = await response.json(); models = await response.json();
// Populate model selects based on current mode
populateModelSelects();
} catch (error) {
console.error('Error loading models:', error);
showToast('Failed to load models', 'error');
}
}
// Populate model selects based on current mode
function populateModelSelects() {
const modelSelect = document.getElementById('model'); const modelSelect = document.getElementById('model');
const imageModelSelect = document.getElementById('image_model'); const imageModelSelect = document.getElementById('image_model');
...@@ -64,18 +74,29 @@ async function loadModels() { ...@@ -64,18 +74,29 @@ async function loadModels() {
option.value = model.name; option.value = model.name;
option.textContent = `${model.name} (${model.type || 'video'})`; option.textContent = `${model.name} (${model.type || 'video'})`;
option.dataset.type = model.type; option.dataset.type = model.type;
modelSelect.appendChild(option);
// Add image models to image model select // Determine if this model should be shown in main select based on mode
if (model.type === 'image' || model.type === 't2i') { const isImageModel = model.type === 'image' || model.type === 't2i' || model.type === 'i2i';
const imgOption = option.cloneNode(true); const isVideoModel = model.type === 'video' || model.type === 't2v' || model.type === 'i2v' ||
imageModelSelect.appendChild(imgOption); model.type === 'v2v' || !model.type; // Default to video if no type
// For T2I mode, only show image models in main select
if (currentMode === 't2i') {
if (isImageModel) {
modelSelect.appendChild(option.cloneNode(true));
}
} else {
// For other modes, show video models in main select
if (isVideoModel) {
modelSelect.appendChild(option.cloneNode(true));
} }
});
} catch (error) {
console.error('Error loading models:', error);
showToast('Failed to load models', 'error');
} }
// Add image models to image model select (for I2V mode)
if (isImageModel) {
imageModelSelect.appendChild(option.cloneNode(true));
}
});
} }
// Load TTS voices // Load TTS voices
...@@ -238,6 +259,9 @@ function switchMode(mode) { ...@@ -238,6 +259,9 @@ function switchMode(mode) {
audioSection.classList.add('hidden'); audioSection.classList.add('hidden');
break; break;
} }
// Update model select based on mode
populateModelSelects();
} }
// Handle file upload // Handle file upload
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment