From da2490ec310577b9b4fa897d88cb031dd4ef12a2 Mon Sep 17 00:00:00 2001 From: ghostubborn Date: Wed, 1 Apr 2026 16:41:22 +0800 Subject: [PATCH] fix(i18n): protect JSON field values from language instruction in config generator Ensure poster_type stays PascalCase English and stance stays English enum values regardless of language setting. Only natural language fields follow the user's language preference. --- backend/app/services/simulation_config_generator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/app/services/simulation_config_generator.py b/backend/app/services/simulation_config_generator.py index 328369de..3b57abc9 100644 --- a/backend/app/services/simulation_config_generator.py +++ b/backend/app/services/simulation_config_generator.py @@ -703,7 +703,7 @@ class SimulationConfigGenerator: }}""" system_prompt = "你是舆论分析专家。返回纯JSON格式。注意 poster_type 必须精确匹配可用实体类型。" - system_prompt = f"{system_prompt}\n\n{get_language_instruction()}" + system_prompt = f"{system_prompt}\n\n{get_language_instruction()}\nIMPORTANT: The 'poster_type' field value MUST be in English PascalCase exactly matching the available entity types. Only 'content', 'narrative_direction', 'hot_topics' and 'reasoning' fields should use the specified language." try: return self._call_llm_with_retry(prompt, system_prompt) @@ -867,7 +867,7 @@ class SimulationConfigGenerator: }}""" system_prompt = "你是社交媒体行为分析专家。返回纯JSON,配置需符合中国人作息习惯。" - system_prompt = f"{system_prompt}\n\n{get_language_instruction()}" + system_prompt = f"{system_prompt}\n\n{get_language_instruction()}\nIMPORTANT: The 'stance' field value MUST be one of the English strings: 'supportive', 'opposing', 'neutral', 'observer'. All JSON field names and numeric values must remain unchanged. Only natural language text fields should use the specified language." try: result = self._call_llm_with_retry(prompt, system_prompt)