From 94e57778403fb4c51031c8702171c601a2310b66 Mon Sep 17 00:00:00 2001 From: SXP-Simon Date: Thu, 11 Sep 2025 21:38:37 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20(llm=5Fanalyzer)=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=92=8C=E7=94=A8=E6=88=B7=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _conf_schema.json | 14 +++++++------- src/analysis/llm_analyzer.py | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/_conf_schema.json b/_conf_schema.json index cf5aef8..2b05a01 100644 --- a/_conf_schema.json +++ b/_conf_schema.json @@ -61,19 +61,19 @@ "type": "int", "description": "最大话题数量", "default": 5, - "hint": "分析报告中显示的最大话题数量" + "hint": "分析报告中显示的最大话题数量,依赖于 LLM 输出的格式化信息质量,模型越好结果越好,可能出现数量不匹配。" }, "max_user_titles": { "type": "int", "description": "最大用户称号数量", "default": 8, - "hint": "分析报告中显示的最大用户称号数量" + "hint": "分析报告中显示的最大用户称号数量,依赖于 LLM 输出的格式化信息质量,模型越好结果越好,可能出现数量不匹配。" }, "max_golden_quotes": { "type": "int", "description": "最大金句数量", "default": 5, - "hint": "分析报告中显示的最大金句数量" + "hint": "分析报告中显示的最大金句数量,依赖于 LLM 输出的格式化信息质量,模型越好结果越好,可能出现数量不匹配。" }, "max_query_rounds": { "type": "int", @@ -84,8 +84,8 @@ "llm_timeout": { "type": "int", "description": "LLM 请求超时时间(秒)", - "default": 30, - "hint": "LLM 单次请求的超时时间,单位秒。可根据模型响应速度适当调整,增大可减少超时失败,但会占用更多等待时间。" + "default": 100, + "hint": "LLM 单次请求的超时时间,单位秒。可根据模型响应速度适当调整,增大可减少超时失败,但会占用更多等待时间,思考模型可以根据情况进行调大。" }, "llm_retries": { "type": "int", @@ -109,13 +109,13 @@ "type": "string", "description": "自定义 LLM 服务 Base URL (选填)", "default": "", - "hint": "自定义 LLM 服务的基础请求地址,例如 https://api.example.com/v1/chat 。留空则使用 Astrbot 统一内置提供商。" + "hint": "自定义 LLM 服务的基础请求地址,例如 https://openrouter.ai/api/v1/chat/completions 。留空则使用 Astrbot 统一内置提供商。" }, "custom_model_name": { "type": "string", "description": "自定义 LLM 模型名称 (选填)", "default": "", - "hint": "自定义服务所使用的模型名称,例如 gpt-4 或自定义模型标识。留空则使用 Astrbot 统一内置提供商。" + "hint": "自定义服务所使用的模型名称,例如 gpt-4 、deepseek/deepseek-r1:free 或自定义模型标识,由于自定义情况复杂,无法给出有效的参数参考,需要根据实际情况例如日志报错判断。留空则使用 Astrbot 统一内置提供商。" }, "pdf_output_dir": { "type": "string", diff --git a/src/analysis/llm_analyzer.py b/src/analysis/llm_analyzer.py index 11fdde7..327cce1 100644 --- a/src/analysis/llm_analyzer.py +++ b/src/analysis/llm_analyzer.py @@ -421,14 +421,19 @@ class LLMAnalyzer: else: result_text = str(response) + # debug日志:打印原始响应 + logger.debug(f"用户称号分析原始响应: {result_text[:500]}...") + # 尝试解析JSON try: json_match = re.search(r'\[.*\]', result_text, re.DOTALL) if json_match: + logger.debug(f"用户称号分析JSON原文: {json_match.group()[:500]}...") titles_data = json.loads(json_match.group()) return [UserTitle(**title) for title in titles_data], token_usage - except: - pass + except Exception as e: + logger.error(f"用户称号分析JSON解析失败: {e}") + logger.debug(f"原始响应: {result_text}") return [], token_usage @@ -524,14 +529,19 @@ class LLMAnalyzer: else: result_text = str(response) + # debug日志:打印原始响应 + logger.debug(f"金句分析原始响应: {result_text[:500]}...") + # 尝试解析JSON try: json_match = re.search(r'\[.*\]', result_text, re.DOTALL) if json_match: + logger.debug(f"金句分析JSON原文: {json_match.group()[:500]}...") quotes_data = json.loads(json_match.group()) return [GoldenQuote(**quote) for quote in quotes_data[:max_golden_quotes]], token_usage - except: - pass + except Exception as e: + logger.error(f"金句分析JSON解析失败: {e}") + logger.debug(f"原始响应: {result_text}") return [], token_usage