diff --git a/backend/app/api/graph.py b/backend/app/api/graph.py
index 12ff1ba..39dba18 100644
--- a/backend/app/api/graph.py
+++ b/backend/app/api/graph.py
@@ -42,9 +42,9 @@ def get_project(project_id: str):
if not project:
return jsonify({
"success": False,
- "error": f"项目不存在: {project_id}"
+ "error": f"Project not found: {project_id}"
}), 404
-
+
return jsonify({
"success": True,
"data": project.to_dict()
@@ -58,7 +58,7 @@ def list_projects():
"""
limit = request.args.get('limit', 50, type=int)
projects = ProjectManager.list_projects(limit=limit)
-
+
return jsonify({
"success": True,
"data": [p.to_dict() for p in projects],
@@ -72,16 +72,16 @@ def delete_project(project_id: str):
删除项目
"""
success = ProjectManager.delete_project(project_id)
-
+
if not success:
return jsonify({
"success": False,
- "error": f"项目不存在或删除失败: {project_id}"
+ "error": f"Project not found or delete failed: {project_id}"
}), 404
-
+
return jsonify({
"success": True,
- "message": f"项目已删除: {project_id}"
+ "message": f"Project deleted: {project_id}"
})
@@ -91,11 +91,11 @@ def reset_project(project_id: str):
重置项目状态(用于重新构建图谱)
"""
project = ProjectManager.get_project(project_id)
-
+
if not project:
return jsonify({
"success": False,
- "error": f"项目不存在: {project_id}"
+ "error": f"Project not found: {project_id}"
}), 404
# 重置到本体已生成状态
@@ -111,7 +111,7 @@ def reset_project(project_id: str):
return jsonify({
"success": True,
- "message": f"项目已重置: {project_id}",
+ "message": f"Project reset: {project_id}",
"data": project.to_dict()
})
@@ -160,7 +160,7 @@ def generate_ontology():
if not simulation_requirement:
return jsonify({
"success": False,
- "error": "请提供模拟需求描述 (simulation_requirement)"
+ "error": "Please provide simulation_requirement"
}), 400
# 获取上传的文件
@@ -168,7 +168,7 @@ def generate_ontology():
if not uploaded_files or all(not f.filename for f in uploaded_files):
return jsonify({
"success": False,
- "error": "请至少上传一个文档文件"
+ "error": "Please upload at least one document file"
}), 400
# 创建项目
@@ -203,7 +203,7 @@ def generate_ontology():
ProjectManager.delete_project(project.project_id)
return jsonify({
"success": False,
- "error": "没有成功处理任何文档,请检查文件格式"
+ "error": "No documents were processed successfully, please check file format"
}), 400
# 保存提取的文本
@@ -285,12 +285,12 @@ def build_graph():
# 检查配置
errors = []
if not Config.ZEP_API_KEY:
- errors.append("ZEP_API_KEY未配置")
+ errors.append("ZEP_API_KEY is not configured")
if errors:
logger.error(f"配置错误: {errors}")
return jsonify({
"success": False,
- "error": "配置错误: " + "; ".join(errors)
+ "error": "Configuration error: " + "; ".join(errors)
}), 500
# 解析请求
@@ -301,7 +301,7 @@ def build_graph():
if not project_id:
return jsonify({
"success": False,
- "error": "请提供 project_id"
+ "error": "Please provide project_id"
}), 400
# 获取项目
@@ -309,22 +309,22 @@ def build_graph():
if not project:
return jsonify({
"success": False,
- "error": f"项目不存在: {project_id}"
+ "error": f"Project not found: {project_id}"
}), 404
-
+
# 检查项目状态
force = data.get('force', False) # 强制重新构建
-
+
if project.status == ProjectStatus.CREATED:
return jsonify({
"success": False,
- "error": "项目尚未生成本体,请先调用 /ontology/generate"
+ "error": "Ontology not yet generated for this project. Please call /ontology/generate first"
}), 400
if project.status == ProjectStatus.GRAPH_BUILDING and not force:
return jsonify({
"success": False,
- "error": "图谱正在构建中,请勿重复提交。如需强制重建,请添加 force: true",
+ "error": "Graph is currently being built. To force rebuild, add force: true",
"task_id": project.graph_build_task_id
}), 400
@@ -349,7 +349,7 @@ def build_graph():
if not text:
return jsonify({
"success": False,
- "error": "未找到提取的文本内容"
+ "error": "Extracted text content not found"
}), 400
# 获取本体
@@ -357,12 +357,12 @@ def build_graph():
if not ontology:
return jsonify({
"success": False,
- "error": "未找到本体定义"
+ "error": "Ontology definition not found"
}), 400
# 创建异步任务
task_manager = TaskManager()
- task_id = task_manager.create_task(f"构建图谱: {graph_name}")
+ task_id = task_manager.create_task(f"Build graph: {graph_name}")
logger.info(f"创建图谱构建任务: task_id={task_id}, project_id={project_id}")
# 更新项目状态
@@ -378,7 +378,7 @@ def build_graph():
task_manager.update_task(
task_id,
status=TaskStatus.PROCESSING,
- message="初始化图谱构建服务..."
+ message="Initializing graph build service..."
)
# 创建图谱构建服务
@@ -387,7 +387,7 @@ def build_graph():
# 分块
task_manager.update_task(
task_id,
- message="文本分块中...",
+ message="Splitting text into chunks...",
progress=5
)
chunks = TextProcessor.split_text(
@@ -400,7 +400,7 @@ def build_graph():
# 创建图谱
task_manager.update_task(
task_id,
- message="创建Zep图谱...",
+ message="Creating Zep graph...",
progress=10
)
graph_id = builder.create_graph(name=graph_name)
@@ -412,7 +412,7 @@ def build_graph():
# 设置本体
task_manager.update_task(
task_id,
- message="设置本体定义...",
+ message="Setting ontology definition...",
progress=15
)
builder.set_ontology(graph_id, ontology)
@@ -428,7 +428,7 @@ def build_graph():
task_manager.update_task(
task_id,
- message=f"开始添加 {total_chunks} 个文本块...",
+ message=f"Adding {total_chunks} text chunks...",
progress=15
)
@@ -442,7 +442,7 @@ def build_graph():
# 等待Zep处理完成(查询每个episode的processed状态)
task_manager.update_task(
task_id,
- message="等待Zep处理数据...",
+ message="Waiting for Zep to process data...",
progress=55
)
@@ -459,7 +459,7 @@ def build_graph():
# 获取图谱数据
task_manager.update_task(
task_id,
- message="获取图谱数据...",
+ message="Retrieving graph data...",
progress=95
)
graph_data = builder.get_graph_data(graph_id)
@@ -476,7 +476,7 @@ def build_graph():
task_manager.update_task(
task_id,
status=TaskStatus.COMPLETED,
- message="图谱构建完成",
+ message="Graph construction complete",
progress=100,
result={
"project_id": project_id,
@@ -499,7 +499,7 @@ def build_graph():
task_manager.update_task(
task_id,
status=TaskStatus.FAILED,
- message=f"构建失败: {str(e)}",
+ message=f"Build failed: {str(e)}",
error=traceback.format_exc()
)
@@ -512,7 +512,7 @@ def build_graph():
"data": {
"project_id": project_id,
"task_id": task_id,
- "message": "图谱构建任务已启动,请通过 /task/{task_id} 查询进度"
+ "message": "Graph build task started. Query progress via /task/{task_id}"
}
})
@@ -536,7 +536,7 @@ def get_task(task_id: str):
if not task:
return jsonify({
"success": False,
- "error": f"任务不存在: {task_id}"
+ "error": f"Task not found: {task_id}"
}), 404
return jsonify({
@@ -570,17 +570,17 @@ def get_graph_data(graph_id: str):
if not Config.ZEP_API_KEY:
return jsonify({
"success": False,
- "error": "ZEP_API_KEY未配置"
+ "error": "ZEP_API_KEY is not configured"
}), 500
-
+
builder = GraphBuilderService(api_key=Config.ZEP_API_KEY)
graph_data = builder.get_graph_data(graph_id)
-
+
return jsonify({
"success": True,
"data": graph_data
})
-
+
except Exception as e:
return jsonify({
"success": False,
@@ -598,7 +598,7 @@ def delete_graph(graph_id: str):
if not Config.ZEP_API_KEY:
return jsonify({
"success": False,
- "error": "ZEP_API_KEY未配置"
+ "error": "ZEP_API_KEY is not configured"
}), 500
builder = GraphBuilderService(api_key=Config.ZEP_API_KEY)
@@ -606,7 +606,7 @@ def delete_graph(graph_id: str):
return jsonify({
"success": True,
- "message": f"图谱已删除: {graph_id}"
+ "message": f"Graph deleted: {graph_id}"
})
except Exception as e:
diff --git a/backend/app/api/report.py b/backend/app/api/report.py
index e05c73c..a9ec958 100644
--- a/backend/app/api/report.py
+++ b/backend/app/api/report.py
@@ -53,7 +53,7 @@ def generate_report():
if not simulation_id:
return jsonify({
"success": False,
- "error": "请提供 simulation_id"
+ "error": "Please provide simulation_id"
}), 400
force_regenerate = data.get('force_regenerate', False)
@@ -65,9 +65,9 @@ def generate_report():
if not state:
return jsonify({
"success": False,
- "error": f"模拟不存在: {simulation_id}"
+ "error": f"Simulation not found: {simulation_id}"
}), 404
-
+
# 检查是否已有报告
if not force_regenerate:
existing_report = ReportManager.get_report_by_simulation(simulation_id)
@@ -78,7 +78,7 @@ def generate_report():
"simulation_id": simulation_id,
"report_id": existing_report.report_id,
"status": "completed",
- "message": "报告已存在",
+ "message": "Report already exists",
"already_generated": True
}
})
@@ -88,21 +88,21 @@ def generate_report():
if not project:
return jsonify({
"success": False,
- "error": f"项目不存在: {state.project_id}"
+ "error": f"Project not found: {state.project_id}"
}), 404
graph_id = state.graph_id or project.graph_id
if not graph_id:
return jsonify({
"success": False,
- "error": "缺少图谱ID,请确保已构建图谱"
+ "error": "Missing graph ID, please ensure graph has been built"
}), 400
simulation_requirement = project.simulation_requirement
if not simulation_requirement:
return jsonify({
"success": False,
- "error": "缺少模拟需求描述"
+ "error": "Missing simulation requirement description"
}), 400
# 提前生成 report_id,以便立即返回给前端
@@ -127,7 +127,7 @@ def generate_report():
task_id,
status=TaskStatus.PROCESSING,
progress=0,
- message="初始化Report Agent..."
+ message="Initializing Report Agent..."
)
# 创建Report Agent
@@ -164,7 +164,7 @@ def generate_report():
}
)
else:
- task_manager.fail_task(task_id, report.error or "报告生成失败")
+ task_manager.fail_task(task_id, report.error or "Report generation failed")
except Exception as e:
logger.error(f"报告生成失败: {str(e)}")
@@ -181,7 +181,7 @@ def generate_report():
"report_id": report_id,
"task_id": task_id,
"status": "generating",
- "message": "报告生成任务已启动,请通过 /api/report/generate/status 查询进度",
+ "message": "Report generation task started. Query progress via /api/report/generate/status",
"already_generated": False
}
})
@@ -234,7 +234,7 @@ def get_generate_status():
"report_id": existing_report.report_id,
"status": "completed",
"progress": 100,
- "message": "报告已生成",
+ "message": "Report generated",
"already_completed": True
}
})
@@ -242,7 +242,7 @@ def get_generate_status():
if not task_id:
return jsonify({
"success": False,
- "error": "请提供 task_id 或 simulation_id"
+ "error": "Please provide task_id or simulation_id"
}), 400
task_manager = TaskManager()
@@ -251,7 +251,7 @@ def get_generate_status():
if not task:
return jsonify({
"success": False,
- "error": f"任务不存在: {task_id}"
+ "error": f"Task not found: {task_id}"
}), 404
return jsonify({
@@ -294,7 +294,7 @@ def get_report(report_id: str):
if not report:
return jsonify({
"success": False,
- "error": f"报告不存在: {report_id}"
+ "error": f"Report not found: {report_id}"
}), 404
return jsonify({
@@ -403,7 +403,7 @@ def download_report(report_id: str):
if not report:
return jsonify({
"success": False,
- "error": f"报告不存在: {report_id}"
+ "error": f"Report not found: {report_id}"
}), 404
md_path = ReportManager._get_report_markdown_path(report_id)
@@ -445,12 +445,12 @@ def delete_report(report_id: str):
if not success:
return jsonify({
"success": False,
- "error": f"报告不存在: {report_id}"
+ "error": f"Report not found: {report_id}"
}), 404
-
+
return jsonify({
"success": True,
- "message": f"报告已删除: {report_id}"
+ "message": f"Report deleted: {report_id}"
})
except Exception as e:
@@ -501,13 +501,13 @@ def chat_with_report_agent():
if not simulation_id:
return jsonify({
"success": False,
- "error": "请提供 simulation_id"
+ "error": "Please provide simulation_id"
}), 400
-
+
if not message:
return jsonify({
"success": False,
- "error": "请提供 message"
+ "error": "Please provide message"
}), 400
# 获取模拟和项目信息
@@ -517,21 +517,21 @@ def chat_with_report_agent():
if not state:
return jsonify({
"success": False,
- "error": f"模拟不存在: {simulation_id}"
+ "error": f"Simulation not found: {simulation_id}"
}), 404
-
+
project = ProjectManager.get_project(state.project_id)
if not project:
return jsonify({
"success": False,
- "error": f"项目不存在: {state.project_id}"
+ "error": f"Project not found: {state.project_id}"
}), 404
graph_id = state.graph_id or project.graph_id
if not graph_id:
return jsonify({
"success": False,
- "error": "缺少图谱ID"
+ "error": "Missing graph ID"
}), 400
simulation_requirement = project.simulation_requirement or ""
@@ -585,7 +585,7 @@ def get_report_progress(report_id: str):
if not progress:
return jsonify({
"success": False,
- "error": f"报告不存在或进度信息不可用: {report_id}"
+ "error": f"Report not found or progress unavailable: {report_id}"
}), 404
return jsonify({
@@ -673,7 +673,7 @@ def get_single_section(report_id: str, section_index: int):
if not os.path.exists(section_path):
return jsonify({
"success": False,
- "error": f"章节不存在: section_{section_index:02d}.md"
+ "error": f"Section not found: section_{section_index:02d}.md"
}), 404
with open(section_path, 'r', encoding='utf-8') as f:
@@ -949,7 +949,7 @@ def search_graph_tool():
if not graph_id or not query:
return jsonify({
"success": False,
- "error": "请提供 graph_id 和 query"
+ "error": "Please provide graph_id and query"
}), 400
from ..services.zep_tools import ZepToolsService
@@ -993,7 +993,7 @@ def get_graph_statistics_tool():
if not graph_id:
return jsonify({
"success": False,
- "error": "请提供 graph_id"
+ "error": "Please provide graph_id"
}), 400
from ..services.zep_tools import ZepToolsService
diff --git a/backend/app/api/simulation.py b/backend/app/api/simulation.py
index 3a0f681..568e7f0 100644
--- a/backend/app/api/simulation.py
+++ b/backend/app/api/simulation.py
@@ -21,7 +21,7 @@ logger = get_logger('mirofish.api.simulation')
# Interview prompt 优化前缀
# 添加此前缀可以避免Agent调用工具,直接用文本回复
-INTERVIEW_PROMPT_PREFIX = "结合你的人设、所有的过往记忆与行动,不调用任何工具直接用文本回复我:"
+INTERVIEW_PROMPT_PREFIX = "Based on your persona, all past memories and actions, respond directly with text without calling any tools: "
def optimize_interview_prompt(prompt: str) -> str:
@@ -59,7 +59,7 @@ def get_graph_entities(graph_id: str):
if not Config.ZEP_API_KEY:
return jsonify({
"success": False,
- "error": "ZEP_API_KEY未配置"
+ "error": "ZEP_API_KEY is not configured"
}), 500
entity_types_str = request.args.get('entity_types', '')
@@ -96,7 +96,7 @@ def get_entity_detail(graph_id: str, entity_uuid: str):
if not Config.ZEP_API_KEY:
return jsonify({
"success": False,
- "error": "ZEP_API_KEY未配置"
+ "error": "ZEP_API_KEY is not configured"
}), 500
reader = ZepEntityReader()
@@ -105,7 +105,7 @@ def get_entity_detail(graph_id: str, entity_uuid: str):
if not entity:
return jsonify({
"success": False,
- "error": f"实体不存在: {entity_uuid}"
+ "error": f"Entity not found: {entity_uuid}"
}), 404
return jsonify({
@@ -129,7 +129,7 @@ def get_entities_by_type(graph_id: str, entity_type: str):
if not Config.ZEP_API_KEY:
return jsonify({
"success": False,
- "error": "ZEP_API_KEY未配置"
+ "error": "ZEP_API_KEY is not configured"
}), 500
enrich = request.args.get('enrich', 'true').lower() == 'true'
@@ -197,21 +197,21 @@ def create_simulation():
if not project_id:
return jsonify({
"success": False,
- "error": "请提供 project_id"
+ "error": "Please provide project_id"
}), 400
project = ProjectManager.get_project(project_id)
if not project:
return jsonify({
"success": False,
- "error": f"项目不存在: {project_id}"
+ "error": f"Project not found: {project_id}"
}), 404
graph_id = data.get('graph_id') or project.graph_id
if not graph_id:
return jsonify({
"success": False,
- "error": "项目尚未构建图谱,请先调用 /api/graph/build"
+ "error": "Graph not yet built for this project. Please call /api/graph/build first"
}), 400
manager = SimulationManager()
@@ -259,7 +259,7 @@ def _check_simulation_prepared(simulation_id: str) -> tuple:
# 检查目录是否存在
if not os.path.exists(simulation_dir):
- return False, {"reason": "模拟目录不存在"}
+ return False, {"reason": "Simulation directory does not exist"}
# 必要文件列表(不包括脚本,脚本位于 backend/scripts/)
required_files = [
@@ -281,7 +281,7 @@ def _check_simulation_prepared(simulation_id: str) -> tuple:
if missing_files:
return False, {
- "reason": "缺少必要文件",
+ "reason": "Missing required files",
"missing_files": missing_files,
"existing_files": existing_files
}
@@ -346,13 +346,13 @@ def _check_simulation_prepared(simulation_id: str) -> tuple:
else:
logger.warning(f"模拟 {simulation_id} 检测结果: 未准备完成 (status={status}, config_generated={config_generated})")
return False, {
- "reason": f"状态不在已准备列表中或config_generated为false: status={status}, config_generated={config_generated}",
+ "reason": f"Status not in prepared list or config_generated is false: status={status}, config_generated={config_generated}",
"status": status,
"config_generated": config_generated
}
except Exception as e:
- return False, {"reason": f"读取状态文件失败: {str(e)}"}
+ return False, {"reason": f"Failed to read state file: {str(e)}"}
@simulation_bp.route('/prepare', methods=['POST'])
@@ -408,7 +408,7 @@ def prepare_simulation():
if not simulation_id:
return jsonify({
"success": False,
- "error": "请提供 simulation_id"
+ "error": "Please provide simulation_id"
}), 400
manager = SimulationManager()
@@ -417,7 +417,7 @@ def prepare_simulation():
if not state:
return jsonify({
"success": False,
- "error": f"模拟不存在: {simulation_id}"
+ "error": f"Simulation not found: {simulation_id}"
}), 404
# 检查是否强制重新生成
@@ -436,7 +436,7 @@ def prepare_simulation():
"data": {
"simulation_id": simulation_id,
"status": "ready",
- "message": "已有完成的准备工作,无需重复生成",
+ "message": "Preparation already completed, no need to regenerate",
"already_prepared": True,
"prepare_info": prepare_info
}
@@ -449,7 +449,7 @@ def prepare_simulation():
if not project:
return jsonify({
"success": False,
- "error": f"项目不存在: {state.project_id}"
+ "error": f"Project not found: {state.project_id}"
}), 404
# 获取模拟需求
@@ -457,7 +457,7 @@ def prepare_simulation():
if not simulation_requirement:
return jsonify({
"success": False,
- "error": "项目缺少模拟需求描述 (simulation_requirement)"
+ "error": "Project is missing simulation_requirement"
}), 400
# 获取文档文本
@@ -612,7 +612,7 @@ def prepare_simulation():
"simulation_id": simulation_id,
"task_id": task_id,
"status": "preparing",
- "message": "准备任务已启动,请通过 /api/simulation/prepare/status 查询进度",
+ "message": "Preparation task started. Query progress via /api/simulation/prepare/status",
"already_prepared": False,
"expected_entities_count": state.entities_count, # 预期的Agent总数
"entity_types": state.entity_types # 实体类型列表
@@ -680,7 +680,7 @@ def get_prepare_status():
"simulation_id": simulation_id,
"status": "ready",
"progress": 100,
- "message": "已有完成的准备工作",
+ "message": "Preparation already completed",
"already_prepared": True,
"prepare_info": prepare_info
}
@@ -696,13 +696,13 @@ def get_prepare_status():
"simulation_id": simulation_id,
"status": "not_started",
"progress": 0,
- "message": "尚未开始准备,请调用 /api/simulation/prepare 开始",
+ "message": "Preparation not yet started. Call /api/simulation/prepare to begin",
"already_prepared": False
}
})
return jsonify({
"success": False,
- "error": "请提供 task_id 或 simulation_id"
+ "error": "Please provide task_id or simulation_id"
}), 400
task_manager = TaskManager()
@@ -720,7 +720,7 @@ def get_prepare_status():
"task_id": task_id,
"status": "ready",
"progress": 100,
- "message": "任务已完成(准备工作已存在)",
+ "message": "Task completed (preparation already exists)",
"already_prepared": True,
"prepare_info": prepare_info
}
@@ -728,7 +728,7 @@ def get_prepare_status():
return jsonify({
"success": False,
- "error": f"任务不存在: {task_id}"
+ "error": f"Task not found: {task_id}"
}), 404
task_dict = task.to_dict()
@@ -757,7 +757,7 @@ def get_simulation(simulation_id: str):
if not state:
return jsonify({
"success": False,
- "error": f"模拟不存在: {simulation_id}"
+ "error": f"Simulation not found: {simulation_id}"
}), 404
result = state.to_dict()
@@ -1061,7 +1061,7 @@ def get_simulation_profiles_realtime(simulation_id: str):
if not os.path.exists(sim_dir):
return jsonify({
"success": False,
- "error": f"模拟不存在: {simulation_id}"
+ "error": f"Simulation not found: {simulation_id}"
}), 404
# 确定文件路径
@@ -1164,7 +1164,7 @@ def get_simulation_config_realtime(simulation_id: str):
if not os.path.exists(sim_dir):
return jsonify({
"success": False,
- "error": f"模拟不存在: {simulation_id}"
+ "error": f"Simulation not found: {simulation_id}"
}), 404
# 配置文件路径
@@ -1269,7 +1269,7 @@ def get_simulation_config(simulation_id: str):
if not config:
return jsonify({
"success": False,
- "error": f"模拟配置不存在,请先调用 /prepare 接口"
+ "error": f"Simulation config does not exist. Please call /prepare first"
}), 404
return jsonify({
@@ -1297,7 +1297,7 @@ def download_simulation_config(simulation_id: str):
if not os.path.exists(config_path):
return jsonify({
"success": False,
- "error": "配置文件不存在,请先调用 /prepare 接口"
+ "error": "Config file does not exist. Please call /prepare first"
}), 404
return send_file(
@@ -1341,7 +1341,7 @@ def download_simulation_script(script_name: str):
if script_name not in allowed_scripts:
return jsonify({
"success": False,
- "error": f"未知脚本: {script_name},可选: {allowed_scripts}"
+ "error": f"Unknown script: {script_name}, available: {allowed_scripts}"
}), 400
script_path = os.path.join(scripts_dir, script_name)
@@ -1349,7 +1349,7 @@ def download_simulation_script(script_name: str):
if not os.path.exists(script_path):
return jsonify({
"success": False,
- "error": f"脚本文件不存在: {script_name}"
+ "error": f"Script file not found: {script_name}"
}), 404
return send_file(
@@ -1389,7 +1389,7 @@ def generate_profiles():
if not graph_id:
return jsonify({
"success": False,
- "error": "请提供 graph_id"
+ "error": "Please provide graph_id"
}), 400
entity_types = data.get('entity_types')
@@ -1406,7 +1406,7 @@ def generate_profiles():
if filtered.filtered_count == 0:
return jsonify({
"success": False,
- "error": "没有找到符合条件的实体"
+ "error": "No matching entities found"
}), 400
generator = OasisProfileGenerator()
@@ -1491,7 +1491,7 @@ def start_simulation():
if not simulation_id:
return jsonify({
"success": False,
- "error": "请提供 simulation_id"
+ "error": "Please provide simulation_id"
}), 400
platform = data.get('platform', 'parallel')
@@ -1506,18 +1506,18 @@ def start_simulation():
if max_rounds <= 0:
return jsonify({
"success": False,
- "error": "max_rounds 必须是正整数"
+ "error": "max_rounds must be a positive integer"
}), 400
except (ValueError, TypeError):
return jsonify({
"success": False,
- "error": "max_rounds 必须是有效的整数"
+ "error": "max_rounds must be a valid integer"
}), 400
if platform not in ['twitter', 'reddit', 'parallel']:
return jsonify({
"success": False,
- "error": f"无效的平台类型: {platform},可选: twitter/reddit/parallel"
+ "error": f"Invalid platform type: {platform}, available: twitter/reddit/parallel"
}), 400
# 检查模拟是否已准备好
@@ -1527,7 +1527,7 @@ def start_simulation():
if not state:
return jsonify({
"success": False,
- "error": f"模拟不存在: {simulation_id}"
+ "error": f"Simulation not found: {simulation_id}"
}), 404
force_restarted = False
@@ -1554,7 +1554,7 @@ def start_simulation():
else:
return jsonify({
"success": False,
- "error": f"模拟正在运行中,请先调用 /stop 接口停止,或使用 force=true 强制重新开始"
+ "error": f"Simulation is already running. Call /stop first, or use force=true to force restart"
}), 400
# 如果是强制模式,清理运行日志
@@ -1573,7 +1573,7 @@ def start_simulation():
# 准备工作未完成
return jsonify({
"success": False,
- "error": f"模拟未准备好,当前状态: {state.status.value},请先调用 /prepare 接口"
+ "error": f"Simulation not ready. Current status: {state.status.value}. Please call /prepare first"
}), 400
# 获取图谱ID(用于图谱记忆更新)
@@ -1590,7 +1590,7 @@ def start_simulation():
if not graph_id:
return jsonify({
"success": False,
- "error": "启用图谱记忆更新需要有效的 graph_id,请确保项目已构建图谱"
+ "error": "Graph memory update requires a valid graph_id. Please ensure the project graph has been built"
}), 400
logger.info(f"启用图谱记忆更新: simulation_id={simulation_id}, graph_id={graph_id}")
@@ -1663,7 +1663,7 @@ def stop_simulation():
if not simulation_id:
return jsonify({
"success": False,
- "error": "请提供 simulation_id"
+ "error": "Please provide simulation_id"
}), 400
run_state = SimulationRunner.stop_simulation(simulation_id)
@@ -2011,7 +2011,7 @@ def get_simulation_posts(simulation_id: str):
"platform": platform,
"count": 0,
"posts": [],
- "message": "数据库不存在,模拟可能尚未运行"
+ "message": "Database does not exist, simulation may not have run yet"
}
})
@@ -2197,33 +2197,33 @@ def interview_agent():
if not simulation_id:
return jsonify({
"success": False,
- "error": "请提供 simulation_id"
+ "error": "Please provide simulation_id"
}), 400
if agent_id is None:
return jsonify({
"success": False,
- "error": "请提供 agent_id"
+ "error": "Please provide agent_id"
}), 400
if not prompt:
return jsonify({
"success": False,
- "error": "请提供 prompt(采访问题)"
+ "error": "Please provide prompt (interview question)"
}), 400
# 验证platform参数
if platform and platform not in ("twitter", "reddit"):
return jsonify({
"success": False,
- "error": "platform 参数只能是 'twitter' 或 'reddit'"
+ "error": "platform must be 'twitter' or 'reddit'"
}), 400
# 检查环境状态
if not SimulationRunner.check_env_alive(simulation_id):
return jsonify({
"success": False,
- "error": "模拟环境未运行或已关闭。请确保模拟已完成并进入等待命令模式。"
+ "error": "Simulation environment is not running or has been shut down. Please ensure simulation is complete and in command-waiting mode."
}), 400
# 优化prompt,添加前缀避免Agent调用工具
@@ -2251,7 +2251,7 @@ def interview_agent():
except TimeoutError as e:
return jsonify({
"success": False,
- "error": f"等待Interview响应超时: {str(e)}"
+ "error": f"Interview response timed out: {str(e)}"
}), 504
except Exception as e:
@@ -2318,20 +2318,20 @@ def interview_agents_batch():
if not simulation_id:
return jsonify({
"success": False,
- "error": "请提供 simulation_id"
+ "error": "Please provide simulation_id"
}), 400
if not interviews or not isinstance(interviews, list):
return jsonify({
"success": False,
- "error": "请提供 interviews(采访列表)"
+ "error": "Please provide interviews (interview list)"
}), 400
# 验证platform参数
if platform and platform not in ("twitter", "reddit"):
return jsonify({
"success": False,
- "error": "platform 参数只能是 'twitter' 或 'reddit'"
+ "error": "platform must be 'twitter' or 'reddit'"
}), 400
# 验证每个采访项
@@ -2339,26 +2339,26 @@ def interview_agents_batch():
if 'agent_id' not in interview:
return jsonify({
"success": False,
- "error": f"采访列表第{i+1}项缺少 agent_id"
+ "error": f"Interview item {i+1} is missing agent_id"
}), 400
if 'prompt' not in interview:
return jsonify({
"success": False,
- "error": f"采访列表第{i+1}项缺少 prompt"
+ "error": f"Interview item {i+1} is missing prompt"
}), 400
# 验证每项的platform(如果有)
item_platform = interview.get('platform')
if item_platform and item_platform not in ("twitter", "reddit"):
return jsonify({
"success": False,
- "error": f"采访列表第{i+1}项的platform只能是 'twitter' 或 'reddit'"
+ "error": f"Interview item {i+1}: platform must be 'twitter' or 'reddit'"
}), 400
# 检查环境状态
if not SimulationRunner.check_env_alive(simulation_id):
return jsonify({
"success": False,
- "error": "模拟环境未运行或已关闭。请确保模拟已完成并进入等待命令模式。"
+ "error": "Simulation environment is not running or has been shut down. Please ensure simulation is complete and in command-waiting mode."
}), 400
# 优化每个采访项的prompt,添加前缀避免Agent调用工具
@@ -2389,7 +2389,7 @@ def interview_agents_batch():
except TimeoutError as e:
return jsonify({
"success": False,
- "error": f"等待批量Interview响应超时: {str(e)}"
+ "error": f"Batch interview response timed out: {str(e)}"
}), 504
except Exception as e:
@@ -2445,27 +2445,27 @@ def interview_all_agents():
if not simulation_id:
return jsonify({
"success": False,
- "error": "请提供 simulation_id"
+ "error": "Please provide simulation_id"
}), 400
if not prompt:
return jsonify({
"success": False,
- "error": "请提供 prompt(采访问题)"
+ "error": "Please provide prompt (interview question)"
}), 400
# 验证platform参数
if platform and platform not in ("twitter", "reddit"):
return jsonify({
"success": False,
- "error": "platform 参数只能是 'twitter' 或 'reddit'"
+ "error": "platform must be 'twitter' or 'reddit'"
}), 400
# 检查环境状态
if not SimulationRunner.check_env_alive(simulation_id):
return jsonify({
"success": False,
- "error": "模拟环境未运行或已关闭。请确保模拟已完成并进入等待命令模式。"
+ "error": "Simulation environment is not running or has been shut down. Please ensure simulation is complete and in command-waiting mode."
}), 400
# 优化prompt,添加前缀避免Agent调用工具
@@ -2492,7 +2492,7 @@ def interview_all_agents():
except TimeoutError as e:
return jsonify({
"success": False,
- "error": f"等待全局Interview响应超时: {str(e)}"
+ "error": f"Global interview response timed out: {str(e)}"
}), 504
except Exception as e:
@@ -2549,7 +2549,7 @@ def get_interview_history():
if not simulation_id:
return jsonify({
"success": False,
- "error": "请提供 simulation_id"
+ "error": "Please provide simulation_id"
}), 400
history = SimulationRunner.get_interview_history(
@@ -2596,7 +2596,7 @@ def get_env_status():
"env_alive": true,
"twitter_available": true,
"reddit_available": true,
- "message": "环境正在运行,可以接收Interview命令"
+ "message": "Environment is running and ready to accept interview commands"
}
}
"""
@@ -2608,7 +2608,7 @@ def get_env_status():
if not simulation_id:
return jsonify({
"success": False,
- "error": "请提供 simulation_id"
+ "error": "Please provide simulation_id"
}), 400
env_alive = SimulationRunner.check_env_alive(simulation_id)
@@ -2661,7 +2661,7 @@ def close_simulation_env():
{
"success": true,
"data": {
- "message": "环境关闭命令已发送",
+ "message": "Environment shutdown command sent",
"result": {...},
"timestamp": "2025-12-08T10:00:01"
}
@@ -2676,7 +2676,7 @@ def close_simulation_env():
if not simulation_id:
return jsonify({
"success": False,
- "error": "请提供 simulation_id"
+ "error": "Please provide simulation_id"
}), 400
result = SimulationRunner.close_simulation_env(
diff --git a/backend/app/services/graph_builder.py b/backend/app/services/graph_builder.py
index 0e0444b..b02fc30 100644
--- a/backend/app/services/graph_builder.py
+++ b/backend/app/services/graph_builder.py
@@ -45,7 +45,7 @@ class GraphBuilderService:
def __init__(self, api_key: Optional[str] = None):
self.api_key = api_key or Config.ZEP_API_KEY
if not self.api_key:
- raise ValueError("ZEP_API_KEY 未配置")
+ raise ValueError("ZEP_API_KEY is not configured")
self.client = Zep(api_key=self.api_key)
self.task_manager = TaskManager()
@@ -109,7 +109,7 @@ class GraphBuilderService:
task_id,
status=TaskStatus.PROCESSING,
progress=5,
- message="开始构建图谱..."
+ message="Starting graph construction..."
)
# 1. 创建图谱
@@ -117,7 +117,7 @@ class GraphBuilderService:
self.task_manager.update_task(
task_id,
progress=10,
- message=f"图谱已创建: {graph_id}"
+ message=f"Graph created: {graph_id}"
)
# 2. 设置本体
@@ -125,7 +125,7 @@ class GraphBuilderService:
self.task_manager.update_task(
task_id,
progress=15,
- message="本体已设置"
+ message="Ontology configured"
)
# 3. 文本分块
@@ -134,7 +134,7 @@ class GraphBuilderService:
self.task_manager.update_task(
task_id,
progress=20,
- message=f"文本已分割为 {total_chunks} 个块"
+ message=f"Text split into {total_chunks} chunks"
)
# 4. 分批发送数据
@@ -151,7 +151,7 @@ class GraphBuilderService:
self.task_manager.update_task(
task_id,
progress=60,
- message="等待Zep处理数据..."
+ message="Waiting for Zep to process data..."
)
self._wait_for_episodes(
@@ -167,7 +167,7 @@ class GraphBuilderService:
self.task_manager.update_task(
task_id,
progress=90,
- message="获取图谱信息..."
+ message="Retrieving graph info..."
)
graph_info = self._get_graph_info(graph_id)
@@ -304,7 +304,7 @@ class GraphBuilderService:
if progress_callback:
progress = (i + len(batch_chunks)) / total_chunks
progress_callback(
- f"发送第 {batch_num}/{total_batches} 批数据 ({len(batch_chunks)} 块)...",
+ f"Sending batch {batch_num}/{total_batches} ({len(batch_chunks)} chunks)...",
progress
)
@@ -333,7 +333,7 @@ class GraphBuilderService:
except Exception as e:
if progress_callback:
- progress_callback(f"批次 {batch_num} 发送失败: {str(e)}", 0)
+ progress_callback(f"Batch {batch_num} failed: {str(e)}", 0)
raise
return episode_uuids
@@ -347,7 +347,7 @@ class GraphBuilderService:
"""等待所有 episode 处理完成(通过查询每个 episode 的 processed 状态)"""
if not episode_uuids:
if progress_callback:
- progress_callback("无需等待(没有 episode)", 1.0)
+ progress_callback("No episodes to wait for", 1.0)
return
start_time = time.time()
@@ -356,13 +356,13 @@ class GraphBuilderService:
total_episodes = len(episode_uuids)
if progress_callback:
- progress_callback(f"开始等待 {total_episodes} 个文本块处理...", 0)
+ progress_callback(f"Waiting for {total_episodes} text chunks to be processed...", 0)
while pending_episodes:
if time.time() - start_time > timeout:
if progress_callback:
progress_callback(
- f"部分文本块超时,已完成 {completed_count}/{total_episodes}",
+ f"Some chunks timed out, completed {completed_count}/{total_episodes}",
completed_count / total_episodes
)
break
@@ -384,7 +384,7 @@ class GraphBuilderService:
elapsed = int(time.time() - start_time)
if progress_callback:
progress_callback(
- f"Zep处理中... {completed_count}/{total_episodes} 完成, {len(pending_episodes)} 待处理 ({elapsed}秒)",
+ f"Zep processing... {completed_count}/{total_episodes} done, {len(pending_episodes)} pending ({elapsed}s)",
completed_count / total_episodes if total_episodes > 0 else 0
)
@@ -392,7 +392,7 @@ class GraphBuilderService:
time.sleep(3) # 每3秒检查一次
if progress_callback:
- progress_callback(f"处理完成: {completed_count}/{total_episodes}", 1.0)
+ progress_callback(f"Processing complete: {completed_count}/{total_episodes}", 1.0)
def _get_graph_info(self, graph_id: str) -> GraphInfo:
"""获取图谱信息"""
diff --git a/backend/app/services/oasis_profile_generator.py b/backend/app/services/oasis_profile_generator.py
index 57836c5..d160f8c 100644
--- a/backend/app/services/oasis_profile_generator.py
+++ b/backend/app/services/oasis_profile_generator.py
@@ -190,7 +190,7 @@ class OasisProfileGenerator:
self.model_name = model_name or Config.LLM_MODEL_NAME
if not self.api_key:
- raise ValueError("LLM_API_KEY 未配置")
+ raise ValueError("LLM_API_KEY is not configured")
self.client = OpenAI(
api_key=self.api_key,
@@ -313,7 +313,7 @@ class OasisProfileGenerator:
logger.debug(f"跳过Zep检索:未设置graph_id")
return results
- comprehensive_query = f"关于{entity_name}的所有信息、活动、事件、关系和背景"
+ comprehensive_query = f"All information, activities, events, relationships, and background about {entity_name}"
def search_edges():
"""搜索边(事实/关系)- 带重试机制"""
@@ -390,15 +390,15 @@ class OasisProfileGenerator:
if hasattr(node, 'summary') and node.summary:
all_summaries.add(node.summary)
if hasattr(node, 'name') and node.name and node.name != entity_name:
- all_summaries.add(f"相关实体: {node.name}")
+ all_summaries.add(f"Related entity: {node.name}")
results["node_summaries"] = list(all_summaries)
# 构建综合上下文
context_parts = []
if results["facts"]:
- context_parts.append("事实信息:\n" + "\n".join(f"- {f}" for f in results["facts"][:20]))
+ context_parts.append("Factual information:\n" + "\n".join(f"- {f}" for f in results["facts"][:20]))
if results["node_summaries"]:
- context_parts.append("相关实体:\n" + "\n".join(f"- {s}" for s in results["node_summaries"][:10]))
+ context_parts.append("Related entities:\n" + "\n".join(f"- {s}" for s in results["node_summaries"][:10]))
results["context"] = "\n\n".join(context_parts)
logger.info(f"Zep混合检索完成: {entity_name}, 获取 {len(results['facts'])} 条事实, {len(results['node_summaries'])} 个相关节点")
@@ -428,7 +428,7 @@ class OasisProfileGenerator:
if value and str(value).strip():
attrs.append(f"- {key}: {value}")
if attrs:
- context_parts.append("### 实体属性\n" + "\n".join(attrs))
+ context_parts.append("### Entity Attributes\n" + "\n".join(attrs))
# 2. 添加相关边信息(事实/关系)
existing_facts = set()
@@ -444,12 +444,12 @@ class OasisProfileGenerator:
existing_facts.add(fact)
elif edge_name:
if direction == "outgoing":
- relationships.append(f"- {entity.name} --[{edge_name}]--> (相关实体)")
+ relationships.append(f"- {entity.name} --[{edge_name}]--> (related entity)")
else:
- relationships.append(f"- (相关实体) --[{edge_name}]--> {entity.name}")
+ relationships.append(f"- (related entity) --[{edge_name}]--> {entity.name}")
if relationships:
- context_parts.append("### 相关事实和关系\n" + "\n".join(relationships))
+ context_parts.append("### Related Facts and Relationships\n" + "\n".join(relationships))
# 3. 添加关联节点的详细信息
if entity.related_nodes:
@@ -469,7 +469,7 @@ class OasisProfileGenerator:
related_info.append(f"- **{node_name}**{label_str}")
if related_info:
- context_parts.append("### 关联实体信息\n" + "\n".join(related_info))
+ context_parts.append("### Related Entity Information\n" + "\n".join(related_info))
# 4. 使用Zep混合检索获取更丰富的信息
zep_results = self._search_zep_for_entity(entity)
@@ -478,10 +478,10 @@ class OasisProfileGenerator:
# 去重:排除已存在的事实
new_facts = [f for f in zep_results["facts"] if f not in existing_facts]
if new_facts:
- context_parts.append("### Zep检索到的事实信息\n" + "\n".join(f"- {f}" for f in new_facts[:15]))
+ context_parts.append("### Facts Retrieved from Zep\n" + "\n".join(f"- {f}" for f in new_facts[:15]))
if zep_results.get("node_summaries"):
- context_parts.append("### Zep检索到的相关节点\n" + "\n".join(f"- {s}" for s in zep_results["node_summaries"][:10]))
+ context_parts.append("### Related Nodes Retrieved from Zep\n" + "\n".join(f"- {s}" for s in zep_results["node_summaries"][:10]))
return "\n\n".join(context_parts)
@@ -553,7 +553,7 @@ class OasisProfileGenerator:
if "bio" not in result or not result["bio"]:
result["bio"] = entity_summary[:200] if entity_summary else f"{entity_type}: {entity_name}"
if "persona" not in result or not result["persona"]:
- result["persona"] = entity_summary or f"{entity_name}是一个{entity_type}。"
+ result["persona"] = entity_summary or f"{entity_name} is a {entity_type}."
return result
@@ -670,7 +670,7 @@ class OasisProfileGenerator:
def _get_system_prompt(self, is_individual: bool) -> str:
"""获取系统提示词"""
- base_prompt = "你是社交媒体用户画像生成专家。生成详细、真实的人设用于舆论模拟,最大程度还原已有现实情况。必须返回有效的JSON格式,所有字符串值不能包含未转义的换行符。使用中文。"
+ base_prompt = "You are a social media user profile generation expert. Generate detailed, realistic personas for public opinion simulation, maximally faithful to existing real-world information. You must return valid JSON format, all string values must not contain unescaped newlines."
return base_prompt
def _build_individual_persona_prompt(
@@ -683,43 +683,43 @@ class OasisProfileGenerator:
) -> str:
"""构建个人实体的详细人设提示词"""
- attrs_str = json.dumps(entity_attributes, ensure_ascii=False) if entity_attributes else "无"
- context_str = context[:3000] if context else "无额外上下文"
-
- return f"""为实体生成详细的社交媒体用户人设,最大程度还原已有现实情况。
+ attrs_str = json.dumps(entity_attributes, ensure_ascii=False) if entity_attributes else "None"
+ context_str = context[:3000] if context else "No additional context"
-实体名称: {entity_name}
-实体类型: {entity_type}
-实体摘要: {entity_summary}
-实体属性: {attrs_str}
+ return f"""Generate a detailed social media user persona for this entity, maximally faithful to existing real-world information.
-上下文信息:
+Entity Name: {entity_name}
+Entity Type: {entity_type}
+Entity Summary: {entity_summary}
+Entity Attributes: {attrs_str}
+
+Context Information:
{context_str}
-请生成JSON,包含以下字段:
+Generate JSON with the following fields:
-1. bio: 社交媒体简介,200字
-2. persona: 详细人设描述(2000字的纯文本),需包含:
- - 基本信息(年龄、职业、教育背景、所在地)
- - 人物背景(重要经历、与事件的关联、社会关系)
- - 性格特征(MBTI类型、核心性格、情绪表达方式)
- - 社交媒体行为(发帖频率、内容偏好、互动风格、语言特点)
- - 立场观点(对话题的态度、可能被激怒/感动的内容)
- - 独特特征(口头禅、特殊经历、个人爱好)
- - 个人记忆(人设的重要部分,要介绍这个个体与事件的关联,以及这个个体在事件中的已有动作与反应)
-3. age: 年龄数字(必须是整数)
-4. gender: 性别,必须是英文: "male" 或 "female"
-5. mbti: MBTI类型(如INTJ、ENFP等)
-6. country: 国家(使用中文,如"中国")
-7. profession: 职业
-8. interested_topics: 感兴趣话题数组
+1. bio: Social media biography, 200 words
+2. persona: Detailed persona description (2000 words of plain text), must include:
+ - Basic information (age, profession, educational background, location)
+ - Background (important experiences, connection to events, social relationships)
+ - Personality traits (MBTI type, core personality, emotional expression style)
+ - Social media behavior (posting frequency, content preferences, interaction style, language characteristics)
+ - Stances and opinions (attitudes toward topics, content that may provoke or move them)
+ - Unique traits (catchphrases, special experiences, personal hobbies)
+ - Personal memories (important part of the persona, describe this individual's connection to events, and their existing actions and reactions in those events)
+3. age: Age as a number (must be an integer)
+4. gender: Must be in English: "male" or "female"
+5. mbti: MBTI type (e.g., INTJ, ENFP)
+6. country: Country name
+7. profession: Profession
+8. interested_topics: Array of topics of interest
-重要:
-- 所有字段值必须是字符串或数字,不要使用换行符
-- persona必须是一段连贯的文字描述
-- 使用中文(除了gender字段必须用英文male/female)
-- 内容要与实体信息保持一致
-- age必须是有效的整数,gender必须是"male"或"female"
+Important:
+- All field values must be strings or numbers, do not use newline characters
+- persona must be a coherent text description
+- Write in English (gender field must be "male" or "female")
+- Content must be consistent with entity information
+- age must be a valid integer, gender must be "male" or "female"
"""
def _build_group_persona_prompt(
@@ -732,43 +732,43 @@ class OasisProfileGenerator:
) -> str:
"""构建群体/机构实体的详细人设提示词"""
- attrs_str = json.dumps(entity_attributes, ensure_ascii=False) if entity_attributes else "无"
- context_str = context[:3000] if context else "无额外上下文"
-
- return f"""为机构/群体实体生成详细的社交媒体账号设定,最大程度还原已有现实情况。
+ attrs_str = json.dumps(entity_attributes, ensure_ascii=False) if entity_attributes else "None"
+ context_str = context[:3000] if context else "No additional context"
-实体名称: {entity_name}
-实体类型: {entity_type}
-实体摘要: {entity_summary}
-实体属性: {attrs_str}
+ return f"""Generate a detailed social media account profile for this institution/group entity, maximally faithful to existing real-world information.
-上下文信息:
+Entity Name: {entity_name}
+Entity Type: {entity_type}
+Entity Summary: {entity_summary}
+Entity Attributes: {attrs_str}
+
+Context Information:
{context_str}
-请生成JSON,包含以下字段:
+Generate JSON with the following fields:
-1. bio: 官方账号简介,200字,专业得体
-2. persona: 详细账号设定描述(2000字的纯文本),需包含:
- - 机构基本信息(正式名称、机构性质、成立背景、主要职能)
- - 账号定位(账号类型、目标受众、核心功能)
- - 发言风格(语言特点、常用表达、禁忌话题)
- - 发布内容特点(内容类型、发布频率、活跃时间段)
- - 立场态度(对核心话题的官方立场、面对争议的处理方式)
- - 特殊说明(代表的群体画像、运营习惯)
- - 机构记忆(机构人设的重要部分,要介绍这个机构与事件的关联,以及这个机构在事件中的已有动作与反应)
-3. age: 固定填30(机构账号的虚拟年龄)
-4. gender: 固定填"other"(机构账号使用other表示非个人)
-5. mbti: MBTI类型,用于描述账号风格,如ISTJ代表严谨保守
-6. country: 国家(使用中文,如"中国")
-7. profession: 机构职能描述
-8. interested_topics: 关注领域数组
+1. bio: Official account biography, 200 words, professional and appropriate
+2. persona: Detailed account profile description (2000 words of plain text), must include:
+ - Institutional basic information (official name, nature, founding background, primary functions)
+ - Account positioning (account type, target audience, core functions)
+ - Communication style (language characteristics, common expressions, taboo topics)
+ - Content characteristics (content types, posting frequency, active time periods)
+ - Stances and attitudes (official positions on core topics, approach to handling controversies)
+ - Special notes (group portrait represented, operational habits)
+ - Institutional memory (important part of the persona, describe this institution's connection to events, and its existing actions and reactions in those events)
+3. age: Fixed value 30 (virtual age for institutional accounts)
+4. gender: Fixed value "other" (institutional accounts use "other" to indicate non-personal)
+5. mbti: MBTI type to describe account style, e.g., ISTJ for rigorous and conservative
+6. country: Country name
+7. profession: Institutional function description
+8. interested_topics: Array of focus areas
-重要:
-- 所有字段值必须是字符串或数字,不允许null值
-- persona必须是一段连贯的文字描述,不要使用换行符
-- 使用中文(除了gender字段必须用英文"other")
-- age必须是整数30,gender必须是字符串"other"
-- 机构账号发言要符合其身份定位"""
+Important:
+- All field values must be strings or numbers, null values are not allowed
+- persona must be a coherent text description, do not use newline characters
+- Write in English (gender field must be "other")
+- age must be integer 30, gender must be string "other"
+- Institutional account communication must align with its identity positioning"""
def _generate_profile_rule_based(
self,
@@ -813,7 +813,7 @@ class OasisProfileGenerator:
"age": 30, # 机构虚拟年龄
"gender": "other", # 机构使用other
"mbti": "ISTJ", # 机构风格:严谨保守
- "country": "中国",
+ "country": "China",
"profession": "Media",
"interested_topics": ["General News", "Current Events", "Public Affairs"],
}
@@ -825,7 +825,7 @@ class OasisProfileGenerator:
"age": 30, # 机构虚拟年龄
"gender": "other", # 机构使用other
"mbti": "ISTJ", # 机构风格:严谨保守
- "country": "中国",
+ "country": "China",
"profession": entity_type,
"interested_topics": ["Public Policy", "Community", "Official Announcements"],
}
@@ -947,7 +947,7 @@ class OasisProfileGenerator:
logger.info(f"开始并行生成 {total} 个Agent人设(并行数: {parallel_count})...")
print(f"\n{'='*60}")
- print(f"开始生成Agent人设 - 共 {total} 个实体,并行数: {parallel_count}")
+ print(f"Starting agent persona generation - {total} entities, parallel count: {parallel_count}")
print(f"{'='*60}\n")
# 使用线程池并行执行
@@ -976,9 +976,9 @@ class OasisProfileGenerator:
if progress_callback:
progress_callback(
- current,
- total,
- f"已完成 {current}/{total}: {entity.name}({entity_type})"
+ current,
+ total,
+ f"Completed {current}/{total}: {entity.name} ({entity_type})"
)
if error:
@@ -1003,7 +1003,7 @@ class OasisProfileGenerator:
save_profiles_realtime()
print(f"\n{'='*60}")
- print(f"人设生成完成!共生成 {len([p for p in profiles if p])} 个Agent")
+ print(f"Persona generation complete! Generated {len([p for p in profiles if p])} agents")
print(f"{'='*60}\n")
return profiles
@@ -1013,24 +1013,24 @@ class OasisProfileGenerator:
separator = "-" * 70
# 构建完整输出内容(不截断)
- topics_str = ', '.join(profile.interested_topics) if profile.interested_topics else '无'
-
+ topics_str = ', '.join(profile.interested_topics) if profile.interested_topics else 'None'
+
output_lines = [
f"\n{separator}",
- f"[已生成] {entity_name} ({entity_type})",
+ f"[Generated] {entity_name} ({entity_type})",
f"{separator}",
- f"用户名: {profile.user_name}",
+ f"Username: {profile.user_name}",
f"",
- f"【简介】",
+ f"[Bio]",
f"{profile.bio}",
f"",
- f"【详细人设】",
+ f"[Detailed Persona]",
f"{profile.persona}",
f"",
- f"【基本属性】",
- f"年龄: {profile.age} | 性别: {profile.gender} | MBTI: {profile.mbti}",
- f"职业: {profile.profession} | 国家: {profile.country}",
- f"兴趣话题: {topics_str}",
+ f"[Basic Attributes]",
+ f"Age: {profile.age} | Gender: {profile.gender} | MBTI: {profile.mbti}",
+ f"Profession: {profile.profession} | Country: {profile.country}",
+ f"Interests: {topics_str}",
separator
]
diff --git a/backend/app/services/ontology_generator.py b/backend/app/services/ontology_generator.py
index 2d3e39b..3c08fde 100644
--- a/backend/app/services/ontology_generator.py
+++ b/backend/app/services/ontology_generator.py
@@ -8,150 +8,150 @@ from typing import Dict, Any, List, Optional
from ..utils.llm_client import LLMClient
-# 本体生成的系统提示词
-ONTOLOGY_SYSTEM_PROMPT = """你是一个专业的知识图谱本体设计专家。你的任务是分析给定的文本内容和模拟需求,设计适合**社交媒体舆论模拟**的实体类型和关系类型。
+# System prompt for ontology generation
+ONTOLOGY_SYSTEM_PROMPT = """You are a professional knowledge graph ontology design expert. Your task is to analyze the given text content and simulation requirements, and design entity types and relationship types suitable for **social media public opinion simulation**.
-**重要:你必须输出有效的JSON格式数据,不要输出任何其他内容。**
+**Important: You must output valid JSON format data. Do not output anything else.**
-## 核心任务背景
+## Core Task Background
-我们正在构建一个**社交媒体舆论模拟系统**。在这个系统中:
-- 每个实体都是一个可以在社交媒体上发声、互动、传播信息的"账号"或"主体"
-- 实体之间会相互影响、转发、评论、回应
-- 我们需要模拟舆论事件中各方的反应和信息传播路径
+We are building a **social media public opinion simulation system**. In this system:
+- Each entity is an "account" or "actor" that can post, interact, and spread information on social media
+- Entities influence each other through reposts, comments, and responses
+- We need to simulate the reactions and information propagation paths of various parties in public opinion events
-因此,**实体必须是现实中真实存在的、可以在社媒上发声和互动的主体**:
+Therefore, **entities must be real-world actors that can post and interact on social media**:
-**可以是**:
-- 具体的个人(公众人物、当事人、意见领袖、专家学者、普通人)
-- 公司、企业(包括其官方账号)
-- 组织机构(大学、协会、NGO、工会等)
-- 政府部门、监管机构
-- 媒体机构(报纸、电视台、自媒体、网站)
-- 社交媒体平台本身
-- 特定群体代表(如校友会、粉丝团、维权群体等)
+**Can be**:
+- Specific individuals (public figures, parties involved, opinion leaders, experts, ordinary people)
+- Companies and enterprises (including their official accounts)
+- Organizations (universities, associations, NGOs, unions, etc.)
+- Government departments and regulatory agencies
+- Media organizations (newspapers, TV stations, self-media, websites)
+- Social media platforms themselves
+- Representatives of specific groups (e.g., alumni associations, fan groups, advocacy groups, etc.)
-**不可以是**:
-- 抽象概念(如"舆论"、"情绪"、"趋势")
-- 主题/话题(如"学术诚信"、"教育改革")
-- 观点/态度(如"支持方"、"反对方")
+**Cannot be**:
+- Abstract concepts (e.g., "public opinion", "emotion", "trend")
+- Topics/themes (e.g., "academic integrity", "education reform")
+- Viewpoints/attitudes (e.g., "supporters", "opponents")
-## 输出格式
+## Output Format
-请输出JSON格式,包含以下结构:
+Please output in JSON format with the following structure:
```json
{
"entity_types": [
{
- "name": "实体类型名称(英文,PascalCase)",
- "description": "简短描述(英文,不超过100字符)",
+ "name": "Entity type name (English, PascalCase)",
+ "description": "Brief description (English, no more than 100 characters)",
"attributes": [
{
- "name": "属性名(英文,snake_case)",
+ "name": "Attribute name (English, snake_case)",
"type": "text",
- "description": "属性描述"
+ "description": "Attribute description"
}
],
- "examples": ["示例实体1", "示例实体2"]
+ "examples": ["Example entity 1", "Example entity 2"]
}
],
"edge_types": [
{
- "name": "关系类型名称(英文,UPPER_SNAKE_CASE)",
- "description": "简短描述(英文,不超过100字符)",
+ "name": "Relationship type name (English, UPPER_SNAKE_CASE)",
+ "description": "Brief description (English, no more than 100 characters)",
"source_targets": [
- {"source": "源实体类型", "target": "目标实体类型"}
+ {"source": "Source entity type", "target": "Target entity type"}
],
"attributes": []
}
],
- "analysis_summary": "对文本内容的简要分析说明(中文)"
+ "analysis_summary": "Brief analysis of the text content"
}
```
-## 设计指南(极其重要!)
+## Design Guidelines (Extremely Important!)
-### 1. 实体类型设计 - 必须严格遵守
+### 1. Entity Type Design - Must Be Strictly Followed
-**数量要求:必须正好10个实体类型**
+**Quantity requirement: Exactly 10 entity types**
-**层次结构要求(必须同时包含具体类型和兜底类型)**:
+**Hierarchy requirements (must include both specific types and fallback types)**:
-你的10个实体类型必须包含以下层次:
+Your 10 entity types must include the following levels:
-A. **兜底类型(必须包含,放在列表最后2个)**:
- - `Person`: 任何自然人个体的兜底类型。当一个人不属于其他更具体的人物类型时,归入此类。
- - `Organization`: 任何组织机构的兜底类型。当一个组织不属于其他更具体的组织类型时,归入此类。
+A. **Fallback types (must be included, placed as the last 2 in the list)**:
+ - `Person`: Fallback type for any individual person. When a person doesn't fit other more specific person types, they go here.
+ - `Organization`: Fallback type for any organization. When an organization doesn't fit other more specific organization types, it goes here.
-B. **具体类型(8个,根据文本内容设计)**:
- - 针对文本中出现的主要角色,设计更具体的类型
- - 例如:如果文本涉及学术事件,可以有 `Student`, `Professor`, `University`
- - 例如:如果文本涉及商业事件,可以有 `Company`, `CEO`, `Employee`
+B. **Specific types (8 types, designed based on text content)**:
+ - Design more specific types for the main roles appearing in the text
+ - For example: if the text involves academic events, you can have `Student`, `Professor`, `University`
+ - For example: if the text involves business events, you can have `Company`, `CEO`, `Employee`
-**为什么需要兜底类型**:
-- 文本中会出现各种人物,如"中小学教师"、"路人甲"、"某位网友"
-- 如果没有专门的类型匹配,他们应该被归入 `Person`
-- 同理,小型组织、临时团体等应该归入 `Organization`
+**Why fallback types are needed**:
+- Various people appear in the text, such as "elementary school teachers", "bystanders", "random netizens"
+- If there is no specific type match, they should be classified under `Person`
+- Similarly, small organizations, temporary groups, etc. should be classified under `Organization`
-**具体类型的设计原则**:
-- 从文本中识别出高频出现或关键的角色类型
-- 每个具体类型应该有明确的边界,避免重叠
-- description 必须清晰说明这个类型和兜底类型的区别
+**Design principles for specific types**:
+- Identify high-frequency or key role types from the text
+- Each specific type should have clear boundaries to avoid overlap
+- The description must clearly explain how this type differs from the fallback type
-### 2. 关系类型设计
+### 2. Relationship Type Design
-- 数量:6-10个
-- 关系应该反映社媒互动中的真实联系
-- 确保关系的 source_targets 涵盖你定义的实体类型
+- Quantity: 6-10
+- Relationships should reflect real connections in social media interactions
+- Ensure the source_targets of relationships cover the entity types you defined
-### 3. 属性设计
+### 3. Attribute Design
-- 每个实体类型1-3个关键属性
-- **注意**:属性名不能使用 `name`、`uuid`、`group_id`、`created_at`、`summary`(这些是系统保留字)
-- 推荐使用:`full_name`, `title`, `role`, `position`, `location`, `description` 等
+- 1-3 key attributes per entity type
+- **Note**: Attribute names cannot use `name`, `uuid`, `group_id`, `created_at`, `summary` (these are system reserved words)
+- Recommended: `full_name`, `title`, `role`, `position`, `location`, `description`, etc.
-## 实体类型参考
+## Entity Type Reference
-**个人类(具体)**:
-- Student: 学生
-- Professor: 教授/学者
-- Journalist: 记者
-- Celebrity: 明星/网红
-- Executive: 高管
-- Official: 政府官员
-- Lawyer: 律师
-- Doctor: 医生
+**Individual types (specific)**:
+- Student: Student
+- Professor: Professor/Scholar
+- Journalist: Journalist
+- Celebrity: Celebrity/Influencer
+- Executive: Executive
+- Official: Government official
+- Lawyer: Lawyer
+- Doctor: Doctor
-**个人类(兜底)**:
-- Person: 任何自然人(不属于上述具体类型时使用)
+**Individual types (fallback)**:
+- Person: Any individual (used when not fitting the above specific types)
-**组织类(具体)**:
-- University: 高校
-- Company: 公司企业
-- GovernmentAgency: 政府机构
-- MediaOutlet: 媒体机构
-- Hospital: 医院
-- School: 中小学
-- NGO: 非政府组织
+**Organization types (specific)**:
+- University: University
+- Company: Company/Enterprise
+- GovernmentAgency: Government agency
+- MediaOutlet: Media organization
+- Hospital: Hospital
+- School: School
+- NGO: Non-governmental organization
-**组织类(兜底)**:
-- Organization: 任何组织机构(不属于上述具体类型时使用)
+**Organization types (fallback)**:
+- Organization: Any organization (used when not fitting the above specific types)
-## 关系类型参考
+## Relationship Type Reference
-- WORKS_FOR: 工作于
-- STUDIES_AT: 就读于
-- AFFILIATED_WITH: 隶属于
-- REPRESENTS: 代表
-- REGULATES: 监管
-- REPORTS_ON: 报道
-- COMMENTS_ON: 评论
-- RESPONDS_TO: 回应
-- SUPPORTS: 支持
-- OPPOSES: 反对
-- COLLABORATES_WITH: 合作
-- COMPETES_WITH: 竞争
+- WORKS_FOR: Works for
+- STUDIES_AT: Studies at
+- AFFILIATED_WITH: Affiliated with
+- REPRESENTS: Represents
+- REGULATES: Regulates
+- REPORTS_ON: Reports on
+- COMMENTS_ON: Comments on
+- RESPONDS_TO: Responds to
+- SUPPORTS: Supports
+- OPPOSES: Opposes
+- COLLABORATES_WITH: Collaborates with
+- COMPETES_WITH: Competes with
"""
@@ -223,33 +223,33 @@ class OntologyGenerator:
# 如果文本超过5万字,截断(仅影响传给LLM的内容,不影响图谱构建)
if len(combined_text) > self.MAX_TEXT_LENGTH_FOR_LLM:
combined_text = combined_text[:self.MAX_TEXT_LENGTH_FOR_LLM]
- combined_text += f"\n\n...(原文共{original_length}字,已截取前{self.MAX_TEXT_LENGTH_FOR_LLM}字用于本体分析)..."
-
- message = f"""## 模拟需求
+ combined_text += f"\n\n...(Original text: {original_length} chars, truncated to first {self.MAX_TEXT_LENGTH_FOR_LLM} chars for ontology analysis)..."
+
+ message = f"""## Simulation Requirements
{simulation_requirement}
-## 文档内容
+## Document Content
{combined_text}
"""
-
+
if additional_context:
message += f"""
-## 额外说明
+## Additional Notes
{additional_context}
"""
-
- message += """
-请根据以上内容,设计适合社会舆论模拟的实体类型和关系类型。
-**必须遵守的规则**:
-1. 必须正好输出10个实体类型
-2. 最后2个必须是兜底类型:Person(个人兜底)和 Organization(组织兜底)
-3. 前8个是根据文本内容设计的具体类型
-4. 所有实体类型必须是现实中可以发声的主体,不能是抽象概念
-5. 属性名不能使用 name、uuid、group_id 等保留字,用 full_name、org_name 等替代
+ message += """
+Based on the above content, design entity types and relationship types suitable for social media public opinion simulation.
+
+**Mandatory rules**:
+1. Output exactly 10 entity types
+2. The last 2 must be fallback types: Person (individual fallback) and Organization (organization fallback)
+3. The first 8 are specific types designed based on the text content
+4. All entity types must be real-world actors that can post on social media, not abstract concepts
+5. Attribute names cannot use reserved words like name, uuid, group_id — use full_name, org_name, etc. instead
"""
return message
diff --git a/backend/app/services/report_agent.py b/backend/app/services/report_agent.py
index 02ca5bd..4b15a64 100644
--- a/backend/app/services/report_agent.py
+++ b/backend/app/services/report_agent.py
@@ -473,387 +473,386 @@ class Report:
# ── 工具描述 ──
TOOL_DESC_INSIGHT_FORGE = """\
-【深度洞察检索 - 强大的检索工具】
-这是我们强大的检索函数,专为深度分析设计。它会:
-1. 自动将你的问题分解为多个子问题
-2. 从多个维度检索模拟图谱中的信息
-3. 整合语义搜索、实体分析、关系链追踪的结果
-4. 返回最全面、最深度的检索内容
+[Deep Insight Retrieval - Powerful Retrieval Tool]
+This is our powerful retrieval function, designed for deep analysis. It will:
+1. Automatically decompose your question into multiple sub-questions
+2. Retrieve information from the simulation graph across multiple dimensions
+3. Integrate results from semantic search, entity analysis, and relationship chain tracking
+4. Return the most comprehensive and in-depth retrieval content
-【使用场景】
-- 需要深入分析某个话题
-- 需要了解事件的多个方面
-- 需要获取支撑报告章节的丰富素材
+[Use Cases]
+- Need to deeply analyze a topic
+- Need to understand multiple aspects of an event
+- Need to obtain rich material to support report sections
-【返回内容】
-- 相关事实原文(可直接引用)
-- 核心实体洞察
-- 关系链分析"""
+[Return Content]
+- Original relevant facts (can be directly quoted)
+- Core entity insights
+- Relationship chain analysis"""
TOOL_DESC_PANORAMA_SEARCH = """\
-【广度搜索 - 获取全貌视图】
-这个工具用于获取模拟结果的完整全貌,特别适合了解事件演变过程。它会:
-1. 获取所有相关节点和关系
-2. 区分当前有效的事实和历史/过期的事实
-3. 帮助你了解舆情是如何演变的
+[Broad Search - Full Overview]
+This tool is used to obtain a complete overview of simulation results, particularly suited for understanding event evolution. It will:
+1. Retrieve all related nodes and relationships
+2. Distinguish between currently valid facts and historical/expired facts
+3. Help you understand how public opinion evolved
-【使用场景】
-- 需要了解事件的完整发展脉络
-- 需要对比不同阶段的舆情变化
-- 需要获取全面的实体和关系信息
+[Use Cases]
+- Need to understand the complete development timeline of events
+- Need to compare opinion changes across different stages
+- Need to obtain comprehensive entity and relationship information
-【返回内容】
-- 当前有效事实(模拟最新结果)
-- 历史/过期事实(演变记录)
-- 所有涉及的实体"""
+[Return Content]
+- Currently valid facts (latest simulation results)
+- Historical/expired facts (evolution records)
+- All involved entities"""
TOOL_DESC_QUICK_SEARCH = """\
-【简单搜索 - 快速检索】
-轻量级的快速检索工具,适合简单、直接的信息查询。
+[Simple Search - Quick Retrieval]
+A lightweight quick retrieval tool, suitable for simple, direct information queries.
-【使用场景】
-- 需要快速查找某个具体信息
-- 需要验证某个事实
-- 简单的信息检索
+[Use Cases]
+- Need to quickly find specific information
+- Need to verify a fact
+- Simple information retrieval
-【返回内容】
-- 与查询最相关的事实列表"""
+[Return Content]
+- List of facts most relevant to the query"""
TOOL_DESC_INTERVIEW_AGENTS = """\
-【深度采访 - 真实Agent采访(双平台)】
-调用OASIS模拟环境的采访API,对正在运行的模拟Agent进行真实采访!
-这不是LLM模拟,而是调用真实的采访接口获取模拟Agent的原始回答。
-默认在Twitter和Reddit两个平台同时采访,获取更全面的观点。
+[Deep Interview - Real Agent Interview (Dual Platform)]
+Calls the OASIS simulation environment's interview API to conduct real interviews with running simulation Agents!
+This is not an LLM simulation, but calls the real interview interface to obtain original answers from simulation Agents.
+By default, interviews are conducted simultaneously on both Twitter and Reddit platforms for more comprehensive perspectives.
-功能流程:
-1. 自动读取人设文件,了解所有模拟Agent
-2. 智能选择与采访主题最相关的Agent(如学生、媒体、官方等)
-3. 自动生成采访问题
-4. 调用 /api/simulation/interview/batch 接口在双平台进行真实采访
-5. 整合所有采访结果,提供多视角分析
+Workflow:
+1. Automatically reads persona files to understand all simulation Agents
+2. Intelligently selects Agents most relevant to the interview topic (e.g., students, media, officials)
+3. Automatically generates interview questions
+4. Calls /api/simulation/interview/batch interface for real interviews on both platforms
+5. Integrates all interview results, providing multi-perspective analysis
-【使用场景】
-- 需要从不同角色视角了解事件看法(学生怎么看?媒体怎么看?官方怎么说?)
-- 需要收集多方意见和立场
-- 需要获取模拟Agent的真实回答(来自OASIS模拟环境)
-- 想让报告更生动,包含"采访实录"
+[Use Cases]
+- Need to understand event perspectives from different roles (How do students see it? How does media cover it? What do officials say?)
+- Need to collect opinions and stances from multiple parties
+- Need to obtain real answers from simulation Agents (from the OASIS simulation environment)
+- Want to make the report more vivid with "interview transcripts"
-【返回内容】
-- 被采访Agent的身份信息
-- 各Agent在Twitter和Reddit两个平台的采访回答
-- 关键引言(可直接引用)
-- 采访摘要和观点对比
+[Return Content]
+- Identity information of interviewed Agents
+- Each Agent's interview responses on both Twitter and Reddit platforms
+- Key quotes (can be directly cited)
+- Interview summary and viewpoint comparison
-【重要】需要OASIS模拟环境正在运行才能使用此功能!"""
+[Important] The OASIS simulation environment must be running to use this feature!"""
# ── 大纲规划 prompt ──
PLAN_SYSTEM_PROMPT = """\
-你是一个「未来预测报告」的撰写专家,拥有对模拟世界的「上帝视角」——你可以洞察模拟中每一位Agent的行为、言论和互动。
+You are an expert at writing "Future Prediction Reports," with a "god's eye view" of the simulated world — you can observe every Agent's behavior, statements, and interactions within the simulation.
-【核心理念】
-我们构建了一个模拟世界,并向其中注入了特定的「模拟需求」作为变量。模拟世界的演化结果,就是对未来可能发生情况的预测。你正在观察的不是"实验数据",而是"未来的预演"。
+[Core Concept]
+We built a simulated world and injected specific "simulation requirements" as variables. The evolution results of the simulated world are predictions of what may happen in the future. What you are observing is not "experimental data," but a "rehearsal of the future."
-【你的任务】
-撰写一份「未来预测报告」,回答:
-1. 在我们设定的条件下,未来发生了什么?
-2. 各类Agent(人群)是如何反应和行动?
-3. 这个模拟揭示了哪些值得关注的未来趋势和风险?
+[Your Task]
+Write a "Future Prediction Report" that answers:
+1. Under the conditions we set, what happened in the future?
+2. How did various types of Agents (groups) react and act?
+3. What noteworthy future trends and risks does this simulation reveal?
-【报告定位】
-- ✅ 这是一份基于模拟的未来预测报告,揭示"如果这样,未来会怎样"
-- ✅ 聚焦于预测结果:事件走向、群体反应、涌现现象、潜在风险
-- ✅ 模拟世界中的Agent言行就是对未来人群行为的预测
-- ❌ 不是对现实世界现状的分析
-- ❌ 不是泛泛而谈的舆情综述
+[Report Positioning]
+- This is a simulation-based future prediction report, revealing "if this happens, what will the future look like"
+- Focus on prediction results: event trajectories, group reactions, emergent phenomena, potential risks
+- Agent behaviors and statements in the simulated world are predictions of future human behavior
+- This is NOT an analysis of the current real world
+- This is NOT a generic public opinion summary
-【章节数量限制】
-- 最少2个章节,最多5个章节
-- 不需要子章节,每个章节直接撰写完整内容
-- 内容要精炼,聚焦于核心预测发现
-- 章节结构由你根据预测结果自主设计
+[Section Count Limits]
+- Minimum 2 sections, maximum 5 sections
+- No sub-sections needed, each section should contain complete content
+- Content should be concise, focused on core prediction findings
+- Section structure should be designed by you based on prediction results
-请输出JSON格式的报告大纲,格式如下:
+Output a JSON-formatted report outline in the following format:
{
- "title": "报告标题",
- "summary": "报告摘要(一句话概括核心预测发现)",
+ "title": "Report Title",
+ "summary": "Report summary (one sentence summarizing core prediction findings)",
"sections": [
{
- "title": "章节标题",
- "description": "章节内容描述"
+ "title": "Section Title",
+ "description": "Section content description"
}
]
}
-注意:sections数组最少2个,最多5个元素!"""
+Note: the sections array must have at least 2 and at most 5 elements!"""
PLAN_USER_PROMPT_TEMPLATE = """\
-【预测场景设定】
-我们向模拟世界注入的变量(模拟需求):{simulation_requirement}
+[Prediction Scenario Setup]
+Variable injected into the simulated world (simulation requirement): {simulation_requirement}
-【模拟世界规模】
-- 参与模拟的实体数量: {total_nodes}
-- 实体间产生的关系数量: {total_edges}
-- 实体类型分布: {entity_types}
-- 活跃Agent数量: {total_entities}
+[Simulated World Scale]
+- Number of entities in simulation: {total_nodes}
+- Number of relationships between entities: {total_edges}
+- Entity type distribution: {entity_types}
+- Number of active Agents: {total_entities}
-【模拟预测到的部分未来事实样本】
+[Sample Future Facts Predicted by Simulation]
{related_facts_json}
-请以「上帝视角」审视这个未来预演:
-1. 在我们设定的条件下,未来呈现出了什么样的状态?
-2. 各类人群(Agent)是如何反应和行动的?
-3. 这个模拟揭示了哪些值得关注的未来趋势?
+Examine this future rehearsal from a "god's eye view":
+1. Under the conditions we set, what state did the future present?
+2. How did various groups (Agents) react and act?
+3. What noteworthy future trends does this simulation reveal?
-根据预测结果,设计最合适的报告章节结构。
+Design the most appropriate report section structure based on prediction results.
-【再次提醒】报告章节数量:最少2个,最多5个,内容要精炼聚焦于核心预测发现。"""
+[Reminder] Report section count: minimum 2, maximum 5, content should be concise and focused on core prediction findings."""
# ── 章节生成 prompt ──
SECTION_SYSTEM_PROMPT_TEMPLATE = """\
-你是一个「未来预测报告」的撰写专家,正在撰写报告的一个章节。
+You are an expert at writing "Future Prediction Reports," currently writing one section of the report.
-报告标题: {report_title}
-报告摘要: {report_summary}
-预测场景(模拟需求): {simulation_requirement}
+Report Title: {report_title}
+Report Summary: {report_summary}
+Prediction Scenario (Simulation Requirement): {simulation_requirement}
-当前要撰写的章节: {section_title}
+Current Section to Write: {section_title}
═══════════════════════════════════════════════════════════════
-【核心理念】
+[Core Concept]
═══════════════════════════════════════════════════════════════
-模拟世界是对未来的预演。我们向模拟世界注入了特定条件(模拟需求),
-模拟中Agent的行为和互动,就是对未来人群行为的预测。
+The simulated world is a rehearsal of the future. We injected specific conditions (simulation requirements) into the simulated world. The behaviors and interactions of Agents in the simulation are predictions of future human behavior.
-你的任务是:
-- 揭示在设定条件下,未来发生了什么
-- 预测各类人群(Agent)是如何反应和行动的
-- 发现值得关注的未来趋势、风险和机会
+Your task is to:
+- Reveal what happened in the future under the set conditions
+- Predict how various groups (Agents) reacted and acted
+- Discover noteworthy future trends, risks, and opportunities
-❌ 不要写成对现实世界现状的分析
-✅ 要聚焦于"未来会怎样"——模拟结果就是预测的未来
+Do NOT write this as an analysis of the current real world.
+DO focus on "what will the future look like" — simulation results ARE the predicted future.
═══════════════════════════════════════════════════════════════
-【最重要的规则 - 必须遵守】
+[Most Important Rules - Must Follow]
═══════════════════════════════════════════════════════════════
-1. 【必须调用工具观察模拟世界】
- - 你正在以「上帝视角」观察未来的预演
- - 所有内容必须来自模拟世界中发生的事件和Agent言行
- - 禁止使用你自己的知识来编写报告内容
- - 每个章节至少调用3次工具(最多5次)来观察模拟的世界,它代表了未来
+1. [Must Call Tools to Observe the Simulated World]
+ - You are observing a future rehearsal from a "god's eye view"
+ - All content must come from events and Agent behaviors in the simulated world
+ - Do NOT use your own knowledge to write report content
+ - Each section must call tools at least 3 times (maximum 5) to observe the simulated world, which represents the future
-2. 【必须引用Agent的原始言行】
- - Agent的发言和行为是对未来人群行为的预测
- - 在报告中使用引用格式展示这些预测,例如:
- > "某类人群会表示:原文内容..."
- - 这些引用是模拟预测的核心证据
+2. [Must Quote Agents' Original Behaviors and Statements]
+ - Agent statements and behaviors are predictions of future human behavior
+ - Use quote format in the report to display these predictions, for example:
+ > "A certain group would say: original content..."
+ - These quotes are the core evidence of simulation predictions
-3. 【语言一致性 - 引用内容必须翻译为报告语言】
- - 工具返回的内容可能包含英文或中英文混杂的表述
- - 如果模拟需求和材料原文是中文的,报告必须全部使用中文撰写
- - 当你引用工具返回的英文或中英混杂内容时,必须将其翻译为流畅的中文后再写入报告
- - 翻译时保持原意不变,确保表述自然通顺
- - 这一规则同时适用于正文和引用块(> 格式)中的内容
+3. [Language Consistency - Report Language]
+ - Tool-returned content may contain mixed languages
+ - The report should be written in a language consistent with the simulation requirement
+ - When quoting tool-returned content, translate it into the report language for fluency
+ - Maintain original meaning while ensuring natural expression
+ - This rule applies to both body text and quoted blocks (> format)
-4. 【忠实呈现预测结果】
- - 报告内容必须反映模拟世界中的代表未来的模拟结果
- - 不要添加模拟中不存在的信息
- - 如果某方面信息不足,如实说明
+4. [Faithfully Present Prediction Results]
+ - Report content must reflect simulation results representing the future
+ - Do not add information that does not exist in the simulation
+ - If information is insufficient in some area, state it honestly
═══════════════════════════════════════════════════════════════
-【⚠️ 格式规范 - 极其重要!】
+[Format Specifications - Extremely Important!]
═══════════════════════════════════════════════════════════════
-【一个章节 = 最小内容单位】
-- 每个章节是报告的最小分块单位
-- ❌ 禁止在章节内使用任何 Markdown 标题(#、##、###、#### 等)
-- ❌ 禁止在内容开头添加章节主标题
-- ✅ 章节标题由系统自动添加,你只需撰写纯正文内容
-- ✅ 使用**粗体**、段落分隔、引用、列表来组织内容,但不要用标题
+[One Section = Minimum Content Unit]
+- Each section is the smallest chunk unit of the report
+- Do NOT use any Markdown headings (#, ##, ###, #### etc.) within sections
+- Do NOT add a section title at the beginning of content
+- Section titles are automatically added by the system, you only need to write body text
+- Use **bold**, paragraph breaks, quotes, and lists to organize content, but NO headings
-【正确示例】
+[Correct Example]
```
-本章节分析了事件的舆论传播态势。通过对模拟数据的深入分析,我们发现...
+This section analyzes the public opinion propagation dynamics. Through in-depth analysis of simulation data, we found...
-**首发引爆阶段**
+**Initial Breakout Phase**
-微博作为舆情的第一现场,承担了信息首发的核心功能:
+Platform A served as the primary venue, carrying the core function of initial information release:
-> "微博贡献了68%的首发声量..."
+> "Platform A contributed 68% of initial voice volume..."
-**情绪放大阶段**
+**Emotion Amplification Phase**
-抖音平台进一步放大了事件影响力:
+Platform B further amplified the event's impact:
-- 视觉冲击力强
-- 情绪共鸣度高
+- Strong visual impact
+- High emotional resonance
```
-【错误示例】
+[Incorrect Example]
```
-## 执行摘要 ← 错误!不要添加任何标题
-### 一、首发阶段 ← 错误!不要用###分小节
-#### 1.1 详细分析 ← 错误!不要用####细分
+## Executive Summary <- Wrong! Do not add any headings
+### 1. Initial Phase <- Wrong! Do not use ### for sub-sections
+#### 1.1 Detailed Analysis <- Wrong! Do not use #### for details
-本章节分析了...
+This section analyzes...
```
═══════════════════════════════════════════════════════════════
-【可用检索工具】(每章节调用3-5次)
+[Available Retrieval Tools] (call 3-5 times per section)
═══════════════════════════════════════════════════════════════
{tools_description}
-【工具使用建议 - 请混合使用不同工具,不要只用一种】
-- insight_forge: 深度洞察分析,自动分解问题并多维度检索事实和关系
-- panorama_search: 广角全景搜索,了解事件全貌、时间线和演变过程
-- quick_search: 快速验证某个具体信息点
-- interview_agents: 采访模拟Agent,获取不同角色的第一人称观点和真实反应
+[Tool Usage Suggestions - Mix different tools, don't use only one]
+- insight_forge: Deep insight analysis, auto-decomposes questions and retrieves facts and relationships across multiple dimensions
+- panorama_search: Wide-angle panoramic search, understand full event picture, timeline, and evolution
+- quick_search: Quick verification of a specific information point
+- interview_agents: Interview simulation Agents, get first-person perspectives and real reactions from different roles
═══════════════════════════════════════════════════════════════
-【工作流程】
+[Workflow]
═══════════════════════════════════════════════════════════════
-每次回复你只能做以下两件事之一(不可同时做):
+Each reply you can only do ONE of the following two things (not both):
-选项A - 调用工具:
-输出你的思考,然后用以下格式调用一个工具:
+Option A - Call a tool:
+Output your thinking, then call a tool using the following format:
-{{"name": "工具名称", "parameters": {{"参数名": "参数值"}}}}
+{{"name": "tool_name", "parameters": {{"param_name": "param_value"}}}}
-系统会执行工具并把结果返回给你。你不需要也不能自己编写工具返回结果。
+The system will execute the tool and return results to you. You do not need to and cannot write tool return results yourself.
-选项B - 输出最终内容:
-当你已通过工具获取了足够信息,以 "Final Answer:" 开头输出章节内容。
+Option B - Output final content:
+When you have obtained sufficient information through tools, output section content starting with "Final Answer:".
-⚠️ 严格禁止:
-- 禁止在一次回复中同时包含工具调用和 Final Answer
-- 禁止自己编造工具返回结果(Observation),所有工具结果由系统注入
-- 每次回复最多调用一个工具
+Strictly prohibited:
+- Do NOT include both tool calls and Final Answer in a single reply
+- Do NOT fabricate tool return results (Observation); all tool results are injected by the system
+- Maximum one tool call per reply
═══════════════════════════════════════════════════════════════
-【章节内容要求】
+[Section Content Requirements]
═══════════════════════════════════════════════════════════════
-1. 内容必须基于工具检索到的模拟数据
-2. 大量引用原文来展示模拟效果
-3. 使用Markdown格式(但禁止使用标题):
- - 使用 **粗体文字** 标记重点(代替子标题)
- - 使用列表(-或1.2.3.)组织要点
- - 使用空行分隔不同段落
- - ❌ 禁止使用 #、##、###、#### 等任何标题语法
-4. 【引用格式规范 - 必须单独成段】
- 引用必须独立成段,前后各有一个空行,不能混在段落中:
+1. Content must be based on simulation data retrieved by tools
+2. Quote original text extensively to demonstrate simulation effects
+3. Use Markdown format (but NO headings):
+ - Use **bold text** to mark key points (instead of sub-headings)
+ - Use lists (- or 1.2.3.) to organize points
+ - Use blank lines to separate paragraphs
+ - Do NOT use #, ##, ###, #### or any heading syntax
+4. [Quote Format - Must Be Standalone Paragraphs]
+ Quotes must be standalone paragraphs with blank lines before and after, not mixed into paragraphs:
- ✅ 正确格式:
+ Correct format:
```
- 校方的回应被认为缺乏实质内容。
+ The response was considered lacking in substance.
- > "校方的应对模式在瞬息万变的社交媒体环境中显得僵化和迟缓。"
+ > "The response pattern appeared rigid and sluggish in the fast-changing social media environment."
- 这一评价反映了公众的普遍不满。
+ This assessment reflects widespread public dissatisfaction.
```
- ❌ 错误格式:
+ Incorrect format:
```
- 校方的回应被认为缺乏实质内容。> "校方的应对模式..." 这一评价反映了...
+ The response was considered lacking. > "The response pattern..." This assessment reflects...
```
-5. 保持与其他章节的逻辑连贯性
-6. 【避免重复】仔细阅读下方已完成的章节内容,不要重复描述相同的信息
-7. 【再次强调】不要添加任何标题!用**粗体**代替小节标题"""
+5. Maintain logical coherence with other sections
+6. [Avoid Repetition] Carefully read the completed sections below, do not repeat the same information
+7. [Emphasis] Do not add any headings! Use **bold** instead of sub-section headings"""
SECTION_USER_PROMPT_TEMPLATE = """\
-已完成的章节内容(请仔细阅读,避免重复):
+Completed section content (read carefully to avoid repetition):
{previous_content}
═══════════════════════════════════════════════════════════════
-【当前任务】撰写章节: {section_title}
+[Current Task] Write section: {section_title}
═══════════════════════════════════════════════════════════════
-【重要提醒】
-1. 仔细阅读上方已完成的章节,避免重复相同的内容!
-2. 开始前必须先调用工具获取模拟数据
-3. 请混合使用不同工具,不要只用一种
-4. 报告内容必须来自检索结果,不要使用自己的知识
+[Important Reminders]
+1. Carefully read the completed sections above, avoid repeating the same content!
+2. You must call tools to retrieve simulation data before starting
+3. Mix different tools, don't use only one type
+4. Report content must come from retrieval results, do not use your own knowledge
-【⚠️ 格式警告 - 必须遵守】
-- ❌ 不要写任何标题(#、##、###、####都不行)
-- ❌ 不要写"{section_title}"作为开头
-- ✅ 章节标题由系统自动添加
-- ✅ 直接写正文,用**粗体**代替小节标题
+[Format Warning - Must Follow]
+- Do NOT write any headings (#, ##, ###, #### are all prohibited)
+- Do NOT write "{section_title}" as the opening
+- Section titles are automatically added by the system
+- Write body text directly, use **bold** instead of sub-section headings
-请开始:
-1. 首先思考(Thought)这个章节需要什么信息
-2. 然后调用工具(Action)获取模拟数据
-3. 收集足够信息后输出 Final Answer(纯正文,无任何标题)"""
+Begin:
+1. First think (Thought) about what information this section needs
+2. Then call tools (Action) to retrieve simulation data
+3. After collecting sufficient information, output Final Answer (body text only, no headings)"""
# ── ReACT 循环内消息模板 ──
REACT_OBSERVATION_TEMPLATE = """\
-Observation(检索结果):
+Observation (retrieval results):
-═══ 工具 {tool_name} 返回 ═══
+═══ Tool {tool_name} returned ═══
{result}
═══════════════════════════════════════════════════════════════
-已调用工具 {tool_calls_count}/{max_tool_calls} 次(已用: {used_tools_str}){unused_hint}
-- 如果信息充分:以 "Final Answer:" 开头输出章节内容(必须引用上述原文)
-- 如果需要更多信息:调用一个工具继续检索
+Tools called {tool_calls_count}/{max_tool_calls} times (used: {used_tools_str}){unused_hint}
+- If information is sufficient: output section content starting with "Final Answer:" (must quote the above original text)
+- If more information is needed: call a tool to continue retrieval
═══════════════════════════════════════════════════════════════"""
REACT_INSUFFICIENT_TOOLS_MSG = (
- "【注意】你只调用了{tool_calls_count}次工具,至少需要{min_tool_calls}次。"
- "请再调用工具获取更多模拟数据,然后再输出 Final Answer。{unused_hint}"
+ "[Notice] You have only called tools {tool_calls_count} times, at least {min_tool_calls} times required. "
+ "Please call more tools to retrieve additional simulation data before outputting Final Answer. {unused_hint}"
)
REACT_INSUFFICIENT_TOOLS_MSG_ALT = (
- "当前只调用了 {tool_calls_count} 次工具,至少需要 {min_tool_calls} 次。"
- "请调用工具获取模拟数据。{unused_hint}"
+ "Currently only {tool_calls_count} tool calls made, at least {min_tool_calls} required. "
+ "Please call tools to retrieve simulation data. {unused_hint}"
)
REACT_TOOL_LIMIT_MSG = (
- "工具调用次数已达上限({tool_calls_count}/{max_tool_calls}),不能再调用工具。"
- '请立即基于已获取的信息,以 "Final Answer:" 开头输出章节内容。'
+ "Tool call limit reached ({tool_calls_count}/{max_tool_calls}), no more tool calls allowed. "
+ 'Please immediately output section content starting with "Final Answer:" based on information already obtained.'
)
-REACT_UNUSED_TOOLS_HINT = "\n💡 你还没有使用过: {unused_list},建议尝试不同工具获取多角度信息"
+REACT_UNUSED_TOOLS_HINT = "\nHint: You haven't used: {unused_list} yet. Consider trying different tools for multi-perspective information."
-REACT_FORCE_FINAL_MSG = "已达到工具调用限制,请直接输出 Final Answer: 并生成章节内容。"
+REACT_FORCE_FINAL_MSG = "Tool call limit reached. Please output Final Answer: and generate section content immediately."
# ── Chat prompt ──
CHAT_SYSTEM_PROMPT_TEMPLATE = """\
-你是一个简洁高效的模拟预测助手。
+You are a concise and efficient simulation prediction assistant.
-【背景】
-预测条件: {simulation_requirement}
+[Background]
+Prediction conditions: {simulation_requirement}
-【已生成的分析报告】
+[Generated Analysis Report]
{report_content}
-【规则】
-1. 优先基于上述报告内容回答问题
-2. 直接回答问题,避免冗长的思考论述
-3. 仅在报告内容不足以回答时,才调用工具检索更多数据
-4. 回答要简洁、清晰、有条理
+[Rules]
+1. Prioritize answering questions based on the report content above
+2. Answer questions directly, avoid lengthy deliberation
+3. Only call tools to retrieve more data when the report content is insufficient
+4. Answers should be concise, clear, and well-organized
-【可用工具】(仅在需要时使用,最多调用1-2次)
+[Available Tools] (use only when needed, maximum 1-2 calls)
{tools_description}
-【工具调用格式】
+[Tool Call Format]
-{{"name": "工具名称", "parameters": {{"参数名": "参数值"}}}}
+{{"name": "tool_name", "parameters": {{"param_name": "param_value"}}}}
-【回答风格】
-- 简洁直接,不要长篇大论
-- 使用 > 格式引用关键内容
-- 优先给出结论,再解释原因"""
+[Answer Style]
+- Concise and direct, no lengthy essays
+- Use > format to quote key content
+- Give conclusions first, then explain reasons"""
-CHAT_OBSERVATION_SUFFIX = "\n\n请简洁回答问题。"
+CHAT_OBSERVATION_SUFFIX = "\n\nPlease answer the question concisely."
# ═══════════════════════════════════════════════════════════════
@@ -922,32 +921,32 @@ class ReportAgent:
"name": "insight_forge",
"description": TOOL_DESC_INSIGHT_FORGE,
"parameters": {
- "query": "你想深入分析的问题或话题",
- "report_context": "当前报告章节的上下文(可选,有助于生成更精准的子问题)"
+ "query": "The question or topic you want to deeply analyze",
+ "report_context": "Current report section context (optional, helps generate more precise sub-questions)"
}
},
"panorama_search": {
"name": "panorama_search",
"description": TOOL_DESC_PANORAMA_SEARCH,
"parameters": {
- "query": "搜索查询,用于相关性排序",
- "include_expired": "是否包含过期/历史内容(默认True)"
+ "query": "Search query for relevance ranking",
+ "include_expired": "Whether to include expired/historical content (default True)"
}
},
"quick_search": {
"name": "quick_search",
"description": TOOL_DESC_QUICK_SEARCH,
"parameters": {
- "query": "搜索查询字符串",
- "limit": "返回结果数量(可选,默认10)"
+ "query": "Search query string",
+ "limit": "Number of results to return (optional, default 10)"
}
},
"interview_agents": {
"name": "interview_agents",
"description": TOOL_DESC_INTERVIEW_AGENTS,
"parameters": {
- "interview_topic": "采访主题或需求描述(如:'了解学生对宿舍甲醛事件的看法')",
- "max_agents": "最多采访的Agent数量(可选,默认5,最大10)"
+ "interview_topic": "Interview topic or requirement description (e.g., 'understand students' views on the dormitory formaldehyde incident')",
+ "max_agents": "Maximum number of Agents to interview (optional, default 5, max 10)"
}
}
}
@@ -1054,11 +1053,11 @@ class ReportAgent:
return json.dumps(result, ensure_ascii=False, indent=2)
else:
- return f"未知工具: {tool_name}。请使用以下工具之一: insight_forge, panorama_search, quick_search"
+ return f"Unknown tool: {tool_name}. Please use one of: insight_forge, panorama_search, quick_search"
except Exception as e:
logger.error(f"工具执行失败: {tool_name}, 错误: {str(e)}")
- return f"工具执行失败: {str(e)}"
+ return f"Tool execution failed: {str(e)}"
# 合法的工具名称集合,用于裸 JSON 兜底解析时校验
VALID_TOOL_NAMES = {"insight_forge", "panorama_search", "quick_search", "interview_agents"}
@@ -1125,12 +1124,12 @@ class ReportAgent:
def _get_tools_description(self) -> str:
"""生成工具描述文本"""
- desc_parts = ["可用工具:"]
+ desc_parts = ["Available tools:"]
for name, tool in self.tools.items():
params_desc = ", ".join([f"{k}: {v}" for k, v in tool["parameters"].items()])
desc_parts.append(f"- {name}: {tool['description']}")
if params_desc:
- desc_parts.append(f" 参数: {params_desc}")
+ desc_parts.append(f" Parameters: {params_desc}")
return "\n".join(desc_parts)
def plan_outline(
@@ -1151,7 +1150,7 @@ class ReportAgent:
logger.info("开始规划报告大纲...")
if progress_callback:
- progress_callback("planning", 0, "正在分析模拟需求...")
+ progress_callback("planning", 0, "Analyzing simulation requirements...")
# 首先获取模拟上下文
context = self.zep_tools.get_simulation_context(
@@ -1160,7 +1159,7 @@ class ReportAgent:
)
if progress_callback:
- progress_callback("planning", 30, "正在生成报告大纲...")
+ progress_callback("planning", 30, "Generating report outline...")
system_prompt = PLAN_SYSTEM_PROMPT
user_prompt = PLAN_USER_PROMPT_TEMPLATE.format(
@@ -1182,7 +1181,7 @@ class ReportAgent:
)
if progress_callback:
- progress_callback("planning", 80, "正在解析大纲结构...")
+ progress_callback("planning", 80, "Parsing outline structure...")
# 解析大纲
sections = []
@@ -1193,13 +1192,13 @@ class ReportAgent:
))
outline = ReportOutline(
- title=response.get("title", "模拟分析报告"),
+ title=response.get("title", "Simulation Analysis Report"),
summary=response.get("summary", ""),
sections=sections
)
if progress_callback:
- progress_callback("planning", 100, "大纲规划完成")
+ progress_callback("planning", 100, "Outline planning complete")
logger.info(f"大纲规划完成: {len(sections)} 个章节")
return outline
@@ -1208,12 +1207,12 @@ class ReportAgent:
logger.error(f"大纲规划失败: {str(e)}")
# 返回默认大纲(3个章节,作为fallback)
return ReportOutline(
- title="未来预测报告",
- summary="基于模拟预测的未来趋势与风险分析",
+ title="Future Prediction Report",
+ summary="Future trends and risk analysis based on simulation predictions",
sections=[
- ReportSection(title="预测场景与核心发现"),
- ReportSection(title="人群行为预测分析"),
- ReportSection(title="趋势展望与风险提示")
+ ReportSection(title="Prediction Scenario and Core Findings"),
+ ReportSection(title="Group Behavior Prediction Analysis"),
+ ReportSection(title="Trend Outlook and Risk Indicators")
]
)
@@ -1268,7 +1267,7 @@ class ReportAgent:
previous_parts.append(truncated)
previous_content = "\n\n---\n\n".join(previous_parts)
else:
- previous_content = "(这是第一个章节)"
+ previous_content = "(This is the first section)"
user_prompt = SECTION_USER_PROMPT_TEMPLATE.format(
previous_content=previous_content,
@@ -1289,14 +1288,14 @@ class ReportAgent:
all_tools = {"insight_forge", "panorama_search", "quick_search", "interview_agents"}
# 报告上下文,用于InsightForge的子问题生成
- report_context = f"章节标题: {section.title}\n模拟需求: {self.simulation_requirement}"
+ report_context = f"Section title: {section.title}\nSimulation requirement: {self.simulation_requirement}"
for iteration in range(max_iterations):
if progress_callback:
progress_callback(
"generating",
int((iteration / max_iterations) * 100),
- f"深度检索与撰写中 ({tool_calls_count}/{self.MAX_TOOL_CALLS_PER_SECTION})"
+ f"Deep retrieval and writing ({tool_calls_count}/{self.MAX_TOOL_CALLS_PER_SECTION})"
)
# 调用LLM
@@ -1311,8 +1310,8 @@ class ReportAgent:
logger.warning(f"章节 {section.title} 第 {iteration + 1} 次迭代: LLM 返回 None")
# 如果还有迭代次数,添加消息并重试
if iteration < max_iterations - 1:
- messages.append({"role": "assistant", "content": "(响应为空)"})
- messages.append({"role": "user", "content": "请继续生成内容。"})
+ messages.append({"role": "assistant", "content": "(empty response)"})
+ messages.append({"role": "user", "content": "Please continue generating content."})
continue
# 最后一次迭代也返回 None,跳出循环进入强制收尾
break
@@ -1338,11 +1337,11 @@ class ReportAgent:
messages.append({
"role": "user",
"content": (
- "【格式错误】你在一次回复中同时包含了工具调用和 Final Answer,这是不允许的。\n"
- "每次回复只能做以下两件事之一:\n"
- "- 调用一个工具(输出一个 块,不要写 Final Answer)\n"
- "- 输出最终内容(以 'Final Answer:' 开头,不要包含 )\n"
- "请重新回复,只做其中一件事。"
+ "[Format Error] You included both a tool call and Final Answer in one reply, which is not allowed.\n"
+ "Each reply can only do one of the following:\n"
+ "- Call a tool (output a block, do not write Final Answer)\n"
+ "- Output final content (start with 'Final Answer:', do not include )\n"
+ "Please reply again, doing only one of these."
),
})
continue
@@ -1377,7 +1376,7 @@ class ReportAgent:
if tool_calls_count < min_tool_calls:
messages.append({"role": "assistant", "content": response})
unused_tools = all_tools - used_tools
- unused_hint = f"(这些工具还未使用,推荐用一下他们: {', '.join(unused_tools)})" if unused_tools else ""
+ unused_hint = f"(These tools haven't been used yet, try them: {', '.join(unused_tools)})" if unused_tools else ""
messages.append({
"role": "user",
"content": REACT_INSUFFICIENT_TOOLS_MSG.format(
@@ -1473,7 +1472,7 @@ class ReportAgent:
if tool_calls_count < min_tool_calls:
# 工具调用次数不足,推荐未用过的工具
unused_tools = all_tools - used_tools
- unused_hint = f"(这些工具还未使用,推荐用一下他们: {', '.join(unused_tools)})" if unused_tools else ""
+ unused_hint = f"(These tools haven't been used yet, try them: {', '.join(unused_tools)})" if unused_tools else ""
messages.append({
"role": "user",
@@ -1512,7 +1511,7 @@ class ReportAgent:
# 检查强制收尾时 LLM 返回是否为 None
if response is None:
logger.error(f"章节 {section.title} 强制收尾时 LLM 返回 None,使用默认错误提示")
- final_answer = f"(本章节生成失败:LLM 返回空响应,请稍后重试)"
+ final_answer = f"(This section failed to generate: LLM returned an empty response, please try again later)"
elif "Final Answer:" in response:
final_answer = response.split("Final Answer:")[-1].strip()
else:
@@ -1590,7 +1589,7 @@ class ReportAgent:
self.console_logger = ReportConsoleLogger(report_id)
ReportManager.update_progress(
- report_id, "pending", 0, "初始化报告...",
+ report_id, "pending", 0, "Initializing report...",
completed_sections=[]
)
ReportManager.save_report(report)
@@ -1598,7 +1597,7 @@ class ReportAgent:
# 阶段1: 规划大纲
report.status = ReportStatus.PLANNING
ReportManager.update_progress(
- report_id, "planning", 5, "开始规划报告大纲...",
+ report_id, "planning", 5, "Starting report outline planning...",
completed_sections=[]
)
@@ -1606,7 +1605,7 @@ class ReportAgent:
self.report_logger.log_planning_start()
if progress_callback:
- progress_callback("planning", 0, "开始规划报告大纲...")
+ progress_callback("planning", 0, "Starting report outline planning...")
outline = self.plan_outline(
progress_callback=lambda stage, prog, msg:
@@ -1620,7 +1619,7 @@ class ReportAgent:
# 保存大纲到文件
ReportManager.save_outline(report_id, outline)
ReportManager.update_progress(
- report_id, "planning", 15, f"大纲规划完成,共{len(outline.sections)}个章节",
+ report_id, "planning", 15, f"Outline planning complete, {len(outline.sections)} sections total",
completed_sections=[]
)
ReportManager.save_report(report)
@@ -1640,7 +1639,7 @@ class ReportAgent:
# 更新进度
ReportManager.update_progress(
report_id, "generating", base_progress,
- f"正在生成章节: {section.title} ({section_num}/{total_sections})",
+ f"Generating section: {section.title} ({section_num}/{total_sections})",
current_section=section.title,
completed_sections=completed_section_titles
)
@@ -1649,7 +1648,7 @@ class ReportAgent:
progress_callback(
"generating",
base_progress,
- f"正在生成章节: {section.title} ({section_num}/{total_sections})"
+ f"Generating section: {section.title} ({section_num}/{total_sections})"
)
# 生成主章节内容
@@ -1689,17 +1688,17 @@ class ReportAgent:
ReportManager.update_progress(
report_id, "generating",
base_progress + int(70 / total_sections),
- f"章节 {section.title} 已完成",
+ f"Section {section.title} completed",
current_section=None,
completed_sections=completed_section_titles
)
# 阶段3: 组装完整报告
if progress_callback:
- progress_callback("generating", 95, "正在组装完整报告...")
+ progress_callback("generating", 95, "Assembling full report...")
ReportManager.update_progress(
- report_id, "generating", 95, "正在组装完整报告...",
+ report_id, "generating", 95, "Assembling full report...",
completed_sections=completed_section_titles
)
@@ -1721,12 +1720,12 @@ class ReportAgent:
# 保存最终报告
ReportManager.save_report(report)
ReportManager.update_progress(
- report_id, "completed", 100, "报告生成完成",
+ report_id, "completed", 100, "Report generation complete",
completed_sections=completed_section_titles
)
if progress_callback:
- progress_callback("completed", 100, "报告生成完成")
+ progress_callback("completed", 100, "Report generation complete")
logger.info(f"报告生成完成: {report_id}")
@@ -1750,7 +1749,7 @@ class ReportAgent:
try:
ReportManager.save_report(report)
ReportManager.update_progress(
- report_id, "failed", -1, f"报告生成失败: {str(e)}",
+ report_id, "failed", -1, f"Report generation failed: {str(e)}",
completed_sections=completed_section_titles
)
except Exception:
@@ -1796,13 +1795,13 @@ class ReportAgent:
# 限制报告长度,避免上下文过长
report_content = report.markdown_content[:15000]
if len(report.markdown_content) > 15000:
- report_content += "\n\n... [报告内容已截断] ..."
+ report_content += "\n\n... [Report content truncated] ..."
except Exception as e:
logger.warning(f"获取报告内容失败: {e}")
system_prompt = CHAT_SYSTEM_PROMPT_TEMPLATE.format(
simulation_requirement=self.simulation_requirement,
- report_content=report_content if report_content else "(暂无报告)",
+ report_content=report_content if report_content else "(No report available yet)",
tools_description=self._get_tools_description(),
)
@@ -1857,7 +1856,7 @@ class ReportAgent:
# 将结果添加到消息
messages.append({"role": "assistant", "content": response})
- observation = "\n".join([f"[{r['tool']}结果]\n{r['result']}" for r in tool_results])
+ observation = "\n".join([f"[{r['tool']} result]\n{r['result']}" for r in tool_results])
messages.append({
"role": "user",
"content": observation + CHAT_OBSERVATION_SUFFIX
diff --git a/backend/app/services/simulation_config_generator.py b/backend/app/services/simulation_config_generator.py
index cc36250..4a5be06 100644
--- a/backend/app/services/simulation_config_generator.py
+++ b/backend/app/services/simulation_config_generator.py
@@ -232,7 +232,7 @@ class SimulationConfigGenerator:
self.model_name = model_name or Config.LLM_MODEL_NAME
if not self.api_key:
- raise ValueError("LLM_API_KEY 未配置")
+ raise ValueError("LLM_API_KEY is not configured")
self.client = OpenAI(
api_key=self.api_key,
@@ -292,14 +292,14 @@ class SimulationConfigGenerator:
reasoning_parts = []
# ========== 步骤1: 生成时间配置 ==========
- report_progress(1, "生成时间配置...")
+ report_progress(1, "Generating time configuration...")
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', '成功')}")
# ========== 步骤2: 生成事件配置 ==========
- report_progress(2, "生成事件配置和热点话题...")
+ report_progress(2, "Generating event configuration and hot topics...")
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', '成功')}")
@@ -313,7 +313,7 @@ class SimulationConfigGenerator:
report_progress(
3 + batch_idx,
- f"生成Agent配置 ({start_idx + 1}-{end_idx}/{len(entities)})..."
+ f"Generating agent configs ({start_idx + 1}-{end_idx}/{len(entities)})..."
)
batch_configs = self._generate_agent_configs_batch(
@@ -333,7 +333,7 @@ class SimulationConfigGenerator:
reasoning_parts.append(f"初始帖子分配: {assigned_count} 个帖子已分配发布者")
# ========== 最后一步: 生成平台配置 ==========
- report_progress(total_steps, "生成平台配置...")
+ report_progress(total_steps, "Generating platform configuration...")
twitter_config = None
reddit_config = None
@@ -390,8 +390,8 @@ class SimulationConfigGenerator:
# 构建上下文
context_parts = [
- f"## 模拟需求\n{simulation_requirement}",
- f"\n## 实体信息 ({len(entities)}个)\n{entity_summary}",
+ f"## Simulation Requirements\n{simulation_requirement}",
+ f"\n## Entity Information ({len(entities)} entities)\n{entity_summary}",
]
current_length = sum(len(p) for p in context_parts)
@@ -400,8 +400,8 @@ class SimulationConfigGenerator:
if remaining_length > 0 and document_text:
doc_text = document_text[:remaining_length]
if len(document_text) > remaining_length:
- doc_text += "\n...(文档已截断)"
- context_parts.append(f"\n## 原始文档内容\n{doc_text}")
+ doc_text += "\n...(document truncated)"
+ context_parts.append(f"\n## Original Document Content\n{doc_text}")
return "\n".join(context_parts)
@@ -418,7 +418,7 @@ class SimulationConfigGenerator:
by_type[t].append(e)
for entity_type, type_entities in by_type.items():
- lines.append(f"\n### {entity_type} ({len(type_entities)}个)")
+ lines.append(f"\n### {entity_type} ({len(type_entities)} entities)")
# 使用配置的显示数量和摘要长度
display_count = self.ENTITIES_PER_TYPE_DISPLAY
summary_len = self.ENTITY_SUMMARY_LENGTH
@@ -426,7 +426,7 @@ class SimulationConfigGenerator:
summary_preview = (e.summary[:summary_len] + "...") if len(e.summary) > summary_len else e.summary
lines.append(f"- {e.name}: {summary_preview}")
if len(type_entities) > display_count:
- lines.append(f" ... 还有 {len(type_entities) - display_count} 个")
+ lines.append(f" ... and {len(type_entities) - display_count} more")
return "\n".join(lines)
@@ -539,28 +539,28 @@ class SimulationConfigGenerator:
# 计算最大允许值(80%的agent数)
max_agents_allowed = max(1, int(num_entities * 0.9))
- prompt = f"""基于以下模拟需求,生成时间模拟配置。
+ prompt = f"""Based on the following simulation requirements, generate a time simulation configuration.
{context_truncated}
-## 任务
-请生成时间配置JSON。
+## Task
+Generate the time configuration JSON.
-### 基本原则(仅供参考,需根据具体事件和参与群体灵活调整):
-- 用户群体为中国人,需符合北京时间作息习惯
-- 凌晨0-5点几乎无人活动(活跃度系数0.05)
-- 早上6-8点逐渐活跃(活跃度系数0.4)
-- 工作时间9-18点中等活跃(活跃度系数0.7)
-- 晚间19-22点是高峰期(活跃度系数1.5)
-- 23点后活跃度下降(活跃度系数0.5)
-- 一般规律:凌晨低活跃、早间渐增、工作时段中等、晚间高峰
-- **重要**:以下示例值仅供参考,你需要根据事件性质、参与群体特点来调整具体时段
- - 例如:学生群体高峰可能是21-23点;媒体全天活跃;官方机构只在工作时间
- - 例如:突发热点可能导致深夜也有讨论,off_peak_hours 可适当缩短
+### Basic Principles (for reference only, adjust flexibly based on the specific event and participant groups):
+- The user base follows Chinese timezone daily routines (Beijing Time, UTC+8)
+- 0-5 AM: almost no activity (activity coefficient 0.05)
+- 6-8 AM: gradually increasing activity (activity coefficient 0.4)
+- 9 AM - 6 PM: moderate activity during work hours (activity coefficient 0.7)
+- 7-10 PM: peak hours (activity coefficient 1.5)
+- After 11 PM: activity decreases (activity coefficient 0.5)
+- General pattern: low activity at dawn, gradual increase in morning, moderate during work, peak in evening
+- **Important**: The example values below are for reference only. Adjust time periods based on the nature of the event and characteristics of participants.
+ - Example: Student groups may peak at 9-11 PM; media is active all day; government agencies only during work hours
+ - Example: Breaking news may cause late-night discussions, off_peak_hours can be shortened
-### 返回JSON格式(不要markdown)
+### Return JSON format (no markdown)
-示例:
+Example:
{{
"total_simulation_hours": 72,
"minutes_per_round": 60,
@@ -570,21 +570,21 @@ class SimulationConfigGenerator:
"off_peak_hours": [0, 1, 2, 3, 4, 5],
"morning_hours": [6, 7, 8],
"work_hours": [9, 10, 11, 12, 13, 14, 15, 16, 17, 18],
- "reasoning": "针对该事件的时间配置说明"
+ "reasoning": "Explanation of the time configuration for this event"
}}
-字段说明:
-- total_simulation_hours (int): 模拟总时长,24-168小时,突发事件短、持续话题长
-- minutes_per_round (int): 每轮时长,30-120分钟,建议60分钟
-- agents_per_hour_min (int): 每小时最少激活Agent数(取值范围: 1-{max_agents_allowed})
-- agents_per_hour_max (int): 每小时最多激活Agent数(取值范围: 1-{max_agents_allowed})
-- peak_hours (int数组): 高峰时段,根据事件参与群体调整
-- off_peak_hours (int数组): 低谷时段,通常深夜凌晨
-- morning_hours (int数组): 早间时段
-- work_hours (int数组): 工作时段
-- reasoning (string): 简要说明为什么这样配置"""
+Field descriptions:
+- total_simulation_hours (int): Total simulation duration, 24-168 hours. Shorter for breaking events, longer for ongoing topics
+- minutes_per_round (int): Duration per round, 30-120 minutes, recommended 60 minutes
+- agents_per_hour_min (int): Minimum agents activated per hour (range: 1-{max_agents_allowed})
+- agents_per_hour_max (int): Maximum agents activated per hour (range: 1-{max_agents_allowed})
+- peak_hours (int array): Peak hours, adjust based on participant groups
+- off_peak_hours (int array): Off-peak hours, typically late night/early morning
+- morning_hours (int array): Morning hours
+- work_hours (int array): Work hours
+- reasoning (string): Brief explanation of why this configuration was chosen"""
- system_prompt = "你是社交媒体模拟专家。返回纯JSON格式,时间配置需符合中国人作息习惯。"
+ system_prompt = "You are a social media simulation expert. Return pure JSON format. Time configuration should follow Chinese timezone daily routines."
try:
return self._call_llm_with_retry(prompt, system_prompt)
@@ -603,7 +603,7 @@ class SimulationConfigGenerator:
"off_peak_hours": [0, 1, 2, 3, 4, 5],
"morning_hours": [6, 7, 8],
"work_hours": [9, 10, 11, 12, 13, 14, 15, 16, 17, 18],
- "reasoning": "使用默认中国人作息配置(每轮1小时)"
+ "reasoning": "Using default Chinese timezone daily routine configuration (1 hour per round)"
}
def _parse_time_config(self, result: Dict[str, Any], num_entities: int) -> TimeSimulationConfig:
@@ -671,36 +671,36 @@ class SimulationConfigGenerator:
# 使用配置的上下文截断长度
context_truncated = context[:self.EVENT_CONFIG_CONTEXT_LENGTH]
- prompt = f"""基于以下模拟需求,生成事件配置。
+ prompt = f"""Based on the following simulation requirements, generate event configuration.
-模拟需求: {simulation_requirement}
+Simulation requirements: {simulation_requirement}
{context_truncated}
-## 可用实体类型及示例
+## Available Entity Types and Examples
{type_info}
-## 任务
-请生成事件配置JSON:
-- 提取热点话题关键词
-- 描述舆论发展方向
-- 设计初始帖子内容,**每个帖子必须指定 poster_type(发布者类型)**
+## Task
+Generate event configuration JSON:
+- Extract hot topic keywords
+- Describe the direction of public opinion development
+- Design initial post content. **Each post must specify a poster_type (publisher type)**
-**重要**: poster_type 必须从上面的"可用实体类型"中选择,这样初始帖子才能分配给合适的 Agent 发布。
-例如:官方声明应由 Official/University 类型发布,新闻由 MediaOutlet 发布,学生观点由 Student 发布。
+**Important**: poster_type must be selected from the "Available Entity Types" above, so initial posts can be assigned to appropriate Agents.
+Example: Official statements should be published by Official/University types, news by MediaOutlet, student opinions by Student.
-返回JSON格式(不要markdown):
+Return JSON format (no markdown):
{{
- "hot_topics": ["关键词1", "关键词2", ...],
- "narrative_direction": "<舆论发展方向描述>",
+ "hot_topics": ["keyword1", "keyword2", ...],
+ "narrative_direction": "",
"initial_posts": [
- {{"content": "帖子内容", "poster_type": "实体类型(必须从可用类型中选择)"}},
+ {{"content": "post content", "poster_type": "entity type (must be from available types)"}},
...
],
- "reasoning": "<简要说明>"
+ "reasoning": ""
}}"""
- system_prompt = "你是舆论分析专家。返回纯JSON格式。注意 poster_type 必须精确匹配可用实体类型。"
+ system_prompt = "You are a public opinion analysis expert. Return pure JSON format. Note that poster_type must exactly match available entity types."
try:
return self._call_llm_with_retry(prompt, system_prompt)
@@ -710,7 +710,7 @@ class SimulationConfigGenerator:
"hot_topics": [],
"narrative_direction": "",
"initial_posts": [],
- "reasoning": "使用默认配置"
+ "reasoning": "Using default configuration"
}
def _parse_event_config(self, result: Dict[str, Any]) -> EventConfig:
@@ -827,43 +827,43 @@ class SimulationConfigGenerator:
"summary": e.summary[:summary_len] if e.summary else ""
})
- prompt = f"""基于以下信息,为每个实体生成社交媒体活动配置。
+ prompt = f"""Based on the following information, generate social media activity configuration for each entity.
-模拟需求: {simulation_requirement}
+Simulation requirements: {simulation_requirement}
-## 实体列表
+## Entity List
```json
{json.dumps(entity_list, ensure_ascii=False, indent=2)}
```
-## 任务
-为每个实体生成活动配置,注意:
-- **时间符合中国人作息**:凌晨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)
-- **公众人物/专家**:活跃度中(0.4-0.6),影响力中高(1.5-2.0)
+## Task
+Generate activity configuration for each entity. Guidelines:
+- **Follow Chinese timezone daily routines**: Almost no activity 0-5 AM, most active 7-10 PM
+- **Official institutions** (University/GovernmentAgency): Low activity (0.1-0.3), active during work hours (9-17), slow response (60-240 min), high influence (2.5-3.0)
+- **Media** (MediaOutlet): Medium activity (0.4-0.6), active all day (8-23), fast response (5-30 min), high influence (2.0-2.5)
+- **Individuals** (Student/Person/Alumni): High activity (0.6-0.9), mainly active evenings (18-23), fast response (1-15 min), low influence (0.8-1.2)
+- **Public figures/experts**: Medium activity (0.4-0.6), medium-high influence (1.5-2.0)
-返回JSON格式(不要markdown):
+Return JSON format (no markdown):
{{
"agent_configs": [
{{
- "agent_id": <必须与输入一致>,
+ "agent_id": ,
"activity_level": <0.0-1.0>,
- "posts_per_hour": <发帖频率>,
- "comments_per_hour": <评论频率>,
- "active_hours": [<活跃小时列表,考虑中国人作息>],
- "response_delay_min": <最小响应延迟分钟>,
- "response_delay_max": <最大响应延迟分钟>,
- "sentiment_bias": <-1.0到1.0>,
+ "posts_per_hour": ,
+ "comments_per_hour": ,
+ "active_hours": [],
+ "response_delay_min": ,
+ "response_delay_max": ,
+ "sentiment_bias": <-1.0 to 1.0>,
"stance": "",
- "influence_weight": <影响力权重>
+ "influence_weight":
}},
...
]
}}"""
- system_prompt = "你是社交媒体行为分析专家。返回纯JSON,配置需符合中国人作息习惯。"
+ system_prompt = "You are a social media behavior analysis expert. Return pure JSON. Configuration should follow Chinese timezone daily routines."
try:
result = self._call_llm_with_retry(prompt, system_prompt)
diff --git a/backend/app/services/simulation_manager.py b/backend/app/services/simulation_manager.py
index 96c496f..4aa2169 100644
--- a/backend/app/services/simulation_manager.py
+++ b/backend/app/services/simulation_manager.py
@@ -260,7 +260,7 @@ class SimulationManager:
"""
state = self._load_simulation_state(simulation_id)
if not state:
- raise ValueError(f"模拟不存在: {simulation_id}")
+ raise ValueError(f"Simulation not found: {simulation_id}")
try:
state.status = SimulationStatus.PREPARING
@@ -270,12 +270,12 @@ class SimulationManager:
# ========== 阶段1: 读取并过滤实体 ==========
if progress_callback:
- progress_callback("reading", 0, "正在连接Zep图谱...")
+ progress_callback("reading", 0, "Connecting to Zep graph...")
reader = ZepEntityReader()
if progress_callback:
- progress_callback("reading", 30, "正在读取节点数据...")
+ progress_callback("reading", 30, "Reading node data...")
filtered = reader.filter_defined_entities(
graph_id=state.graph_id,
@@ -289,14 +289,14 @@ class SimulationManager:
if progress_callback:
progress_callback(
"reading", 100,
- f"完成,共 {filtered.filtered_count} 个实体",
+ f"Done, {filtered.filtered_count} entities found",
current=filtered.filtered_count,
total=filtered.filtered_count
)
if filtered.filtered_count == 0:
state.status = SimulationStatus.FAILED
- state.error = "没有找到符合条件的实体,请检查图谱是否正确构建"
+ state.error = "No matching entities found. Please check that the graph was built correctly"
self._save_simulation_state(state)
return state
@@ -306,7 +306,7 @@ class SimulationManager:
if progress_callback:
progress_callback(
"generating_profiles", 0,
- "开始生成...",
+ "Starting generation...",
current=0,
total=total_entities
)
@@ -352,7 +352,7 @@ class SimulationManager:
if progress_callback:
progress_callback(
"generating_profiles", 95,
- "保存Profile文件...",
+ "Saving profile files...",
current=total_entities,
total=total_entities
)
@@ -375,7 +375,7 @@ class SimulationManager:
if progress_callback:
progress_callback(
"generating_profiles", 100,
- f"完成,共 {len(profiles)} 个Profile",
+ f"Done, {len(profiles)} profiles generated",
current=len(profiles),
total=len(profiles)
)
@@ -384,7 +384,7 @@ class SimulationManager:
if progress_callback:
progress_callback(
"generating_config", 0,
- "正在分析模拟需求...",
+ "Analyzing simulation requirements...",
current=0,
total=3
)
@@ -394,7 +394,7 @@ class SimulationManager:
if progress_callback:
progress_callback(
"generating_config", 30,
- "正在调用LLM生成配置...",
+ "Calling LLM to generate config...",
current=1,
total=3
)
@@ -413,7 +413,7 @@ class SimulationManager:
if progress_callback:
progress_callback(
"generating_config", 70,
- "正在保存配置文件...",
+ "Saving config files...",
current=2,
total=3
)
@@ -429,7 +429,7 @@ class SimulationManager:
if progress_callback:
progress_callback(
"generating_config", 100,
- "配置生成完成",
+ "Config generation complete",
current=3,
total=3
)
@@ -481,7 +481,7 @@ class SimulationManager:
"""获取模拟的Agent Profile"""
state = self._load_simulation_state(simulation_id)
if not state:
- raise ValueError(f"模拟不存在: {simulation_id}")
+ raise ValueError(f"Simulation not found: {simulation_id}")
sim_dir = self._get_simulation_dir(simulation_id)
profile_path = os.path.join(sim_dir, f"{platform}_profiles.json")
diff --git a/backend/app/services/simulation_runner.py b/backend/app/services/simulation_runner.py
index 8c35380..33e80c3 100644
--- a/backend/app/services/simulation_runner.py
+++ b/backend/app/services/simulation_runner.py
@@ -333,14 +333,14 @@ class SimulationRunner:
# 检查是否已在运行
existing = cls.get_run_state(simulation_id)
if existing and existing.runner_status in [RunnerStatus.RUNNING, RunnerStatus.STARTING]:
- raise ValueError(f"模拟已在运行中: {simulation_id}")
+ raise ValueError(f"Simulation is already running: {simulation_id}")
# 加载模拟配置
sim_dir = os.path.join(cls.RUN_STATE_DIR, simulation_id)
config_path = os.path.join(sim_dir, "simulation_config.json")
if not os.path.exists(config_path):
- raise ValueError(f"模拟配置不存在,请先调用 /prepare 接口")
+ raise ValueError(f"Simulation config does not exist. Please call /prepare first")
with open(config_path, 'r', encoding='utf-8') as f:
config = json.load(f)
@@ -371,7 +371,7 @@ class SimulationRunner:
# 如果启用图谱记忆更新,创建更新器
if enable_graph_memory_update:
if not graph_id:
- raise ValueError("启用图谱记忆更新时必须提供 graph_id")
+ raise ValueError("graph_id is required when graph memory update is enabled")
try:
ZepGraphMemoryManager.create_updater(simulation_id, graph_id)
@@ -398,7 +398,7 @@ class SimulationRunner:
script_path = os.path.join(cls.SCRIPTS_DIR, script_name)
if not os.path.exists(script_path):
- raise ValueError(f"脚本不存在: {script_path}")
+ raise ValueError(f"Script not found: {script_path}")
# 创建动作队列
action_queue = Queue()
@@ -773,10 +773,10 @@ class SimulationRunner:
"""停止模拟"""
state = cls.get_run_state(simulation_id)
if not state:
- raise ValueError(f"模拟不存在: {simulation_id}")
+ raise ValueError(f"Simulation not found: {simulation_id}")
if state.runner_status not in [RunnerStatus.RUNNING, RunnerStatus.PAUSED]:
- raise ValueError(f"模拟未在运行: {simulation_id}, status={state.runner_status}")
+ raise ValueError(f"Simulation not running: {simulation_id}, status={state.runner_status}")
state.runner_status = RunnerStatus.STOPPING
cls._save_run_state(state)
@@ -1122,7 +1122,7 @@ class SimulationRunner:
sim_dir = os.path.join(cls.RUN_STATE_DIR, simulation_id)
if not os.path.exists(sim_dir):
- return {"success": True, "message": "模拟目录不存在,无需清理"}
+ return {"success": True, "message": "Simulation directory does not exist, no cleanup needed"}
cleaned_files = []
errors = []
@@ -1450,12 +1450,12 @@ class SimulationRunner:
"""
sim_dir = os.path.join(cls.RUN_STATE_DIR, simulation_id)
if not os.path.exists(sim_dir):
- raise ValueError(f"模拟不存在: {simulation_id}")
+ raise ValueError(f"Simulation not found: {simulation_id}")
ipc_client = SimulationIPCClient(sim_dir)
if not ipc_client.check_env_alive():
- raise ValueError(f"模拟环境未运行或已关闭,无法执行Interview: {simulation_id}")
+ raise ValueError(f"Simulation environment not running or shut down, cannot execute interview: {simulation_id}")
logger.info(f"发送Interview命令: simulation_id={simulation_id}, agent_id={agent_id}, platform={platform}")
@@ -1512,12 +1512,12 @@ class SimulationRunner:
"""
sim_dir = os.path.join(cls.RUN_STATE_DIR, simulation_id)
if not os.path.exists(sim_dir):
- raise ValueError(f"模拟不存在: {simulation_id}")
+ raise ValueError(f"Simulation not found: {simulation_id}")
ipc_client = SimulationIPCClient(sim_dir)
if not ipc_client.check_env_alive():
- raise ValueError(f"模拟环境未运行或已关闭,无法执行Interview: {simulation_id}")
+ raise ValueError(f"Simulation environment not running or shut down, cannot execute interview: {simulation_id}")
logger.info(f"发送批量Interview命令: simulation_id={simulation_id}, count={len(interviews)}, platform={platform}")
@@ -1569,19 +1569,19 @@ class SimulationRunner:
"""
sim_dir = os.path.join(cls.RUN_STATE_DIR, simulation_id)
if not os.path.exists(sim_dir):
- raise ValueError(f"模拟不存在: {simulation_id}")
+ raise ValueError(f"Simulation not found: {simulation_id}")
# 从配置文件获取所有Agent信息
config_path = os.path.join(sim_dir, "simulation_config.json")
if not os.path.exists(config_path):
- raise ValueError(f"模拟配置不存在: {simulation_id}")
+ raise ValueError(f"Simulation config not found: {simulation_id}")
with open(config_path, 'r', encoding='utf-8') as f:
config = json.load(f)
agent_configs = config.get("agent_configs", [])
if not agent_configs:
- raise ValueError(f"模拟配置中没有Agent: {simulation_id}")
+ raise ValueError(f"No agents in simulation config: {simulation_id}")
# 构建批量采访列表
interviews = []
@@ -1622,14 +1622,14 @@ class SimulationRunner:
"""
sim_dir = os.path.join(cls.RUN_STATE_DIR, simulation_id)
if not os.path.exists(sim_dir):
- raise ValueError(f"模拟不存在: {simulation_id}")
+ raise ValueError(f"Simulation not found: {simulation_id}")
ipc_client = SimulationIPCClient(sim_dir)
if not ipc_client.check_env_alive():
return {
"success": True,
- "message": "环境已经关闭"
+ "message": "Environment already shut down"
}
logger.info(f"发送关闭环境命令: simulation_id={simulation_id}")
@@ -1639,7 +1639,7 @@ class SimulationRunner:
return {
"success": response.status.value == "completed",
- "message": "环境关闭命令已发送",
+ "message": "Environment shutdown command sent",
"result": response.result,
"timestamp": response.timestamp
}
@@ -1647,7 +1647,7 @@ class SimulationRunner:
# 超时可能是因为环境正在关闭
return {
"success": True,
- "message": "环境关闭命令已发送(等待响应超时,环境可能正在关闭)"
+ "message": "Environment shutdown command sent (response timed out, environment may be shutting down)"
}
@classmethod
diff --git a/backend/app/services/zep_entity_reader.py b/backend/app/services/zep_entity_reader.py
index 71661be..0aad946 100644
--- a/backend/app/services/zep_entity_reader.py
+++ b/backend/app/services/zep_entity_reader.py
@@ -81,7 +81,7 @@ class ZepEntityReader:
def __init__(self, api_key: Optional[str] = None):
self.api_key = api_key or Config.ZEP_API_KEY
if not self.api_key:
- raise ValueError("ZEP_API_KEY 未配置")
+ raise ValueError("ZEP_API_KEY is not configured")
self.client = Zep(api_key=self.api_key)
diff --git a/backend/app/services/zep_graph_memory_updater.py b/backend/app/services/zep_graph_memory_updater.py
index a8f3cec..4458ace 100644
--- a/backend/app/services/zep_graph_memory_updater.py
+++ b/backend/app/services/zep_graph_memory_updater.py
@@ -63,139 +63,139 @@ class AgentActivity:
def _describe_create_post(self) -> str:
content = self.action_args.get("content", "")
if content:
- return f"发布了一条帖子:「{content}」"
- return "发布了一条帖子"
-
+ return f"published a post: \"{content}\""
+ return "published a post"
+
def _describe_like_post(self) -> str:
- """点赞帖子 - 包含帖子原文和作者信息"""
+ """Like post - includes post content and author info"""
post_content = self.action_args.get("post_content", "")
post_author = self.action_args.get("post_author_name", "")
-
+
if post_content and post_author:
- return f"点赞了{post_author}的帖子:「{post_content}」"
+ return f"liked {post_author}'s post: \"{post_content}\""
elif post_content:
- return f"点赞了一条帖子:「{post_content}」"
+ return f"liked a post: \"{post_content}\""
elif post_author:
- return f"点赞了{post_author}的一条帖子"
- return "点赞了一条帖子"
-
+ return f"liked a post by {post_author}"
+ return "liked a post"
+
def _describe_dislike_post(self) -> str:
- """踩帖子 - 包含帖子原文和作者信息"""
+ """Dislike post - includes post content and author info"""
post_content = self.action_args.get("post_content", "")
post_author = self.action_args.get("post_author_name", "")
-
+
if post_content and post_author:
- return f"踩了{post_author}的帖子:「{post_content}」"
+ return f"disliked {post_author}'s post: \"{post_content}\""
elif post_content:
- return f"踩了一条帖子:「{post_content}」"
+ return f"disliked a post: \"{post_content}\""
elif post_author:
- return f"踩了{post_author}的一条帖子"
- return "踩了一条帖子"
-
+ return f"disliked a post by {post_author}"
+ return "disliked a post"
+
def _describe_repost(self) -> str:
- """转发帖子 - 包含原帖内容和作者信息"""
+ """Repost - includes original post content and author info"""
original_content = self.action_args.get("original_content", "")
original_author = self.action_args.get("original_author_name", "")
-
+
if original_content and original_author:
- return f"转发了{original_author}的帖子:「{original_content}」"
+ return f"reposted {original_author}'s post: \"{original_content}\""
elif original_content:
- return f"转发了一条帖子:「{original_content}」"
+ return f"reposted a post: \"{original_content}\""
elif original_author:
- return f"转发了{original_author}的一条帖子"
- return "转发了一条帖子"
-
+ return f"reposted a post by {original_author}"
+ return "reposted a post"
+
def _describe_quote_post(self) -> str:
- """引用帖子 - 包含原帖内容、作者信息和引用评论"""
+ """Quote post - includes original content, author info, and quote comment"""
original_content = self.action_args.get("original_content", "")
original_author = self.action_args.get("original_author_name", "")
quote_content = self.action_args.get("quote_content", "") or self.action_args.get("content", "")
-
+
base = ""
if original_content and original_author:
- base = f"引用了{original_author}的帖子「{original_content}」"
+ base = f"quoted {original_author}'s post \"{original_content}\""
elif original_content:
- base = f"引用了一条帖子「{original_content}」"
+ base = f"quoted a post \"{original_content}\""
elif original_author:
- base = f"引用了{original_author}的一条帖子"
+ base = f"quoted a post by {original_author}"
else:
- base = "引用了一条帖子"
-
+ base = "quoted a post"
+
if quote_content:
- base += f",并评论道:「{quote_content}」"
+ base += f", commenting: \"{quote_content}\""
return base
-
+
def _describe_follow(self) -> str:
- """关注用户 - 包含被关注用户的名称"""
+ """Follow user - includes followed user's name"""
target_user_name = self.action_args.get("target_user_name", "")
-
+
if target_user_name:
- return f"关注了用户「{target_user_name}」"
- return "关注了一个用户"
-
+ return f"followed user \"{target_user_name}\""
+ return "followed a user"
+
def _describe_create_comment(self) -> str:
- """发表评论 - 包含评论内容和所评论的帖子信息"""
+ """Create comment - includes comment content and post info"""
content = self.action_args.get("content", "")
post_content = self.action_args.get("post_content", "")
post_author = self.action_args.get("post_author_name", "")
-
+
if content:
if post_content and post_author:
- return f"在{post_author}的帖子「{post_content}」下评论道:「{content}」"
+ return f"commented on {post_author}'s post \"{post_content}\": \"{content}\""
elif post_content:
- return f"在帖子「{post_content}」下评论道:「{content}」"
+ return f"commented on post \"{post_content}\": \"{content}\""
elif post_author:
- return f"在{post_author}的帖子下评论道:「{content}」"
- return f"评论道:「{content}」"
- return "发表了评论"
-
+ return f"commented on {post_author}'s post: \"{content}\""
+ return f"commented: \"{content}\""
+ return "posted a comment"
+
def _describe_like_comment(self) -> str:
- """点赞评论 - 包含评论内容和作者信息"""
+ """Like comment - includes comment content and author info"""
comment_content = self.action_args.get("comment_content", "")
comment_author = self.action_args.get("comment_author_name", "")
-
+
if comment_content and comment_author:
- return f"点赞了{comment_author}的评论:「{comment_content}」"
+ return f"liked {comment_author}'s comment: \"{comment_content}\""
elif comment_content:
- return f"点赞了一条评论:「{comment_content}」"
+ return f"liked a comment: \"{comment_content}\""
elif comment_author:
- return f"点赞了{comment_author}的一条评论"
- return "点赞了一条评论"
-
+ return f"liked a comment by {comment_author}"
+ return "liked a comment"
+
def _describe_dislike_comment(self) -> str:
- """踩评论 - 包含评论内容和作者信息"""
+ """Dislike comment - includes comment content and author info"""
comment_content = self.action_args.get("comment_content", "")
comment_author = self.action_args.get("comment_author_name", "")
-
+
if comment_content and comment_author:
- return f"踩了{comment_author}的评论:「{comment_content}」"
+ return f"disliked {comment_author}'s comment: \"{comment_content}\""
elif comment_content:
- return f"踩了一条评论:「{comment_content}」"
+ return f"disliked a comment: \"{comment_content}\""
elif comment_author:
- return f"踩了{comment_author}的一条评论"
- return "踩了一条评论"
-
+ return f"disliked a comment by {comment_author}"
+ return "disliked a comment"
+
def _describe_search(self) -> str:
- """搜索帖子 - 包含搜索关键词"""
+ """Search posts - includes search keywords"""
query = self.action_args.get("query", "") or self.action_args.get("keyword", "")
- return f"搜索了「{query}」" if query else "进行了搜索"
-
+ return f"searched for \"{query}\"" if query else "performed a search"
+
def _describe_search_user(self) -> str:
- """搜索用户 - 包含搜索关键词"""
+ """Search user - includes search keywords"""
query = self.action_args.get("query", "") or self.action_args.get("username", "")
- return f"搜索了用户「{query}」" if query else "搜索了用户"
-
+ return f"searched for user \"{query}\"" if query else "searched for a user"
+
def _describe_mute(self) -> str:
- """屏蔽用户 - 包含被屏蔽用户的名称"""
+ """Mute user - includes muted user's name"""
target_user_name = self.action_args.get("target_user_name", "")
-
+
if target_user_name:
- return f"屏蔽了用户「{target_user_name}」"
- return "屏蔽了一个用户"
-
+ return f"muted user \"{target_user_name}\""
+ return "muted a user"
+
def _describe_generic(self) -> str:
- # 对于未知的动作类型,生成通用描述
- return f"执行了{self.action_type}操作"
+ # Generic description for unknown action types
+ return f"performed {self.action_type} action"
class ZepGraphMemoryUpdater:
@@ -240,7 +240,7 @@ class ZepGraphMemoryUpdater:
self.api_key = api_key or Config.ZEP_API_KEY
if not self.api_key:
- raise ValueError("ZEP_API_KEY未配置")
+ raise ValueError("ZEP_API_KEY is not configured")
self.client = Zep(api_key=self.api_key)
diff --git a/backend/app/services/zep_tools.py b/backend/app/services/zep_tools.py
index 384cf54..93ac6a1 100644
--- a/backend/app/services/zep_tools.py
+++ b/backend/app/services/zep_tools.py
@@ -43,10 +43,10 @@ class SearchResult:
def to_text(self) -> str:
"""转换为文本格式,供LLM理解"""
- text_parts = [f"搜索查询: {self.query}", f"找到 {self.total_count} 条相关信息"]
-
+ text_parts = [f"Search query: {self.query}", f"Found {self.total_count} relevant items"]
+
if self.facts:
- text_parts.append("\n### 相关事实:")
+ text_parts.append("\n### Related facts:")
for i, fact in enumerate(self.facts, 1):
text_parts.append(f"{i}. {fact}")
@@ -73,8 +73,8 @@ class NodeInfo:
def to_text(self) -> str:
"""转换为文本格式"""
- entity_type = next((l for l in self.labels if l not in ["Entity", "Node"]), "未知类型")
- return f"实体: {self.name} (类型: {entity_type})\n摘要: {self.summary}"
+ entity_type = next((l for l in self.labels if l not in ["Entity", "Node"]), "Unknown type")
+ return f"Entity: {self.name} (Type: {entity_type})\nSummary: {self.summary}"
@dataclass
@@ -112,14 +112,14 @@ class EdgeInfo:
"""转换为文本格式"""
source = self.source_node_name or self.source_node_uuid[:8]
target = self.target_node_name or self.target_node_uuid[:8]
- base_text = f"关系: {source} --[{self.name}]--> {target}\n事实: {self.fact}"
-
+ base_text = f"Relationship: {source} --[{self.name}]--> {target}\nFact: {self.fact}"
+
if include_temporal:
- valid_at = self.valid_at or "未知"
- invalid_at = self.invalid_at or "至今"
- base_text += f"\n时效: {valid_at} - {invalid_at}"
+ valid_at = self.valid_at or "Unknown"
+ invalid_at = self.invalid_at or "Present"
+ base_text += f"\nValidity: {valid_at} - {invalid_at}"
if self.expired_at:
- base_text += f" (已过期: {self.expired_at})"
+ base_text += f" (Expired: {self.expired_at})"
return base_text
@@ -170,40 +170,40 @@ class InsightForgeResult:
def to_text(self) -> str:
"""转换为详细的文本格式,供LLM理解"""
text_parts = [
- f"## 未来预测深度分析",
- f"分析问题: {self.query}",
- f"预测场景: {self.simulation_requirement}",
- f"\n### 预测数据统计",
- f"- 相关预测事实: {self.total_facts}条",
- f"- 涉及实体: {self.total_entities}个",
- f"- 关系链: {self.total_relationships}条"
+ f"## Future Prediction Deep Analysis",
+ f"Analysis question: {self.query}",
+ f"Prediction scenario: {self.simulation_requirement}",
+ f"\n### Prediction Data Statistics",
+ f"- Related prediction facts: {self.total_facts}",
+ f"- Entities involved: {self.total_entities}",
+ f"- Relationship chains: {self.total_relationships}"
]
-
- # 子问题
+
+ # Sub-questions
if self.sub_queries:
- text_parts.append(f"\n### 分析的子问题")
+ text_parts.append(f"\n### Analyzed Sub-questions")
for i, sq in enumerate(self.sub_queries, 1):
text_parts.append(f"{i}. {sq}")
-
- # 语义搜索结果
+
+ # Semantic search results
if self.semantic_facts:
- text_parts.append(f"\n### 【关键事实】(请在报告中引用这些原文)")
+ text_parts.append(f"\n### [Key Facts] (please quote these in the report)")
for i, fact in enumerate(self.semantic_facts, 1):
text_parts.append(f"{i}. \"{fact}\"")
-
- # 实体洞察
+
+ # Entity insights
if self.entity_insights:
- text_parts.append(f"\n### 【核心实体】")
+ text_parts.append(f"\n### [Core Entities]")
for entity in self.entity_insights:
- text_parts.append(f"- **{entity.get('name', '未知')}** ({entity.get('type', '实体')})")
+ text_parts.append(f"- **{entity.get('name', 'Unknown')}** ({entity.get('type', 'Entity')})")
if entity.get('summary'):
- text_parts.append(f" 摘要: \"{entity.get('summary')}\"")
+ text_parts.append(f" Summary: \"{entity.get('summary')}\"")
if entity.get('related_facts'):
- text_parts.append(f" 相关事实: {len(entity.get('related_facts', []))}条")
-
- # 关系链
+ text_parts.append(f" Related facts: {len(entity.get('related_facts', []))}")
+
+ # Relationship chains
if self.relationship_chains:
- text_parts.append(f"\n### 【关系链】")
+ text_parts.append(f"\n### [Relationship Chains]")
for chain in self.relationship_chains:
text_parts.append(f"- {chain}")
@@ -249,32 +249,32 @@ class PanoramaResult:
def to_text(self) -> str:
"""转换为文本格式(完整版本,不截断)"""
text_parts = [
- f"## 广度搜索结果(未来全景视图)",
- f"查询: {self.query}",
- f"\n### 统计信息",
- f"- 总节点数: {self.total_nodes}",
- f"- 总边数: {self.total_edges}",
- f"- 当前有效事实: {self.active_count}条",
- f"- 历史/过期事实: {self.historical_count}条"
+ f"## Broad Search Results (Future Panoramic View)",
+ f"Query: {self.query}",
+ f"\n### Statistics",
+ f"- Total nodes: {self.total_nodes}",
+ f"- Total edges: {self.total_edges}",
+ f"- Currently valid facts: {self.active_count}",
+ f"- Historical/expired facts: {self.historical_count}"
]
-
- # 当前有效的事实(完整输出,不截断)
+
+ # Currently valid facts (full output, no truncation)
if self.active_facts:
- text_parts.append(f"\n### 【当前有效事实】(模拟结果原文)")
+ text_parts.append(f"\n### [Currently Valid Facts] (simulation result original text)")
for i, fact in enumerate(self.active_facts, 1):
text_parts.append(f"{i}. \"{fact}\"")
-
- # 历史/过期事实(完整输出,不截断)
+
+ # Historical/expired facts (full output, no truncation)
if self.historical_facts:
- text_parts.append(f"\n### 【历史/过期事实】(演变过程记录)")
+ text_parts.append(f"\n### [Historical/Expired Facts] (evolution process records)")
for i, fact in enumerate(self.historical_facts, 1):
text_parts.append(f"{i}. \"{fact}\"")
-
- # 关键实体(完整输出,不截断)
+
+ # Key entities (full output, no truncation)
if self.all_nodes:
- text_parts.append(f"\n### 【涉及实体】")
+ text_parts.append(f"\n### [Involved Entities]")
for node in self.all_nodes:
- entity_type = next((l for l in node.labels if l not in ["Entity", "Node"]), "实体")
+ entity_type = next((l for l in node.labels if l not in ["Entity", "Node"]), "Entity")
text_parts.append(f"- **{node.name}** ({entity_type})")
return "\n".join(text_parts)
@@ -302,12 +302,12 @@ class AgentInterview:
def to_text(self) -> str:
text = f"**{self.agent_name}** ({self.agent_role})\n"
- # 显示完整的agent_bio,不截断
- text += f"_简介: {self.agent_bio}_\n\n"
+ # Display full agent_bio without truncation
+ text += f"_Bio: {self.agent_bio}_\n\n"
text += f"**Q:** {self.question}\n\n"
text += f"**A:** {self.response}\n"
if self.key_quotes:
- text += "\n**关键引言:**\n"
+ text += "\n**Key Quotes:**\n"
for quote in self.key_quotes:
# 清理各种引号
clean_quote = quote.replace('\u201c', '').replace('\u201d', '').replace('"', '')
@@ -374,25 +374,25 @@ class InterviewResult:
def to_text(self) -> str:
"""转换为详细的文本格式,供LLM理解和报告引用"""
text_parts = [
- "## 深度采访报告",
- f"**采访主题:** {self.interview_topic}",
- f"**采访人数:** {self.interviewed_count} / {self.total_agents} 位模拟Agent",
- "\n### 采访对象选择理由",
- self.selection_reasoning or "(自动选择)",
+ "## Deep Interview Report",
+ f"**Interview Topic:** {self.interview_topic}",
+ f"**Interviewees:** {self.interviewed_count} / {self.total_agents} simulation Agents",
+ "\n### Interview Subject Selection Reasoning",
+ self.selection_reasoning or "(Automatic selection)",
"\n---",
- "\n### 采访实录",
+ "\n### Interview Transcript",
]
if self.interviews:
for i, interview in enumerate(self.interviews, 1):
- text_parts.append(f"\n#### 采访 #{i}: {interview.agent_name}")
+ text_parts.append(f"\n#### Interview #{i}: {interview.agent_name}")
text_parts.append(interview.to_text())
text_parts.append("\n---")
else:
- text_parts.append("(无采访记录)\n\n---")
+ text_parts.append("(No interview records)\n\n---")
- text_parts.append("\n### 采访摘要与核心观点")
- text_parts.append(self.summary or "(无摘要)")
+ text_parts.append("\n### Interview Summary and Core Viewpoints")
+ text_parts.append(self.summary or "(No summary)")
return "\n".join(text_parts)
@@ -424,7 +424,7 @@ class ZepToolsService:
def __init__(self, api_key: Optional[str] = None, llm_client: Optional[LLMClient] = None):
self.api_key = api_key or Config.ZEP_API_KEY
if not self.api_key:
- raise ValueError("ZEP_API_KEY 未配置")
+ raise ValueError("ZEP_API_KEY is not configured")
self.client = Zep(api_key=self.api_key)
# LLM客户端用于InsightForge生成子问题
@@ -1046,7 +1046,7 @@ class ZepToolsService:
node = self.get_node_detail(uuid)
if node:
node_map[uuid] = node
- entity_type = next((l for l in node.labels if l not in ["Entity", "Node"]), "实体")
+ entity_type = next((l for l in node.labels if l not in ["Entity", "Node"]), "Entity")
# 获取该实体相关的所有事实(不截断)
related_facts = [
@@ -1101,23 +1101,23 @@ class ZepToolsService:
将复杂问题分解为多个可以独立检索的子问题
"""
- system_prompt = """你是一个专业的问题分析专家。你的任务是将一个复杂问题分解为多个可以在模拟世界中独立观察的子问题。
+ system_prompt = """You are a professional question analysis expert. Your task is to decompose a complex question into multiple sub-questions that can be independently observed in the simulated world.
-要求:
-1. 每个子问题应该足够具体,可以在模拟世界中找到相关的Agent行为或事件
-2. 子问题应该覆盖原问题的不同维度(如:谁、什么、为什么、怎么样、何时、何地)
-3. 子问题应该与模拟场景相关
-4. 返回JSON格式:{"sub_queries": ["子问题1", "子问题2", ...]}"""
+Requirements:
+1. Each sub-question should be specific enough to find related Agent behaviors or events in the simulated world
+2. Sub-questions should cover different dimensions of the original question (e.g., who, what, why, how, when, where)
+3. Sub-questions should be relevant to the simulation scenario
+4. Return in JSON format: {"sub_queries": ["sub-question 1", "sub-question 2", ...]}"""
- user_prompt = f"""模拟需求背景:
+ user_prompt = f"""Simulation requirement background:
{simulation_requirement}
-{f"报告上下文:{report_context[:500]}" if report_context else ""}
+{f"Report context: {report_context[:500]}" if report_context else ""}
-请将以下问题分解为{max_queries}个子问题:
+Please decompose the following question into {max_queries} sub-questions:
{query}
-返回JSON格式的子问题列表。"""
+Return a JSON-formatted list of sub-questions."""
try:
response = self.llm.chat_json(
@@ -1137,9 +1137,9 @@ class ZepToolsService:
# 降级:返回基于原问题的变体
return [
query,
- f"{query} 的主要参与者",
- f"{query} 的原因和影响",
- f"{query} 的发展过程"
+ f"Key participants in {query}",
+ f"Causes and impacts of {query}",
+ f"Development process of {query}"
][:max_queries]
def panorama_search(
@@ -1200,8 +1200,8 @@ class ZepToolsService:
if is_historical:
# 历史/过期事实,添加时间标记
- valid_at = edge.valid_at or "未知"
- invalid_at = edge.invalid_at or edge.expired_at or "未知"
+ valid_at = edge.valid_at or "Unknown"
+ invalid_at = edge.invalid_at or edge.expired_at or "Unknown"
fact_with_time = f"[{valid_at} - {invalid_at}] {edge.fact}"
historical_facts.append(fact_with_time)
else:
@@ -1318,7 +1318,7 @@ class ZepToolsService:
if not profiles:
logger.warning(f"未找到模拟 {simulation_id} 的人设文件")
- result.summary = "未找到可采访的Agent人设文件"
+ result.summary = "No Agent persona files found for interview"
return result
result.total_agents = len(profiles)
@@ -1350,15 +1350,15 @@ class ZepToolsService:
# 添加优化前缀,约束Agent回复格式
INTERVIEW_PROMPT_PREFIX = (
- "你正在接受一次采访。请结合你的人设、所有的过往记忆与行动,"
- "以纯文本方式直接回答以下问题。\n"
- "回复要求:\n"
- "1. 直接用自然语言回答,不要调用任何工具\n"
- "2. 不要返回JSON格式或工具调用格式\n"
- "3. 不要使用Markdown标题(如#、##、###)\n"
- "4. 按问题编号逐一回答,每个回答以「问题X:」开头(X为问题编号)\n"
- "5. 每个问题的回答之间用空行分隔\n"
- "6. 回答要有实质内容,每个问题至少回答2-3句话\n\n"
+ "You are being interviewed. Based on your persona, all past memories and actions, "
+ "respond directly in plain text to the following questions.\n"
+ "Response requirements:\n"
+ "1. Answer directly in natural language, do not call any tools\n"
+ "2. Do not return JSON format or tool call format\n"
+ "3. Do not use Markdown headings (such as #, ##, ###)\n"
+ "4. Answer each question in order, starting each answer with 'Question X:' (X is the question number)\n"
+ "5. Separate answers to different questions with blank lines\n"
+ "6. Answers should have substantial content, at least 2-3 sentences per question\n\n"
)
optimized_prompt = f"{INTERVIEW_PROMPT_PREFIX}{combined_prompt}"
@@ -1387,9 +1387,9 @@ class ZepToolsService:
# 检查API调用是否成功
if not api_result.get("success", False):
- error_msg = api_result.get("error", "未知错误")
+ error_msg = api_result.get("error", "Unknown error")
logger.warning(f"采访API返回失败: {error_msg}")
- result.summary = f"采访API调用失败:{error_msg}。请检查OASIS模拟环境状态。"
+ result.summary = f"Interview API call failed: {error_msg}. Please check the OASIS simulation environment status."
return result
# Step 5: 解析API返回结果,构建AgentInterview对象
@@ -1400,7 +1400,7 @@ class ZepToolsService:
for i, agent_idx in enumerate(selected_indices):
agent = selected_agents[i]
agent_name = agent.get("realname", agent.get("username", f"Agent_{agent_idx}"))
- agent_role = agent.get("profession", "未知")
+ agent_role = agent.get("profession", "Unknown")
agent_bio = agent.get("bio", "")
# 获取该Agent在两个平台的采访结果
@@ -1415,9 +1415,9 @@ class ZepToolsService:
reddit_response = self._clean_tool_call_response(reddit_response)
# 始终输出双平台标记
- twitter_text = twitter_response if twitter_response else "(该平台未获得回复)"
- reddit_text = reddit_response if reddit_response else "(该平台未获得回复)"
- response_text = f"【Twitter平台回答】\n{twitter_text}\n\n【Reddit平台回答】\n{reddit_text}"
+ twitter_text = twitter_response if twitter_response else "(No response obtained on this platform)"
+ reddit_text = reddit_response if reddit_response else "(No response obtained on this platform)"
+ response_text = f"[Twitter Platform Response]\n{twitter_text}\n\n[Reddit Platform Response]\n{reddit_text}"
# 提取关键引言(从两个平台的回答中)
import re
@@ -1462,13 +1462,13 @@ class ZepToolsService:
except ValueError as e:
# 模拟环境未运行
logger.warning(f"采访API调用失败(环境未运行?): {e}")
- result.summary = f"采访失败:{str(e)}。模拟环境可能已关闭,请确保OASIS环境正在运行。"
+ result.summary = f"Interview failed: {str(e)}. The simulation environment may be shut down. Please ensure the OASIS environment is running."
return result
except Exception as e:
logger.error(f"采访API调用异常: {e}")
import traceback
logger.error(traceback.format_exc())
- result.summary = f"采访过程发生错误:{str(e)}"
+ result.summary = f"Error occurred during interview: {str(e)}"
return result
# Step 6: 生成采访摘要
@@ -1539,7 +1539,7 @@ class ZepToolsService:
"username": row.get("username", ""),
"bio": row.get("description", ""),
"persona": row.get("user_char", ""),
- "profession": "未知"
+ "profession": "Unknown"
})
logger.info(f"从 twitter_profiles.csv 加载了 {len(profiles)} 个人设")
return profiles
@@ -1571,36 +1571,36 @@ class ZepToolsService:
summary = {
"index": i,
"name": profile.get("realname", profile.get("username", f"Agent_{i}")),
- "profession": profile.get("profession", "未知"),
+ "profession": profile.get("profession", "Unknown"),
"bio": profile.get("bio", "")[:200],
"interested_topics": profile.get("interested_topics", [])
}
agent_summaries.append(summary)
- system_prompt = """你是一个专业的采访策划专家。你的任务是根据采访需求,从模拟Agent列表中选择最适合采访的对象。
+ system_prompt = """You are a professional interview planning expert. Your task is to select the most suitable interview subjects from the simulation Agent list based on interview requirements.
-选择标准:
-1. Agent的身份/职业与采访主题相关
-2. Agent可能持有独特或有价值的观点
-3. 选择多样化的视角(如:支持方、反对方、中立方、专业人士等)
-4. 优先选择与事件直接相关的角色
+Selection criteria:
+1. Agent's identity/profession is relevant to the interview topic
+2. Agent may hold unique or valuable perspectives
+3. Select diverse viewpoints (e.g., supporters, opponents, neutral parties, professionals, etc.)
+4. Prioritize roles directly related to the event
-返回JSON格式:
+Return in JSON format:
{
- "selected_indices": [选中Agent的索引列表],
- "reasoning": "选择理由说明"
+ "selected_indices": [list of selected Agent indices],
+ "reasoning": "explanation of selection reasoning"
}"""
- user_prompt = f"""采访需求:
+ user_prompt = f"""Interview requirement:
{interview_requirement}
-模拟背景:
-{simulation_requirement if simulation_requirement else "未提供"}
+Simulation background:
+{simulation_requirement if simulation_requirement else "Not provided"}
-可选择的Agent列表(共{len(agent_summaries)}个):
+Available Agent list ({len(agent_summaries)} total):
{json.dumps(agent_summaries, ensure_ascii=False, indent=2)}
-请选择最多{max_agents}个最适合采访的Agent,并说明选择理由。"""
+Please select up to {max_agents} most suitable Agents for interview, and explain the selection reasoning."""
try:
response = self.llm.chat_json(
@@ -1612,7 +1612,7 @@ class ZepToolsService:
)
selected_indices = response.get("selected_indices", [])[:max_agents]
- reasoning = response.get("reasoning", "基于相关性自动选择")
+ reasoning = response.get("reasoning", "Automatically selected based on relevance")
# 获取选中的Agent完整信息
selected_agents = []
@@ -1629,7 +1629,7 @@ class ZepToolsService:
# 降级:选择前N个
selected = profiles[:max_agents]
indices = list(range(min(max_agents, len(profiles))))
- return selected, indices, "使用默认选择策略"
+ return selected, indices, "Using default selection strategy"
def _generate_interview_questions(
self,
@@ -1639,27 +1639,27 @@ class ZepToolsService:
) -> List[str]:
"""使用LLM生成采访问题"""
- agent_roles = [a.get("profession", "未知") for a in selected_agents]
-
- system_prompt = """你是一个专业的记者/采访者。根据采访需求,生成3-5个深度采访问题。
+ agent_roles = [a.get("profession", "Unknown") for a in selected_agents]
-问题要求:
-1. 开放性问题,鼓励详细回答
-2. 针对不同角色可能有不同答案
-3. 涵盖事实、观点、感受等多个维度
-4. 语言自然,像真实采访一样
-5. 每个问题控制在50字以内,简洁明了
-6. 直接提问,不要包含背景说明或前缀
+ system_prompt = """You are a professional journalist/interviewer. Based on interview requirements, generate 3-5 in-depth interview questions.
-返回JSON格式:{"questions": ["问题1", "问题2", ...]}"""
+Question requirements:
+1. Open-ended questions that encourage detailed answers
+2. Different roles may give different answers
+3. Cover multiple dimensions including facts, opinions, and feelings
+4. Natural language, like a real interview
+5. Keep each question concise and clear
+6. Ask directly, don't include background explanations or prefixes
- user_prompt = f"""采访需求:{interview_requirement}
+Return in JSON format: {"questions": ["question 1", "question 2", ...]}"""
-模拟背景:{simulation_requirement if simulation_requirement else "未提供"}
+ user_prompt = f"""Interview requirement: {interview_requirement}
-采访对象角色:{', '.join(agent_roles)}
+Simulation background: {simulation_requirement if simulation_requirement else "Not provided"}
-请生成3-5个采访问题。"""
+Interviewee roles: {', '.join(agent_roles)}
+
+Please generate 3-5 interview questions."""
try:
response = self.llm.chat_json(
@@ -1670,14 +1670,14 @@ class ZepToolsService:
temperature=0.5
)
- return response.get("questions", [f"关于{interview_requirement},您有什么看法?"])
-
+ return response.get("questions", [f"What are your thoughts on {interview_requirement}?"])
+
except Exception as e:
- logger.warning(f"生成采访问题失败: {e}")
+ logger.warning(f"Failed to generate interview questions: {e}")
return [
- f"关于{interview_requirement},您的观点是什么?",
- "这件事对您或您所代表的群体有什么影响?",
- "您认为应该如何解决或改进这个问题?"
+ f"What is your perspective on {interview_requirement}?",
+ "How does this affect you or the group you represent?",
+ "How do you think this issue should be resolved or improved?"
]
def _generate_interview_summary(
@@ -1688,35 +1688,35 @@ class ZepToolsService:
"""生成采访摘要"""
if not interviews:
- return "未完成任何采访"
-
- # 收集所有采访内容
+ return "No interviews completed"
+
+ # Collect all interview content
interview_texts = []
for interview in interviews:
- interview_texts.append(f"【{interview.agent_name}({interview.agent_role})】\n{interview.response[:500]}")
-
- system_prompt = """你是一个专业的新闻编辑。请根据多位受访者的回答,生成一份采访摘要。
+ interview_texts.append(f"[{interview.agent_name} ({interview.agent_role})]\n{interview.response[:500]}")
-摘要要求:
-1. 提炼各方主要观点
-2. 指出观点的共识和分歧
-3. 突出有价值的引言
-4. 客观中立,不偏袒任何一方
-5. 控制在1000字内
+ system_prompt = """You are a professional news editor. Based on responses from multiple interviewees, generate an interview summary.
-格式约束(必须遵守):
-- 使用纯文本段落,用空行分隔不同部分
-- 不要使用Markdown标题(如#、##、###)
-- 不要使用分割线(如---、***)
-- 引用受访者原话时使用中文引号「」
-- 可以使用**加粗**标记关键词,但不要使用其他Markdown语法"""
+Summary requirements:
+1. Distill main viewpoints from all parties
+2. Identify consensus and disagreements
+3. Highlight valuable quotes
+4. Remain objective and neutral, without favoring any party
+5. Keep within 1000 words
- user_prompt = f"""采访主题:{interview_requirement}
+Format constraints (must follow):
+- Use plain text paragraphs, separate sections with blank lines
+- Do not use Markdown headings (such as #, ##, ###)
+- Do not use dividers (such as ---, ***)
+- Use quotation marks when citing interviewee quotes
+- You may use **bold** to mark keywords, but do not use other Markdown syntax"""
-采访内容:
+ user_prompt = f"""Interview topic: {interview_requirement}
+
+Interview content:
{"".join(interview_texts)}
-请生成采访摘要。"""
+Please generate an interview summary."""
try:
summary = self.llm.chat(
@@ -1732,4 +1732,4 @@ class ZepToolsService:
except Exception as e:
logger.warning(f"生成采访摘要失败: {e}")
# 降级:简单拼接
- return f"共采访了{len(interviews)}位受访者,包括:" + "、".join([i.agent_name for i in interviews])
+ return f"Interviewed {len(interviews)} respondents, including: " + ", ".join([i.agent_name for i in interviews])
diff --git a/backend/app/utils/llm_client.py b/backend/app/utils/llm_client.py
index 6c1a81f..2d32a6c 100644
--- a/backend/app/utils/llm_client.py
+++ b/backend/app/utils/llm_client.py
@@ -25,7 +25,7 @@ class LLMClient:
self.model = model or Config.LLM_MODEL_NAME
if not self.api_key:
- raise ValueError("LLM_API_KEY 未配置")
+ raise ValueError("LLM_API_KEY is not configured")
self.client = OpenAI(
api_key=self.api_key,
@@ -99,5 +99,5 @@ class LLMClient:
try:
return json.loads(cleaned_response)
except json.JSONDecodeError:
- raise ValueError(f"LLM返回的JSON格式无效: {cleaned_response}")
+ raise ValueError(f"Invalid JSON returned by LLM: {cleaned_response}")