From 429c267ffc019d93bb66d0cbc6f1ef92c196fe85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E5=95=A6b=E6=A2=A6?= <1715109585@qq.com> Date: Sun, 15 Sep 2024 14:07:13 +0800 Subject: [PATCH] Update httpxHelp.py --- app/provider/httpxHelp.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/provider/httpxHelp.py b/app/provider/httpxHelp.py index 1410737..ca45b4e 100644 --- a/app/provider/httpxHelp.py +++ b/app/provider/httpxHelp.py @@ -18,13 +18,17 @@ async def raise_for_status(sendReady, response: httpx.Response): # print("raise_for_status", response.status_code) return response_content = await response.aread() + new_url = sendReady.get("url") + # 截取域名部分 + new_url = new_url.split("//")[-1] + error_data = { "error": "上游服务器出现错误", "response_body": response_content.decode("utf-8"), "status_code": response.status_code, "model": sendReady.get("model"), "body": sendReady.get("body"), - "url": sendReady.get("url"), + "url": new_url, } raise HTTPException(status_code=500, detail=error_data) @@ -101,7 +105,6 @@ async def get_api_data_cache(sendReady) -> AsyncGenerator[str, None]: else: logger.info(f"没有命中缓存{cache_md5}") - cacheData = "" try: if sendReady["stream"]: