fix: API URL 处理规则
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
--index-url https://pypi.tuna.tsinghua.edu.cn/simple
|
# 本地打包使用国内镜像源加速下载, 默认不使用,影响github actions
|
||||||
|
# --index-url https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
|
|
||||||
# 基础科学计算和数据处理库
|
# 基础科学计算和数据处理库
|
||||||
numpy==2.1.2
|
numpy==2.1.2
|
||||||
|
|||||||
@@ -50,12 +50,8 @@ def test_api_stream():
|
|||||||
logger.error("API Key未配置,无法进行测试")
|
logger.error("API Key未配置,无法进行测试")
|
||||||
return
|
return
|
||||||
|
|
||||||
# 标准化API URL
|
if api_url.endswith('/'):
|
||||||
if not (api_url.endswith('/chat/completions') or api_url.endswith('/v1/chat/completions')):
|
api_url = f"{api_url}chat/completions"
|
||||||
if api_url.endswith('/v1'):
|
|
||||||
api_url = f"{api_url}/chat/completions"
|
|
||||||
elif api_url.endswith('/'):
|
|
||||||
api_url = f"{api_url}v1/chat/completions"
|
|
||||||
else:
|
else:
|
||||||
api_url = f"{api_url}/v1/chat/completions"
|
api_url = f"{api_url}/v1/chat/completions"
|
||||||
|
|
||||||
|
|||||||
@@ -138,15 +138,13 @@ def test_api_connection():
|
|||||||
return jsonify({'error': '请提供API Key'}), 400
|
return jsonify({'error': '请提供API Key'}), 400
|
||||||
|
|
||||||
# 构建API URL
|
# 构建API URL
|
||||||
test_url = api_url
|
if api_url.endswith('/'):
|
||||||
if not (api_url.endswith('/chat/completions') or api_url.endswith('/v1/chat/completions')):
|
|
||||||
if api_url.endswith('/v1'):
|
|
||||||
test_url = f"{api_url}/chat/completions"
|
|
||||||
elif api_url.endswith('/'):
|
|
||||||
test_url = f"{api_url}chat/completions"
|
test_url = f"{api_url}chat/completions"
|
||||||
else:
|
else:
|
||||||
test_url = f"{api_url}/v1/chat/completions"
|
test_url = f"{api_url}/v1/chat/completions"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
logger.debug(f"完整API测试URL: {test_url}")
|
logger.debug(f"完整API测试URL: {test_url}")
|
||||||
|
|
||||||
# 发送测试请求
|
# 发送测试请求
|
||||||
|
|||||||
Reference in New Issue
Block a user