Add conditional model selection in analyze interface

- Show model dropdown only when multiple video-capable models are available
- Filter models by 'video to text' capabilities and availability status
- Admins see all models, regular users see only available ones
- Fall back to text input when only one or no models are available
parent 4a86491b
......@@ -231,9 +231,22 @@
{% endwith %}
<form method="post" enctype="multipart/form-data">
{% if video_models and video_models|length > 1 %}
<div class="form-group">
<label for="model_path">Select Model:</label>
<select name="model_path" id="model_path" required>
{% for model in video_models %}
<option value="{{ model.path }}" {% if model.path == 'Qwen/Qwen2.5-VL-7B-Instruct' %}selected{% endif %}>
{{ model.name }} ({{ model.capabilities }})
</option>
{% endfor %}
</select>
</div>
{% else %}
<div class="form-group">
<label>Model Path: <input type="text" name="model_path" value="Qwen/Qwen2.5-VL-7B-Instruct"></label>
</div>
{% endif %}
<div class="form-group">
<label>Upload File: <input type="file" name="file" accept="image/*,video/*"></label>
......
......@@ -233,6 +233,19 @@ def analyze():
user = get_current_user_session()
result = None
# Get available models with video capabilities
from .database import get_all_models
all_models = get_all_models()
# Filter models with video capabilities
video_models = []
for model in all_models:
capabilities = model.get('capabilities', '').lower()
if 'video to text' in capabilities:
# For regular users, only show available models
if user.get('role') == 'admin' or model.get('available', False):
video_models.append(model)
if request.method == 'POST':
# Check token balance (skip for admin users)
if user.get('role') != 'admin':
......@@ -281,6 +294,7 @@ def analyze():
tokens=get_user_tokens(user["id"]),
result=result,
server_dir=server_dir,
video_models=video_models,
active_page='analyze')
......
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