diff --git a/utils/__pycache__/file_io.cpython-312.pyc b/utils/__pycache__/file_io.cpython-312.pyc index 7838b7d..fd6f2e9 100644 Binary files a/utils/__pycache__/file_io.cpython-312.pyc and b/utils/__pycache__/file_io.cpython-312.pyc differ diff --git a/utils/tweet/__pycache__/content_judger.cpython-312.pyc b/utils/tweet/__pycache__/content_judger.cpython-312.pyc index 90270b5..04be3aa 100644 Binary files a/utils/tweet/__pycache__/content_judger.cpython-312.pyc and b/utils/tweet/__pycache__/content_judger.cpython-312.pyc differ diff --git a/utils/tweet/content_judger.py b/utils/tweet/content_judger.py index fe8e37b..1c72c43 100644 --- a/utils/tweet/content_judger.py +++ b/utils/tweet/content_judger.py @@ -7,7 +7,7 @@ import logging import json -from typing import Dict, Any +from typing import Dict, Any, Union from core.ai import AIAgent from core.config import ConfigManager, GenerateTopicConfig, GenerateContentConfig @@ -36,12 +36,12 @@ class ContentJudger: self.prompt_builder = JudgerPromptBuilder(config_manager) self.output_manager = output_manager - async def judge_content(self, generated_content: str, topic: Dict[str, Any]) -> Dict[str, Any]: + async def judge_content(self, generated_content: Union[str, Dict[str, Any]], topic: Dict[str, Any]) -> Dict[str, Any]: """ 调用AI审核生成的内容 Args: - generated_content: 已生成的原始内容(JSON字符串格式) + generated_content: 已生成的原始内容(JSON字符串或字典对象) topic: 与内容相关的原始选题字典 Returns: @@ -62,10 +62,16 @@ class ContentJudger: else: logger.warning("从原始内容提取标签失败") + # 将字典转换为JSON字符串,以便在提示中使用 + if isinstance(generated_content, dict): + generated_content_str = json.dumps(generated_content, ensure_ascii=False, indent=2) + else: + generated_content_str = str(generated_content) + # 1. 构建提示 system_prompt = self.prompt_builder.get_system_prompt() user_prompt = self.prompt_builder.build_user_prompt( - generated_content=generated_content, + generated_content=generated_content_str, topic=topic )