fix: 统一前后端API_URL处理规则: /结尾忽略v1版本,#结尾强制使用输入地址。 优化公告区域位置

This commit is contained in:
兰志宏
2025-03-04 18:24:37 +08:00
parent 661741e25d
commit 0847e557fb
6 changed files with 282 additions and 42 deletions

View File

@@ -6,6 +6,11 @@ import os
import traceback
import requests
from logger import get_logger
from utils.api_utils import APIUtils
# 加载环境变量
from dotenv import load_dotenv
load_dotenv()
# 获取日志器
logger = get_logger()
@@ -138,13 +143,7 @@ def test_api_connection():
return jsonify({'error': '请提供API Key'}), 400
# 构建API URL
if api_url.endswith('/'):
test_url = f"{api_url}chat/completions"
else:
test_url = f"{api_url}/v1/chat/completions"
test_url = APIUtils.format_api_url(api_url)
logger.debug(f"完整API测试URL: {test_url}")
# 发送测试请求