|
|
@ -107,7 +107,7 @@ class ToolsLoad: |
|
|
resp.raise_for_status() |
|
|
resp.raise_for_status() |
|
|
return resp.json() |
|
|
return resp.json() |
|
|
|
|
|
|
|
|
@retry('更新任务状态', 5) |
|
|
|
|
|
|
|
|
@retry('更新任务状态', 1) |
|
|
def update_task_status(self, task_id, status): |
|
|
def update_task_status(self, task_id, status): |
|
|
url = f"{TASK_URL}/api/third/updateTask?app_id=aa65700299848d6f21b969dbc9f6cf7c&secret=5588071d36f0bc61af849c311a03f2c4" |
|
|
url = f"{TASK_URL}/api/third/updateTask?app_id=aa65700299848d6f21b969dbc9f6cf7c&secret=5588071d36f0bc61af849c311a03f2c4" |
|
|
payload = json.dumps({ |
|
|
payload = json.dumps({ |
|
|
@ -210,7 +210,8 @@ class DeepSeekChatClient: |
|
|
logger.info(f"PoW求解结果: {res}") |
|
|
logger.info(f"PoW求解结果: {res}") |
|
|
return res.get("answer") |
|
|
return res.get("answer") |
|
|
|
|
|
|
|
|
def pow_to_header_value(self, algorithm: str, challenge: str, salt: str, answer: int, signature: str, target_path: str) -> str: |
|
|
|
|
|
|
|
|
def pow_to_header_value(self, algorithm: str, challenge: str, salt: str, answer: int, signature: str, |
|
|
|
|
|
target_path: str) -> str: |
|
|
"""组装x-ds-pow-response头""" |
|
|
"""组装x-ds-pow-response头""" |
|
|
payload = { |
|
|
payload = { |
|
|
'algorithm': algorithm, |
|
|
'algorithm': algorithm, |
|
|
@ -298,7 +299,7 @@ class DeepSeekChatClient: |
|
|
if not raw: |
|
|
if not raw: |
|
|
continue |
|
|
continue |
|
|
line = raw.strip() |
|
|
line = raw.strip() |
|
|
# print(line,end=' ') |
|
|
|
|
|
|
|
|
# print(line) |
|
|
data_str = line[6:] if line.startswith("data: ") else line |
|
|
data_str = line[6:] if line.startswith("data: ") else line |
|
|
|
|
|
|
|
|
if data_str == "[DONE]": |
|
|
if data_str == "[DONE]": |
|
|
@ -410,8 +411,8 @@ class Start: |
|
|
thinking_enabled=True, |
|
|
thinking_enabled=True, |
|
|
search_enabled=True, |
|
|
search_enabled=True, |
|
|
) |
|
|
) |
|
|
if 'answer' == '': |
|
|
|
|
|
print('异常结果',ai_search_result_list, answer, thinking) |
|
|
|
|
|
|
|
|
if thinking == '': |
|
|
|
|
|
print('异常结果', ai_search_result_list, answer, thinking) |
|
|
return False |
|
|
return False |
|
|
|
|
|
|
|
|
# 构建结果 |
|
|
# 构建结果 |
|
|
@ -449,7 +450,7 @@ class Start: |
|
|
|
|
|
|
|
|
# token失效处理 |
|
|
# token失效处理 |
|
|
if "Authorization Failed (invalid token)" in error_msg: |
|
|
if "Authorization Failed (invalid token)" in error_msg: |
|
|
self.tools.update_session(cookie_id, "full_datetime", "2") |
|
|
|
|
|
|
|
|
self.tools.update_session(cookie_id, "", "2") |
|
|
|
|
|
|
|
|
# 更新任务状态为失败 |
|
|
# 更新任务状态为失败 |
|
|
if task_id: |
|
|
if task_id: |
|
|
@ -476,7 +477,6 @@ class Start: |
|
|
return True |
|
|
return True |
|
|
self.process_task(task_data) |
|
|
self.process_task(task_data) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return True |
|
|
return True |
|
|
|
|
|
|
|
|
def run(self): |
|
|
def run(self): |
|
|
@ -491,4 +491,4 @@ class Start: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
if __name__ == "__main__": |
|
|
Start().run() |
|
|
|
|
|
|
|
|
Start().run() |