Fix duplicate default model insertion

- Modified init_db to check for existing default model before inserting
- Prevents multiple insertions of the same model
parent 2852d318
...@@ -561,11 +561,9 @@ def init_db(conn) -> None: ...@@ -561,11 +561,9 @@ def init_db(conn) -> None:
# Insert default model if not exist # Insert default model if not exist
default_model_name = 'Qwen/Qwen2.5-VL-7B-Instruct' default_model_name = 'Qwen/Qwen2.5-VL-7B-Instruct'
if config['type'] == 'mysql': cursor.execute('SELECT id FROM models WHERE path = ?', (default_model_name,))
cursor.execute('INSERT IGNORE INTO models (name, type, path, vram_estimate) VALUES (?, ?, ?, ?)', if not cursor.fetchone():
('Qwen 2.5 VL 7B Instruct', 'huggingface', default_model_name, 16)) cursor.execute('INSERT INTO models (name, type, path, vram_estimate) VALUES (?, ?, ?, ?)',
else:
cursor.execute('INSERT OR IGNORE INTO models (name, type, path, vram_estimate) VALUES (?, ?, ?, ?)',
('Qwen 2.5 VL 7B Instruct', 'huggingface', default_model_name, 16)) ('Qwen 2.5 VL 7B Instruct', 'huggingface', default_model_name, 16))
# Add data column to sessions table if it doesn't exist # Add data column to sessions table if it doesn't exist
......
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