Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d4b1f3dfff | |||
| dc2e822ea9 |
@@ -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()}
|
||||
|
||||
@@ -140,7 +140,13 @@ async function loadBackendConfig() {
|
||||
|
||||
// 将后台 LLM 配置赋值到 CONFIG
|
||||
if (backendConfig.llm) {
|
||||
CONFIG.apiUrl = backendConfig.llm.api_url;
|
||||
// 自动拼接 /chat/completions(如果不是完整URL)
|
||||
let apiUrl = backendConfig.llm.api_url;
|
||||
if (apiUrl && !apiUrl.includes('/chat/completions')) {
|
||||
// 确保URL以/结尾再拼接,或直接拼接
|
||||
apiUrl = apiUrl.endsWith('/') ? apiUrl + 'chat/completions' : apiUrl + '/chat/completions';
|
||||
}
|
||||
CONFIG.apiUrl = apiUrl;
|
||||
CONFIG.apiKey = backendConfig.llm.api_key;
|
||||
CONFIG.model = backendConfig.llm.model;
|
||||
CONFIG.maxTokens = backendConfig.llm.max_tokens || 2048;
|
||||
|
||||
Reference in New Issue
Block a user