feat(i18n): replace hardcoded Chinese in backend SSE progress messages
This commit is contained in:
@@ -379,7 +379,7 @@ def build_graph():
|
|||||||
task_manager.update_task(
|
task_manager.update_task(
|
||||||
task_id,
|
task_id,
|
||||||
status=TaskStatus.PROCESSING,
|
status=TaskStatus.PROCESSING,
|
||||||
message="初始化图谱构建服务..."
|
message=t('progress.initGraphService')
|
||||||
)
|
)
|
||||||
|
|
||||||
# 创建图谱构建服务
|
# 创建图谱构建服务
|
||||||
@@ -388,7 +388,7 @@ def build_graph():
|
|||||||
# 分块
|
# 分块
|
||||||
task_manager.update_task(
|
task_manager.update_task(
|
||||||
task_id,
|
task_id,
|
||||||
message="文本分块中...",
|
message=t('progress.textChunking'),
|
||||||
progress=5
|
progress=5
|
||||||
)
|
)
|
||||||
chunks = TextProcessor.split_text(
|
chunks = TextProcessor.split_text(
|
||||||
@@ -401,7 +401,7 @@ def build_graph():
|
|||||||
# 创建图谱
|
# 创建图谱
|
||||||
task_manager.update_task(
|
task_manager.update_task(
|
||||||
task_id,
|
task_id,
|
||||||
message="创建Zep图谱...",
|
message=t('progress.creatingZepGraph'),
|
||||||
progress=10
|
progress=10
|
||||||
)
|
)
|
||||||
graph_id = builder.create_graph(name=graph_name)
|
graph_id = builder.create_graph(name=graph_name)
|
||||||
@@ -413,7 +413,7 @@ def build_graph():
|
|||||||
# 设置本体
|
# 设置本体
|
||||||
task_manager.update_task(
|
task_manager.update_task(
|
||||||
task_id,
|
task_id,
|
||||||
message="设置本体定义...",
|
message=t('progress.settingOntology'),
|
||||||
progress=15
|
progress=15
|
||||||
)
|
)
|
||||||
builder.set_ontology(graph_id, ontology)
|
builder.set_ontology(graph_id, ontology)
|
||||||
@@ -429,7 +429,7 @@ def build_graph():
|
|||||||
|
|
||||||
task_manager.update_task(
|
task_manager.update_task(
|
||||||
task_id,
|
task_id,
|
||||||
message=f"开始添加 {total_chunks} 个文本块...",
|
message=t('progress.addingChunks', count=total_chunks),
|
||||||
progress=15
|
progress=15
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -443,7 +443,7 @@ def build_graph():
|
|||||||
# 等待Zep处理完成(查询每个episode的processed状态)
|
# 等待Zep处理完成(查询每个episode的processed状态)
|
||||||
task_manager.update_task(
|
task_manager.update_task(
|
||||||
task_id,
|
task_id,
|
||||||
message="等待Zep处理数据...",
|
message=t('progress.waitingZepProcess'),
|
||||||
progress=55
|
progress=55
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -460,7 +460,7 @@ def build_graph():
|
|||||||
# 获取图谱数据
|
# 获取图谱数据
|
||||||
task_manager.update_task(
|
task_manager.update_task(
|
||||||
task_id,
|
task_id,
|
||||||
message="获取图谱数据...",
|
message=t('progress.fetchingGraphData'),
|
||||||
progress=95
|
progress=95
|
||||||
)
|
)
|
||||||
graph_data = builder.get_graph_data(graph_id)
|
graph_data = builder.get_graph_data(graph_id)
|
||||||
@@ -477,7 +477,7 @@ def build_graph():
|
|||||||
task_manager.update_task(
|
task_manager.update_task(
|
||||||
task_id,
|
task_id,
|
||||||
status=TaskStatus.COMPLETED,
|
status=TaskStatus.COMPLETED,
|
||||||
message="图谱构建完成",
|
message=t('progress.graphBuildComplete'),
|
||||||
progress=100,
|
progress=100,
|
||||||
result={
|
result={
|
||||||
"project_id": project_id,
|
"project_id": project_id,
|
||||||
@@ -500,7 +500,7 @@ def build_graph():
|
|||||||
task_manager.update_task(
|
task_manager.update_task(
|
||||||
task_id,
|
task_id,
|
||||||
status=TaskStatus.FAILED,
|
status=TaskStatus.FAILED,
|
||||||
message=f"构建失败: {str(e)}",
|
message=t('progress.buildFailed', error=str(e)),
|
||||||
error=traceback.format_exc()
|
error=traceback.format_exc()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -508,7 +508,7 @@ def prepare_simulation():
|
|||||||
task_id,
|
task_id,
|
||||||
status=TaskStatus.PROCESSING,
|
status=TaskStatus.PROCESSING,
|
||||||
progress=0,
|
progress=0,
|
||||||
message="开始准备模拟环境..."
|
message=t('progress.startPreparingEnv')
|
||||||
)
|
)
|
||||||
|
|
||||||
# 准备模拟(带进度回调)
|
# 准备模拟(带进度回调)
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ from enum import Enum
|
|||||||
from typing import Dict, Any, Optional
|
from typing import Dict, Any, Optional
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
|
|
||||||
|
from ..utils.locale import t
|
||||||
|
|
||||||
|
|
||||||
class TaskStatus(str, Enum):
|
class TaskStatus(str, Enum):
|
||||||
"""任务状态枚举"""
|
"""任务状态枚举"""
|
||||||
@@ -148,7 +150,7 @@ class TaskManager:
|
|||||||
task_id,
|
task_id,
|
||||||
status=TaskStatus.COMPLETED,
|
status=TaskStatus.COMPLETED,
|
||||||
progress=100,
|
progress=100,
|
||||||
message="任务完成",
|
message=t('progress.taskComplete'),
|
||||||
result=result
|
result=result
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -157,7 +159,7 @@ class TaskManager:
|
|||||||
self.update_task(
|
self.update_task(
|
||||||
task_id,
|
task_id,
|
||||||
status=TaskStatus.FAILED,
|
status=TaskStatus.FAILED,
|
||||||
message="任务失败",
|
message=t('progress.taskFailed'),
|
||||||
error=error
|
error=error
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ from ..config import Config
|
|||||||
from ..models.task import TaskManager, TaskStatus
|
from ..models.task import TaskManager, TaskStatus
|
||||||
from ..utils.zep_paging import fetch_all_nodes, fetch_all_edges
|
from ..utils.zep_paging import fetch_all_nodes, fetch_all_edges
|
||||||
from .text_processor import TextProcessor
|
from .text_processor import TextProcessor
|
||||||
|
from ..utils.locale import t
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@@ -109,7 +110,7 @@ class GraphBuilderService:
|
|||||||
task_id,
|
task_id,
|
||||||
status=TaskStatus.PROCESSING,
|
status=TaskStatus.PROCESSING,
|
||||||
progress=5,
|
progress=5,
|
||||||
message="开始构建图谱..."
|
message=t('progress.startBuildingGraph')
|
||||||
)
|
)
|
||||||
|
|
||||||
# 1. 创建图谱
|
# 1. 创建图谱
|
||||||
@@ -117,7 +118,7 @@ class GraphBuilderService:
|
|||||||
self.task_manager.update_task(
|
self.task_manager.update_task(
|
||||||
task_id,
|
task_id,
|
||||||
progress=10,
|
progress=10,
|
||||||
message=f"图谱已创建: {graph_id}"
|
message=t('progress.graphCreated', graphId=graph_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
# 2. 设置本体
|
# 2. 设置本体
|
||||||
@@ -125,7 +126,7 @@ class GraphBuilderService:
|
|||||||
self.task_manager.update_task(
|
self.task_manager.update_task(
|
||||||
task_id,
|
task_id,
|
||||||
progress=15,
|
progress=15,
|
||||||
message="本体已设置"
|
message=t('progress.ontologySet')
|
||||||
)
|
)
|
||||||
|
|
||||||
# 3. 文本分块
|
# 3. 文本分块
|
||||||
@@ -134,7 +135,7 @@ class GraphBuilderService:
|
|||||||
self.task_manager.update_task(
|
self.task_manager.update_task(
|
||||||
task_id,
|
task_id,
|
||||||
progress=20,
|
progress=20,
|
||||||
message=f"文本已分割为 {total_chunks} 个块"
|
message=t('progress.textSplit', count=total_chunks)
|
||||||
)
|
)
|
||||||
|
|
||||||
# 4. 分批发送数据
|
# 4. 分批发送数据
|
||||||
@@ -151,7 +152,7 @@ class GraphBuilderService:
|
|||||||
self.task_manager.update_task(
|
self.task_manager.update_task(
|
||||||
task_id,
|
task_id,
|
||||||
progress=60,
|
progress=60,
|
||||||
message="等待Zep处理数据..."
|
message=t('progress.waitingZepProcess')
|
||||||
)
|
)
|
||||||
|
|
||||||
self._wait_for_episodes(
|
self._wait_for_episodes(
|
||||||
@@ -167,7 +168,7 @@ class GraphBuilderService:
|
|||||||
self.task_manager.update_task(
|
self.task_manager.update_task(
|
||||||
task_id,
|
task_id,
|
||||||
progress=90,
|
progress=90,
|
||||||
message="获取图谱信息..."
|
message=t('progress.fetchingGraphInfo')
|
||||||
)
|
)
|
||||||
|
|
||||||
graph_info = self._get_graph_info(graph_id)
|
graph_info = self._get_graph_info(graph_id)
|
||||||
@@ -304,7 +305,7 @@ class GraphBuilderService:
|
|||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress = (i + len(batch_chunks)) / total_chunks
|
progress = (i + len(batch_chunks)) / total_chunks
|
||||||
progress_callback(
|
progress_callback(
|
||||||
f"发送第 {batch_num}/{total_batches} 批数据 ({len(batch_chunks)} 块)...",
|
t('progress.sendingBatch', current=batch_num, total=total_batches, chunks=len(batch_chunks)),
|
||||||
progress
|
progress
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -333,7 +334,7 @@ class GraphBuilderService:
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback(f"批次 {batch_num} 发送失败: {str(e)}", 0)
|
progress_callback(t('progress.batchFailed', batch=batch_num, error=str(e)), 0)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
return episode_uuids
|
return episode_uuids
|
||||||
@@ -347,7 +348,7 @@ class GraphBuilderService:
|
|||||||
"""等待所有 episode 处理完成(通过查询每个 episode 的 processed 状态)"""
|
"""等待所有 episode 处理完成(通过查询每个 episode 的 processed 状态)"""
|
||||||
if not episode_uuids:
|
if not episode_uuids:
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback("无需等待(没有 episode)", 1.0)
|
progress_callback(t('progress.noEpisodesWait'), 1.0)
|
||||||
return
|
return
|
||||||
|
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
@@ -356,13 +357,13 @@ class GraphBuilderService:
|
|||||||
total_episodes = len(episode_uuids)
|
total_episodes = len(episode_uuids)
|
||||||
|
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback(f"开始等待 {total_episodes} 个文本块处理...", 0)
|
progress_callback(t('progress.waitingEpisodes', count=total_episodes), 0)
|
||||||
|
|
||||||
while pending_episodes:
|
while pending_episodes:
|
||||||
if time.time() - start_time > timeout:
|
if time.time() - start_time > timeout:
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback(
|
progress_callback(
|
||||||
f"部分文本块超时,已完成 {completed_count}/{total_episodes}",
|
t('progress.episodesTimeout', completed=completed_count, total=total_episodes),
|
||||||
completed_count / total_episodes
|
completed_count / total_episodes
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
@@ -384,7 +385,7 @@ class GraphBuilderService:
|
|||||||
elapsed = int(time.time() - start_time)
|
elapsed = int(time.time() - start_time)
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback(
|
progress_callback(
|
||||||
f"Zep处理中... {completed_count}/{total_episodes} 完成, {len(pending_episodes)} 待处理 ({elapsed}秒)",
|
t('progress.zepProcessing', completed=completed_count, total=total_episodes, pending=len(pending_episodes), elapsed=elapsed),
|
||||||
completed_count / total_episodes if total_episodes > 0 else 0
|
completed_count / total_episodes if total_episodes > 0 else 0
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -392,7 +393,7 @@ class GraphBuilderService:
|
|||||||
time.sleep(3) # 每3秒检查一次
|
time.sleep(3) # 每3秒检查一次
|
||||||
|
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback(f"处理完成: {completed_count}/{total_episodes}", 1.0)
|
progress_callback(t('progress.processingComplete', completed=completed_count, total=total_episodes), 1.0)
|
||||||
|
|
||||||
def _get_graph_info(self, graph_id: str) -> GraphInfo:
|
def _get_graph_info(self, graph_id: str) -> GraphInfo:
|
||||||
"""获取图谱信息"""
|
"""获取图谱信息"""
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ from enum import Enum
|
|||||||
from ..config import Config
|
from ..config import Config
|
||||||
from ..utils.llm_client import LLMClient
|
from ..utils.llm_client import LLMClient
|
||||||
from ..utils.logger import get_logger
|
from ..utils.logger import get_logger
|
||||||
from ..utils.locale import get_language_instruction
|
from ..utils.locale import get_language_instruction, t
|
||||||
from .zep_tools import (
|
from .zep_tools import (
|
||||||
ZepToolsService,
|
ZepToolsService,
|
||||||
SearchResult,
|
SearchResult,
|
||||||
@@ -1152,7 +1152,7 @@ class ReportAgent:
|
|||||||
logger.info("开始规划报告大纲...")
|
logger.info("开始规划报告大纲...")
|
||||||
|
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback("planning", 0, "正在分析模拟需求...")
|
progress_callback("planning", 0, t('progress.analyzingRequirements'))
|
||||||
|
|
||||||
# 首先获取模拟上下文
|
# 首先获取模拟上下文
|
||||||
context = self.zep_tools.get_simulation_context(
|
context = self.zep_tools.get_simulation_context(
|
||||||
@@ -1161,7 +1161,7 @@ class ReportAgent:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback("planning", 30, "正在生成报告大纲...")
|
progress_callback("planning", 30, t('progress.generatingOutline'))
|
||||||
|
|
||||||
system_prompt = f"{PLAN_SYSTEM_PROMPT}\n\n{get_language_instruction()}"
|
system_prompt = f"{PLAN_SYSTEM_PROMPT}\n\n{get_language_instruction()}"
|
||||||
user_prompt = PLAN_USER_PROMPT_TEMPLATE.format(
|
user_prompt = PLAN_USER_PROMPT_TEMPLATE.format(
|
||||||
@@ -1183,7 +1183,7 @@ class ReportAgent:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback("planning", 80, "正在解析大纲结构...")
|
progress_callback("planning", 80, t('progress.parsingOutline'))
|
||||||
|
|
||||||
# 解析大纲
|
# 解析大纲
|
||||||
sections = []
|
sections = []
|
||||||
@@ -1200,7 +1200,7 @@ class ReportAgent:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback("planning", 100, "大纲规划完成")
|
progress_callback("planning", 100, t('progress.outlinePlanComplete'))
|
||||||
|
|
||||||
logger.info(f"大纲规划完成: {len(sections)} 个章节")
|
logger.info(f"大纲规划完成: {len(sections)} 个章节")
|
||||||
return outline
|
return outline
|
||||||
@@ -1298,7 +1298,7 @@ class ReportAgent:
|
|||||||
progress_callback(
|
progress_callback(
|
||||||
"generating",
|
"generating",
|
||||||
int((iteration / max_iterations) * 100),
|
int((iteration / max_iterations) * 100),
|
||||||
f"深度检索与撰写中 ({tool_calls_count}/{self.MAX_TOOL_CALLS_PER_SECTION})"
|
t('progress.deepSearchAndWrite', current=tool_calls_count, max=self.MAX_TOOL_CALLS_PER_SECTION)
|
||||||
)
|
)
|
||||||
|
|
||||||
# 调用LLM
|
# 调用LLM
|
||||||
@@ -1592,7 +1592,7 @@ class ReportAgent:
|
|||||||
self.console_logger = ReportConsoleLogger(report_id)
|
self.console_logger = ReportConsoleLogger(report_id)
|
||||||
|
|
||||||
ReportManager.update_progress(
|
ReportManager.update_progress(
|
||||||
report_id, "pending", 0, "初始化报告...",
|
report_id, "pending", 0, t('progress.initReport'),
|
||||||
completed_sections=[]
|
completed_sections=[]
|
||||||
)
|
)
|
||||||
ReportManager.save_report(report)
|
ReportManager.save_report(report)
|
||||||
@@ -1600,7 +1600,7 @@ class ReportAgent:
|
|||||||
# 阶段1: 规划大纲
|
# 阶段1: 规划大纲
|
||||||
report.status = ReportStatus.PLANNING
|
report.status = ReportStatus.PLANNING
|
||||||
ReportManager.update_progress(
|
ReportManager.update_progress(
|
||||||
report_id, "planning", 5, "开始规划报告大纲...",
|
report_id, "planning", 5, t('progress.startPlanningOutline'),
|
||||||
completed_sections=[]
|
completed_sections=[]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1608,7 +1608,7 @@ class ReportAgent:
|
|||||||
self.report_logger.log_planning_start()
|
self.report_logger.log_planning_start()
|
||||||
|
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback("planning", 0, "开始规划报告大纲...")
|
progress_callback("planning", 0, t('progress.startPlanningOutline'))
|
||||||
|
|
||||||
outline = self.plan_outline(
|
outline = self.plan_outline(
|
||||||
progress_callback=lambda stage, prog, msg:
|
progress_callback=lambda stage, prog, msg:
|
||||||
@@ -1622,7 +1622,7 @@ class ReportAgent:
|
|||||||
# 保存大纲到文件
|
# 保存大纲到文件
|
||||||
ReportManager.save_outline(report_id, outline)
|
ReportManager.save_outline(report_id, outline)
|
||||||
ReportManager.update_progress(
|
ReportManager.update_progress(
|
||||||
report_id, "planning", 15, f"大纲规划完成,共{len(outline.sections)}个章节",
|
report_id, "planning", 15, t('progress.outlineDone', count=len(outline.sections)),
|
||||||
completed_sections=[]
|
completed_sections=[]
|
||||||
)
|
)
|
||||||
ReportManager.save_report(report)
|
ReportManager.save_report(report)
|
||||||
@@ -1642,16 +1642,16 @@ class ReportAgent:
|
|||||||
# 更新进度
|
# 更新进度
|
||||||
ReportManager.update_progress(
|
ReportManager.update_progress(
|
||||||
report_id, "generating", base_progress,
|
report_id, "generating", base_progress,
|
||||||
f"正在生成章节: {section.title} ({section_num}/{total_sections})",
|
t('progress.generatingSection', title=section.title, current=section_num, total=total_sections),
|
||||||
current_section=section.title,
|
current_section=section.title,
|
||||||
completed_sections=completed_section_titles
|
completed_sections=completed_section_titles
|
||||||
)
|
)
|
||||||
|
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback(
|
progress_callback(
|
||||||
"generating",
|
"generating",
|
||||||
base_progress,
|
base_progress,
|
||||||
f"正在生成章节: {section.title} ({section_num}/{total_sections})"
|
t('progress.generatingSection', title=section.title, current=section_num, total=total_sections)
|
||||||
)
|
)
|
||||||
|
|
||||||
# 生成主章节内容
|
# 生成主章节内容
|
||||||
@@ -1691,17 +1691,17 @@ class ReportAgent:
|
|||||||
ReportManager.update_progress(
|
ReportManager.update_progress(
|
||||||
report_id, "generating",
|
report_id, "generating",
|
||||||
base_progress + int(70 / total_sections),
|
base_progress + int(70 / total_sections),
|
||||||
f"章节 {section.title} 已完成",
|
t('progress.sectionDone', title=section.title),
|
||||||
current_section=None,
|
current_section=None,
|
||||||
completed_sections=completed_section_titles
|
completed_sections=completed_section_titles
|
||||||
)
|
)
|
||||||
|
|
||||||
# 阶段3: 组装完整报告
|
# 阶段3: 组装完整报告
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback("generating", 95, "正在组装完整报告...")
|
progress_callback("generating", 95, t('progress.assemblingReport'))
|
||||||
|
|
||||||
ReportManager.update_progress(
|
ReportManager.update_progress(
|
||||||
report_id, "generating", 95, "正在组装完整报告...",
|
report_id, "generating", 95, t('progress.assemblingReport'),
|
||||||
completed_sections=completed_section_titles
|
completed_sections=completed_section_titles
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1723,12 +1723,12 @@ class ReportAgent:
|
|||||||
# 保存最终报告
|
# 保存最终报告
|
||||||
ReportManager.save_report(report)
|
ReportManager.save_report(report)
|
||||||
ReportManager.update_progress(
|
ReportManager.update_progress(
|
||||||
report_id, "completed", 100, "报告生成完成",
|
report_id, "completed", 100, t('progress.reportComplete'),
|
||||||
completed_sections=completed_section_titles
|
completed_sections=completed_section_titles
|
||||||
)
|
)
|
||||||
|
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback("completed", 100, "报告生成完成")
|
progress_callback("completed", 100, t('progress.reportComplete'))
|
||||||
|
|
||||||
logger.info(f"报告生成完成: {report_id}")
|
logger.info(f"报告生成完成: {report_id}")
|
||||||
|
|
||||||
@@ -1752,7 +1752,7 @@ class ReportAgent:
|
|||||||
try:
|
try:
|
||||||
ReportManager.save_report(report)
|
ReportManager.save_report(report)
|
||||||
ReportManager.update_progress(
|
ReportManager.update_progress(
|
||||||
report_id, "failed", -1, f"报告生成失败: {str(e)}",
|
report_id, "failed", -1, t('progress.reportFailed', error=str(e)),
|
||||||
completed_sections=completed_section_titles
|
completed_sections=completed_section_titles
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ from ..utils.logger import get_logger
|
|||||||
from .zep_entity_reader import ZepEntityReader, FilteredEntities
|
from .zep_entity_reader import ZepEntityReader, FilteredEntities
|
||||||
from .oasis_profile_generator import OasisProfileGenerator, OasisAgentProfile
|
from .oasis_profile_generator import OasisProfileGenerator, OasisAgentProfile
|
||||||
from .simulation_config_generator import SimulationConfigGenerator, SimulationParameters
|
from .simulation_config_generator import SimulationConfigGenerator, SimulationParameters
|
||||||
|
from ..utils.locale import t
|
||||||
|
|
||||||
logger = get_logger('mirofish.simulation')
|
logger = get_logger('mirofish.simulation')
|
||||||
|
|
||||||
@@ -270,12 +271,12 @@ class SimulationManager:
|
|||||||
|
|
||||||
# ========== 阶段1: 读取并过滤实体 ==========
|
# ========== 阶段1: 读取并过滤实体 ==========
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback("reading", 0, "正在连接Zep图谱...")
|
progress_callback("reading", 0, t('progress.connectingZepGraph'))
|
||||||
|
|
||||||
reader = ZepEntityReader()
|
reader = ZepEntityReader()
|
||||||
|
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback("reading", 30, "正在读取节点数据...")
|
progress_callback("reading", 30, t('progress.readingNodeData'))
|
||||||
|
|
||||||
filtered = reader.filter_defined_entities(
|
filtered = reader.filter_defined_entities(
|
||||||
graph_id=state.graph_id,
|
graph_id=state.graph_id,
|
||||||
@@ -288,8 +289,8 @@ class SimulationManager:
|
|||||||
|
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback(
|
progress_callback(
|
||||||
"reading", 100,
|
"reading", 100,
|
||||||
f"完成,共 {filtered.filtered_count} 个实体",
|
t('progress.readingComplete', count=filtered.filtered_count),
|
||||||
current=filtered.filtered_count,
|
current=filtered.filtered_count,
|
||||||
total=filtered.filtered_count
|
total=filtered.filtered_count
|
||||||
)
|
)
|
||||||
@@ -305,8 +306,8 @@ class SimulationManager:
|
|||||||
|
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback(
|
progress_callback(
|
||||||
"generating_profiles", 0,
|
"generating_profiles", 0,
|
||||||
"开始生成...",
|
t('progress.startGenerating'),
|
||||||
current=0,
|
current=0,
|
||||||
total=total_entities
|
total=total_entities
|
||||||
)
|
)
|
||||||
|
|||||||
115
locales/en.json
115
locales/en.json
@@ -352,5 +352,120 @@
|
|||||||
"envNotRunningShort": "Environment not running or closed",
|
"envNotRunningShort": "Environment not running or closed",
|
||||||
"requireGraphIdAndQuery": "Please provide graph_id and query",
|
"requireGraphIdAndQuery": "Please provide graph_id and query",
|
||||||
"initReportAgent": "Initializing Report Agent..."
|
"initReportAgent": "Initializing Report Agent..."
|
||||||
|
},
|
||||||
|
"progress": {
|
||||||
|
"initGraphService": "Initializing graph build service...",
|
||||||
|
"textChunking": "Chunking text...",
|
||||||
|
"creatingZepGraph": "Creating Zep graph...",
|
||||||
|
"settingOntology": "Setting ontology definition...",
|
||||||
|
"addingChunks": "Adding {count} text chunks...",
|
||||||
|
"waitingZepProcess": "Waiting for Zep to process data...",
|
||||||
|
"fetchingGraphData": "Fetching graph data...",
|
||||||
|
"graphBuildComplete": "Graph build complete",
|
||||||
|
"buildFailed": "Build failed: {error}",
|
||||||
|
"startBuildingGraph": "Starting graph build...",
|
||||||
|
"graphCreated": "Graph created: {graphId}",
|
||||||
|
"ontologySet": "Ontology set",
|
||||||
|
"textSplit": "Text split into {count} chunks",
|
||||||
|
"fetchingGraphInfo": "Fetching graph info...",
|
||||||
|
"sendingBatch": "Sending batch {current}/{total} ({chunks} chunks)...",
|
||||||
|
"batchFailed": "Batch {batch} failed: {error}",
|
||||||
|
"noEpisodesWait": "No episodes to wait for",
|
||||||
|
"waitingEpisodes": "Waiting for {count} text chunks to process...",
|
||||||
|
"episodesTimeout": "Some chunks timed out, {completed}/{total} completed",
|
||||||
|
"zepProcessing": "Zep processing... {completed}/{total} done, {pending} pending ({elapsed}s)",
|
||||||
|
"processingComplete": "Processing complete: {completed}/{total}",
|
||||||
|
"taskComplete": "Task complete",
|
||||||
|
"taskFailed": "Task failed",
|
||||||
|
"startPreparingEnv": "Preparing simulation environment...",
|
||||||
|
"connectingZepGraph": "Connecting to Zep graph...",
|
||||||
|
"readingNodeData": "Reading node data...",
|
||||||
|
"readingComplete": "Done, {count} entities found",
|
||||||
|
"startGenerating": "Starting generation...",
|
||||||
|
"analyzingRequirements": "Analyzing simulation requirements...",
|
||||||
|
"generatingOutline": "Generating report outline...",
|
||||||
|
"parsingOutline": "Parsing outline structure...",
|
||||||
|
"outlinePlanComplete": "Outline planning complete",
|
||||||
|
"deepSearchAndWrite": "Deep search & writing ({current}/{max})",
|
||||||
|
"initReport": "Initializing report...",
|
||||||
|
"startPlanningOutline": "Planning report outline...",
|
||||||
|
"outlineDone": "Outline complete, {count} sections",
|
||||||
|
"generatingSection": "Generating section: {title} ({current}/{total})",
|
||||||
|
"sectionDone": "Section {title} complete",
|
||||||
|
"assemblingReport": "Assembling full report...",
|
||||||
|
"reportComplete": "Report generation complete",
|
||||||
|
"reportFailed": "Report generation failed: {error}"
|
||||||
|
},
|
||||||
|
"log": {
|
||||||
|
"preparingGoBack": "Preparing to return to Step 2, closing simulation...",
|
||||||
|
"closingSimEnv": "Closing simulation environment...",
|
||||||
|
"simEnvClosed": "✓ Simulation environment closed",
|
||||||
|
"closeSimEnvFailed": "Failed to close simulation environment, attempting force stop...",
|
||||||
|
"simForceStopSuccess": "✓ Simulation force stopped",
|
||||||
|
"forceStopFailed": "Force stop failed: {error}",
|
||||||
|
"stoppingSimProcess": "Stopping simulation process...",
|
||||||
|
"simStopped": "✓ Simulation stopped",
|
||||||
|
"stopSimFailed": "Failed to stop simulation: {error}",
|
||||||
|
"checkStatusFailed": "Failed to check simulation status: {error}",
|
||||||
|
"enterStep4": "Entering Step 4: Report Generation",
|
||||||
|
"loadingSimData": "Loading simulation data: {id}",
|
||||||
|
"timeConfig": "Time config: {minutes} minutes per round",
|
||||||
|
"timeConfigFetchFailed": "Failed to fetch time config, using default: {minutes} min/round",
|
||||||
|
"projectLoadSuccess": "Project loaded: {id}",
|
||||||
|
"loadSimDataFailed": "Failed to load simulation data: {error}",
|
||||||
|
"loadException": "Load error: {error}",
|
||||||
|
"graphDataLoadSuccess": "Graph data loaded successfully",
|
||||||
|
"graphLoadFailed": "Graph load failed: {error}",
|
||||||
|
"graphRealtimeRefreshStart": "Graph real-time refresh enabled (30s)",
|
||||||
|
"graphRealtimeRefreshStop": "Graph real-time refresh stopped",
|
||||||
|
"simRunViewInit": "SimulationRunView initialized",
|
||||||
|
"customRounds": "Custom simulation rounds: {rounds}",
|
||||||
|
"enterStep3": "Entering Step 3: Run Simulation",
|
||||||
|
"customRoundsConfig": "Custom simulation rounds: {rounds} rounds",
|
||||||
|
"useAutoRounds": "Using auto-configured simulation rounds",
|
||||||
|
"detectedSimEnvRunning": "Detected running simulation environment, closing...",
|
||||||
|
"closeSimEnvFailedWithError": "Failed to close simulation environment: {error}",
|
||||||
|
"closeSimEnvException": "Simulation environment close error: {error}",
|
||||||
|
"detectedSimRunning": "Detected simulation is running, stopping...",
|
||||||
|
"forceStopSimFailed": "Force stop simulation failed: {error}",
|
||||||
|
"forceStopSimException": "Force stop simulation error: {error}",
|
||||||
|
"simViewInit": "SimulationView initialized",
|
||||||
|
"errorMissingSimId": "Error: missing simulationId",
|
||||||
|
"simInstanceCreated": "Simulation instance created: {id}",
|
||||||
|
"preparingSimEnv": "Preparing simulation environment...",
|
||||||
|
"detectedExistingPrep": "Detected existing preparation, using it directly",
|
||||||
|
"prepareTaskStarted": "Preparation task started",
|
||||||
|
"prepareTaskId": " └─ Task ID: {taskId}",
|
||||||
|
"zepEntitiesFound": "Found {count} entities from Zep graph",
|
||||||
|
"entityTypes": " └─ Entity types: {types}",
|
||||||
|
"startPollingProgress": "Polling preparation progress...",
|
||||||
|
"prepareFailed": "Preparation failed: {error}",
|
||||||
|
"prepareException": "Preparation error: {error}",
|
||||||
|
"prepareComplete": "✓ Preparation complete",
|
||||||
|
"prepareFailedWithError": "✗ Preparation failed: {error}",
|
||||||
|
"startGeneratingConfig": "Generating dual-platform simulation config...",
|
||||||
|
"generatingAgentProfileConfig": "Generating agent persona config...",
|
||||||
|
"generatingLLMConfig": "Calling LLM to generate simulation config parameters...",
|
||||||
|
"configComplete": "✓ Simulation config generated",
|
||||||
|
"configSummaryAgents": " ├─ Agents: {count}",
|
||||||
|
"configSummaryHours": " ├─ Duration: {hours} hours",
|
||||||
|
"configSummaryPosts": " ├─ Initial posts: {count}",
|
||||||
|
"configSummaryTopics": " ├─ Hot topics: {count}",
|
||||||
|
"configSummaryPlatforms": " └─ Platforms: Twitter {twitter}, Reddit {reddit}",
|
||||||
|
"timeConfigDetail": "Time config: {minutes} min/round, {rounds} rounds total",
|
||||||
|
"narrativeDirection": "Narrative direction: {direction}",
|
||||||
|
"envSetupComplete": "✓ Environment setup complete, ready to simulate",
|
||||||
|
"startSimCustomRounds": "Starting simulation, custom rounds: {rounds}",
|
||||||
|
"startSimAutoRounds": "Starting simulation, auto-configured rounds: {rounds}",
|
||||||
|
"startGeneratingAgentProfiles": "Generating agent personas...",
|
||||||
|
"agentProfile": "→ Agent persona {current}/{total}: {name} ({profession})",
|
||||||
|
"allProfilesComplete": "✓ All {count} agent personas generated",
|
||||||
|
"loadingExistingConfig": "Loading existing config data...",
|
||||||
|
"loadedAgentProfiles": "Loaded {count} agent personas",
|
||||||
|
"configLoadSuccess": "✓ Simulation config loaded",
|
||||||
|
"configSummaryPostsAlt": " └─ Initial posts: {count}",
|
||||||
|
"configGenerating": "Config generating, polling...",
|
||||||
|
"loadConfigFailed": "Failed to load config: {error}",
|
||||||
|
"step2Init": "Step 2 environment setup initialized"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
115
locales/zh.json
115
locales/zh.json
@@ -352,5 +352,120 @@
|
|||||||
"envNotRunningShort": "环境未运行或已关闭",
|
"envNotRunningShort": "环境未运行或已关闭",
|
||||||
"requireGraphIdAndQuery": "请提供 graph_id 和 query",
|
"requireGraphIdAndQuery": "请提供 graph_id 和 query",
|
||||||
"initReportAgent": "初始化Report Agent..."
|
"initReportAgent": "初始化Report Agent..."
|
||||||
|
},
|
||||||
|
"progress": {
|
||||||
|
"initGraphService": "初始化图谱构建服务...",
|
||||||
|
"textChunking": "文本分块中...",
|
||||||
|
"creatingZepGraph": "创建Zep图谱...",
|
||||||
|
"settingOntology": "设置本体定义...",
|
||||||
|
"addingChunks": "开始添加 {count} 个文本块...",
|
||||||
|
"waitingZepProcess": "等待Zep处理数据...",
|
||||||
|
"fetchingGraphData": "获取图谱数据...",
|
||||||
|
"graphBuildComplete": "图谱构建完成",
|
||||||
|
"buildFailed": "构建失败: {error}",
|
||||||
|
"startBuildingGraph": "开始构建图谱...",
|
||||||
|
"graphCreated": "图谱已创建: {graphId}",
|
||||||
|
"ontologySet": "本体已设置",
|
||||||
|
"textSplit": "文本已分割为 {count} 个块",
|
||||||
|
"fetchingGraphInfo": "获取图谱信息...",
|
||||||
|
"sendingBatch": "发送第 {current}/{total} 批数据 ({chunks} 块)...",
|
||||||
|
"batchFailed": "批次 {batch} 发送失败: {error}",
|
||||||
|
"noEpisodesWait": "无需等待(没有 episode)",
|
||||||
|
"waitingEpisodes": "开始等待 {count} 个文本块处理...",
|
||||||
|
"episodesTimeout": "部分文本块超时,已完成 {completed}/{total}",
|
||||||
|
"zepProcessing": "Zep处理中... {completed}/{total} 完成, {pending} 待处理 ({elapsed}秒)",
|
||||||
|
"processingComplete": "处理完成: {completed}/{total}",
|
||||||
|
"taskComplete": "任务完成",
|
||||||
|
"taskFailed": "任务失败",
|
||||||
|
"startPreparingEnv": "开始准备模拟环境...",
|
||||||
|
"connectingZepGraph": "正在连接Zep图谱...",
|
||||||
|
"readingNodeData": "正在读取节点数据...",
|
||||||
|
"readingComplete": "完成,共 {count} 个实体",
|
||||||
|
"startGenerating": "开始生成...",
|
||||||
|
"analyzingRequirements": "正在分析模拟需求...",
|
||||||
|
"generatingOutline": "正在生成报告大纲...",
|
||||||
|
"parsingOutline": "正在解析大纲结构...",
|
||||||
|
"outlinePlanComplete": "大纲规划完成",
|
||||||
|
"deepSearchAndWrite": "深度检索与撰写中 ({current}/{max})",
|
||||||
|
"initReport": "初始化报告...",
|
||||||
|
"startPlanningOutline": "开始规划报告大纲...",
|
||||||
|
"outlineDone": "大纲规划完成,共{count}个章节",
|
||||||
|
"generatingSection": "正在生成章节: {title} ({current}/{total})",
|
||||||
|
"sectionDone": "章节 {title} 已完成",
|
||||||
|
"assemblingReport": "正在组装完整报告...",
|
||||||
|
"reportComplete": "报告生成完成",
|
||||||
|
"reportFailed": "报告生成失败: {error}"
|
||||||
|
},
|
||||||
|
"log": {
|
||||||
|
"preparingGoBack": "准备返回 Step 2,正在关闭模拟...",
|
||||||
|
"closingSimEnv": "正在关闭模拟环境...",
|
||||||
|
"simEnvClosed": "✓ 模拟环境已关闭",
|
||||||
|
"closeSimEnvFailed": "关闭模拟环境失败,尝试强制停止...",
|
||||||
|
"simForceStopSuccess": "✓ 模拟已强制停止",
|
||||||
|
"forceStopFailed": "强制停止失败: {error}",
|
||||||
|
"stoppingSimProcess": "正在停止模拟进程...",
|
||||||
|
"simStopped": "✓ 模拟已停止",
|
||||||
|
"stopSimFailed": "停止模拟失败: {error}",
|
||||||
|
"checkStatusFailed": "检查模拟状态失败: {error}",
|
||||||
|
"enterStep4": "进入 Step 4: 报告生成",
|
||||||
|
"loadingSimData": "加载模拟数据: {id}",
|
||||||
|
"timeConfig": "时间配置: 每轮 {minutes} 分钟",
|
||||||
|
"timeConfigFetchFailed": "获取时间配置失败,使用默认值: {minutes}分钟/轮",
|
||||||
|
"projectLoadSuccess": "项目加载成功: {id}",
|
||||||
|
"loadSimDataFailed": "加载模拟数据失败: {error}",
|
||||||
|
"loadException": "加载异常: {error}",
|
||||||
|
"graphDataLoadSuccess": "图谱数据加载成功",
|
||||||
|
"graphLoadFailed": "图谱加载失败: {error}",
|
||||||
|
"graphRealtimeRefreshStart": "开启图谱实时刷新 (30s)",
|
||||||
|
"graphRealtimeRefreshStop": "停止图谱实时刷新",
|
||||||
|
"simRunViewInit": "SimulationRunView 初始化",
|
||||||
|
"customRounds": "自定义模拟轮数: {rounds}",
|
||||||
|
"enterStep3": "进入 Step 3: 开始模拟",
|
||||||
|
"customRoundsConfig": "自定义模拟轮数: {rounds} 轮",
|
||||||
|
"useAutoRounds": "使用自动配置的模拟轮数",
|
||||||
|
"detectedSimEnvRunning": "检测到模拟环境正在运行,正在关闭...",
|
||||||
|
"closeSimEnvFailedWithError": "关闭模拟环境失败: {error}",
|
||||||
|
"closeSimEnvException": "关闭模拟环境异常: {error}",
|
||||||
|
"detectedSimRunning": "检测到模拟状态为运行中,正在停止...",
|
||||||
|
"forceStopSimFailed": "强制停止模拟失败: {error}",
|
||||||
|
"forceStopSimException": "强制停止模拟异常: {error}",
|
||||||
|
"simViewInit": "SimulationView 初始化",
|
||||||
|
"errorMissingSimId": "错误:缺少 simulationId",
|
||||||
|
"simInstanceCreated": "模拟实例已创建: {id}",
|
||||||
|
"preparingSimEnv": "正在准备模拟环境...",
|
||||||
|
"detectedExistingPrep": "检测到已有完成的准备工作,直接使用",
|
||||||
|
"prepareTaskStarted": "准备任务已启动",
|
||||||
|
"prepareTaskId": " └─ Task ID: {taskId}",
|
||||||
|
"zepEntitiesFound": "从Zep图谱读取到 {count} 个实体",
|
||||||
|
"entityTypes": " └─ 实体类型: {types}",
|
||||||
|
"startPollingProgress": "开始轮询准备进度...",
|
||||||
|
"prepareFailed": "准备失败: {error}",
|
||||||
|
"prepareException": "准备异常: {error}",
|
||||||
|
"prepareComplete": "✓ 准备工作已完成",
|
||||||
|
"prepareFailedWithError": "✗ 准备失败: {error}",
|
||||||
|
"startGeneratingConfig": "开始生成双平台模拟配置...",
|
||||||
|
"generatingAgentProfileConfig": "正在生成Agent人设配置...",
|
||||||
|
"generatingLLMConfig": "正在调用LLM生成模拟配置参数...",
|
||||||
|
"configComplete": "✓ 模拟配置生成完成",
|
||||||
|
"configSummaryAgents": " ├─ Agent数量: {count}个",
|
||||||
|
"configSummaryHours": " ├─ 模拟时长: {hours}小时",
|
||||||
|
"configSummaryPosts": " ├─ 初始帖子: {count}条",
|
||||||
|
"configSummaryTopics": " ├─ 热点话题: {count}个",
|
||||||
|
"configSummaryPlatforms": " └─ 平台配置: Twitter {twitter}, Reddit {reddit}",
|
||||||
|
"timeConfigDetail": "时间配置: 每轮{minutes}分钟, 共{rounds}轮",
|
||||||
|
"narrativeDirection": "叙事方向: {direction}",
|
||||||
|
"envSetupComplete": "✓ 环境搭建完成,可以开始模拟",
|
||||||
|
"startSimCustomRounds": "开始模拟,自定义轮数: {rounds} 轮",
|
||||||
|
"startSimAutoRounds": "开始模拟,使用自动配置轮数: {rounds} 轮",
|
||||||
|
"startGeneratingAgentProfiles": "开始生成Agent人设...",
|
||||||
|
"agentProfile": "→ Agent人设 {current}/{total}: {name} ({profession})",
|
||||||
|
"allProfilesComplete": "✓ 全部 {count} 个Agent人设生成完成",
|
||||||
|
"loadingExistingConfig": "正在加载已有配置数据...",
|
||||||
|
"loadedAgentProfiles": "已加载 {count} 个Agent人设",
|
||||||
|
"configLoadSuccess": "✓ 模拟配置加载成功",
|
||||||
|
"configSummaryPostsAlt": " └─ 初始帖子: {count}条",
|
||||||
|
"configGenerating": "配置生成中,开始轮询等待...",
|
||||||
|
"loadConfigFailed": "加载配置失败: {error}",
|
||||||
|
"step2Init": "Step2 环境搭建初始化"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user