From 661741e25daa9e7ca368d4980925dad0220827de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=B0=E5=BF=97=E5=AE=8F?= Date: Tue, 4 Mar 2025 17:08:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20API=20URL=20=E5=A4=84=E7=90=86=E8=A7=84?= =?UTF-8?q?=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 3 ++- tests/test_stream.py | 12 ++++-------- web_server.py | 14 ++++++-------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/requirements.txt b/requirements.txt index 7799faf..c77a82b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/tests/test_stream.py b/tests/test_stream.py index 7d01ada..defe173 100644 --- a/tests/test_stream.py +++ b/tests/test_stream.py @@ -50,14 +50,10 @@ def test_api_stream(): logger.error("API Key未配置,无法进行测试") return - # 标准化API URL - if not (api_url.endswith('/chat/completions') or api_url.endswith('/v1/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: - api_url = f"{api_url}/v1/chat/completions" + if api_url.endswith('/'): + api_url = f"{api_url}chat/completions" + else: + api_url = f"{api_url}/v1/chat/completions" logger.debug(f"标准化后的API URL: {api_url}") diff --git a/web_server.py b/web_server.py index b30aaf2..46796ee 100644 --- a/web_server.py +++ b/web_server.py @@ -138,14 +138,12 @@ def test_api_connection(): return jsonify({'error': '请提供API Key'}), 400 # 构建API URL - test_url = api_url - 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" - else: - test_url = f"{api_url}/v1/chat/completions" + if api_url.endswith('/'): + test_url = f"{api_url}chat/completions" + else: + test_url = f"{api_url}/v1/chat/completions" + + logger.debug(f"完整API测试URL: {test_url}")