From 87be34487685029864e8bfa492d6953fd1296bb3 Mon Sep 17 00:00:00 2001 From: zhurunlin Date: Tue, 1 Jul 2025 20:37:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=80=9A=E4=B9=89=E6=94=B9?= =?UTF-8?q?=E7=89=88=E5=90=8Ebody=E4=B8=BA=E7=A9=BA=E7=9A=84=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spiders/ai_seo/tongyi.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/spiders/ai_seo/tongyi.py b/spiders/ai_seo/tongyi.py index fcd4774..a9a6f1e 100644 --- a/spiders/ai_seo/tongyi.py +++ b/spiders/ai_seo/tongyi.py @@ -91,6 +91,7 @@ class TongyiSpider(AbstractAiSeoSpider): stream = await response.body() response_text = stream.decode('utf-8') datas = response_text.split("\n") + # print("datas:",datas) # 合规数据转成字典 for data_str in datas: if not data_str or data_str == 'data: [DONE]': @@ -111,9 +112,9 @@ class TongyiSpider(AbstractAiSeoSpider): if content_type == 'plugin': logger.debug(f"获取到联网搜索结果") if self.think: - search_result_list = glom(content, 'content.pluginResult', default=[]) + search_result_list = glom(content, 'content.pluginResult.links', default=[]) else: - search_result_list = glom(content, 'content.pluginResult.-1.search_results', default=[]) + search_result_list = glom(content, 'content.pluginResult.links.-1.search_results', default=[]) # for search_result in search_result_list: # url = search_result.get('url', '') # title = search_result.get('title', '') @@ -124,9 +125,9 @@ class TongyiSpider(AbstractAiSeoSpider): # ai_search_result_list.append( # AiSearchResult(title=title, url=url, body=body, host_name=host_name, publish_time=publish_time) # ) - if content_type == 'text': + if content_type == 'think': logger.debug(f'获取到ai回复结果') - answer = content.get('content', '') + answer = content.get('content', '').get('content', '') logger.debug(f"ai回复: {answer}") self.ai_answer.answer = answer pattern = r'ty-reference]\((\d+)\)' @@ -143,7 +144,7 @@ class TongyiSpider(AbstractAiSeoSpider): is_referenced = "0" logger.debug(f"ai参考资料: [{host_name}]{title}({url})") ai_search_result_list.append( - AiSearchResult(title=title, url=url, body=body, host_name=host_name, publish_time=publish_time,is_referenced=is_referenced) + AiSearchResult(title=title, url=url, body=body, host_name=host_name, publish_time=publish_time , is_referenced=is_referenced) ) if ai_search_result_list: self.ai_answer.search_result = ai_search_result_list