fix: 普通对话使用后台配置的LLM

This commit is contained in:
2026-04-28 22:53:22 +08:00
parent 53db607b8d
commit 7b985fbaff

View File

@@ -1345,10 +1345,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_config_id = chat_config['llm_config_id'] if chat_config else 1
cursor.execute('SELECT * FROM llm_configs WHERE id=?', (llm_config_id,))
llm = cursor.fetchone()
# 如果找不到对应的LLM配置使用默认的
if not llm:
cursor.execute('SELECT * FROM llm_configs WHERE is_default=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()]
@@ -1361,10 +1371,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()}