fix(i18n): replace remaining hardcoded language directives in LLM prompts
- oasis_profile_generator: replace hardcoded "使用中文" with dynamic get_language_instruction() - ontology_generator: remove hardcoded "(中文)" from schema annotation - report_agent: replace Chinese-specific language consistency rules with language-neutral ones - zep_tools: dynamically select quote style based on locale
This commit is contained in:
parent
fbaa3dbbeb
commit
f75c6487b3
|
|
@ -20,6 +20,7 @@ from zep_cloud.client import Zep
|
||||||
|
|
||||||
from ..config import Config
|
from ..config import Config
|
||||||
from ..utils.logger import get_logger
|
from ..utils.logger import get_logger
|
||||||
|
from ..utils.locale import get_language_instruction
|
||||||
from .zep_entity_reader import EntityNode, ZepEntityReader
|
from .zep_entity_reader import EntityNode, ZepEntityReader
|
||||||
|
|
||||||
logger = get_logger('mirofish.oasis_profile')
|
logger = get_logger('mirofish.oasis_profile')
|
||||||
|
|
@ -670,8 +671,8 @@ class OasisProfileGenerator:
|
||||||
|
|
||||||
def _get_system_prompt(self, is_individual: bool) -> str:
|
def _get_system_prompt(self, is_individual: bool) -> str:
|
||||||
"""获取系统提示词"""
|
"""获取系统提示词"""
|
||||||
base_prompt = "你是社交媒体用户画像生成专家。生成详细、真实的人设用于舆论模拟,最大程度还原已有现实情况。必须返回有效的JSON格式,所有字符串值不能包含未转义的换行符。使用中文。"
|
base_prompt = "你是社交媒体用户画像生成专家。生成详细、真实的人设用于舆论模拟,最大程度还原已有现实情况。必须返回有效的JSON格式,所有字符串值不能包含未转义的换行符。"
|
||||||
return base_prompt
|
return f"{base_prompt}\n\n{get_language_instruction()}"
|
||||||
|
|
||||||
def _build_individual_persona_prompt(
|
def _build_individual_persona_prompt(
|
||||||
self,
|
self,
|
||||||
|
|
@ -717,7 +718,7 @@ class OasisProfileGenerator:
|
||||||
重要:
|
重要:
|
||||||
- 所有字段值必须是字符串或数字,不要使用换行符
|
- 所有字段值必须是字符串或数字,不要使用换行符
|
||||||
- persona必须是一段连贯的文字描述
|
- persona必须是一段连贯的文字描述
|
||||||
- 使用中文(除了gender字段必须用英文male/female)
|
- {get_language_instruction()} (gender字段必须用英文male/female)
|
||||||
- 内容要与实体信息保持一致
|
- 内容要与实体信息保持一致
|
||||||
- age必须是有效的整数,gender必须是"male"或"female"
|
- age必须是有效的整数,gender必须是"male"或"female"
|
||||||
"""
|
"""
|
||||||
|
|
@ -766,7 +767,7 @@ class OasisProfileGenerator:
|
||||||
重要:
|
重要:
|
||||||
- 所有字段值必须是字符串或数字,不允许null值
|
- 所有字段值必须是字符串或数字,不允许null值
|
||||||
- persona必须是一段连贯的文字描述,不要使用换行符
|
- persona必须是一段连贯的文字描述,不要使用换行符
|
||||||
- 使用中文(除了gender字段必须用英文"other")
|
- {get_language_instruction()} (gender字段必须用英文"other")
|
||||||
- age必须是整数30,gender必须是字符串"other"
|
- age必须是整数30,gender必须是字符串"other"
|
||||||
- 机构账号发言要符合其身份定位"""
|
- 机构账号发言要符合其身份定位"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ ONTOLOGY_SYSTEM_PROMPT = """你是一个专业的知识图谱本体设计专家
|
||||||
"attributes": []
|
"attributes": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"analysis_summary": "对文本内容的简要分析说明(中文)"
|
"analysis_summary": "对文本内容的简要分析说明"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -653,9 +653,9 @@ SECTION_SYSTEM_PROMPT_TEMPLATE = """\
|
||||||
- 这些引用是模拟预测的核心证据
|
- 这些引用是模拟预测的核心证据
|
||||||
|
|
||||||
3. 【语言一致性 - 引用内容必须翻译为报告语言】
|
3. 【语言一致性 - 引用内容必须翻译为报告语言】
|
||||||
- 工具返回的内容可能包含英文或中英文混杂的表述
|
- 工具返回的内容可能包含与报告语言不同的表述
|
||||||
- 如果模拟需求和材料原文是中文的,报告必须全部使用中文撰写
|
- 报告必须全部使用与用户指定语言一致的语言撰写
|
||||||
- 当你引用工具返回的英文或中英混杂内容时,必须将其翻译为流畅的中文后再写入报告
|
- 当你引用工具返回的其他语言内容时,必须将其翻译为报告语言后再写入
|
||||||
- 翻译时保持原意不变,确保表述自然通顺
|
- 翻译时保持原意不变,确保表述自然通顺
|
||||||
- 这一规则同时适用于正文和引用块(> 格式)中的内容
|
- 这一规则同时适用于正文和引用块(> 格式)中的内容
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ from zep_cloud.client import Zep
|
||||||
from ..config import Config
|
from ..config import Config
|
||||||
from ..utils.logger import get_logger
|
from ..utils.logger import get_logger
|
||||||
from ..utils.llm_client import LLMClient
|
from ..utils.llm_client import LLMClient
|
||||||
|
from ..utils.locale import get_locale
|
||||||
from ..utils.zep_paging import fetch_all_nodes, fetch_all_edges
|
from ..utils.zep_paging import fetch_all_nodes, fetch_all_edges
|
||||||
|
|
||||||
logger = get_logger('mirofish.zep_tools')
|
logger = get_logger('mirofish.zep_tools')
|
||||||
|
|
@ -1695,7 +1696,8 @@ class ZepToolsService:
|
||||||
for interview in interviews:
|
for interview in interviews:
|
||||||
interview_texts.append(f"【{interview.agent_name}({interview.agent_role})】\n{interview.response[:500]}")
|
interview_texts.append(f"【{interview.agent_name}({interview.agent_role})】\n{interview.response[:500]}")
|
||||||
|
|
||||||
system_prompt = """你是一个专业的新闻编辑。请根据多位受访者的回答,生成一份采访摘要。
|
quote_instruction = "引用受访者原话时使用中文引号「」" if get_locale() == 'zh' else 'Use quotation marks "" when quoting interviewees'
|
||||||
|
system_prompt = f"""你是一个专业的新闻编辑。请根据多位受访者的回答,生成一份采访摘要。
|
||||||
|
|
||||||
摘要要求:
|
摘要要求:
|
||||||
1. 提炼各方主要观点
|
1. 提炼各方主要观点
|
||||||
|
|
@ -1708,7 +1710,7 @@ class ZepToolsService:
|
||||||
- 使用纯文本段落,用空行分隔不同部分
|
- 使用纯文本段落,用空行分隔不同部分
|
||||||
- 不要使用Markdown标题(如#、##、###)
|
- 不要使用Markdown标题(如#、##、###)
|
||||||
- 不要使用分割线(如---、***)
|
- 不要使用分割线(如---、***)
|
||||||
- 引用受访者原话时使用中文引号「」
|
- {quote_instruction}
|
||||||
- 可以使用**加粗**标记关键词,但不要使用其他Markdown语法"""
|
- 可以使用**加粗**标记关键词,但不要使用其他Markdown语法"""
|
||||||
|
|
||||||
user_prompt = f"""采访主题:{interview_requirement}
|
user_prompt = f"""采访主题:{interview_requirement}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue