@@ -89,12 +89,12 @@ def init_account_queue():
8989DEEPSEEK_COMPLETION_URL = f"https://{ DEEPSEEK_HOST } /api/v0/chat/completion"
9090BASE_HEADERS = {
9191 'Host' : "chat.deepseek.com" ,
92- 'User-Agent' : "DeepSeek/1.0.11 Android/35" ,
92+ 'User-Agent' : "DeepSeek/1.0.13 Android/35" ,
9393 'Accept' : "application/json" ,
9494 'Accept-Encoding' : "gzip" ,
9595 'Content-Type' : "application/json" ,
9696 'x-client-platform' : "android" ,
97- 'x-client-version' : "1.0.11 " ,
97+ 'x-client-version' : "1.0.13 " ,
9898 'x-client-locale' : "zh_CN" ,
9999 'accept-charset' : "UTF-8"
100100}
@@ -207,7 +207,7 @@ def determine_mode_and_token(request: Request):
207207 request .state .tried_accounts = [] # 初始化已尝试账号
208208 selected_account = choose_new_account ()
209209 if not selected_account :
210- raise HTTPException (status_code = 500 , detail = "No accounts configured or all accounts are busy." )
210+ raise HTTPException (status_code = 429 , detail = "No accounts configured or all accounts are busy." )
211211 if not selected_account .get ("token" , "" ).strip ():
212212 try :
213213 login_deepseek_via_account (selected_account )
@@ -430,7 +430,7 @@ def get_pow_response(request: Request, max_attempts=3):
430430 "target_path" : challenge ["target_path" ]
431431 }
432432 pow_str = json .dumps (pow_dict , separators = (',' , ':' ), ensure_ascii = False )
433- encoded = base64 .b64encode (pow_str .encode ("utf-8" )).decode ("utf-8" ).rstrip ("=" )
433+ encoded = base64 .b64encode (pow_str .encode ("utf-8" )).decode ("utf-8" ).rstrip ()
434434 resp .close ()
435435 return encoded
436436 else :
@@ -633,7 +633,7 @@ def process_data():
633633 line = raw_line .decode ("utf-8" )
634634 except Exception as e :
635635 logger .warning (f"[sse_stream] 解码失败: { e } " )
636- continue
636+ raise HTTPException ( status_code = 500 , detail = "Server is error." )
637637 if not line :
638638 continue
639639 if line .startswith ("data:" ):
@@ -652,6 +652,10 @@ def process_data():
652652 result_queue .put (chunk ) # 将数据放入队列
653653 except Exception as e :
654654 logger .warning (f"[sse_stream] 无法解析: { data_str } , 错误: { e } " )
655+ raise HTTPException (status_code = 500 , detail = "Server is error." )
656+ except Exception as e :
657+ logger .warning (f"[sse_stream] 错误: { e } " )
658+ raise HTTPException (status_code = 500 , detail = "Server is error." )
655659 finally :
656660 deepseek_resp .close ()
657661
@@ -752,7 +756,7 @@ def collect_data():
752756 line = raw_line .decode ("utf-8" )
753757 except Exception as e :
754758 logger .warning (f"[chat_completions] 解码失败: { e } " )
755- continue
759+ raise HTTPException ( status_code = 500 , detail = "Server is error." )
756760 if not line :
757761 continue
758762 if line .startswith ("data:" ):
@@ -778,8 +782,11 @@ def collect_data():
778782 elif ctype == "text" :
779783 text_list .append (ctext )
780784 except Exception as e :
781- logger .warning (f"[chat_completions] 无法解析: { data_str } , 错误: { e } " )
782- continue
785+ logger .warning (f"[collect_data] 无法解析: { data_str } , 错误: { e } " )
786+ raise HTTPException (status_code = 500 , detail = "Server is error." )
787+ except Exception as e :
788+ logger .warning (f"[collect_data] 错误: { e } " )
789+ raise HTTPException (status_code = 500 , detail = "Server is error." )
783790 finally :
784791 deepseek_resp .close ()
785792 final_reasoning = "" .join (think_list )
0 commit comments