feat: Implement DeepSeek V3 streaming response parsing to differentiate thinking and text content, and update Safari impersonation.

This commit is contained in:
CJACK
2026-02-01 04:25:24 +08:00
parent 70cd51309f
commit fc2175474b
3 changed files with 278 additions and 78 deletions

View File

@@ -231,7 +231,7 @@ async def test_account_api(account: dict, model: str = "deepseek-chat", message:
DEEPSEEK_COMPLETION_URL,
headers=completion_headers,
json=payload,
impersonate="safari15_4",
impersonate="safari15_3",
timeout=60,
stream=True,
)
@@ -277,9 +277,37 @@ async def test_account_api(account: dict, model: str = "deepseek-chat", message:
else:
content_parts.append(v_value)
elif isinstance(v_value, list):
# DeepSeek V3 嵌套列表格式处理
for item in v_value:
if not isinstance(item, dict):
continue
if item.get("p") == "status" and item.get("v") == "FINISHED":
break
item_p = item.get("p", "")
item_v = item.get("v")
if item_p == "response/search_status":
continue
itype = "thinking" if "thinking" in item_p else "text"
# 处理不同的 v 类型
if isinstance(item_v, str) and item_v:
if itype == "thinking":
thinking_parts.append(item_v)
else:
content_parts.append(item_v)
elif isinstance(item_v, list):
# 内层可能是 [{"content": "text", ...}] 格式
for inner in item_v:
if isinstance(inner, dict):
content = inner.get("content", "")
if content:
if itype == "thinking":
thinking_parts.append(content)
else:
content_parts.append(content)
except:
continue