修复了judeger的响应问题
This commit is contained in:
parent
ae6801a7d5
commit
157d3348a6
Binary file not shown.
Binary file not shown.
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
from typing import Dict, Any
|
from typing import Dict, Any, Union
|
||||||
|
|
||||||
from core.ai import AIAgent
|
from core.ai import AIAgent
|
||||||
from core.config import ConfigManager, GenerateTopicConfig, GenerateContentConfig
|
from core.config import ConfigManager, GenerateTopicConfig, GenerateContentConfig
|
||||||
@ -36,12 +36,12 @@ class ContentJudger:
|
|||||||
self.prompt_builder = JudgerPromptBuilder(config_manager)
|
self.prompt_builder = JudgerPromptBuilder(config_manager)
|
||||||
self.output_manager = output_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审核生成的内容
|
调用AI审核生成的内容
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
generated_content: 已生成的原始内容(JSON字符串格式)
|
generated_content: 已生成的原始内容(JSON字符串或字典对象)
|
||||||
topic: 与内容相关的原始选题字典
|
topic: 与内容相关的原始选题字典
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -62,10 +62,16 @@ class ContentJudger:
|
|||||||
else:
|
else:
|
||||||
logger.warning("从原始内容提取标签失败")
|
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. 构建提示
|
# 1. 构建提示
|
||||||
system_prompt = self.prompt_builder.get_system_prompt()
|
system_prompt = self.prompt_builder.get_system_prompt()
|
||||||
user_prompt = self.prompt_builder.build_user_prompt(
|
user_prompt = self.prompt_builder.build_user_prompt(
|
||||||
generated_content=generated_content,
|
generated_content=generated_content_str,
|
||||||
topic=topic
|
topic=topic
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user