File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
astrbot/core/provider/sources Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -130,15 +130,22 @@ async def rerank(
130130 request_url = self ._get_endpoint ()
131131
132132 async with client .post (request_url , json = payload ) as response :
133- response_data = await response .json ()
134- logger .debug (f"[NVIDIA Rerank] API Response: { response_data } " )
135-
136133 if response .status != 200 :
137- error_detail = response_data .get (
138- "detail" , response_data .get ("message" , "Unknown Error" )
139- )
134+ try :
135+ response_data = await response .json ()
136+ error_detail = response_data .get (
137+ "detail" , response_data .get ("message" , "Unknown Error" )
138+ )
139+
140+ except Exception :
141+ error_detail = await response .text ()
142+ response_data = {"message" : error_detail }
143+
144+ logger .error (f"[NVIDIA Rerank] API Error Response: { response_data } " )
140145 raise Exception (f"HTTP { response .status } - { error_detail } " )
141146
147+ response_data = await response .json ()
148+ logger .debug (f"[NVIDIA Rerank] API Response: { response_data } " )
142149 results = self ._parse_results (response_data , top_n )
143150 self ._log_usage (response_data )
144151 return results
You can’t perform that action at this time.
0 commit comments