From da71f99db44cfdb90b7110b8ade57bbd1efe0028 Mon Sep 17 00:00:00 2001 From: hubian <908234780@qq.com> Date: Wed, 29 Apr 2026 16:33:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20API=E8=BF=94=E5=9B=9E=E5=AF=B9=E8=AF=9D?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=80=89=E6=8B=A9=E7=9A=84LLM=E8=83=BD?= =?UTF-8?q?=E5=8A=9B=E8=80=8C=E9=9D=9E=E9=BB=98=E8=AE=A4LLM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - /api/config 根据chat_config.llm_config_id获取对应LLM配置 - 解决用户选择有视觉能力的LLM但前端不显示上传图片按钮的问题 - 如果找不到对应LLM,回退到默认LLM配置 --- backend/app.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/backend/app.py b/backend/app.py index 236b847..bba4d57 100644 --- a/backend/app.py +++ b/backend/app.py @@ -955,10 +955,20 @@ def get_frontend_config(): conn = get_db() cursor = conn.cursor() - # 获取默认LLM配置 - cursor.execute('SELECT * FROM llm_configs WHERE is_default=1 AND is_active=1 LIMIT 1') + # 获取默认对话配置 + cursor.execute('SELECT * FROM chat_configs WHERE is_default=1 LIMIT 1') + chat_config = cursor.fetchone() + + # 根据对话配置的llm_config_id获取LLM配置(而不是默认LLM) + llm_config_id = chat_config['llm_config_id'] if chat_config else 1 + cursor.execute('SELECT * FROM llm_configs WHERE id=? AND is_active=1', (llm_config_id,)) llm = cursor.fetchone() + # 如果没找到,使用默认LLM + if not llm: + cursor.execute('SELECT * FROM llm_configs WHERE is_default=1 AND is_active=1 LIMIT 1') + llm = cursor.fetchone() + # 获取默认工具配置(搜索等) cursor.execute('SELECT * FROM tool_configs WHERE is_default=1 AND is_active=1') tools = [dict(row) for row in cursor.fetchall()] @@ -967,10 +977,6 @@ def get_frontend_config(): cursor.execute('SELECT agent_id, name, avatar, category, description, system_prompt, heat, tags, enable_tools FROM agents WHERE is_online=1 AND is_active=1') agents = [dict(row) for row in cursor.fetchall()] - # 获取默认对话配置 - cursor.execute('SELECT * FROM chat_configs WHERE is_default=1 LIMIT 1') - chat_config = cursor.fetchone() - # 获取系统配置 cursor.execute('SELECT key, value FROM system_configs') system = {row['key']: row['value'] for row in cursor.fetchall()}