Invert content of settings and configuration pages

parent e16ed66a
...@@ -91,15 +91,31 @@ ...@@ -91,15 +91,31 @@
<form method="post" action="/update_settings"> <form method="post" action="/update_settings">
<div class="form-group"> <div class="form-group">
<label for="default_model">Default AI Model</label> <label for="analysis_backend">Analysis Backend:</label>
<input type="text" id="default_model" name="default_model" value="Qwen/Qwen2.5-VL-7B-Instruct" placeholder="Model path or HuggingFace ID"> <select name="analysis_backend" id="analysis_backend">
{% if 'cuda' in available_backends %}
<option value="cuda" {% if current_config.get('analysis_backend') == 'cuda' %}selected{% endif %}>CUDA</option>
{% endif %}
{% if 'rocm' in available_backends %}
<option value="rocm" {% if current_config.get('analysis_backend') == 'rocm' %}selected{% endif %}>ROCm</option>
{% endif %}
{% if not available_backends %}
<option value="cpu" selected>CPU (No GPU detected)</option>
{% endif %}
</select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="theme">Theme Preference</label> <label for="training_backend">Training Backend:</label>
<select id="theme" name="theme"> <select name="training_backend" id="training_backend">
<option value="light" selected>Light</option> {% if 'cuda' in available_backends %}
<option value="dark">Dark</option> <option value="cuda" {% if current_config.get('training_backend') == 'cuda' %}selected{% endif %}>CUDA</option>
{% endif %}
{% if 'rocm' in available_backends %}
<option value="rocm" {% if current_config.get('training_backend') == 'rocm' %}selected{% endif %}>ROCm</option>
{% endif %}
{% if not available_backends %}
<option value="cpu" selected>CPU (No GPU detected)</option>
{% endif %}
</select> </select>
</div> </div>
......
...@@ -36,33 +36,18 @@ ...@@ -36,33 +36,18 @@
<h1 class="config-title">Configuration</h1> <h1 class="config-title">Configuration</h1>
<form method="post" class="config-form"> <form method="post" class="config-form">
<div class="form-group"> <div class="form-group">
<label for="analysis_backend">Analysis Backend:</label> <label for="default_model">Default AI Model</label>
<select name="analysis_backend" id="analysis_backend"> <input type="text" id="default_model" name="default_model" value="Qwen/Qwen2.5-VL-7B-Instruct" placeholder="Model path or HuggingFace ID">
{% if 'cuda' in available_backends %}
<option value="cuda" {% if current_config.get('analysis_backend') == 'cuda' %}selected{% endif %}>CUDA</option>
{% endif %}
{% if 'rocm' in available_backends %}
<option value="rocm" {% if current_config.get('analysis_backend') == 'rocm' %}selected{% endif %}>ROCm</option>
{% endif %}
{% if not available_backends %}
<option value="cpu" selected>CPU (No GPU detected)</option>
{% endif %}
</select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="training_backend">Training Backend:</label> <label for="theme">Theme Preference</label>
<select name="training_backend" id="training_backend"> <select id="theme" name="theme">
{% if 'cuda' in available_backends %} <option value="light" selected>Light</option>
<option value="cuda" {% if current_config.get('training_backend') == 'cuda' %}selected{% endif %}>CUDA</option> <option value="dark">Dark</option>
{% endif %}
{% if 'rocm' in available_backends %}
<option value="rocm" {% if current_config.get('training_backend') == 'rocm' %}selected{% endif %}>ROCm</option>
{% endif %}
{% if not available_backends %}
<option value="cpu" selected>CPU (No GPU detected)</option>
{% endif %}
</select> </select>
</div> </div>
<button type="submit" class="btn-submit">Save Configuration</button> <button type="submit" class="btn-submit">Save Configuration</button>
</form> </form>
</div> </div>
......
...@@ -280,18 +280,33 @@ def settings(): ...@@ -280,18 +280,33 @@ def settings():
"""Admin settings page.""" """Admin settings page."""
user = get_current_user_session() user = get_current_user_session()
# Get current config
from .config import get_analysis_backend, get_training_backend
current_config = {
'analysis_backend': get_analysis_backend(),
'training_backend': get_training_backend()
}
# Get available backends
from .compat import get_available_backends
available_backends = get_available_backends()
return render_template('admin/settings.html', return render_template('admin/settings.html',
user=user, user=user,
tokens=get_user_tokens(user["id"]), tokens=get_user_tokens(user["id"]),
current_config=current_config,
available_backends=available_backends,
active_page='settings') active_page='settings')
@admin_bp.route('/update_settings', methods=['POST']) @admin_bp.route('/update_settings', methods=['POST'])
@admin_required @admin_required
def update_settings(): def update_settings():
"""Update admin settings.""" """Update admin settings."""
# For now, just flash a success message from .config import set_analysis_backend, set_training_backend
# In a real implementation, this would save admin preferences analysis_backend = request.form.get('analysis_backend', 'cuda')
from flask import flash training_backend = request.form.get('training_backend', 'cuda')
set_analysis_backend(analysis_backend)
set_training_backend(training_backend)
flash('Settings updated successfully!', 'success') flash('Settings updated successfully!', 'success')
return redirect(url_for('admin.settings')) return redirect(url_for('admin.settings'))
......
...@@ -269,24 +269,21 @@ def analyze(): ...@@ -269,24 +269,21 @@ def analyze():
@app.route('/config', methods=['GET', 'POST']) @app.route('/config', methods=['GET', 'POST'])
def config(): def config():
if request.method == 'POST': if request.method == 'POST':
data = { from .config import set_default_model, set_default_model_type
'analysis_backend': request.form.get('analysis_backend', 'cuda'), default_model = request.form.get('default_model', 'Qwen/Qwen2.5-VL-7B-Instruct')
'training_backend': request.form.get('training_backend', 'cuda') theme = request.form.get('theme', 'light')
} set_default_model(default_model)
msg_id = send_to_backend('config_update', data) # For theme, perhaps store it somewhere, but for now, just flash
result_data = get_result(msg_id) flash('Configuration updated successfully!', 'success')
status = result_data.get('data', {}).get('status', 'Error')
# Get current config # Get current config
msg_id = send_to_backend('get_config', {}) from .config import get_default_model
config_data = get_result(msg_id) current_config = {
current_config = config_data.get('data', {}) 'default_model': get_default_model(),
'theme': 'light' # Default
# Get available backends }
from .compat import get_available_backends
available_backends = get_available_backends()
return render_template('config.html', current_config=current_config, available_backends=available_backends, active_page='config', user=None) return render_template('config.html', current_config=current_config, available_backends=[], active_page='config', user=None)
@app.route('/history') @app.route('/history')
@login_required @login_required
...@@ -306,8 +303,11 @@ def history(): ...@@ -306,8 +303,11 @@ def history():
@login_required @login_required
def update_settings(): def update_settings():
"""Update user settings.""" """Update user settings."""
# For now, just flash a success message from .config import set_analysis_backend, set_training_backend
# In a real implementation, this would save user preferences analysis_backend = request.form.get('analysis_backend', 'cuda')
training_backend = request.form.get('training_backend', 'cuda')
set_analysis_backend(analysis_backend)
set_training_backend(training_backend)
flash('Settings updated successfully!', 'success') flash('Settings updated successfully!', 'success')
return redirect(url_for('settings')) return redirect(url_for('settings'))
......
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