Skip to content

Commit d9fed9f

Browse files
authored
Merge pull request #28 from iidamie/dev
fix: Dev to Main
2 parents 03205fa + ff954be commit d9fed9f

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## [1.2.8-beta.1](https://github.com/iidamie/deepseek2api/compare/v1.2.7...v1.2.8-beta.1) (2025-02-20)
2+
3+
4+
### Bug Fixes
5+
6+
* 优化 POW 生成机制 ([286f3bd](https://github.com/iidamie/deepseek2api/commit/286f3bdab4ddeed302784dd6c148d72c040d0202))
7+
* 优化异常处理 ([66ce0ae](https://github.com/iidamie/deepseek2api/commit/66ce0ae9c02af83fe256e6d01821980be4ba2304))
8+
* 优化异常处理 ([755b20f](https://github.com/iidamie/deepseek2api/commit/755b20f59ceaa70182db24024d1118e16c24de73))
9+
* 优化异常处理 ([ef9073b](https://github.com/iidamie/deepseek2api/commit/ef9073b6c8a57b84902705780ca54f52746b6a21))
10+
111
## [1.2.7](https://github.com/iidamie/deepseek2api/compare/v1.2.6...v1.2.7) (2025-02-19)
212

313

app.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ def init_account_queue():
8989
DEEPSEEK_COMPLETION_URL = f"https://{DEEPSEEK_HOST}/api/v0/chat/completion"
9090
BASE_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)

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.7
1+
1.2.8-beta.1

0 commit comments

Comments
 (0)