#!/usr/bin/env python3 """ Generate HTML report comparing RAG modes Visualizes benchmark results with charts and tables """ import json from pathlib import Path from datetime import datetime import statistics class RAGComparisonReporter: """Generate HTML reports from benchmark data""" def __init__(self, results_file: str = "data/benchmark_results.json"): """Initialize reporter with benchmark results""" self.results_file = Path(results_file) self.data = None self.load_results() def load_results(self): """Load benchmark results from JSON""" if self.results_file.exists(): with open(self.results_file, "r") as f: self.data = json.load(f) else: print(f"Results file not found: {self.results_file}") self.data = {} def generate_html(self, output_file: str = "rag_comparison_report.html"): """Generate complete HTML report""" html_content = f"""
Comprehensive benchmark of Simple, Agentic, and Graph RAG modes
| RAG Mode | Latency (ms) | Tokens/Query | Sources | Cost/Query |
|---|---|---|---|---|
| {mode.upper()} | {data['latency']['mean_ms']:.0f} | {data['tokens']['total_avg']:.0f} | {data['sources_avg']:.1f} | ${data['cost_per_query_usd']:.4f} |