feat(i18n): replace remaining Chinese in config generator and profile generator

Also update simulation prompts to be locale-neutral for timezone/schedule.
This commit is contained in:
ghostubborn 2026-04-01 17:19:12 +08:00
parent 7c07237544
commit 0e55e4cf6b
4 changed files with 107 additions and 15 deletions

View file

@ -1022,7 +1022,7 @@ class OasisProfileGenerator:
output_lines = [
f"\n{separator}",
f"[已生成] {entity_name} ({entity_type})",
t('progress.profileGenerated', name=entity_name, type=entity_type),
f"{separator}",
f"用户名: {profile.user_name}",
f"",

View file

@ -297,13 +297,13 @@ class SimulationConfigGenerator:
num_entities = len(entities)
time_config_result = self._generate_time_config(context, num_entities)
time_config = self._parse_time_config(time_config_result, num_entities)
reasoning_parts.append(f"时间配置: {time_config_result.get('reasoning', '成功')}")
reasoning_parts.append(f"{t('progress.timeConfigLabel')}: {time_config_result.get('reasoning', t('common.success'))}")
# ========== 步骤2: 生成事件配置 ==========
report_progress(2, t('progress.generatingEventConfig'))
event_config_result = self._generate_event_config(context, simulation_requirement, entities)
event_config = self._parse_event_config(event_config_result)
reasoning_parts.append(f"事件配置: {event_config_result.get('reasoning', '成功')}")
reasoning_parts.append(f"{t('progress.eventConfigLabel')}: {event_config_result.get('reasoning', t('common.success'))}")
# ========== 步骤3-N: 分批生成Agent配置 ==========
all_agent_configs = []
@ -325,13 +325,13 @@ class SimulationConfigGenerator:
)
all_agent_configs.extend(batch_configs)
reasoning_parts.append(f"Agent配置: 成功生成 {len(all_agent_configs)}")
reasoning_parts.append(t('progress.agentConfigResult', count=len(all_agent_configs)))
# ========== 为初始帖子分配发布者 Agent ==========
logger.info("为初始帖子分配合适的发布者 Agent...")
event_config = self._assign_initial_post_agents(event_config, all_agent_configs)
assigned_count = len([p for p in event_config.initial_posts if p.get("poster_agent_id") is not None])
reasoning_parts.append(f"初始帖子分配: {assigned_count} 个帖子已分配发布者")
reasoning_parts.append(t('progress.postAssignResult', count=assigned_count))
# ========== 最后一步: 生成平台配置 ==========
report_progress(total_steps, t('progress.generatingPlatformConfig'))
@ -548,7 +548,7 @@ class SimulationConfigGenerator:
请生成时间配置JSON
### 基本原则(仅供参考,需根据具体事件和参与群体灵活调整):
- 用户群体为中国人需符合北京时间作息习惯
- 请根据模拟场景推断目标用户群体所在时区和作息习惯以下为东八区(UTC+8)的参考示例
- 凌晨0-5点几乎无人活动活跃度系数0.05
- 早上6-8点逐渐活跃活跃度系数0.4
- 工作时间9-18点中等活跃活跃度系数0.7
@ -585,7 +585,7 @@ class SimulationConfigGenerator:
- work_hours (int数组): 工作时段
- reasoning (string): 简要说明为什么这样配置"""
system_prompt = "你是社交媒体模拟专家。返回纯JSON格式时间配置需符合中国人作息习惯。"
system_prompt = "你是社交媒体模拟专家。返回纯JSON格式时间配置需符合模拟场景中目标用户群体的作息习惯。"
system_prompt = f"{system_prompt}\n\n{get_language_instruction()}"
try:
@ -841,7 +841,7 @@ class SimulationConfigGenerator:
## 任务
为每个实体生成活动配置注意
- **时间符合中国人作息**凌晨0-5点几乎不活动晚间19-22点最活跃
- **时间符合目标用户群体作息**以下为参考东八区请根据模拟场景调整
- **官方机构**University/GovernmentAgency活跃度低(0.1-0.3)工作时间(9-17)活动响应慢(60-240分钟)影响力高(2.5-3.0)
- **媒体**MediaOutlet活跃度中(0.4-0.6)全天活动(8-23)响应快(5-30分钟)影响力高(2.0-2.5)
- **个人**Student/Person/Alumni活跃度高(0.6-0.9)主要晚间活动(18-23)响应快(1-15分钟)影响力低(0.8-1.2)
@ -866,7 +866,7 @@ class SimulationConfigGenerator:
]
}}"""
system_prompt = "你是社交媒体行为分析专家。返回纯JSON配置需符合中国人作息习惯。"
system_prompt = "你是社交媒体行为分析专家。返回纯JSON配置需符合模拟场景中目标用户群体的作息习惯。"
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:

View file

@ -177,7 +177,7 @@
"generating": "Generating"
},
"step3": {
"startGenerateReport": "Generate Result Report",
"startGenerateReport": "Generate Report",
"generatingReport": "Starting...",
"waitingForActions": "Waiting for agent actions...",
"errorMissingSimId": "Error: missing simulationId",
@ -204,7 +204,7 @@
"checkStatusFailed": "Failed to check simulation status: {error}",
"forceStopSuccess": "Simulation force stopped",
"forceStopFailed": "Force stop failed: {error}",
"startGenerateReportBtn": "Generate Result Report",
"startGenerateReportBtn": "Generate Report",
"generatingReportBtn": "Starting..."
},
"step4": {
@ -404,7 +404,12 @@
"generatingEventConfig": "Generating event config and hot topics...",
"generatingAgentConfig": "Generating agent config ({start}-{end}/{total})...",
"generatingPlatformConfig": "Generating platform config...",
"zepSearchQuery": "All information, activities, events, relationships and background about {name}"
"zepSearchQuery": "All information, activities, events, relationships and background about {name}",
"timeConfigLabel": "Time Config",
"eventConfigLabel": "Event Config",
"agentConfigResult": "Agent Config: {count} generated",
"postAssignResult": "Post Assignment: {count} posts assigned",
"profileGenerated": "[Generated] {name} ({type})"
},
"log": {
"preparingGoBack": "Preparing to return to Step 2, closing simulation...",
@ -476,6 +481,47 @@
"configSummaryPostsAlt": " └─ Initial posts: {count}",
"configGenerating": "Config generating, polling...",
"loadConfigFailed": "Failed to load config: {error}",
"step2Init": "Step 2 environment setup initialized"
"step2Init": "Step 2 environment setup initialized",
"step3Init": "Step 3 simulation run initialized",
"startingDualSim": "Starting dual-platform parallel simulation...",
"setMaxRounds": "Max simulation rounds set to: {rounds}",
"graphMemoryUpdateEnabled": "Dynamic graph memory update enabled",
"oldSimCleared": "✓ Old simulation logs cleared, restarting simulation",
"engineStarted": "✓ Simulation engine started successfully",
"startFailed": "✗ Start failed: {error}",
"startException": "✗ Start error: {error}",
"stoppingSim": "Stopping simulation...",
"simStoppedSuccess": "✓ Simulation stopped",
"stopFailed": "Stop failed: {error}",
"stopException": "Stop error: {error}",
"allPlatformsCompleted": "✓ All platform simulations have ended",
"simCompleted": "✓ Simulation completed",
"reportRequestSent": "Report generation request sent, please wait...",
"startingReportGen": "Starting report generation...",
"reportGenTaskStarted": "✓ Report generation task started: {reportId}",
"reportGenFailed": "✗ Failed to start report generation: {error}",
"reportGenException": "✗ Report generation error: {error}",
"step5Init": "Step 5 deep interaction initialized",
"selectChatTarget": "Selected chat target: {name}",
"sendFailed": "Send failed: {error}",
"sendToReportAgent": "Sent to Report Agent: {message}...",
"reportAgentReplied": "Report Agent replied",
"sendToAgent": "Sent to {name}: {message}...",
"agentReplied": "{name} replied",
"sendSurvey": "Sending survey to {count} targets...",
"receivedReplies": "Received {count} replies",
"surveySendFailed": "Survey send failed: {error}",
"loadReportData": "Loading report data: {id}",
"loadReportFailed": "Failed to load report: {error}",
"reportDataLoaded": "Report data loaded",
"loadReportLogFailed": "Failed to load report logs: {error}",
"loadedProfiles": "Loaded {count} simulated individuals",
"loadProfilesFailed": "Failed to load simulated individuals: {error}",
"interactionViewInit": "InteractionView initialized",
"reportViewInit": "ReportView initialized",
"getReportInfoFailed": "Failed to get report info: {error}",
"enterStep": "Entering Step {step}: {name}",
"returnToStep": "Returning to Step {step}: {name}",
"customSimRounds": "Custom simulation rounds: {rounds} rounds"
}
}

View file

@ -404,7 +404,12 @@
"generatingEventConfig": "生成事件配置和热点话题...",
"generatingAgentConfig": "生成Agent配置 ({start}-{end}/{total})...",
"generatingPlatformConfig": "生成平台配置...",
"zepSearchQuery": "关于{name}的所有信息、活动、事件、关系和背景"
"zepSearchQuery": "关于{name}的所有信息、活动、事件、关系和背景",
"timeConfigLabel": "时间配置",
"eventConfigLabel": "事件配置",
"agentConfigResult": "Agent配置: 成功生成 {count} 个",
"postAssignResult": "初始帖子分配: {count} 个帖子已分配发布者",
"profileGenerated": "[已生成] {name} ({type})"
},
"log": {
"preparingGoBack": "准备返回 Step 2正在关闭模拟...",
@ -476,6 +481,47 @@
"configSummaryPostsAlt": " └─ 初始帖子: {count}条",
"configGenerating": "配置生成中,开始轮询等待...",
"loadConfigFailed": "加载配置失败: {error}",
"step2Init": "Step2 环境搭建初始化"
"step2Init": "Step2 环境搭建初始化",
"step3Init": "Step3 模拟运行初始化",
"startingDualSim": "正在启动双平台并行模拟...",
"setMaxRounds": "设置最大模拟轮数: {rounds}",
"graphMemoryUpdateEnabled": "已开启动态图谱更新模式",
"oldSimCleared": "✓ 已清理旧的模拟日志,重新开始模拟",
"engineStarted": "✓ 模拟引擎启动成功",
"startFailed": "✗ 启动失败: {error}",
"startException": "✗ 启动异常: {error}",
"stoppingSim": "正在停止模拟...",
"simStoppedSuccess": "✓ 模拟已停止",
"stopFailed": "停止失败: {error}",
"stopException": "停止异常: {error}",
"allPlatformsCompleted": "✓ 检测到所有平台模拟已结束",
"simCompleted": "✓ 模拟已完成",
"reportRequestSent": "报告生成请求已发送,请稍候...",
"startingReportGen": "正在启动报告生成...",
"reportGenTaskStarted": "✓ 报告生成任务已启动: {reportId}",
"reportGenFailed": "✗ 启动报告生成失败: {error}",
"reportGenException": "✗ 启动报告生成异常: {error}",
"step5Init": "Step5 深度互动初始化",
"selectChatTarget": "选择对话对象: {name}",
"sendFailed": "发送失败: {error}",
"sendToReportAgent": "向 Report Agent 发送: {message}...",
"reportAgentReplied": "Report Agent 已回复",
"sendToAgent": "向 {name} 发送: {message}...",
"agentReplied": "{name} 已回复",
"sendSurvey": "发送问卷给 {count} 个对象...",
"receivedReplies": "收到 {count} 条回复",
"surveySendFailed": "问卷发送失败: {error}",
"loadReportData": "加载报告数据: {id}",
"loadReportFailed": "加载报告失败: {error}",
"reportDataLoaded": "报告数据加载完成",
"loadReportLogFailed": "加载报告日志失败: {error}",
"loadedProfiles": "加载了 {count} 个模拟个体",
"loadProfilesFailed": "加载模拟个体失败: {error}",
"interactionViewInit": "InteractionView 初始化",
"reportViewInit": "ReportView 初始化",
"getReportInfoFailed": "获取报告信息失败: {error}",
"enterStep": "进入 Step {step}: {name}",
"returnToStep": "返回 Step {step}: {name}",
"customSimRounds": "自定义模拟轮数: {rounds} 轮"
}
}