From e7d701b226b734b14f286192793b295e577fa633 Mon Sep 17 00:00:00 2001 From: yym68686 Date: Thu, 1 Aug 2024 18:15:41 +0800 Subject: [PATCH] Fix error handling when API returns empty --- utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utils.py b/utils.py index 9a1866c..858e483 100644 --- a/utils.py +++ b/utils.py @@ -105,8 +105,7 @@ async def new_generator(): return new_generator() except StopAsyncIteration: - # 处理生成器为空的情况 - return async_generator(["data: {'error': 'No data returned'}\n\n"]) + raise HTTPException(status_code=status_code, detail="data: {'error': 'No data returned'}") def post_all_models(token, config, api_list): all_models = []