This commit is contained in:
2026-03-09 10:37:35 +08:00
parent ba9ed95f04
commit 8fc02944c8
17 changed files with 244 additions and 1298 deletions

View File

@@ -23,7 +23,7 @@ from src.engines.ai_data_understanding import ai_understand_data_with_dal
from src.engines.requirement_understanding import understand_requirement
from src.engines.analysis_planning import plan_analysis
from src.engines.task_execution import execute_task
from src.engines.report_generation import generate_report
from src.engines.report_generation import generate_report, _convert_chart_paths_in_report
from src.tools.tool_manager import ToolManager
from src.tools.base import _global_registry
from src.models import DataProfile, AnalysisResult
@@ -156,7 +156,8 @@ def run_analysis(
else:
report = generate_report(results, requirement, profile, output_path=run_dir)
# Save report
# Save report — convert chart paths to relative (./charts/xxx.png)
report = _convert_chart_paths_in_report(report, run_dir)
with open(report_path, 'w', encoding='utf-8') as f:
f.write(report)
@@ -262,7 +263,8 @@ def _generate_template_report(
def _collect_chart_paths(results: List[AnalysisResult], run_dir: str = "") -> str:
"""Collect all chart paths from task results for embedding in reports."""
"""Collect all chart paths from task results for embedding in reports.
Returns paths relative to run_dir (e.g. ./charts/bar_chart.png)."""
paths = []
for r in results:
if not r.success:
@@ -280,7 +282,10 @@ def _collect_chart_paths(results: List[AnalysisResult], run_dir: str = "") -> st
paths.append(cp)
if not paths:
return "(无图表)"
return "\n".join(f"- {p}" for p in paths)
# Convert to relative paths
from src.engines.report_generation import _to_relative_chart_path
rel_paths = [_to_relative_chart_path(p, run_dir) for p in paths]
return "\n".join(f"- {p}" for p in rel_paths)
if __name__ == "__main__":