|
|
|
@ -110,8 +110,10 @@ class DeepseekSpider(AbstractAiSeoSpider): |
|
|
|
return |
|
|
|
# 读取流式数据 |
|
|
|
response_text = '' |
|
|
|
thinking_text = '' |
|
|
|
search_result_lists = list() |
|
|
|
start_content = False |
|
|
|
start_thinking = False |
|
|
|
stream = await response.body() |
|
|
|
body = stream.decode('utf-8') |
|
|
|
datas = body.split("\n\n") |
|
|
|
@ -147,6 +149,21 @@ class DeepseekSpider(AbstractAiSeoSpider): |
|
|
|
# self.ai_answer.search_result = ai_search_result_list |
|
|
|
# self.search_result_count = len(self.ai_answer.search_result) |
|
|
|
continue |
|
|
|
|
|
|
|
# 是否开始返回深度思考数据 |
|
|
|
if data.get('p', '') == 'response/thinking_content': |
|
|
|
start_thinking = True |
|
|
|
if data.get('p', '') == 'response/thinking_elapsed_secs': |
|
|
|
start_thinking = False |
|
|
|
if start_thinking: |
|
|
|
# 获取深度思考回复 |
|
|
|
value = data.get('v', None) |
|
|
|
if isinstance(value, dict): |
|
|
|
continue |
|
|
|
if value is None: |
|
|
|
target = 'choices.0.delta.content' |
|
|
|
value = glom(data, target, default="") |
|
|
|
thinking_text = thinking_text + str(value) |
|
|
|
# 是否开始返回回复数据 |
|
|
|
if data.get('p', '') == 'response/content': |
|
|
|
start_content = True |
|
|
|
@ -185,4 +202,5 @@ class DeepseekSpider(AbstractAiSeoSpider): |
|
|
|
self.search_result_count = len(self.ai_answer.search_result) |
|
|
|
logger.debug(response_text) |
|
|
|
self.ai_answer.answer = response_text |
|
|
|
self.ai_answer.thinking = thinking_text |
|
|
|
self.completed_event.set() |