fix: API返回对话配置选择的LLM能力而非默认LLM

- /api/config 根据chat_config.llm_config_id获取对应LLM配置
- 解决用户选择有视觉能力的LLM但前端不显示上传图片按钮的问题
- 如果找不到对应LLM,回退到默认LLM配置
This commit is contained in:
2026-04-29 16:33:30 +08:00
parent d75f537df5
commit da71f99db4

View File

@@ -955,7 +955,17 @@ def get_frontend_config():
conn = get_db()
cursor = conn.cursor()
# 获取默认LLM配置
# 获取默认对话配置
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()
@@ -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()}