diff --git a/works/ai-chat-app/backend/app.py b/works/ai-chat-app/backend/app.py index 30b3913..236b847 100644 --- a/works/ai-chat-app/backend/app.py +++ b/works/ai-chat-app/backend/app.py @@ -46,6 +46,8 @@ def init_db(): model TEXT NOT NULL, max_tokens INTEGER DEFAULT 2048, temperature REAL DEFAULT 0.7, + enable_thinking INTEGER DEFAULT 0, + enable_vision INTEGER DEFAULT 0, is_default INTEGER DEFAULT 0, is_active INTEGER DEFAULT 1, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, @@ -53,6 +55,16 @@ def init_db(): ) ''') + # 兼容旧数据库:添加缺失的字段 + try: + cursor.execute('ALTER TABLE llm_configs ADD COLUMN enable_thinking INTEGER DEFAULT 0') + except: + pass + try: + cursor.execute('ALTER TABLE llm_configs ADD COLUMN enable_vision INTEGER DEFAULT 0') + except: + pass + # 智能体配置表 cursor.execute(''' CREATE TABLE IF NOT EXISTS agents ( @@ -601,10 +613,11 @@ def add_llm_config(): conn = get_db() cursor = conn.cursor() cursor.execute(''' - INSERT INTO llm_configs (name, provider, api_url, api_key, model, max_tokens, temperature) - VALUES (?, ?, ?, ?, ?, ?, ?) + INSERT INTO llm_configs (name, provider, api_url, api_key, model, max_tokens, temperature, enable_thinking, enable_vision) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) ''', (data['name'], data['provider'], data['api_url'], data['api_key'], - data['model'], data.get('max_tokens', 2048), data.get('temperature', 0.7))) + data['model'], data.get('max_tokens', 2048), data.get('temperature', 0.7), + data.get('enable_thinking', 0), data.get('enable_vision', 0))) conn.commit() config_id = cursor.lastrowid conn.close() @@ -619,9 +632,10 @@ def update_llm_config(id): cursor = conn.cursor() cursor.execute(''' UPDATE llm_configs SET name=?, provider=?, api_url=?, api_key=?, model=?, - max_tokens=?, temperature=?, updated_at=CURRENT_TIMESTAMP WHERE id=? + max_tokens=?, temperature=?, enable_thinking=?, enable_vision=?, updated_at=CURRENT_TIMESTAMP WHERE id=? ''', (data['name'], data['provider'], data['api_url'], data['api_key'], - data['model'], data.get('max_tokens', 2048), data.get('temperature', 0.7), id)) + data['model'], data.get('max_tokens', 2048), data.get('temperature', 0.7), + data.get('enable_thinking', 0), data.get('enable_vision', 0), id)) conn.commit() conn.close() return jsonify({'success': True}) diff --git a/works/ai-chat-app/www/admin.js b/works/ai-chat-app/www/admin.js index 6ecafd3..a215d65 100644 --- a/works/ai-chat-app/www/admin.js +++ b/works/ai-chat-app/www/admin.js @@ -414,8 +414,9 @@ async function loadLLMPage(content) {