text2sql-eval-toolkit 1.0.0__tar.gz → 1.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. text2sql_eval_toolkit-1.3.0/MANIFEST.in +7 -0
  2. {text2sql_eval_toolkit-1.0.0/src/text2sql_eval_toolkit.egg-info → text2sql_eval_toolkit-1.3.0}/PKG-INFO +107 -6
  3. text2sql_eval_toolkit-1.0.0/PKG-INFO → text2sql_eval_toolkit-1.3.0/README.md +86 -52
  4. text2sql_eval_toolkit-1.3.0/dashboard/dist/assets/BenchmarkDetail-DQVQUBUE.js +4 -0
  5. text2sql_eval_toolkit-1.3.0/dashboard/dist/assets/ComboBox-Cz5Wuuu_.js +1 -0
  6. text2sql_eval_toolkit-1.3.0/dashboard/dist/assets/ErrorAnalysis-ho3kmDX5.js +1 -0
  7. text2sql_eval_toolkit-1.3.0/dashboard/dist/assets/LLMJudgeConfigView-QUABvu1n.js +1 -0
  8. text2sql_eval_toolkit-1.3.0/dashboard/dist/assets/PipelineCompareView-DMBvJ9fJ.js +1 -0
  9. text2sql_eval_toolkit-1.3.0/dashboard/dist/assets/PipelineDetailView-C0cISSC5.js +1 -0
  10. text2sql_eval_toolkit-1.3.0/dashboard/dist/assets/ProfileCompareView-cDVUz-M5.js +1 -0
  11. text2sql_eval_toolkit-1.3.0/dashboard/dist/assets/ResultTableView-Dq7hZwq5.js +1 -0
  12. text2sql_eval_toolkit-1.3.0/dashboard/dist/assets/RunEvaluationView-DBFPVXhW.js +1 -0
  13. text2sql_eval_toolkit-1.3.0/dashboard/dist/assets/ToolkitInsightsView-D3K_ufFW.js +1 -0
  14. text2sql_eval_toolkit-1.3.0/dashboard/dist/assets/defaultItemToString-BtCahKYf.js +9 -0
  15. text2sql_eval_toolkit-1.3.0/dashboard/dist/assets/github-DKhhs9_z.png +0 -0
  16. text2sql_eval_toolkit-1.3.0/dashboard/dist/assets/index-C9VP9iwL.js +97 -0
  17. text2sql_eval_toolkit-1.3.0/dashboard/dist/assets/index-CcHG1DIP.css +1 -0
  18. text2sql_eval_toolkit-1.3.0/dashboard/dist/assets/metricInsightsSelect-B46SO2Wy.js +1 -0
  19. text2sql_eval_toolkit-1.3.0/dashboard/dist/assets/text2sql-eval-toolkit-logo-BPykp9hG.png +0 -0
  20. text2sql_eval_toolkit-1.3.0/dashboard/dist/index.html +14 -0
  21. text2sql_eval_toolkit-1.3.0/pyproject.toml +196 -0
  22. text2sql_eval_toolkit-1.3.0/setup.py +52 -0
  23. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit/__init__.py +17 -2
  24. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/_version.py +36 -0
  25. {text2sql_eval_toolkit-1.0.0/src/text2sql_eval_toolkit/execution → text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/analysis}/__init__.py +0 -1
  26. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit/analysis/error_analysis.py +70 -19
  27. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit/analysis/report_tools.py +68 -32
  28. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/cli.py +381 -0
  29. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit/config_args.py +1 -1
  30. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit/data/__init__.py +0 -1
  31. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit/data/benchmarks.json +64 -47
  32. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit/data/test-benchmarks.json +54 -54
  33. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit/env_loader.py +25 -9
  34. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit/evaluation/__init__.py +1 -2
  35. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit/evaluation/evaluation_tools.py +114 -59
  36. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit/evaluation/llm_as_judge.py +49 -1
  37. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/evaluation/llm_judge_config/llm_judge_alt_config.yaml +43 -0
  38. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/evaluation/llm_judge_config/llm_judge_default_config.yaml +43 -0
  39. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/evaluation/llm_judge_config/llm_judge_no_gt_v1.yaml +38 -0
  40. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/evaluation/llm_judge_config/llm_judge_no_gt_v2.yaml +38 -0
  41. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/evaluation/metric_definitions.py +194 -0
  42. {text2sql_eval_toolkit-1.0.0/src/text2sql_eval_toolkit/analysis → text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/execution}/__init__.py +0 -1
  43. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit/execution/execution_tools.py +136 -47
  44. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit/execution/replace_select_tool.py +2 -2
  45. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/indexing/__init__.py +30 -0
  46. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/indexing/builder.py +427 -0
  47. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/indexing/scanner.py +119 -0
  48. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/indexing/store.py +572 -0
  49. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit/inference/__init__.py +0 -1
  50. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit/inference/agentic_pipeline.py +86 -46
  51. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit/inference/base_pipeline.py +2 -1
  52. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit/inference/baseline_llm_pipeline.py +19 -8
  53. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit/inference/inference_tools.py +377 -46
  54. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/logging.py +99 -0
  55. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/metrics/__init__.py +66 -0
  56. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/metrics/text2sql_utils.py +1081 -0
  57. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit/profiling/profiling_tools.py +39 -2
  58. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/results/__init__.py +30 -0
  59. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/results/_hub.py +366 -0
  60. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/__init__.py +3 -0
  61. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/aliases.py +91 -0
  62. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/auth.py +169 -0
  63. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/capabilities.py +183 -0
  64. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/dataframes.py +77 -0
  65. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/indexes.py +131 -0
  66. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/jobs.py +33 -0
  67. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/judge_budget.py +327 -0
  68. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/middleware.py +307 -0
  69. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/models.py +375 -0
  70. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/paths.py +153 -0
  71. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/registry.py +168 -0
  72. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/routers_auth.py +141 -0
  73. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/routers_benchmarks.py +513 -0
  74. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/routers_compare.py +234 -0
  75. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/routers_errors.py +208 -0
  76. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/routers_execution.py +771 -0
  77. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/routers_jobs.py +85 -0
  78. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/routers_judge.py +294 -0
  79. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/routers_judge_configs.py +112 -0
  80. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/routers_results.py +123 -0
  81. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/runtime.py +131 -0
  82. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/server.py +381 -0
  83. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit/ui/static_files.py +251 -0
  84. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit/utils.py +111 -40
  85. text2sql_eval_toolkit-1.0.0/README.md → text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit.egg-info/PKG-INFO +153 -4
  86. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit.egg-info/SOURCES.txt +119 -0
  87. text2sql_eval_toolkit-1.3.0/src/text2sql_eval_toolkit.egg-info/entry_points.txt +3 -0
  88. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit.egg-info/requires.txt +22 -1
  89. text2sql_eval_toolkit-1.3.0/tests/test_auth_google.py +219 -0
  90. text2sql_eval_toolkit-1.3.0/tests/test_capability_tiers.py +402 -0
  91. text2sql_eval_toolkit-1.3.0/tests/test_category_summary_differential.py +185 -0
  92. text2sql_eval_toolkit-1.3.0/tests/test_copilot_review_fixes.py +171 -0
  93. text2sql_eval_toolkit-1.3.0/tests/test_dashboard_api_index.py +438 -0
  94. text2sql_eval_toolkit-1.3.0/tests/test_dashboard_spa_routing.py +197 -0
  95. text2sql_eval_toolkit-1.3.0/tests/test_dataframe_previews.py +204 -0
  96. text2sql_eval_toolkit-1.3.0/tests/test_error_analysis.py +286 -0
  97. text2sql_eval_toolkit-1.3.0/tests/test_evaluate_prediction.py +327 -0
  98. text2sql_eval_toolkit-1.3.0/tests/test_index_concurrency.py +156 -0
  99. text2sql_eval_toolkit-1.3.0/tests/test_indexing_builder.py +209 -0
  100. text2sql_eval_toolkit-1.3.0/tests/test_indexing_differential.py +233 -0
  101. text2sql_eval_toolkit-1.3.0/tests/test_indexing_scanner.py +93 -0
  102. text2sql_eval_toolkit-1.3.0/tests/test_judge_endpoint.py +298 -0
  103. text2sql_eval_toolkit-1.3.0/tests/test_logging_setup.py +193 -0
  104. text2sql_eval_toolkit-1.3.0/tests/test_pipeline_aliases.py +190 -0
  105. text2sql_eval_toolkit-1.3.0/tests/test_proxy_forwarding.py +142 -0
  106. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/tests/test_public_api.py +2 -3
  107. text2sql_eval_toolkit-1.3.0/tests/test_registry_sync.py +86 -0
  108. text2sql_eval_toolkit-1.3.0/tests/test_report_tools.py +294 -0
  109. text2sql_eval_toolkit-1.3.0/tests/test_route_table.py +92 -0
  110. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/tests/test_run_experiment_behavior.py +0 -1
  111. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/tests/test_run_experiment_integration.py +7 -6
  112. text2sql_eval_toolkit-1.3.0/tests/test_security_hardening.py +338 -0
  113. text2sql_eval_toolkit-1.3.0/tests/test_sqlite_db_resolution.py +106 -0
  114. text2sql_eval_toolkit-1.3.0/tests/test_sqlite_readonly.py +142 -0
  115. text2sql_eval_toolkit-1.3.0/tests/test_text2sql_metrics.py +39 -0
  116. text2sql_eval_toolkit-1.0.0/pyproject.toml +0 -73
  117. text2sql_eval_toolkit-1.0.0/src/text2sql_eval_toolkit/logging.py +0 -54
  118. text2sql_eval_toolkit-1.0.0/src/text2sql_eval_toolkit.egg-info/SOURCES.txt +0 -36
  119. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/LICENSE +0 -0
  120. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/setup.cfg +0 -0
  121. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit.egg-info/dependency_links.txt +0 -0
  122. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/src/text2sql_eval_toolkit.egg-info/top_level.txt +0 -0
  123. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/tests/test_inference_tools.py +0 -0
  124. {text2sql_eval_toolkit-1.0.0 → text2sql_eval_toolkit-1.3.0}/tests/test_sql_analysis.py +0 -0
@@ -0,0 +1,7 @@
1
+ # The wheel's frontend is copied from here by setup.py, so the sdist must carry
2
+ # it -- otherwise `pip install <sdist>` builds a wheel with no dashboard UI.
3
+ graft dashboard/dist
4
+
5
+ exclude .env
6
+ prune dashboard/node_modules
7
+ prune data/results
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: text2sql-eval-toolkit
3
- Version: 1.0.0
3
+ Version: 1.3.0
4
4
  Summary: A toolkit for evaluating text-to-SQL pipelines
5
5
  Author-email: Oktie Hassanzadeh <lastname@us.ibm.com>
6
6
  License: MIT
@@ -16,7 +16,6 @@ Requires-Dist: pandas>=2.2.3
16
16
  Requires-Dist: requests>=2.32.4
17
17
  Requires-Dist: sqlalchemy>=2.0.41
18
18
  Requires-Dist: sqlparse>=0.5.3
19
- Requires-Dist: unitxt>=1.26.1
20
19
  Requires-Dist: psycopg2-binary>=2.9.10
21
20
  Requires-Dist: sqlglot>=27.0.0
22
21
  Requires-Dist: asyncpg>=0.30.0
@@ -29,6 +28,8 @@ Requires-Dist: python-dotenv>=1.1.1
29
28
  Requires-Dist: langgraph>=0.2.0
30
29
  Requires-Dist: langchain-core>=0.3.0
31
30
  Requires-Dist: openai>=1.0.0
31
+ Requires-Dist: google-genai>=1.0.0
32
+ Requires-Dist: huggingface_hub<1.0,>=0.30
32
33
  Provides-Extra: db2
33
34
  Requires-Dist: ibm-db>=3.2.6; extra == "db2"
34
35
  Requires-Dist: ibm-db-sa>=0.4.0; extra == "db2"
@@ -44,6 +45,24 @@ Requires-Dist: presto-python-client>=0.8.4; extra == "presto"
44
45
  Provides-Extra: notebook
45
46
  Requires-Dist: jupyter>=1.0.0; extra == "notebook"
46
47
  Requires-Dist: nbconvert>=7.0.0; extra == "notebook"
48
+ Provides-Extra: dashboard
49
+ Requires-Dist: fastapi>=0.115.0; extra == "dashboard"
50
+ Requires-Dist: uvicorn[standard]>=0.30.0; extra == "dashboard"
51
+ Requires-Dist: authlib>=1.3; extra == "dashboard"
52
+ Requires-Dist: itsdangerous>=2.1; extra == "dashboard"
53
+ Requires-Dist: pymysql>=1.1.1; extra == "dashboard"
54
+ Requires-Dist: aiomysql>=0.2.0; extra == "dashboard"
55
+ Requires-Dist: greenlet>=3.0.0; extra == "dashboard"
56
+ Requires-Dist: cryptography>=45.0.6; extra == "dashboard"
57
+ Provides-Extra: dev
58
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
59
+ Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
60
+ Requires-Dist: pytest-asyncio>=0.24.0; extra == "dev"
61
+ Requires-Dist: ruff>=0.6.0; extra == "dev"
62
+ Requires-Dist: black>=24.0.0; extra == "dev"
63
+ Requires-Dist: mypy>=1.11.0; extra == "dev"
64
+ Requires-Dist: types-PyYAML>=6.0; extra == "dev"
65
+ Requires-Dist: types-requests>=2.32; extra == "dev"
47
66
  Dynamic: license-file
48
67
 
49
68
  # Text-to-SQL Evaluation Toolkit
@@ -51,6 +70,10 @@ Dynamic: license-file
51
70
  > **A modular framework for evaluating natural language to SQL systems**
52
71
  > Supports execution-based metrics, multiple ground truths, LLM-as-judge, and rich error analysis.
53
72
 
73
+ <p align="center">
74
+ <img src="dashboard-screenshot.png" alt="Text2SQL Evaluation Dashboard: benchmark overview with tiles for each dataset" width="560"/>
75
+ </p>
76
+
54
77
  Text-to-SQL systems aim to translate natural language questions into executable SQL queries, enabling intuitive access to structured data. While recent advances in large language models have significantly improved generation quality, evaluating these systems remains a complex and critical challenge.
55
78
 
56
79
  *Why an Evaluation Toolkit?*
@@ -76,6 +99,16 @@ Assessing the correctness and utility of generated SQL queries requires more tha
76
99
 
77
100
  Whether you're building new models, comparing existing ones, or diagnosing performance bottlenecks, this toolkit provides the resources needed to evaluate text-to-SQL systems with rigor and clarity.
78
101
 
102
+ ## Documentation
103
+
104
+ - **[docs/dashboard/](docs/dashboard/)** — the evaluation dashboard: features,
105
+ shareable links, the query index, capability tiers, and deployment.
106
+ - **[data/benchmarks/README.md](data/benchmarks/README.md)** — benchmark
107
+ definitions and configuration.
108
+ - **[data/benchmarks/dbs/README.md](data/benchmarks/dbs/README.md)** — database
109
+ setup for each benchmark.
110
+ - **[CONTRIBUTING.md](CONTRIBUTING.md)** — toolchain, tests, and coding standards.
111
+
79
112
  ## Components
80
113
 
81
114
  <p align="center">
@@ -85,8 +118,9 @@ Whether you're building new models, comparing existing ones, or diagnosing perfo
85
118
  - **Evaluation** ([`scripts/evaluation`](scripts/evaluation)/`src/evaluation.py`): Includes a script and library for evaluating text-to-SQL model outputs using various metrics. See [`scripts/evaluation/README.md`](scripts/evaluation/README.md) for details.
86
119
  - **Text-to-SQL Inference** ([`scripts/inference`](scripts/inference)): Provides a simple LLM inference pipeline for generating SQL queries from natural language inputs. Run `python scripts/inference/run_inference.py -h` for more information.
87
120
  - **SQL Execution** ([`scripts/execution`](scripts/execution)): Runs the ground truth and predicted SQLs for a given benchmark and saves the dataframes for evaluation and error analysis. Run `python scripts/execution/run_execution.py -h` for more information.
88
- - **Results and Error Analysis** ([`scripts/analysis`](`scripts/analysis`)): Contains scripts and utilities for analyzing evaluation results, identifying common error patterns, and generating summary statistics and visualizations. Useful for debugging and improving model performance.
89
- - **SQL Profiling** ([`scripts/profiling`](`scripts/profiling`)) tools to profile SQL queries to gather query characteristics to facilitate better analysis of results and errors.
121
+ - **Results and Error Analysis** ([`scripts/analysis`](scripts/analysis)): Contains scripts and utilities for analyzing evaluation results, identifying common error patterns, and generating summary statistics and visualizations. Useful for debugging and improving model performance.
122
+ - **SQL Profiling** ([`scripts/profiling`](scripts/profiling)) tools to profile SQL queries to gather query characteristics to facilitate better analysis of results and errors.
123
+ - **Evaluation Dashboard** ([`dashboard`](dashboard)): Optional FastAPI + React web UI for browsing benchmarks and pipeline metrics, error analysis (search, filters, cross-pipeline disagreement), side-by-side comparison of result summaries, editing LLM-as-judge YAML, and launching evaluations with job status. See [docs/dashboard/](docs/dashboard/) for features, deployment, and development.
90
124
 
91
125
  ## Setup
92
126
 
@@ -110,6 +144,32 @@ pip install uv
110
144
  brew install uv
111
145
  ```
112
146
 
147
+ ## Pre-computed results
148
+
149
+ Zero-shot and agentic baseline results for all packaged benchmarks are
150
+ hosted on the [Hugging Face Hub](https://huggingface.co/datasets/text2sql-eval-toolkit/text2sql-eval-results).
151
+ To download them (~4 GB) into `${TEXT2SQL_DATA_ROOT:-./data}/results/`:
152
+
153
+ ```bash
154
+ text2sql-eval-toolkit results fetch
155
+ ```
156
+
157
+ After this completes, the dashboard and analysis scripts will work
158
+ against the downloaded artefacts. See [docs/dashboard/](docs/dashboard/) to launch
159
+ the UI.
160
+
161
+ To fetch only a specific benchmark:
162
+
163
+ ```bash
164
+ text2sql-eval-toolkit results fetch --benchmarks bird_mini_dev_sqlite
165
+ ```
166
+
167
+ To list what is available without downloading:
168
+
169
+ ```bash
170
+ text2sql-eval-toolkit results list
171
+ ```
172
+
113
173
  ## Installation
114
174
 
115
175
  ### From PyPI
@@ -313,10 +373,31 @@ python scripts/analysis/make_summary_report.py
313
373
 
314
374
  The output will be written to [data/results/README.md](data/results/README.md).
315
375
 
376
+ ### Evaluation dashboard
377
+
378
+ A web UI for browsing results, comparing pipelines and doing error analysis:
379
+
380
+ ```bash
381
+ uv pip install -e ".[dashboard]"
382
+ text2sql-eval-dashboard --open-browser
383
+ ```
384
+
385
+ Every view has its own URL, so a benchmark, pipeline, filtered query or
386
+ individual record can be linked to directly.
387
+
388
+ The dashboard runs as a local tool with every capability enabled, or as a
389
+ shared read-only site with optional sign-in for a small allowlist. See
390
+ **[docs/dashboard/](docs/dashboard/)** for features, the URL scheme, the query
391
+ index, capability tiers, and deployment.
392
+
316
393
  ## Project Structure
317
394
 
318
395
  ```
319
396
  text2sql-eval-toolkit
397
+ ├── docs/ # Dashboard guides, deployment, development history
398
+ ├── deploy/ # Container, Compose stack, and data provisioning
399
+ ├── dashboard/ # React frontend (production build committed to dist/)
400
+ ├── tests/ # Test suite
320
401
  ├── notebooks/ # Jupyter notebooks showcasing the use of the toolkit functions
321
402
  ├── data/ # Benchmark datasets and evaluation results
322
403
  │ ├── benchmarks/ # Benchmark data and schema files
@@ -340,10 +421,12 @@ text2sql-eval-toolkit
340
421
  │ ├── evaluation/ # Evaluation module
341
422
  │ ├── execution/ # SQL execution module
342
423
  │ ├── inference/ # LLM inference (baseline) module
343
- └── profiling/ # SQL profiling module
424
+ ├── indexing/ # SQLite query index over the result artifacts
425
+ │ ├── profiling/ # SQL profiling module
426
+ │ └── ui/ # Dashboard backend (FastAPI)
344
427
  ├── pyproject.toml # Build system and project metadata
345
428
  ├── README.md # Project documentation
346
- ├── requirements.txt # Python dependencies
429
+ ├── requirements.txt # Pinned export of uv.lock (generated; see its header)
347
430
  └── LICENSE # License file
348
431
 
349
432
  ```
@@ -372,6 +455,24 @@ For detailed contribution guidelines, please see [CONTRIBUTING.md](CONTRIBUTING.
372
455
 
373
456
  This project is licensed under the Apache License 2.0. See the [LICENSE](LICENSE) file for more details.
374
457
 
458
+ ## Citation
459
+
460
+ If you use this toolkit in research, please cite:
461
+
462
+ ```bibtex
463
+ @article{HassanzadehPPKZVGSPR26,
464
+ title = {Text-to-{SQL} Evaluation Toolkit},
465
+ volume = {19},
466
+ url = {https://doi.org/10.14778/3827998.3828071},
467
+ doi = {10.14778/3827998.3828071},
468
+ number = {12},
469
+ journal = {Proc. VLDB Endow.},
470
+ author = {Hassanzadeh, Oktie and Perlitz, Yotam and Pham, Nhan and Kaple, Tanvi and \.{Z}r\'{o}bek, Karolina and Vu, Long and Glass, Michael and Subramanian, Dharmashankar and Pourreza, Mohammadreza and Rafiei, Davood},
471
+ year = {2026},
472
+ pages = {4582--4585},
473
+ }
474
+ ```
475
+
375
476
  ## Additional Resources
376
477
 
377
478
  - [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) - Community guidelines
@@ -1,56 +1,12 @@
1
- Metadata-Version: 2.4
2
- Name: text2sql-eval-toolkit
3
- Version: 1.0.0
4
- Summary: A toolkit for evaluating text-to-SQL pipelines
5
- Author-email: Oktie Hassanzadeh <lastname@us.ibm.com>
6
- License: MIT
7
- Project-URL: Homepage, https://github.com/IBM/text2sql-eval-toolkit
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.11
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
- Requires-Dist: ibm_watsonx_ai>=1.3.30
15
- Requires-Dist: pandas>=2.2.3
16
- Requires-Dist: requests>=2.32.4
17
- Requires-Dist: sqlalchemy>=2.0.41
18
- Requires-Dist: sqlparse>=0.5.3
19
- Requires-Dist: unitxt>=1.26.1
20
- Requires-Dist: psycopg2-binary>=2.9.10
21
- Requires-Dist: sqlglot>=27.0.0
22
- Requires-Dist: asyncpg>=0.30.0
23
- Requires-Dist: setuptools>=77.0.3
24
- Requires-Dist: loguru>=0.7.3
25
- Requires-Dist: func-timeout>=4.3.5
26
- Requires-Dist: tqdm>=4.67.1
27
- Requires-Dist: matplotlib>=3.10.5
28
- Requires-Dist: python-dotenv>=1.1.1
29
- Requires-Dist: langgraph>=0.2.0
30
- Requires-Dist: langchain-core>=0.3.0
31
- Requires-Dist: openai>=1.0.0
32
- Provides-Extra: db2
33
- Requires-Dist: ibm-db>=3.2.6; extra == "db2"
34
- Requires-Dist: ibm-db-sa>=0.4.0; extra == "db2"
35
- Requires-Dist: sqlalchemy>=2.0; extra == "db2"
36
- Provides-Extra: mysql
37
- Requires-Dist: pymysql>=1.1.1; extra == "mysql"
38
- Requires-Dist: aiomysql>=0.2.0; extra == "mysql"
39
- Requires-Dist: greenlet>=3.0.0; extra == "mysql"
40
- Requires-Dist: cryptography>=45.0.6; extra == "mysql"
41
- Provides-Extra: presto
42
- Requires-Dist: pyhive>=0.7.0; extra == "presto"
43
- Requires-Dist: presto-python-client>=0.8.4; extra == "presto"
44
- Provides-Extra: notebook
45
- Requires-Dist: jupyter>=1.0.0; extra == "notebook"
46
- Requires-Dist: nbconvert>=7.0.0; extra == "notebook"
47
- Dynamic: license-file
48
-
49
1
  # Text-to-SQL Evaluation Toolkit
50
2
 
51
3
  > **A modular framework for evaluating natural language to SQL systems**
52
4
  > Supports execution-based metrics, multiple ground truths, LLM-as-judge, and rich error analysis.
53
5
 
6
+ <p align="center">
7
+ <img src="dashboard-screenshot.png" alt="Text2SQL Evaluation Dashboard: benchmark overview with tiles for each dataset" width="560"/>
8
+ </p>
9
+
54
10
  Text-to-SQL systems aim to translate natural language questions into executable SQL queries, enabling intuitive access to structured data. While recent advances in large language models have significantly improved generation quality, evaluating these systems remains a complex and critical challenge.
55
11
 
56
12
  *Why an Evaluation Toolkit?*
@@ -76,6 +32,16 @@ Assessing the correctness and utility of generated SQL queries requires more tha
76
32
 
77
33
  Whether you're building new models, comparing existing ones, or diagnosing performance bottlenecks, this toolkit provides the resources needed to evaluate text-to-SQL systems with rigor and clarity.
78
34
 
35
+ ## Documentation
36
+
37
+ - **[docs/dashboard/](docs/dashboard/)** — the evaluation dashboard: features,
38
+ shareable links, the query index, capability tiers, and deployment.
39
+ - **[data/benchmarks/README.md](data/benchmarks/README.md)** — benchmark
40
+ definitions and configuration.
41
+ - **[data/benchmarks/dbs/README.md](data/benchmarks/dbs/README.md)** — database
42
+ setup for each benchmark.
43
+ - **[CONTRIBUTING.md](CONTRIBUTING.md)** — toolchain, tests, and coding standards.
44
+
79
45
  ## Components
80
46
 
81
47
  <p align="center">
@@ -85,8 +51,9 @@ Whether you're building new models, comparing existing ones, or diagnosing perfo
85
51
  - **Evaluation** ([`scripts/evaluation`](scripts/evaluation)/`src/evaluation.py`): Includes a script and library for evaluating text-to-SQL model outputs using various metrics. See [`scripts/evaluation/README.md`](scripts/evaluation/README.md) for details.
86
52
  - **Text-to-SQL Inference** ([`scripts/inference`](scripts/inference)): Provides a simple LLM inference pipeline for generating SQL queries from natural language inputs. Run `python scripts/inference/run_inference.py -h` for more information.
87
53
  - **SQL Execution** ([`scripts/execution`](scripts/execution)): Runs the ground truth and predicted SQLs for a given benchmark and saves the dataframes for evaluation and error analysis. Run `python scripts/execution/run_execution.py -h` for more information.
88
- - **Results and Error Analysis** ([`scripts/analysis`](`scripts/analysis`)): Contains scripts and utilities for analyzing evaluation results, identifying common error patterns, and generating summary statistics and visualizations. Useful for debugging and improving model performance.
89
- - **SQL Profiling** ([`scripts/profiling`](`scripts/profiling`)) tools to profile SQL queries to gather query characteristics to facilitate better analysis of results and errors.
54
+ - **Results and Error Analysis** ([`scripts/analysis`](scripts/analysis)): Contains scripts and utilities for analyzing evaluation results, identifying common error patterns, and generating summary statistics and visualizations. Useful for debugging and improving model performance.
55
+ - **SQL Profiling** ([`scripts/profiling`](scripts/profiling)) tools to profile SQL queries to gather query characteristics to facilitate better analysis of results and errors.
56
+ - **Evaluation Dashboard** ([`dashboard`](dashboard)): Optional FastAPI + React web UI for browsing benchmarks and pipeline metrics, error analysis (search, filters, cross-pipeline disagreement), side-by-side comparison of result summaries, editing LLM-as-judge YAML, and launching evaluations with job status. See [docs/dashboard/](docs/dashboard/) for features, deployment, and development.
90
57
 
91
58
  ## Setup
92
59
 
@@ -110,6 +77,32 @@ pip install uv
110
77
  brew install uv
111
78
  ```
112
79
 
80
+ ## Pre-computed results
81
+
82
+ Zero-shot and agentic baseline results for all packaged benchmarks are
83
+ hosted on the [Hugging Face Hub](https://huggingface.co/datasets/text2sql-eval-toolkit/text2sql-eval-results).
84
+ To download them (~4 GB) into `${TEXT2SQL_DATA_ROOT:-./data}/results/`:
85
+
86
+ ```bash
87
+ text2sql-eval-toolkit results fetch
88
+ ```
89
+
90
+ After this completes, the dashboard and analysis scripts will work
91
+ against the downloaded artefacts. See [docs/dashboard/](docs/dashboard/) to launch
92
+ the UI.
93
+
94
+ To fetch only a specific benchmark:
95
+
96
+ ```bash
97
+ text2sql-eval-toolkit results fetch --benchmarks bird_mini_dev_sqlite
98
+ ```
99
+
100
+ To list what is available without downloading:
101
+
102
+ ```bash
103
+ text2sql-eval-toolkit results list
104
+ ```
105
+
113
106
  ## Installation
114
107
 
115
108
  ### From PyPI
@@ -313,10 +306,31 @@ python scripts/analysis/make_summary_report.py
313
306
 
314
307
  The output will be written to [data/results/README.md](data/results/README.md).
315
308
 
309
+ ### Evaluation dashboard
310
+
311
+ A web UI for browsing results, comparing pipelines and doing error analysis:
312
+
313
+ ```bash
314
+ uv pip install -e ".[dashboard]"
315
+ text2sql-eval-dashboard --open-browser
316
+ ```
317
+
318
+ Every view has its own URL, so a benchmark, pipeline, filtered query or
319
+ individual record can be linked to directly.
320
+
321
+ The dashboard runs as a local tool with every capability enabled, or as a
322
+ shared read-only site with optional sign-in for a small allowlist. See
323
+ **[docs/dashboard/](docs/dashboard/)** for features, the URL scheme, the query
324
+ index, capability tiers, and deployment.
325
+
316
326
  ## Project Structure
317
327
 
318
328
  ```
319
329
  text2sql-eval-toolkit
330
+ ├── docs/ # Dashboard guides, deployment, development history
331
+ ├── deploy/ # Container, Compose stack, and data provisioning
332
+ ├── dashboard/ # React frontend (production build committed to dist/)
333
+ ├── tests/ # Test suite
320
334
  ├── notebooks/ # Jupyter notebooks showcasing the use of the toolkit functions
321
335
  ├── data/ # Benchmark datasets and evaluation results
322
336
  │ ├── benchmarks/ # Benchmark data and schema files
@@ -340,10 +354,12 @@ text2sql-eval-toolkit
340
354
  │ ├── evaluation/ # Evaluation module
341
355
  │ ├── execution/ # SQL execution module
342
356
  │ ├── inference/ # LLM inference (baseline) module
343
- └── profiling/ # SQL profiling module
357
+ ├── indexing/ # SQLite query index over the result artifacts
358
+ │ ├── profiling/ # SQL profiling module
359
+ │ └── ui/ # Dashboard backend (FastAPI)
344
360
  ├── pyproject.toml # Build system and project metadata
345
361
  ├── README.md # Project documentation
346
- ├── requirements.txt # Python dependencies
362
+ ├── requirements.txt # Pinned export of uv.lock (generated; see its header)
347
363
  └── LICENSE # License file
348
364
 
349
365
  ```
@@ -372,6 +388,24 @@ For detailed contribution guidelines, please see [CONTRIBUTING.md](CONTRIBUTING.
372
388
 
373
389
  This project is licensed under the Apache License 2.0. See the [LICENSE](LICENSE) file for more details.
374
390
 
391
+ ## Citation
392
+
393
+ If you use this toolkit in research, please cite:
394
+
395
+ ```bibtex
396
+ @article{HassanzadehPPKZVGSPR26,
397
+ title = {Text-to-{SQL} Evaluation Toolkit},
398
+ volume = {19},
399
+ url = {https://doi.org/10.14778/3827998.3828071},
400
+ doi = {10.14778/3827998.3828071},
401
+ number = {12},
402
+ journal = {Proc. VLDB Endow.},
403
+ author = {Hassanzadeh, Oktie and Perlitz, Yotam and Pham, Nhan and Kaple, Tanvi and \.{Z}r\'{o}bek, Karolina and Vu, Long and Glass, Michael and Subramanian, Dharmashankar and Pourreza, Mohammadreza and Rafiei, Davood},
404
+ year = {2026},
405
+ pages = {4582--4585},
406
+ }
407
+ ```
408
+
375
409
  ## Additional Resources
376
410
 
377
411
  - [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) - Community guidelines
@@ -0,0 +1,4 @@
1
+ import{R as p,u as Ne,a as Be,r as l,b as Oe,F as Ke,c as We,d as ee,m as He,i as qe,_ as te,W as Ue,e as Ve,C as Qe,f as Xe,s as Ge,g as Je,h as Ye,A as Ze,P as i,j as ue,k as s,I as ve,l as et,D as tt,B as se,n as st,T as at,o as it,p as nt,q as je,t as rt,v as lt,w as ot,x as dt,y as ct,z as ut}from"./index-C9VP9iwL.js";import{d as _e,u as $e,L as ae,a as mt,b as pt}from"./defaultItemToString-BtCahKYf.js";const{ItemMouseMove:ht,MenuMouseLeave:ft,ToggleButtonBlur:gt,FunctionCloseMenu:bt}=$e.stateChangeTypes;function Ie(o,E){const{changes:h,type:S}=E;switch(S){case ht:return o;case ft:return h.highlightedIndex===o.highlightedIndex?o:h;case gt:case bt:return{...h,selectedItem:o.selectedItem};default:return h}}const ie=p.forwardRef(({autoAlign:o=!1,className:E,decorator:h,disabled:S=!1,direction:z="bottom",items:R,label:A,["aria-label"]:I,ariaLabel:Q,itemToString:b=_e,itemToElement:L=null,renderSelectedItem:N,type:X="default",size:D,onChange:y,id:F,titleText:B="",hideLabel:m,helperText:O="",translateWithId:M,light:K,invalid:G,invalidText:$,warn:ne,warnText:P,initialSelectedItem:W,selectedItem:H,downshiftProps:J,readOnly:w,slug:v,...re},Y)=>{const C=Ne("enable-v12-dynamic-floating-styles"),{refs:j,floatingStyles:q,middlewareData:le}=Be(C||o?{placement:z,strategy:"fixed",middleware:[Ge({apply({rects:a,elements:c}){Object.assign(c.floating.style,{width:`${a.reference.width}px`})}}),o&&Je(),o&&Ye()],whileElementsMounted:Xe}:{});l.useEffect(()=>{var a;if(C||o){const c={...q,visibility:(a=le.hide)!=null&&a.referenceHidden?"hidden":"visible"};Object.keys(c).forEach(_=>{j.floating.current&&(j.floating.current.style[_]=c[_])})}},[q,o,j.floating]);const e=Oe(),{isFluid:t}=l.useContext(Ke),n=l.useCallback(({selectedItem:a})=>{y&&y({selectedItem:a??null})},[y]),u=l.useCallback((a,c)=>a!==null&&typeof a=="object"&&"disabled"in a&&a.disabled===!0,[]),d=l.useCallback(a=>{const{highlightedIndex:c}=a;if(c!==void 0&&c>-1){const Z=document.querySelectorAll(`li.${e}--list-box__menu-item[role="option"]`)[c];Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})}},[e]),f=l.useMemo(()=>R,[R]),k=l.useMemo(()=>({items:f,itemToString:b,initialSelectedItem:W,onSelectedItemChange:n,stateReducer:Ie,isItemDisabled:u,onHighlightedIndexChange:d,...J}),[f,b,W,n,Ie,u,d,J]);H!==void 0&&(k.selectedItem=H);const{isOpen:g,getToggleButtonProps:Ce,getLabelProps:ke,getMenuProps:me,getItemProps:Te,selectedItem:x,highlightedIndex:Ee}=$e(k),T=X==="inline",r=We({id:F,readOnly:w,disabled:S??!1,invalid:G??!1,invalidText:$,warn:ne??!1,warnText:P}),[Se,oe]=l.useState(!1),De=ee(`${e}--dropdown`,{[`${e}--dropdown--invalid`]:r.invalid,[`${e}--dropdown--warning`]:r.warn,[`${e}--dropdown--open`]:g,[`${e}--dropdown--focus`]:Se,[`${e}--dropdown--inline`]:T,[`${e}--dropdown--disabled`]:r.disabled,[`${e}--dropdown--light`]:K,[`${e}--dropdown--readonly`]:w,[`${e}--dropdown--${D}`]:D,[`${e}--list-box--up`]:z==="top",[`${e}--autoalign`]:o}),Fe=ee(`${e}--label`,{[`${e}--label--disabled`]:r.disabled,[`${e}--visually-hidden`]:m}),Me=ee(`${e}--form__helper-text`,{[`${e}--form__helper-text--disabled`]:r.disabled}),Pe=ee(`${e}--dropdown__wrapper`,`${e}--list-box__wrapper`,E,{[`${e}--dropdown__wrapper--inline`]:T,[`${e}--list-box__wrapper--inline`]:T,[`${e}--dropdown__wrapper--inline--invalid`]:T&&r.invalid,[`${e}--list-box__wrapper--inline--invalid`]:T&&r.invalid,[`${e}--list-box__wrapper--fluid--invalid`]:t&&r.invalid,[`${e}--list-box__wrapper--slug`]:v,[`${e}--list-box__wrapper--decorator`]:h}),U=Ce({"aria-label":I||Q}),pe=O&&!t?p.createElement("div",{id:r.helperId,className:Me},O):null,he=a=>{oe(a.type==="focus"&&!x)},fe=l.useRef(null),ze=He(U.ref,Y,fe),[V,ge]=l.useState(),[be,de]=l.useState(!1),xe=l.useCallback(a=>{["ArrowDown","ArrowUp"," ","Enter"].includes(a.key)?be&&a.key===" "&&(V&&clearTimeout(V),ge(setTimeout(()=>{de(!1)},3e3))):(de(!0),V&&clearTimeout(V),ge(setTimeout(()=>{de(!1)},3e3))),["ArrowDown"].includes(a.key)&&oe(!1),["Enter"].includes(a.key)&&!x&&!g&&oe(!0),U.onKeyDown&&(a.key!=="ArrowUp"||g&&a.key==="ArrowUp")&&U.onKeyDown(a)},[be,V,U]),Re=l.useMemo(()=>w?{onClick:a=>{var c;a.preventDefault(),(c=fe.current)==null||c.focus()},onKeyDown:a=>{["ArrowDown","ArrowUp"," ","Enter"].includes(a.key)&&a.preventDefault()}}:{onKeyDown:xe},[w,xe]),Ae=l.useMemo(()=>me({ref:C||o?j.setFloating:null}),[o,me,j.setFloating,C]),ce=v??h,ye=qe(ce,Ze)?l.cloneElement(ce,{size:"mini"}):ce,we=ke(),Le=l.isValidElement(B)?{id:we.id}:we;return p.createElement("div",te({className:Pe},re),B&&p.createElement("label",te({className:Fe},Le),B),p.createElement(ae,{onFocus:he,onBlur:he,size:D,className:De,invalid:r.invalid,invalidText:$,invalidTextId:r.invalidId,warn:r.warn,warnText:P,warnTextId:r.warnId,light:K,isOpen:g,ref:C||o?j.setReference:null,id:F},r.invalid&&p.createElement(Ue,{className:`${e}--list-box__invalid-icon`}),r.warn&&p.createElement(Ve,{className:`${e}--list-box__invalid-icon ${e}--list-box__invalid-icon--warning`}),p.createElement("button",te({type:"button",className:`${e}--list-box__field`,disabled:r.disabled,"aria-disabled":w?!0:void 0,"aria-describedby":!T&&!r.invalid&&!r.warn&&pe?r.helperId:r.invalid?r.invalidId:r.warn?r.warnId:void 0,title:x&&b!==void 0?b(x):_e(A)},U,Re,{ref:ze}),p.createElement("span",{className:`${e}--list-box__label`},x?N?N(x):b(x):A),p.createElement(ae.MenuIcon,{isOpen:g,translateWithId:M})),v?ye:h?p.createElement("div",{className:`${e}--list-box__inner-wrapper--decorator`},ye):"",p.createElement(ae.Menu,Ae,g&&f.map((a,c)=>{const _=Te({item:a,index:c}),Z=b(a);return p.createElement(ae.MenuItem,te({key:_.id,isActive:x===a,isHighlighted:Ee===c,title:Z,disabled:_["aria-disabled"]},_),L?L(a):b(a),x===a&&p.createElement(Qe,{className:`${e}--list-box__menu-item__selected-icon`}))}))),!T&&!t&&!r.validation&&pe)});ie.displayName="Dropdown";ie.propTypes={"aria-label":i.string,ariaLabel:ue(i.string),autoAlign:i.bool,className:i.string,decorator:i.node,direction:i.oneOf(["top","bottom"]),disabled:i.bool,downshiftProps:i.object,helperText:i.node,hideLabel:i.bool,id:i.string.isRequired,initialSelectedItem:i.oneOfType([i.object,i.string,i.number]),invalid:i.bool,invalidText:i.node,itemToElement:i.func,itemToString:i.func,items:i.array.isRequired,label:i.node.isRequired,light:ue(i.bool),onChange:i.func,readOnly:i.bool,renderSelectedItem:i.func,selectedItem:i.oneOfType([i.object,i.string,i.number]),size:pt,slug:ue(i.node),titleText:i.node.isRequired,translateWithId:i.func,type:mt,warn:i.bool,warnText:i.node};const vt=({benchmarkId:o,style:E,onSelectPipeline:h,onOpenToolkitInsights:S,onOpenPipelineCompare:z,onOpenProfileCompare:R,onOpenErrorAnalysis:A})=>{const[I,Q]=l.useState(null),[b,L]=l.useState(!0),[N,X]=l.useState(null),[D,y]=l.useState(1),[F,B]=l.useState(10),[m,O]=l.useState(null),[M,K]=l.useState("overall");if(l.useEffect(()=>{(async()=>{try{L(!0),X(null),Q(null);const n=await(await ct(ut(`/api/benchmarks/${o}/summary/by-category`))).json();Q(n),O(n.default_sort_metric),K("overall"),y(1)}catch(t){X(t.message||"Failed to load benchmark summary")}finally{L(!1)}})()},[o]),N)return s.jsx(ve,{kind:"error",title:`Error loading summary for ${o}`,subtitle:N,lowContrast:!0});if(b)return s.jsxs("div",{style:{...E,display:"flex",flexDirection:"column",gap:"1rem"},children:[s.jsxs("h3",{style:{margin:0},children:[o," – Summary"]}),s.jsx(et,{description:`Loading benchmark summary for ${o}…`,status:"active"}),s.jsx(tt,{role:"progressbar",columnCount:5,rowCount:8})]});if(!I)return null;const G=M==="overall"?I.overall:I.categories[M]||[],$=new Set;G.forEach(e=>{Object.keys(e.metrics).forEach(t=>{t!=="num_records"&&t!=="num_evaluated"&&$.add(t)})});const ne=[{key:"name",header:"Pipeline"},...Array.from($).map(e=>({key:e,header:e}))],P=[...G].sort((e,t)=>{var d,f,k,g;if(!m)return 0;const n=((f=(d=e.metrics)==null?void 0:d[m])==null?void 0:f.average)??0;return(((g=(k=t.metrics)==null?void 0:k[m])==null?void 0:g.average)??0)-n}),W=e=>{var n;if(!m)return 0;const t=(n=e.metrics)==null?void 0:n[m];return typeof t=="number"?t:t&&typeof t=="object"&&typeof t.average=="number"?t.average:0},H=e=>{var n;if(!m)return 0;const t=(n=e.metrics)==null?void 0:n[m];return t&&typeof t=="object"&&typeof t.stddev=="number"?Math.max(0,t.stddev):0},J=e=>{var d;if(!m)return{low:0,high:0,hasCI:!1};const t=(d=e.metrics)==null?void 0:d[m];if(t&&typeof t=="object"&&typeof t.ci95_low=="number"&&typeof t.ci95_high=="number")return{low:t.ci95_low,high:t.ci95_high,hasCI:!0};const n=W(e),u=H(e);return{low:Math.max(0,n-u),high:n+u,hasCI:!1}},w=P.map(e=>({name:e.name,value:W(e),stddev:H(e),ci:J(e)})),v=w.reduce((e,t)=>Math.max(e,t.value,t.ci.high),0)||1,re=P.length,Y=(D-1)*F,C=Y+F,j=P.slice(Y,C),q=Array.from($),le=["overall",...Object.keys(I.categories)];return s.jsxs("div",{style:{...E,display:"flex",flexDirection:"column",gap:"0.5rem"},children:[I.has_full_results===!1&&s.jsx(ve,{kind:"info",title:"Summary-only mode",subtitle:`The full evaluation results file (${o}-predictions_eval.json) was not found. Overall pipeline metrics are shown from the summary file, but category breakdown and error analysis are unavailable. Download pre-computed results with: text2sql-eval-toolkit results fetch --benchmarks ${o} or run the evaluation pipeline locally (or fix TEXT2SQL_DATA_ROOT to a directory that already contains this file).`,lowContrast:!0}),s.jsxs("div",{style:{display:"flex",gap:"1rem",alignItems:"center"},children:[s.jsxs("h3",{style:{margin:0},children:[o," – Summary"]}),s.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:"0.75rem",alignItems:"center"},children:[S&&s.jsx(se,{kind:"ghost",size:"sm",onClick:()=>S(),children:"Metric Insights"}),z&&s.jsx(se,{kind:"ghost",size:"sm",onClick:()=>z(),children:"Pipeline Compare"}),R&&s.jsx(se,{kind:"ghost",size:"sm",onClick:()=>R(),children:"Profile Compare"}),A&&s.jsx(se,{kind:"ghost",size:"sm",onClick:()=>A(),children:"Error Analysis"}),s.jsx("div",{style:{minWidth:"220px"},children:s.jsx(ie,{id:"category-dropdown",titleText:"Query Category",label:M,items:le,selectedItem:M,onChange:e=>{K(e.selectedItem),y(1)}})}),q.length>0&&s.jsx("div",{style:{minWidth:"260px"},children:s.jsx(ie,{id:"sort-metric-dropdown",titleText:"Sort by metric",label:m||"Select metric",items:q,selectedItem:m,onChange:e=>{O(e.selectedItem),y(1)}})})]})]}),s.jsxs("div",{style:{border:"1px solid rgba(255,255,255,0.12)",borderRadius:"6px",padding:"0.75rem",background:"rgba(255,255,255,0.02)"},children:[s.jsxs("div",{style:{marginBottom:"0.5rem",fontWeight:600},children:["Pipeline performance by ",m||"selected metric"]}),s.jsx("div",{style:{maxHeight:"260px",overflow:"auto",display:"flex",flexDirection:"column",gap:"0.45rem"},children:w.map(e=>{const t=Math.max(2,e.value/v*100),n=Math.max(0,e.ci.low),u=Math.min(v,e.ci.high),d=n/v*100,f=u/v*100,k=Math.max(0,f-d),g=f>=99.9;return s.jsxs("div",{title:e.ci.hasCI?`${e.name}
2
+ Mean: ${e.value.toFixed(3)}
3
+ 95% CI: [${e.ci.low.toFixed(3)}, ${e.ci.high.toFixed(3)}]`:`${e.name}
4
+ Mean: ${e.value.toFixed(3)}`,style:{display:"grid",gridTemplateColumns:"260px 1fr 56px",gap:"0.6rem",alignItems:"center"},children:[s.jsx("div",{title:e.name,style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontSize:"0.82rem",opacity:.9},children:e.name}),s.jsxs("div",{style:{height:"12px",background:"rgba(255,255,255,0.1)",borderRadius:"999px",overflow:"hidden",position:"relative"},children:[s.jsx("div",{style:{width:`${t}%`,height:"100%",background:"linear-gradient(90deg, #0f62fe, #78a9ff)",borderRadius:"999px"}}),u>n&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{position:"absolute",left:`${d}%`,width:`${k}%`,top:"5.5px",height:"1px",background:"rgba(255,255,255,0.7)"}}),s.jsx("div",{style:{position:"absolute",left:`${d}%`,top:"3px",width:"1px",height:"6px",background:"rgba(255,255,255,0.7)"}}),s.jsx("div",{style:{position:"absolute",...g?{right:0}:{left:`${f}%`},top:"3px",width:"1px",height:"6px",background:"rgba(255,255,255,0.7)"}})]})]}),s.jsx("div",{style:{textAlign:"right",fontSize:"0.82rem"},children:e.value.toFixed(3)})]},`chart-${e.name}`)})})]}),s.jsxs("div",{style:{maxHeight:"360px",overflow:"auto"},children:[s.jsx("div",{style:{fontSize:"0.82rem",opacity:.85,marginBottom:"0.45rem"},children:"Tip: click a pipeline row in the table below for detailed pipeline analysis."}),s.jsx(st,{rows:j.map(e=>({id:e.name,name:e.name,...Object.fromEntries(Array.from($).map(t=>{const n=e.metrics[t];return n&&typeof n=="object"&&"average"in n?[t,n.average.toFixed(3)]:[t,n??""]}))})),headers:ne,size:"sm",children:({rows:e,headers:t,getHeaderProps:n})=>s.jsx(at,{children:s.jsxs(it,{"aria-label":"Pipeline summary",children:[s.jsx(nt,{children:s.jsx(je,{children:t.map(u=>{const{key:d,...f}=n({header:u});return s.jsx(rt,{...f,children:u.header},d)})})}),s.jsx(lt,{children:e.map(u=>s.jsx(je,{style:{cursor:h?"pointer":"default"},onClick:()=>h==null?void 0:h(u.id),children:u.cells.map(d=>s.jsx(ot,{children:d.value},d.id))},u.id))})]})})})]}),s.jsx(dt,{page:D,pageSize:F,pageSizes:[10,25,50],totalItems:re,onChange:({page:e,pageSize:t})=>{y(e),B(t)}})]})};export{vt as BenchmarkDetail};
@@ -0,0 +1 @@
1
+ import{b as Ce,d as k,R as r,N as qe,_ as z,P as n,O as Vt,r as o,u as Lt,a as Mt,F as kt,J as Ft,Q as j,c as Pt,i as At,L as Ue,U as Q,m as Wt,W as Ot,e as Bt,C as jt,f as zt,g as Ht,h as Kt,A as qt,V as Ut,X as Jt,Y as Qt,Z as Xt,$ as Yt,j as xe}from"./index-C9VP9iwL.js";import{d as tt,c as nt,L as we,b as Zt}from"./defaultItemToString-BtCahKYf.js";var Je,Qe;const Xe={"clear.all":"clear.all","clear.selection":"clear.selection"},Gt={[Xe["clear.all"]]:"Clear all selected items",[Xe["clear.selection"]]:"Clear selected item"},vt=d=>Gt[d];function lt({clearSelection:d,selectionCount:c,translateWithId:h=vt,disabled:f,readOnly:g,onClearSelection:_,...F}){const I=Ce(),H=k(`${I}--list-box__selection`,{[`${I}--tag--filter`]:c,[`${I}--list-box__selection--multi`]:c}),P=h(c?"clear.all":"clear.selection"),$=k(`${I}--tag`,`${I}--tag--filter`,`${I}--tag--high-contrast`,{[`${I}--tag--disabled`]:f});function K(C){C.stopPropagation(),!(f||g)&&(d(C),_&&_(C))}return c?r.createElement("div",{className:$},r.createElement("span",{className:`${I}--tag__label`,title:c==null?void 0:c.toString()},c),r.createElement("button",{"aria-label":P,className:`${I}--tag__close-icon`,disabled:f||g,onClick:K,tabIndex:-1,title:P,type:"button","aria-disabled":g?!0:void 0},Je||(Je=r.createElement(qe,null)))):r.createElement("button",z({},F,{"aria-label":P,className:H,disabled:f||g,onClick:K,tabIndex:-1,title:P,type:"button","aria-disabled":g?!0:void 0}),Qe||(Qe=r.createElement(qe,null)))}lt.propTypes={clearSelection:n.func.isRequired,disabled:n.bool,readOnly:n.bool,onClearSelection:n.func,onClick:n.func,onMouseUp:n.func,onKeyDown:n.func,selectionCount:n.number,translateWithId:n.func};var Ye;const Ze={"close.menu":"close.menu","open.menu":"open.menu"},en={[Ze["close.menu"]]:"Close",[Ze["open.menu"]]:"Open"},tn=d=>en[d],st=r.forwardRef(({isOpen:d,translateWithId:c=tn,...h},f)=>{const g=Ce(),_=k({[`${g}--list-box__menu-icon`]:!0,[`${g}--list-box__menu-icon--open`]:d}),F=c(d?"close.menu":"open.menu");return r.createElement("button",z({},h,{"aria-label":F,title:F,className:_,type:"button",tabIndex:-1,ref:f}),Ye||(Ye=r.createElement(Vt,null)))});st.propTypes={isOpen:n.bool.isRequired,translateWithId:n.func};const{InputBlur:nn,InputKeyDownEnter:Ge,FunctionToggleMenu:ln,ToggleButtonClick:sn,ItemMouseMove:an,InputKeyDownArrowUp:rn,InputKeyDownArrowDown:on,MenuMouseLeave:cn,ItemClick:un,FunctionSelectItem:dn}=nt.stateChangeTypes,ve=()=>!0,ye=({item:d,inputValue:c})=>{if(c===null||c==="")return!0;const h=d.toLowerCase(),f=c.toLowerCase();return h.startsWith(f)},et=({initialSelectedItem:d,itemToString:c,selectedItem:h,prevSelectedItem:f})=>h!==null&&typeof h<"u"?c(h):typeof f>"u"&&d!==null&&typeof d<"u"?c(d):"",fn=({items:d,itemToString:c=tt},h)=>{if(!h)return-1;const f=h.toLowerCase();for(let g=0;g<d.length;g++){const _=c(d[g]).toLowerCase();if(!d[g].disabled&&_.indexOf(f)!==-1)return g}return-1},at=o.forwardRef((d,c)=>{var He,Ke;const h=o.useRef(0),f=o.useRef(null),{["aria-label"]:g="Choose an item",ariaLabel:_,autoAlign:F=!1,className:I,decorator:H,direction:P="bottom",disabled:$=!1,downshiftActions:K,downshiftProps:C,helperText:ee,id:Ee,initialSelectedItem:te,invalid:ne,invalidText:le,items:b,itemToElement:se=null,itemToString:a=tt,light:it,onChange:N,onInputChange:ae,onToggleClick:Te,placeholder:rt,readOnly:A,selectedItem:E,shouldFilterItem:_e=ve,size:ot,titleText:ie,translateWithId:$e,typeahead:X=!1,warn:ct,warnText:re,allowCustomValue:R=!1,slug:oe,inputProps:ut,...dt}=d,W=Lt("enable-v12-dynamic-floating-styles")||F,{refs:x,floatingStyles:Se,middlewareData:ft}=Mt(W?{placement:P,strategy:"fixed",middleware:F?[Ht(),Kt()]:void 0,whileElementsMounted:zt}:{}),De=(He=x==null?void 0:x.reference)==null?void 0:He.current,ce=De instanceof HTMLElement?De.clientWidth:void 0;o.useEffect(()=>{var e;if(W){const t={...Se,visibility:(e=ft.hide)!=null&&e.referenceHidden?"hidden":"visible"};Object.keys(t).forEach(u=>{x.floating.current&&(x.floating.current.style[u]=t[u])}),ce&&x.floating.current&&(x.floating.current.style.width=ce+"px")}},[W,Se,x.floating,ce]);const[s,Y]=o.useState(et({initialSelectedItem:te,itemToString:a,selectedItem:E})),[Z,G]=o.useState("");o.useEffect(()=>{if(X){if(s.length>=h.current)if(s){const e=b.filter(t=>ye({item:a(t),inputValue:s}));if(e.length>0){const t=a(e[0]);G(t.slice(s.length))}else G("")}else G("");else G("");h.current=s.length}},[X,s,b,a,ye]);const Ne=o.useRef(!1),O=o.useRef(""),[ue,de]=o.useState(!1),i=Ce(),{isFluid:fe}=o.useContext(kt),w=o.useRef(null),me=Ft(),[Re,mt]=o.useState(!1),Ve=o.useRef(s),pe=o.useRef(E);o.useEffect(()=>{Ne.current=ue,ue&&de(!1)},[ue]),o.useEffect(()=>{if(pe.current!==E){const e=et({initialSelectedItem:te,itemToString:a,selectedItem:E,prevSelectedItem:pe.current});s!==e&&(Y(e),N({selectedItem:E,inputValue:e})),pe.current=E}},[E]);const q=(e,t,u)=>e.filter(l=>X?ye({item:t(l),inputValue:u}):_e?_e({item:l,itemToString:t,inputValue:u}):ve());o.useEffect(()=>{Ve.current!==s&&(Ve.current=s,ae==null||ae(s))},[s]);const Le=()=>{w!=null&&w.current&&w.current.focus()},pt=e=>q(b,a,e||null),Me=e=>fn({...d,items:pt(e)},e),gt=o.useCallback((e,t)=>{const{type:u,changes:l}=t,{highlightedIndex:y}=l;switch(u){case nn:{if(R&&y===-1){const m=e.inputValue??"",p=typeof l.selectedItem>"u"?e.selectedItem:l.selectedItem;if(p!==null&&typeof p<"u"&&a(p)===m&&b.some(M=>j(M,p)))return l;const L=m===""?null:b.find(M=>a(M)===m)??m,J=typeof L=="string"&&L!==""&&!b.some(M=>j(M,L));return!j(p,L)&&N&&(N({selectedItem:L,inputValue:m}),O.current=J?m:""),{...l,selectedItem:L}}if(e.inputValue&&y===-1&&l.selectedItem)return{...l,inputValue:a(l.selectedItem)};if(!R){const m=e.inputValue??"";if(!(!!m&&b.some(D=>a(D)===m))){const D=e.selectedItem!==null?a(e.selectedItem):"";return{...l,inputValue:D}}}return l}case Ge:if(!R)if(e.highlightedIndex!==-1){const p=q(b,a,s)[e.highlightedIndex];if(p&&!p.disabled)return{...l,selectedItem:p,inputValue:a(p)}}else{const m=Me(s);if(m!==-1){const p=b[m];if(p&&!p.disabled)return{...l,selectedItem:p,inputValue:a(p)}}if(e.selectedItem!==null)return{...l,selectedItem:null,inputValue:s}}return{...l,isOpen:!0};case ln:case sn:if(e.isOpen&&!l.isOpen&&!R){const m=e.inputValue??"";if(!(!!m&&b.some(D=>a(D)===m))){const D=e.selectedItem!==null?a(e.selectedItem):"";return{...l,inputValue:D}}}return l;case cn:return{...l,highlightedIndex:e.highlightedIndex};case rn:case on:return y===-1?{...l,highlightedIndex:0}:l;case an:return{...l,highlightedIndex:e.highlightedIndex};default:return l}},[R,s,a,b,N]),ht=e=>t=>{var u,l;if(Te&&Te(t),A){t.preventDownshiftDefault=!0,(u=t==null?void 0:t.persist)==null||u.call(t);return}t.target===w.current&&e&&(t.preventDownshiftDefault=!0,(l=t==null?void 0:t.persist)==null||l.call(t))},S=Pt({id:Ee,readOnly:A,disabled:$||!1,invalid:ne||!1,invalidText:le,warn:ct||!1,warnText:re}),bt=k(`${i}--combo-box`,{[`${i}--combo-box--invalid--focused`]:ne&&Re,[`${i}--list-box--up`]:P==="top",[`${i}--combo-box--warning`]:S.warn,[`${i}--combo-box--readonly`]:A,[`${i}--autoalign`]:W}),It=k(`${i}--label`,{[`${i}--label--disabled`]:$}),ke=`combobox-helper-text-${me}`,Fe=`combobox-warn-text-${me}`,Pe=`combobox-invalid-text-${me}`,xt=k(`${i}--form__helper-text`,{[`${i}--form__helper-text--disabled`]:$}),wt=k(`${i}--list-box__wrapper`,[I,{[`${i}--list-box__wrapper--fluid--invalid`]:fe&&ne,[`${i}--list-box__wrapper--slug`]:oe,[`${i}--list-box__wrapper--decorator`]:H}]),yt=k(`${i}--text-input`,{[`${i}--text-input--empty`]:!s,[`${i}--combo-box--input--focus`]:Re}),ge=oe??H,Ae=At(ge,qt),he=Ae?o.cloneElement(ge,{size:"mini"}):ge,{getInputProps:Ct,getItemProps:Et,getLabelProps:Tt,getMenuProps:We,getToggleButtonProps:_t,isOpen:T,highlightedIndex:U,selectedItem:$t,closeMenu:Oe,openMenu:be,reset:Be,selectItem:V,setHighlightedIndex:Ie,setInputValue:v,toggleMenu:B}=nt({items:q(b,a,s),inputValue:s,itemToString:e=>a(e),onInputValueChange({inputValue:e}){const t=e||"";Y(t),Ie(Me(t))},onHighlightedIndexChange:({highlightedIndex:e})=>{if(e>-1){const u=document.querySelectorAll(`li.${i}--list-box__menu-item[role="option"]`)[e];u&&u.scrollIntoView({behavior:"smooth",block:"nearest"})}},initialSelectedItem:te,inputId:Ee,stateReducer:gt,isItemDisabled(e,t){return e==null?void 0:e.disabled},...C,onStateChange:({type:e,selectedItem:t})=>{var u;(u=C==null?void 0:C.onStateChange)==null||u.call(C,{type:e,selectedItem:t}),!Ne.current&&(e===un||e===dn||e===Ge)&&typeof t<"u"&&!j(E,t)&&(b.some(l=>j(l,t))&&(O.current=""),N({selectedItem:t}))}}),St=typeof E<"u"?E:$t;o.useEffect(()=>{K&&(K.current={closeMenu:Oe,openMenu:be,reset:Be,selectItem:V,setHighlightedIndex:Ie,setInputValue:v,toggleMenu:B})},[Oe,be,Be,V,Ie,v,B]);const Dt=_t({disabled:$||A,onClick:ht(T),onMouseUp(e){T&&e.stopPropagation()}}),je=e=>{var t;mt(e.type==="focus"),!((t=f.current)!=null&&t.value)&&e.type==="blur"&&V(null)},Nt=A?{onKeyDown:e=>{e.key!=="Tab"&&e.preventDefault()},onClick:e=>{e.preventDefault(),e.currentTarget.focus()}}:{},Rt=S.invalid&&le&&Pe||S.warn&&re&&Fe||ee&&!fe&&ke||void 0,ze=o.useMemo(()=>We({ref:W?x.setFloating:null}),[W,_,g,We,x.setFloating]);return o.useEffect(()=>{if(w.current&&f.current&&Z){const e=s.length,t=e+Z.length;f.current.value=s+Z,f.current.setSelectionRange(e,t)}},[s,Z]),r.createElement("div",{className:wt},ie&&r.createElement(Ue,z({as:"label",className:It},Tt()),ie),r.createElement(we,{onFocus:je,onBlur:je,className:bt,disabled:$,invalid:S.invalid,invalidText:le,invalidTextId:Pe,isOpen:T,light:it,size:ot,warn:S.warn,ref:W?x.setReference:null,warnText:re,warnTextId:Fe},r.createElement("div",{className:`${i}--list-box__field`},r.createElement("input",z({disabled:$,className:yt,type:"text",tabIndex:0,"aria-haspopup":"listbox",title:(Ke=w==null?void 0:w.current)==null?void 0:Ke.value},Ct({"aria-label":ie?void 0:_||g,"aria-controls":ze.id,placeholder:rt,value:s,...ut,onChange:e=>{const t=e.target.value,u=R&&O.current&&s===O.current&&t==="";Y(t),v(t),u&&(de(!0),N({selectedItem:null,inputValue:""}),V(null),O.current="")},ref:Wt(w,c,f),onKeyDown:e=>{var t,u;if(Q(e,Ut)&&e.stopPropagation(),Q(e,Jt)&&(!s||R)&&(B(),U!==-1&&V(q(b,a,s)[U]),R&&T&&s&&U===-1&&(O.current=s,N({selectedItem:null,inputValue:s})),e.preventDownshiftDefault=!0,(t=e==null?void 0:e.persist)==null||t.call(e)),Q(e,Qt)&&s&&e.target===w.current&&T&&(B(),e.preventDownshiftDefault=!0,(u=e==null?void 0:e.persist)==null||u.call(e)),Q(e,Xt)&&e.code!=="Numpad7"&&e.target.setSelectionRange(0,0),Q(e,Yt)&&e.code!=="Numpad1"&&e.target.setSelectionRange(e.target.value.length,e.target.value.length),e.altKey&&e.key=="ArrowDown"&&(e.preventDownshiftDefault=!0,T||B()),e.altKey&&e.key=="ArrowUp"&&(e.preventDownshiftDefault=!0,T&&B()),!s&&U==-1&&e.key=="Enter"&&(T||B(),V(null),e.preventDownshiftDefault=!0,e.currentTarget.ariaExpanded==="false"&&be()),X&&e.key==="Tab"){const l=b.find(y=>a(y).toLowerCase().startsWith(s.toLowerCase()));if(l){const y=a(l);v(y),V(l)}}}}),dt,Nt,{readOnly:A,"aria-describedby":Rt})),S.invalid&&r.createElement(Ot,{className:`${i}--list-box__invalid-icon`}),S.warn&&r.createElement(Bt,{className:`${i}--list-box__invalid-icon ${i}--list-box__invalid-icon--warning`}),s&&r.createElement(lt,{clearSelection:()=>{de(!0),Y(""),N({selectedItem:null}),V(null),O.current="",Le()},translateWithId:$e,disabled:$||A,onClearSelection:Le,selectionCount:0}),r.createElement(st,z({},Dt,{isOpen:T,translateWithId:$e}))),oe?he:H?r.createElement("div",{className:`${i}--list-box__inner-wrapper--decorator`},Ae?he:r.createElement("span",null,he)):"",r.createElement(we.Menu,ze,T?q(b,a,s).map((e,t)=>{var M;const l=e!==null&&typeof e=="object"&&"text"in e&&se?(M=e.text)==null?void 0:M.toString():a(e),y=Et({item:e,index:t}),m=y["aria-disabled"],{"aria-disabled":p,"aria-selected":D,...L}=y,J=j(St,e);return r.createElement(we.MenuItem,z({key:y.id,isActive:J,isHighlighted:U===t,title:l,disabled:m},L,{"aria-selected":J}),se?se(e):a(e),J&&r.createElement(jt,{className:`${i}--list-box__menu-item__selected-icon`}))}):null)),ee&&!S.invalid&&!S.warn&&!fe&&r.createElement(Ue,{as:"div",id:ke,className:xt},ee))});at.displayName="ComboBox";at.propTypes={allowCustomValue:n.bool,"aria-label":n.string,ariaLabel:xe(n.string),autoAlign:n.bool,className:n.string,decorator:n.node,direction:n.oneOf(["top","bottom"]),disabled:n.bool,downshiftProps:n.object,downshiftActions:n.exact({current:n.any}),helperText:n.node,id:n.string.isRequired,initialSelectedItem:n.oneOfType([n.object,n.string,n.number]),invalid:n.bool,invalidText:n.node,itemToElement:n.func,itemToString:n.func,items:n.array.isRequired,light:xe(n.bool),onChange:n.func.isRequired,onInputChange:n.func,onToggleClick:n.func,placeholder:n.string,readOnly:n.bool,selectedItem:n.oneOfType([n.object,n.string,n.number]),shouldFilterItem:n.func,size:Zt,slug:xe(n.node),titleText:n.node,translateWithId:n.func,typeahead:n.bool,warn:n.bool,warnText:n.node,inputProps:n.object};export{at as C};
@@ -0,0 +1 @@
1
+ import{r,k as t,B as x,I as h,E as Ae,S as ne,G as y,l as ut,D as pt,n as ft,T as mt,o as xt,p as gt,q as Ge,t as ht,v as yt,w as jt,x as bt,H as St,y as le,z as R}from"./index-C9VP9iwL.js";import{C as Ve}from"./ComboBox-Cz5Wuuu_.js";import{b as Be,f as wt,S as He}from"./metricInsightsSelect-B46SO2Wy.js";import{R as be,h as We}from"./ResultTableView-Dq7hZwq5.js";import"./defaultItemToString-BtCahKYf.js";function _t(a,M,n){const $=M.find(ae=>ae.record_id===a),U=Object.keys(($==null?void 0:$.predictions)??{});return n&&U.includes(n)?n:U[0]??null}function Ue(a){if(a==null)return"N/A";if(typeof a=="number")return Number.isFinite(a)?String(a):"N/A";if(typeof a=="boolean")return a?"true":"false";if(typeof a=="string")return a;try{return JSON.stringify(a)}catch{return String(a)}}function Xe(a,M){const n=a.trim();return n?n.replaceAll("_"," "):M}const Rt=({benchmarkId:a,onBack:M,initialFilters:n,initialPage:$,initialPageSize:U,initialRecordId:ae,onStateChange:w})=>{const[L,Se]=r.useState([]),[Ye,Ke]=r.useState(0),_=$??1,k=U??25,[we,Ze]=r.useState(""),[u,D]=r.useState(()=>(n==null?void 0:n.pipeline)??""),[j,X]=r.useState(()=>(n==null?void 0:n.metric)??"execution_accuracy"),[P,ie]=r.useState(()=>(n==null?void 0:n.value)??"0"),[q,oe]=r.useState(()=>(n==null?void 0:n.op)??"eq"),[m,I]=r.useState(()=>(n==null?void 0:n.pipeline2)??""),[b,Y]=r.useState(()=>(n==null?void 0:n.metric2)??"subset_non_empty_execution_accuracy"),[C,ce]=r.useState(()=>(n==null?void 0:n.disagree)??!1),[_e,ke]=r.useState(!0),[Ce,Te]=r.useState(null),o=ae??null,[T,de]=r.useState(null),ue=r.useCallback((e,s)=>_t(e,s,u),[u]);r.useEffect(()=>{if(!o||T||L.length===0)return;const e=ue(o,L);e&&de(e)},[o,T,L,ue]);const ve=r.useMemo(()=>({pipeline:u,metric:j,value:P,op:q,pipeline2:m,metric2:b,disagree:C}),[u,j,P,q,m,b,C]),J=r.useCallback(e=>{w==null||w({filters:ve,page:e.page??_,pageSize:e.pageSize??k,record:e.record!==void 0?e.record:o})},[ve,w,_,k,o]),pe=r.useCallback(e=>J({page:e}),[J]),Ee=r.useCallback(e=>J({record:e}),[J]);r.useEffect(()=>{w==null||w({filters:{pipeline:u,metric:j,value:P,op:q,pipeline2:m,metric2:b,disagree:C},page:_,pageSize:k,record:o})},[w,u,j,P,q,m,b,C,_,k,o]);const[c,Re]=r.useState(null),[Fe,fe]=r.useState(!1),[Me,me]=r.useState(null),[O,Q]=r.useState("detail"),[xe,ge]=r.useState(null),[et,K]=r.useState(!1),[Le,Z]=r.useState(null),[tt,he]=r.useState(""),[v,F]=r.useState(""),[Pe,A]=r.useState(!1),[qe,G]=r.useState(null),[E,V]=r.useState(null),[st,B]=r.useState(!1),[ze,z]=r.useState(null),[Ne,N]=r.useState(null),[$e,rt]=r.useState([]),[S,De]=r.useState(null),[Ie,Je]=r.useState(null),ee=r.useMemo(()=>Be((S==null?void 0:S.metrics)??[]),[S]);r.useEffect(()=>{let e=!1;return(async()=>{try{Je(null);const d=await(await le(R("/api/evaluation-metric-definitions"))).json();e||De(d)}catch(l){e||(De(null),Je((l==null?void 0:l.message)||"Failed to load metric definitions"))}})(),()=>{e=!0}},[]),r.useEffect(()=>{var d;if(!((d=S==null?void 0:S.metrics)!=null&&d.length))return;const e=Be(S.metrics),s=wt(e);if(s.length===0)return;const l=new Set(s);X(i=>l.has(i)?i:s[0]),Y(i=>l.has(i)?i:s[1]??s[0])},[S]);const H=async e=>{const s=(e==null?void 0:e.page)??_,l=(e==null?void 0:e.pageSize)??k,d=(e==null?void 0:e.search)??we,i=(e==null?void 0:e.pipeline)??u,f=(e==null?void 0:e.metric)??j,g=(e==null?void 0:e.value)??P,te=(e==null?void 0:e.op)??q,se=(e==null?void 0:e.pipeline2)??m,ye=(e==null?void 0:e.metric2)??b,re=(e==null?void 0:e.disagree)??C;try{ke(!0),Te(null),Se([]);const p=new URLSearchParams;p.set("page",String(s)),p.set("page_size",String(l)),d&&p.set("q",d),i&&(p.set("pipeline",i),f&&p.set("metric",f),g&&p.set("value",g),te&&p.set("op",te)),i&&se&&re&&(p.set("pipeline2",se),ye&&p.set("metric2",ye),p.set("disagree","true"));const W=await(await le(R(`/api/benchmarks/${a}/errors?${p.toString()}`))).json();Se(W.items),Ke(W.total)}catch(p){Te(p.message||"Failed to load error records")}finally{ke(!1)}},[nt]=r.useState(()=>(n==null?void 0:n.pipeline)??"");r.useEffect(()=>{(async()=>{var s;try{const l=await fetch(R(`/api/benchmarks/${a}/summary/by-category`));if(!l.ok)return;const i=[...(await l.json()).overall??[]].sort((g,te)=>{var re,p,je,W;const se=Number(((p=(re=g.metrics)==null?void 0:re.subset_non_empty_execution_accuracy)==null?void 0:p.average)??-1);return Number(((W=(je=te.metrics)==null?void 0:je.subset_non_empty_execution_accuracy)==null?void 0:W.average)??-1)-se});rt(i.map(g=>g.name));const f=((s=i[0])==null?void 0:s.name)??"";if(!f)return;D(g=>g||f),I(g=>g||f),nt||H({pipeline:f})}catch{}})()},[a]);const lt=()=>{pe(1),H({page:1})};r.useEffect(()=>{H()},[a,_,k]);const at=[{key:"record_id",header:"Record ID"},{key:"question",header:"Question"},{key:"metric1_pipeline",header:"Pipeline 1"},{key:"metric1_score",header:Xe(j,"Metric 1")},{key:"metric2_pipeline",header:"Pipeline 2"},{key:"metric2_score",header:Xe(b,"Metric 2")}],it=r.useMemo(()=>L.map(e=>{var d,i;const s=u?(d=e.predictions)==null?void 0:d[u]:void 0,l=m?(i=e.predictions)==null?void 0:i[m]:void 0;return{id:e.record_id,record_id:e.record_id,question:e.question,metric1_pipeline:u||"—",metric1_score:u?Ue(s==null?void 0:s[j]):"—",metric2_pipeline:m||"—",metric2_score:m?Ue(l==null?void 0:l[b]):"—"}}),[L,j,b,u,m]);r.useEffect(()=>{if(!o||!T)return;(async()=>{try{fe(!0),me(null);const s=new URLSearchParams;s.set("pipeline",T);const l=await le(R(`/api/benchmarks/${a}/errors/${o}/detail?${s.toString()}`));Re(await l.json())}catch(s){me(s.message||"Failed to load record details")}finally{fe(!1)}})()},[a,o,T]);const Oe=()=>{Ee(null),de(null),Re(null),me(null),fe(!1),Q("detail"),ge(null),Z(null),K(!1),he(""),F(""),A(!1),G(null),V(null),B(!1),z(null),N(null)};r.useEffect(()=>{Q("detail"),ge(null),Z(null),K(!1),he(""),F(""),A(!1),G(null),V(null),B(!1),z(null),N(null)},[o]);const ot=async()=>{if(o&&(Q("raw"),!xe))try{K(!0),Z(null);const e=await le(R(`/api/benchmarks/${a}/errors/${o}`));ge(await e.json())}catch(e){Z(e.message||"Failed to load raw JSON")}finally{K(!1)}},Qe=(e,s)=>{he(s),F(e),A(!1),G(null),V(null),B(!1),z(null),N(null),Q("modify")},ct=async()=>{if(!(!o||!v.trim()))try{A(!0),G(null);const e=await fetch(R(`/api/benchmarks/${a}/execute`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sql:v,record_id:o,db_id:c==null?void 0:c.db_id})}),s=await e.json();if(!e.ok)throw new Error((s==null?void 0:s.detail)||`HTTP ${e.status}`);V(s),z(null),N(null)}catch(e){G(e.message||"Failed to execute SQL"),V(null)}finally{A(!1)}},dt=async()=>{if(!(!o||!v.trim()||!window.confirm("Are you confident this query should be added to benchmark ground truth SQLs?")))try{B(!0),z(null),N(null);const s=await fetch(R(`/api/benchmarks/${a}/ground-truth-sql`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({record_id:o,sql:v})}),l=await s.json();if(!s.ok)throw new Error((l==null?void 0:l.detail)||`HTTP ${s.status}`);N(l.message)}catch(s){z(s.message||"Failed to add query to benchmark ground truth")}finally{B(!1)}};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"0.75rem"},children:[t.jsxs("h3",{style:{margin:0},children:["Error analysis – ",a]}),M&&t.jsx(x,{kind:"ghost",size:"sm",onClick:M,children:"Back"})]}),Ie&&t.jsx(h,{kind:"warning",title:"Metric list unavailable",subtitle:Ie,lowContrast:!0}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"0.5rem",alignItems:"end"},children:[t.jsx(Ae,{id:"error-search",labelText:"Search",placeholder:"Question text or record id",value:we,onChange:e=>Ze(e.target.value)}),t.jsx(Ve,{id:"pipeline-1",titleText:"Pipeline 1 (optional)",placeholder:"e.g. wxai:openai/gpt-oss-120b-greedy-zero-shot-chatapi",items:$e,itemToString:e=>e??"",selectedItem:u||null,onChange:({selectedItem:e})=>D(e??""),onInputChange:e=>D(e),allowCustomValue:!0}),t.jsx(ne,{id:"metric-select",labelText:"Metric",value:j,onChange:e=>X(e.target.value),disabled:ee.length===0,children:ee.map(e=>t.jsx(He,{label:e.label,children:e.metrics.map(s=>t.jsx(y,{value:s.name,text:s.name,title:s.description},s.name))},e.label))}),t.jsx(ne,{id:"metric2-select",labelText:"Metric 2 (for disagreement)",value:b,onChange:e=>Y(e.target.value),disabled:!C||ee.length===0,children:ee.map(e=>t.jsx(He,{label:e.label,children:e.metrics.map(s=>t.jsx(y,{value:s.name,text:s.name,title:s.description},`${s.name}-m2`))},`${e.label}-m2`))}),t.jsxs(ne,{id:"op-select",labelText:"Operator",value:q,onChange:e=>oe(e.target.value),children:[t.jsx(y,{value:"eq",text:"="}),t.jsx(y,{value:"ne",text:"≠"}),t.jsx(y,{value:"lt",text:"<"}),t.jsx(y,{value:"gt",text:">"}),t.jsx(y,{value:"le",text:"≤"}),t.jsx(y,{value:"ge",text:"≥"})]})]}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"flex-end",gap:"0.5rem",width:"100%"},children:[t.jsxs("div",{style:{flex:"1 1 400px",display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"0.5rem",alignItems:"end",minWidth:0},children:[t.jsx(Ae,{id:"metric-value",labelText:"Metric value",value:P,onChange:e=>ie(e.target.value)}),t.jsx(Ve,{id:"pipeline-2",titleText:"Pipeline 2 (for disagreement)",placeholder:"Second pipeline id",items:$e,itemToString:e=>e??"",selectedItem:m||null,onChange:({selectedItem:e})=>I(e??""),onInputChange:e=>I(e),allowCustomValue:!0}),t.jsxs(ne,{id:"disagree-select",labelText:"P1 vs P2 disagree?",value:C?"true":"false",onChange:e=>ce(e.target.value==="true"),children:[t.jsx(y,{value:"false",text:"No"}),t.jsx(y,{value:"true",text:"Yes"})]})]}),t.jsx(x,{kind:"primary",size:"sm",onClick:lt,disabled:_e,style:{flex:"0 0 auto",marginLeft:"auto"},children:"Apply filters"})]}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0.5rem",padding:"0.65rem 0.75rem",borderRadius:"6px",border:"1px solid rgba(15, 98, 254, 0.15)",background:"rgba(15, 98, 254, 0.03)"},children:[t.jsx("span",{style:{fontSize:"0.75rem",fontWeight:600,letterSpacing:"0.02em",color:"var(--cds-text-secondary, #525252)",marginRight:"0.25rem"},children:"Quick presets"}),t.jsx(x,{kind:"secondary",size:"sm",disabled:!u,onClick:()=>{const e=u;e&&(D(e),I(e),X("execution_accuracy"),Y("subset_non_empty_execution_accuracy"),ie("0"),oe("eq"),ce(!0),pe(1),H({page:1,pipeline:e,pipeline2:e,metric:"execution_accuracy",metric2:"subset_non_empty_execution_accuracy",value:"0",op:"eq",disagree:!0}))},children:"Exec=0 & subset=1"}),t.jsx(x,{kind:"secondary",size:"sm",disabled:!u,onClick:()=>{const e=u;e&&(D(e),I(e),X("subset_non_empty_execution_accuracy"),Y("llm_score"),ie("0"),oe("eq"),ce(!0),pe(1),H({page:1,pipeline:e,pipeline2:e,metric:"subset_non_empty_execution_accuracy",metric2:"llm_score",value:"0",op:"eq",disagree:!0}))},children:"Subset=0 & llm=1"})]})]}),Ce&&t.jsx(h,{kind:"error",title:"Error loading error records",subtitle:Ce,lowContrast:!0}),_e?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[t.jsx(ut,{description:`Loading error records for ${a}…`,status:"active"}),t.jsx(pt,{role:"progressbar",columnCount:6,rowCount:10})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{maxHeight:"420px",overflow:"auto"},children:t.jsx(ft,{rows:it,headers:at,size:"sm",children:({rows:e,headers:s,getHeaderProps:l})=>t.jsx(mt,{children:t.jsxs(xt,{"aria-label":"Error records",children:[t.jsx(gt,{children:t.jsx(Ge,{children:s.map(d=>{const{key:i,...f}=l({header:d});return t.jsx(ht,{...f,children:d.header},i)})})}),t.jsx(yt,{children:e.map(d=>t.jsx(Ge,{style:{cursor:"pointer"},onClick:()=>{const i=String(d.id),f=ue(i,L);f&&(Ee(i),de(f))},children:d.cells.map(i=>t.jsx(jt,{children:i.value},i.id))},d.id))})]})})})}),t.jsx(bt,{page:_,pageSize:k,pageSizes:[10,25,50,100],totalItems:Ye,onChange:({page:e,pageSize:s})=>J({page:e,pageSize:s})})]}),o&&t.jsxs(t.Fragment,{children:[t.jsx("div",{onClick:Oe,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.35)",zIndex:7400}}),t.jsxs("div",{style:{position:"fixed",top:"3rem",right:0,bottom:0,width:"min(900px, 92vw)",zIndex:7500,background:"#ffffff",color:"#161616",borderLeft:"1px solid rgba(0,0,0,0.12)",padding:"0.85rem",overflow:"auto",display:"flex",flexDirection:"column",gap:"0.75rem"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("h3",{style:{margin:0},children:O==="raw"?`Raw JSON – ${o}`:O==="modify"?`Modify Query – ${o}`:`Record detail – ${o}${T?` (${T})`:""}`}),t.jsxs("div",{style:{display:"flex",gap:"0.35rem"},children:[O!=="detail"&&t.jsx(x,{kind:"ghost",size:"sm",onClick:()=>Q("detail"),children:"Back to detail"}),t.jsx(x,{kind:"ghost",size:"sm",onClick:Oe,children:"X"})]})]}),O==="raw"?t.jsxs(t.Fragment,{children:[et&&t.jsx(h,{kind:"info",title:"Loading raw JSON...",subtitle:"Fetching full record payload from predictions_eval",lowContrast:!0}),Le&&t.jsx(h,{kind:"error",title:"Failed to load raw JSON",subtitle:Le,lowContrast:!0}),xe&&t.jsx("section",{children:t.jsx("pre",{style:{margin:"0.3rem 0",padding:"0.6rem",background:"#f4f4f4",borderRadius:"4px",whiteSpace:"pre-wrap",border:"1px solid rgba(15,98,254,0.2)",color:"#161616"},children:JSON.stringify(xe,null,2)})})]}):O==="modify"?t.jsxs(t.Fragment,{children:[t.jsxs("section",{children:[t.jsx("h4",{style:{margin:"0.25rem 0",color:"#0f62fe"},children:"Source SQL"}),t.jsx("div",{style:{marginBottom:"0.35rem"},children:tt||"Custom query"})]}),t.jsx(St,{id:"error-analysis-modify-query-sql",labelText:"Editable SQL",rows:14,value:v,onChange:e=>F(e.target.value)}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx(x,{kind:"secondary",size:"sm",disabled:Pe||!v.trim(),onClick:()=>void ct(),children:"Execute"})}),Pe&&t.jsx(h,{kind:"info",title:"Executing SQL...",subtitle:"Running query against the benchmark backend",lowContrast:!0}),qe&&t.jsx(h,{kind:"error",title:"SQL execution failed",subtitle:qe,lowContrast:!0}),ze&&t.jsx(h,{kind:"error",title:"Failed to update ground truth",subtitle:ze,lowContrast:!0}),Ne&&t.jsx(h,{kind:"success",title:"Ground truth updated",subtitle:Ne,lowContrast:!0}),E&&t.jsxs(t.Fragment,{children:[t.jsxs("section",{children:[t.jsx("h4",{style:{margin:"0.25rem 0",color:"#0f62fe"},children:"Execution summary"}),t.jsx("pre",{style:{margin:"0.3rem 0",padding:"0.6rem",background:"#f4f4f4",borderRadius:"4px",whiteSpace:"pre-wrap",color:"#161616"},children:JSON.stringify({db_type:E.db_type,db_id:E.db_id,execution_time_ms:E.execution_time_ms,row_count:E.row_count,column_count:E.column_count},null,2)})]}),t.jsx(be,{title:"Execution result",rawData:E.result}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx(x,{kind:"primary",size:"sm",disabled:st||!v.trim(),onClick:()=>void dt(),children:"Add to benchmark ground truth"})})]})]}):t.jsxs(t.Fragment,{children:[Fe&&t.jsx(h,{kind:"info",title:"Loading details...",subtitle:"Fetching full record detail",lowContrast:!0}),Me&&t.jsx(h,{kind:"error",title:"Failed to load details",subtitle:Me,lowContrast:!0}),c&&t.jsxs(t.Fragment,{children:[t.jsxs("section",{children:[t.jsx("h4",{style:{margin:"0.25rem 0",color:"#0f62fe"},children:"Question"}),t.jsx("div",{style:{whiteSpace:"pre-wrap"},children:c.question||"N/A"})]}),t.jsxs("section",{children:[t.jsx("h4",{style:{margin:"0.25rem 0",color:"#0f62fe"},children:"Ground truth SQL"}),(c.ground_truth_sql||[]).map((e,s)=>t.jsxs("div",{style:{marginBottom:"0.55rem"},children:[t.jsx("pre",{style:{margin:"0.3rem 0",padding:"0.6rem",background:"#f4f4f4",borderRadius:"4px",whiteSpace:"pre-wrap",border:"1px solid rgba(15,98,254,0.2)",color:"#161616"},children:t.jsx("code",{dangerouslySetInnerHTML:{__html:We(e)}})}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx(x,{kind:"ghost",size:"sm",onClick:()=>Qe(e,`Ground truth SQL ${s+1}`),children:"Modify Query"})})]},`gt-sql-${s}`))]}),t.jsxs("section",{children:[t.jsx("h4",{style:{margin:"0.25rem 0",color:"#0f62fe"},children:"Predicted SQL"}),t.jsx("pre",{style:{margin:"0.3rem 0",padding:"0.6rem",background:"#f4f4f4",borderRadius:"4px",whiteSpace:"pre-wrap",border:"1px solid rgba(15,98,254,0.2)",color:"#161616"},children:t.jsx("code",{dangerouslySetInnerHTML:{__html:We(c.predicted_sql||"N/A")}})}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx(x,{kind:"ghost",size:"sm",disabled:!c.predicted_sql,onClick:()=>Qe(c.predicted_sql||"","Predicted SQL"),children:"Modify Query"})})]}),t.jsxs("section",{children:[t.jsx("h4",{style:{margin:"0.25rem 0",color:"#0f62fe"},children:"Evaluation metrics"}),t.jsx("pre",{style:{margin:"0.3rem 0",padding:"0.6rem",background:"#f4f4f4",borderRadius:"4px",whiteSpace:"pre-wrap",color:"#161616"},children:JSON.stringify(c.evaluation_metrics??{},null,2)})]}),(c.ground_truth_results||[]).map((e,s)=>{var l;return t.jsx(be,{title:`Ground truth result ${s+1}`,rawData:e,totalRows:(l=c.ground_truth_result_row_counts)==null?void 0:l[s]},`gt-result-table-${s}`)}),t.jsx(be,{title:"Predicted result",rawData:c.predicted_result,totalRows:c.predicted_result_row_count}),t.jsxs("section",{children:[t.jsx("h4",{style:{margin:"0.25rem 0",color:"#0f62fe"},children:"Prompt"}),t.jsx("pre",{style:{margin:"0.3rem 0",padding:"0.6rem",background:"#f4f4f4",borderRadius:"4px",whiteSpace:"pre-wrap",color:"#161616"},children:c.prompt||"N/A"})]}),t.jsxs("section",{children:[t.jsx("h4",{style:{margin:"0.25rem 0",color:"#0f62fe"},children:"LLM judge"}),t.jsxs("div",{style:{marginBottom:"0.25rem"},children:["Score: ",c.llm_judge_score??"N/A"]}),t.jsx("pre",{style:{margin:"0.3rem 0",padding:"0.6rem",background:"#f4f4f4",borderRadius:"4px",whiteSpace:"pre-wrap",color:"#161616"},children:c.llm_judge_explanation||"N/A"})]}),(c.sql_execution_error||c.inference_error)&&t.jsxs("section",{children:[t.jsx("h4",{style:{margin:"0.25rem 0",color:"#0f62fe"},children:"Errors"}),t.jsx("pre",{style:{margin:"0.3rem 0",padding:"0.6rem",background:"#f4f4f4",borderRadius:"4px",whiteSpace:"pre-wrap",color:"#161616"},children:JSON.stringify({sql_execution_error:c.sql_execution_error,inference_error:c.inference_error},null,2)})]}),t.jsx("div",{style:{marginTop:"0.25rem",display:"flex",justifyContent:"flex-end"},children:t.jsx(x,{kind:"secondary",size:"sm",onClick:()=>void ot(),children:"View Raw JSON"})})]})]})]})]})]})};export{Rt as ErrorAnalysis};
@@ -0,0 +1 @@
1
+ import{r as s,y as j,z as g,k as a,I as y,H as E,B as L}from"./index-C9VP9iwL.js";import{C as T}from"./ComboBox-Cz5Wuuu_.js";import"./defaultItemToString-BtCahKYf.js";const b="llm_judge_default_config",F=()=>{const[C,h]=s.useState([]),[i,u]=s.useState(null),[m,c]=s.useState(""),[p,n]=s.useState(null),[x,r]=s.useState(null),[w,l]=s.useState(!1),d=s.useCallback(async e=>{try{l(!0),n(null),r(null);const o=await(await j(g(`/api/llm-judge/configs/${e.name}`))).json();c(JSON.stringify(o,null,2))}catch(t){n(t.message||"Failed to load config"),c("")}finally{l(!1)}},[]);s.useEffect(()=>{(async()=>{try{n(null);const o=await(await j(g("/api/llm-judge/configs"))).json();h(o.items);const f=o.items.find(v=>v.name===b);f&&(u(f),await d(f))}catch(t){n(t.message||"Failed to load config list")}})()},[d]);const S=async()=>{if(i)try{l(!0),n(null),r(null);const e=JSON.parse(m),t=await fetch(g(`/api/llm-judge/configs/${i.name}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const o=await t.text();throw new Error(o||`HTTP ${t.status}`)}r("Config saved successfully")}catch(e){n(e.message||"Failed to save config")}finally{l(!1)}};return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[a.jsx("h3",{style:{margin:0},children:"LLM-as-judge configuration"}),p&&a.jsx(y,{kind:"error",title:"Error",subtitle:p,lowContrast:!0}),x&&a.jsx(y,{kind:"success",title:"Saved",subtitle:x,lowContrast:!0}),a.jsx(T,{id:"llm-config-select",titleText:"Select config",items:C,itemToString:e=>e?e.name:"",selectedItem:i,onChange:e=>{const t=e.selectedItem;u(t),t&&d(t)},placeholder:"Choose a YAML config"}),a.jsx(E,{id:"llm-config-editor",labelText:"Config JSON (edit and save)",rows:20,value:m,onChange:e=>c(e.target.value),disabled:!i}),a.jsx("div",{children:a.jsx(L,{kind:"primary",onClick:()=>void S(),disabled:!i||w,children:"Save config"})})]})};export{F as LLMJudgeConfigView};
@@ -0,0 +1 @@
1
+ import{r,k as e,I as C,S as Y,G as Z,o as $,p as z,q as M,w as i,v as E,t as A,M as xe,y as L,z as P,B as K}from"./index-C9VP9iwL.js";import{C as ee}from"./ComboBox-Cz5Wuuu_.js";import{b as fe,f as pe,c as te,S as ie}from"./metricInsightsSelect-B46SO2Wy.js";import"./defaultItemToString-BtCahKYf.js";function T(n,o){var N;const a=(N=n==null?void 0:n.metrics)==null?void 0:N[o],u=a==null?void 0:a.average;return typeof u=="number"?u:null}function ne(n){var a,u;const o=(u=(a=n==null?void 0:n.metrics)==null?void 0:a.subset_non_empty_execution_accuracy)==null?void 0:u.average;return typeof o=="number"?o:-1}const ge="Token counts and timings copied from the prediction record when available.";function je(n){switch(n){case"binary":return"0 / 1";case"float":return"Number";case"int":return"Integer";case"text":return"Text";default:return n}}function se(n,o){return o==null?"N/A":n==="int"?Number.isFinite(o)?String(Math.round(o)):"N/A":n==="float"?o.toFixed(2):o.toFixed(3)}function be(n,o,a){if(o==null||a==null)return"N/A";const u=a-o;return n==="int"?Number.isFinite(u)?String(Math.round(u)):"N/A":n==="float"?u.toFixed(2):u.toFixed(3)}const Ce=({benchmarkId:n,onOpenErrorAnalysis:o})=>{const[a,u]=r.useState(null),[N,D]=r.useState(null),[I,k]=r.useState(null),[le,F]=r.useState(!1),[h,H]=r.useState(""),[x,V]=r.useState(""),[re,ae]=r.useState("execution_accuracy"),[oe,ce]=r.useState("subset_non_empty_execution_accuracy"),[p,G]=r.useState(null),[q,O]=r.useState(null),[de,R]=r.useState(null),[ue,B]=r.useState(null),U=r.useMemo(()=>{var t;return((t=a==null?void 0:a.overall)==null?void 0:t.map(s=>s.name))??[]},[a]),w=r.useMemo(()=>fe((p==null?void 0:p.metrics)??[]),[p]);r.useEffect(()=>{let t=!1;return(async()=>{try{O(null);const d=await(await L(P("/api/evaluation-metric-definitions"))).json();t||G(d)}catch(l){t||(G(null),O((l==null?void 0:l.message)||"Failed to load metric definitions"))}})(),()=>{t=!0}},[]);const W=r.useMemo(()=>pe(w),[w]),g=te(re,W,0),j=te(oe,W,1);r.useEffect(()=>{if(!n)return;(async()=>{var s,l;try{D(null),F(!0);const c=await(await L(P(`/api/benchmarks/${n}/summary/by-category`))).json();u(c);const f=[...c.overall??[]].sort((m,he)=>ne(he)-ne(m)),_=((s=f[0])==null?void 0:s.name)??"",me=((l=f[1])==null?void 0:l.name)??_,X=new Set(f.map(m=>m.name));H(m=>m&&X.has(m)?m:_),V(m=>m&&X.has(m)?m:me)}catch(d){D(d.message||"Failed to load summary")}finally{F(!1)}})()},[n]);const b=r.useMemo(()=>a?a.overall.find(t=>t.name===h)??null:null,[a,h]),v=r.useMemo(()=>a?a.overall.find(t=>t.name===x)??null:null,[a,x]),y=r.useMemo(()=>!b||!v?{left:null,right:null}:{left:T(b,g),right:T(v,g)},[b,v,g]),S=r.useMemo(()=>!b||!v?{left:null,right:null}:{left:T(b,j),right:T(v,j)},[b,v,j]),J=r.useMemo(()=>((p==null?void 0:p.metrics)??[]).filter(t=>t.group==="Timing and tokens"),[p]);r.useEffect(()=>{if(!n||!h||!x)return;const t=l=>{const d=new URLSearchParams({pipeline_left:h,pipeline_right:x,metric_left:l,metric_right:l});return L(P(`/api/benchmarks/${n}/insights/cross-pipeline-binary-metric-confusion?${d.toString()}`)).then(c=>c.json())};(async()=>{var l,d;try{k(null),F(!0);const[c,f]=await Promise.allSettled([t(g),t(j)]);if(c.status==="rejected"||f.status==="rejected"){const _=c.status==="rejected"?(l=c.reason)==null?void 0:l.message:f.status==="rejected"?(d=f.reason)==null?void 0:d.message:null;k(_||"Failed to load comparison evidence"),R(null),B(null)}else R(c.value),B(f.value)}catch(c){k(c.message||"Failed to load comparison evidence"),R(null),B(null)}finally{F(!1)}})()},[n,h,x,g,j]);const Q=(t,s)=>{if(!s)return e.jsx(C,{kind:"info",title:`No evidence for ${t}`,subtitle:"Switch pipelines/metrics or ensure results artifacts exist.",lowContrast:!0});const l=s.n_valid,d=s.counts.left0right1,c=s.counts.left1right0,f=l>0?(d+c)/l:0;return e.jsxs("section",{style:{border:"1px solid rgba(15,98,254,0.2)",borderRadius:"6px",padding:"0.75rem"},children:[e.jsx("h4",{style:{margin:"0 0 0.25rem 0",color:"#0f62fe"},children:`Disagreement evidence for ${t}`}),e.jsxs("div",{style:{opacity:.88,fontSize:"0.9rem",marginBottom:"0.5rem"},children:["Disagreement rate: ",e.jsx("strong",{children:f.toFixed(3)})," (valid samples: ",l,")"]}),e.jsx("div",{style:{overflow:"auto",maxHeight:"240px"},children:e.jsxs($,{size:"sm","aria-label":`Cross-pipeline confusion for ${t}`,children:[e.jsx(z,{children:e.jsxs(M,{children:[e.jsx(i,{children:"Case"}),e.jsx(i,{children:"Count"}),e.jsx(i,{children:"Rate"}),e.jsx(i,{})]})}),e.jsxs(E,{children:[e.jsxs(M,{children:[e.jsx(i,{children:"Left=0, Right=1"}),e.jsx(i,{children:d}),e.jsx(i,{children:l>0?(d/l).toFixed(3):"0.000"}),e.jsx(i,{children:e.jsx(K,{size:"sm",kind:"secondary",disabled:d===0,onClick:()=>o({pipeline:h,metric:t,value:"0",op:"eq",pipeline2:x,metric2:t,disagree:!0}),children:"View examples"})})]}),e.jsxs(M,{children:[e.jsx(i,{children:"Left=1, Right=0"}),e.jsx(i,{children:c}),e.jsx(i,{children:l>0?(c/l).toFixed(3):"0.000"}),e.jsx(i,{children:e.jsx(K,{size:"sm",kind:"secondary",disabled:c===0,onClick:()=>o({pipeline:h,metric:t,value:"1",op:"eq",pipeline2:x,metric2:t,disagree:!0}),children:"View examples"})})]})]})]})})]})};return n?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("h3",{style:{margin:0},children:["Pipeline compare – ",n]}),q&&e.jsx(C,{kind:"warning",title:"Metric list unavailable",subtitle:q,lowContrast:!0}),N&&e.jsx(C,{kind:"error",title:"Summary error",subtitle:N,lowContrast:!0}),I&&e.jsx(C,{kind:"error",title:"Comparison evidence unavailable",subtitle:I,lowContrast:!0}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:"0.5rem",alignItems:"end"},children:[e.jsx(ee,{id:"compare-left-pipeline",titleText:"Left pipeline",items:U,itemToString:t=>t??"",selectedItem:h||null,onChange:t=>H(t.selectedItem),placeholder:"Select left pipeline"}),e.jsx(ee,{id:"compare-right-pipeline",titleText:"Right pipeline",items:U,itemToString:t=>t??"",selectedItem:x||null,onChange:t=>V(t.selectedItem),placeholder:"Select right pipeline"}),e.jsx(Y,{id:"metricA-select",labelText:"Metric A",value:g,onChange:t=>ae(t.target.value),disabled:w.length===0,children:w.map(t=>e.jsx(ie,{label:t.label,children:t.metrics.map(s=>e.jsx(Z,{value:s.name,text:s.name,title:s.description},s.name))},t.label))}),e.jsx(Y,{id:"metricB-select",labelText:"Metric B",value:j,onChange:t=>ce(t.target.value),disabled:w.length===0,children:w.map(t=>e.jsx(ie,{label:t.label,children:t.metrics.map(s=>e.jsx(Z,{value:s.name,text:s.name,title:s.description},`${s.name}-b`))},`${t.label}-b`))})]}),e.jsxs("section",{style:{border:"1px solid rgba(15,98,254,0.2)",borderRadius:"6px",padding:"0.75rem"},children:[e.jsx("h4",{style:{margin:"0 0 0.25rem 0",color:"#0f62fe"},children:"Metric averages and deltas"}),e.jsx("div",{style:{overflow:"auto",maxHeight:"220px"},children:e.jsxs($,{size:"sm","aria-label":"Metric averages and deltas",children:[e.jsx(z,{children:e.jsxs(M,{children:[e.jsx(i,{children:"Metric"}),e.jsx(i,{children:`Left (${h})`}),e.jsx(i,{children:`Right (${x})`}),e.jsx(i,{children:"Δ (right - left)"})]})}),e.jsxs(E,{children:[e.jsxs(M,{children:[e.jsx(i,{children:g}),e.jsx(i,{children:y.left==null?"N/A":y.left.toFixed(3)}),e.jsx(i,{children:y.right==null?"N/A":y.right.toFixed(3)}),e.jsx(i,{children:y.left!=null&&y.right!=null?(y.right-y.left).toFixed(3):"N/A"})]}),e.jsxs(M,{children:[e.jsx(i,{children:j}),e.jsx(i,{children:S.left==null?"N/A":S.left.toFixed(3)}),e.jsx(i,{children:S.right==null?"N/A":S.right.toFixed(3)}),e.jsx(i,{children:S.left!=null&&S.right!=null?(S.right-S.left).toFixed(3):"N/A"})]})]})]})})]}),le?e.jsx(C,{kind:"info",title:"Loading evidence…",subtitle:"Computing disagreements across pipelines.",lowContrast:!0}):e.jsxs(e.Fragment,{children:[Q(g,de),Q(j,ue)]}),e.jsxs("section",{style:{border:"1px solid rgba(15,98,254,0.2)",borderRadius:"6px",padding:"0.75rem"},children:[e.jsx("h4",{style:{margin:"0 0 0.25rem 0",color:"#0f62fe"},children:"Timing and tokens"}),e.jsxs("p",{style:{margin:"0 0 0.5rem 0",fontSize:"0.8125rem",lineHeight:1.45,opacity:.88,maxWidth:"52rem"},children:[ge," Averages are benchmark-wide aggregates from the summary artifact (same fields as Eval Playground per-record metrics)."]}),J.length===0?e.jsx(C,{kind:"info",title:"No timing metrics in definitions",subtitle:"Load metric definitions or ensure the toolkit lists Timing and tokens metrics.",lowContrast:!0}):e.jsx("div",{style:{overflow:"auto",maxHeight:"320px"},children:e.jsxs($,{size:"sm","aria-label":"Timing and tokens comparison",children:[e.jsx(z,{children:e.jsxs(M,{children:[e.jsx(A,{children:"Metric"}),e.jsx(A,{children:"Type"}),e.jsx(A,{children:`Left (${h})`}),e.jsx(A,{children:`Right (${x})`}),e.jsx(A,{children:"Δ (right − left)"}),e.jsx(A,{children:"What it means"})]})}),e.jsx(E,{children:J.map(t=>{const s=b?T(b,t.name):null,l=v?T(v,t.name):null;return e.jsxs(M,{children:[e.jsx(i,{style:{fontFamily:"monospace",fontSize:"0.8125rem",verticalAlign:"top"},children:t.name}),e.jsx(i,{style:{verticalAlign:"top"},children:e.jsx(xe,{type:"gray",size:"sm",children:je(t.value_type)})}),e.jsx(i,{style:{verticalAlign:"top",fontVariantNumeric:"tabular-nums"},children:se(t.value_type,s)}),e.jsx(i,{style:{verticalAlign:"top",fontVariantNumeric:"tabular-nums"},children:se(t.value_type,l)}),e.jsx(i,{style:{verticalAlign:"top",fontVariantNumeric:"tabular-nums"},children:be(t.value_type,s,l)}),e.jsx(i,{style:{fontSize:"0.8125rem",lineHeight:1.45,verticalAlign:"top"},children:t.description})]},t.name)})})]})})]})]}):e.jsx(C,{kind:"info",title:"Select a benchmark",subtitle:"Choose a benchmark to compare pipelines.",lowContrast:!0})};export{Ce as PipelineCompareView};
@@ -0,0 +1 @@
1
+ import{r as s,k as e,B as u,I as m,n as ne,T as oe,o as ae,p as le,q as z,t as ce,v as de,w as ue,E as Fe,x as $e,H as ze,y as M,z as j}from"./index-C9VP9iwL.js";import{R as V,h as me}from"./ResultTableView-Dq7hZwq5.js";const Qe=({benchmarkId:d,pipelineName:l,recordId:xe,onSelectRecord:C,onBack:he,onOpenErrorAnalysis:P})=>{const[T,fe]=s.useState(null),[I,ye]=s.useState([]),[pe,ge]=s.useState(0),[L,je]=s.useState(""),[Q,N]=s.useState(1),[J,_e]=s.useState(10),[U,E]=s.useState(null),c=xe??null,W=s.useCallback(r=>C==null?void 0:C(r),[C]),[a,X]=s.useState(null),[be,D]=s.useState(!1),[K,O]=s.useState(null),[_,b]=s.useState("detail"),[G,H]=s.useState(null),[we,R]=s.useState(!1),[Y,q]=s.useState(null),[Se,A]=s.useState(""),[h,F]=s.useState(""),[Z,w]=s.useState(!1),[ee,S]=s.useState(null),[f,k]=s.useState(null),[ke,v]=s.useState(!1),[re,p]=s.useState(null),[te,g]=s.useState(null);s.useEffect(()=>{(async()=>{try{E(null);const t=await M(j(`/api/benchmarks/${d}/summary/by-category`));fe(await t.json())}catch(t){E(t.message||"Failed to load pipeline summary")}})()},[d]),s.useEffect(()=>{(async()=>{try{E(null);const t=new URLSearchParams;t.set("pipeline",l),t.set("failed_only","true"),t.set("page",String(Q)),t.set("page_size",String(J)),L&&t.set("q",L);const n=await(await M(j(`/api/benchmarks/${d}/errors?${t.toString()}`))).json();ye(n.items),ge(n.total)}catch(t){E(t.message||"Failed to load failed examples")}})()},[d,l,Q,J,L]);const y=s.useMemo(()=>{var i;if(!T)return null;const r=((i=(T.overall??[]).find(n=>n.name===l))==null?void 0:i.metrics)??{},t={};for(const[n,o]of Object.entries(T.categories??{})){const x=o.find(B=>B.name===l);x&&(t[n]=x.metrics)}return{overall:r,perCategory:t}},[T,l]),ve=[{key:"scope",header:"Scope"},{key:"execution_accuracy",header:"execution_accuracy"},{key:"subset_non_empty_execution_accuracy",header:"subset_non_empty_execution_accuracy"},{key:"llm_score",header:"llm_score"},{key:"bird_execution_accuracy",header:"bird_execution_accuracy"}],Ce=s.useMemo(()=>{if(!y)return[];const r=(i,n)=>{const o=i==null?void 0:i[n];return o&&typeof o=="object"&&"average"in o?Number(o.average).toFixed(3):typeof o=="number"?o.toFixed(3):""},t=[{id:"overall",scope:"overall",execution_accuracy:r(y.overall,"execution_accuracy"),subset_non_empty_execution_accuracy:r(y.overall,"subset_non_empty_execution_accuracy"),llm_score:r(y.overall,"llm_score"),bird_execution_accuracy:r(y.overall,"bird_execution_accuracy")}];return Object.entries(y.perCategory).forEach(([i,n])=>{t.push({id:i,scope:i,execution_accuracy:r(n,"execution_accuracy"),subset_non_empty_execution_accuracy:r(n,"subset_non_empty_execution_accuracy"),llm_score:r(n,"llm_score"),bird_execution_accuracy:r(n,"bird_execution_accuracy")})}),t},[y]),Te=[{key:"record_id",header:"Record ID"},{key:"question",header:"Question"},{key:"metrics",header:"Pipeline metrics"}],Le=s.useMemo(()=>I.map(r=>{var i;const t=((i=r.predictions)==null?void 0:i[l])??{};return{id:r.record_id,record_id:r.record_id,question:r.question,metrics:`exec=${t.execution_accuracy??"?"}, subset=${t.subset_non_empty_execution_accuracy??"?"}, llm=${t.llm_score??"?"}`}}),[I,l]);s.useEffect(()=>{if(!c)return;(async()=>{try{D(!0),O(null);const t=new URLSearchParams;t.set("pipeline",l);const i=await M(j(`/api/benchmarks/${d}/errors/${c}/detail?${t.toString()}`));X(await i.json())}catch(t){O(t.message||"Failed to load record details")}finally{D(!1)}})()},[d,l,c]);const se=()=>{W(null),X(null),O(null),D(!1),b("detail"),H(null),q(null),R(!1),A(""),F(""),w(!1),S(null),k(null),v(!1),p(null),g(null)};s.useEffect(()=>{b("detail"),H(null),q(null),R(!1),A(""),F(""),w(!1),S(null),k(null),v(!1),p(null),g(null)},[c]);const Ee=async()=>{if(c&&(b("raw"),!G))try{R(!0),q(null);const r=await M(j(`/api/benchmarks/${d}/errors/${c}`));H(await r.json())}catch(r){q(r.message||"Failed to load raw JSON")}finally{R(!1)}},ie=(r,t)=>{A(t),F(r),w(!1),S(null),k(null),v(!1),p(null),g(null),b("modify")},Re=async()=>{if(!(!c||!h.trim()))try{w(!0),S(null);const r=await fetch(j(`/api/benchmarks/${d}/execute`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sql:h,record_id:c,db_id:a==null?void 0:a.db_id})}),t=await r.json();if(!r.ok)throw new Error((t==null?void 0:t.detail)||`HTTP ${r.status}`);k(t),p(null),g(null)}catch(r){S(r.message||"Failed to execute SQL"),k(null)}finally{w(!1)}},qe=async()=>{if(!(!c||!h.trim()||!window.confirm("Are you confident this query should be added to benchmark ground truth SQLs?")))try{v(!0),p(null),g(null);const t=await fetch(j(`/api/benchmarks/${d}/ground-truth-sql`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({record_id:c,sql:h})}),i=await t.json();if(!t.ok)throw new Error((i==null?void 0:i.detail)||`HTTP ${t.status}`);g(i.message)}catch(t){p(t.message||"Failed to add query to benchmark ground truth")}finally{v(!1)}},$=r=>{if(r==null)return"N/A";if(typeof r=="string")try{const t=JSON.parse(r);return JSON.stringify(t,null,2)}catch{return r}try{return JSON.stringify(r,null,2)}catch{return String(r)}};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(u,{kind:"ghost",size:"sm",onClick:he,children:"Back to summary"}),e.jsxs("h3",{style:{margin:0},children:[d," – ",l]})]}),U&&e.jsx(m,{kind:"error",title:"Error loading pipeline details",subtitle:U,lowContrast:!0}),e.jsx("h4",{style:{margin:"0.25rem 0 0 0"},children:"Performance overview"}),e.jsx("div",{style:{maxHeight:"260px",overflow:"auto"},children:e.jsx(ne,{rows:Ce,headers:ve,size:"sm",children:({rows:r,headers:t,getHeaderProps:i})=>e.jsx(oe,{children:e.jsxs(ae,{"aria-label":"Pipeline metrics by scope",children:[e.jsx(le,{children:e.jsx(z,{children:t.map(n=>{const{key:o,...x}=i({header:n});return e.jsx(ce,{...x,children:n.header},o)})})}),e.jsx(de,{children:r.map(n=>e.jsx(z,{children:n.cells.map(o=>e.jsx(ue,{children:o.value},o.id))},n.id))})]})})})}),e.jsx("h4",{style:{margin:"0.25rem 0 0 0"},children:"Failed examples (execution_accuracy = 0)"}),P&&e.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.25rem"},children:[e.jsx(u,{kind:"secondary",size:"sm",onClick:()=>P({pipeline:l,metric:"execution_accuracy",value:"0",op:"eq",pipeline2:l,metric2:"subset_non_empty_execution_accuracy",disagree:!0}),children:"Exec=0 & subset=1"}),e.jsx(u,{kind:"secondary",size:"sm",onClick:()=>P({pipeline:l,metric:"subset_non_empty_execution_accuracy",value:"0",op:"eq",pipeline2:l,metric2:"llm_score",disagree:!0}),children:"Subset=0 & llm=1"})]}),e.jsx(Fe,{id:"pipeline-errors-search",labelText:"Search failed examples",placeholder:"Question text or record id",value:L,onChange:r=>{je(r.target.value),N(1)}}),e.jsx("div",{style:{maxHeight:"360px",overflow:"auto"},children:e.jsx(ne,{rows:Le,headers:Te,size:"sm",children:({rows:r,headers:t,getHeaderProps:i})=>e.jsx(oe,{children:e.jsxs(ae,{"aria-label":"Failed examples",children:[e.jsx(le,{children:e.jsx(z,{children:t.map(n=>{const{key:o,...x}=i({header:n});return e.jsx(ce,{...x,children:n.header},o)})})}),e.jsx(de,{children:r.map(n=>e.jsx(z,{style:{cursor:"pointer"},onClick:()=>{const o=n.cells.find(B=>B.info.header==="record_id"),x=(o==null?void 0:o.value)!=null?String(o.value):String(n.id);W(x)},children:n.cells.map(o=>e.jsx(ue,{children:o.value},o.id))},n.id))})]})})})}),e.jsx($e,{page:Q,pageSize:J,pageSizes:[10,25,50],totalItems:pe,onChange:({page:r,pageSize:t})=>{N(r),_e(t)}}),e.jsx("div",{style:{fontSize:"0.82rem",opacity:.85},children:"Click a failed question row for full details (ground truth SQL/results, prediction, metrics, prompt, and LLM-judge explanation)."}),c&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:se,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.35)",zIndex:7400}}),e.jsxs("div",{style:{position:"fixed",top:"3rem",right:0,bottom:0,width:"min(900px, 92vw)",zIndex:7500,background:"#ffffff",color:"#161616",borderLeft:"1px solid rgba(0,0,0,0.12)",padding:"0.85rem",overflow:"auto",display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("h3",{style:{margin:0},children:_==="raw"?`Raw JSON – ${c}`:_==="modify"?`Modify Query – ${c}`:`Record detail – ${c}`}),e.jsxs("div",{style:{display:"flex",gap:"0.35rem"},children:[_!=="detail"&&e.jsx(u,{kind:"ghost",size:"sm",onClick:()=>b("detail"),children:"Back to detail"}),e.jsx(u,{kind:"ghost",size:"sm",onClick:se,children:"X"})]})]}),_==="raw"?e.jsxs(e.Fragment,{children:[we&&e.jsx(m,{kind:"info",title:"Loading raw JSON...",subtitle:"Fetching full record payload from predictions_eval",lowContrast:!0}),Y&&e.jsx(m,{kind:"error",title:"Failed to load raw JSON",subtitle:Y,lowContrast:!0}),G&&e.jsx("section",{children:e.jsx("pre",{style:{margin:"0.3rem 0",padding:"0.6rem",background:"#f4f4f4",borderRadius:"4px",whiteSpace:"pre-wrap",border:"1px solid rgba(15,98,254,0.2)",color:"#161616"},children:$(G)})})]}):_==="modify"?e.jsxs(e.Fragment,{children:[e.jsxs("section",{children:[e.jsx("h4",{style:{margin:"0.25rem 0",color:"#0f62fe"},children:"Source SQL"}),e.jsx("div",{style:{marginBottom:"0.35rem"},children:Se||"Custom query"})]}),e.jsx(ze,{id:"modify-query-sql",labelText:"Editable SQL",rows:14,value:h,onChange:r=>F(r.target.value)}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem"},children:e.jsx(u,{kind:"secondary",size:"sm",disabled:Z||!h.trim(),onClick:()=>void Re(),children:"Execute"})}),Z&&e.jsx(m,{kind:"info",title:"Executing SQL...",subtitle:"Running query against the benchmark backend",lowContrast:!0}),ee&&e.jsx(m,{kind:"error",title:"SQL execution failed",subtitle:ee,lowContrast:!0}),re&&e.jsx(m,{kind:"error",title:"Failed to update ground truth",subtitle:re,lowContrast:!0}),te&&e.jsx(m,{kind:"success",title:"Ground truth updated",subtitle:te,lowContrast:!0}),f&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{children:[e.jsx("h4",{style:{margin:"0.25rem 0",color:"#0f62fe"},children:"Execution summary"}),e.jsx("pre",{style:{margin:"0.3rem 0",padding:"0.6rem",background:"#f4f4f4",borderRadius:"4px",whiteSpace:"pre-wrap",color:"#161616"},children:$({db_type:f.db_type,db_id:f.db_id,execution_time_ms:f.execution_time_ms,row_count:f.row_count,column_count:f.column_count})})]}),e.jsx(V,{title:"Execution result",rawData:f.result}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(u,{kind:"primary",size:"sm",disabled:ke||!h.trim(),onClick:()=>void qe(),children:"Add to benchmark ground truth"})})]})]}):e.jsxs(e.Fragment,{children:[be&&e.jsx(m,{kind:"info",title:"Loading details...",subtitle:"Fetching full record detail",lowContrast:!0}),K&&e.jsx(m,{kind:"error",title:"Failed to load details",subtitle:K,lowContrast:!0}),a&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{children:[e.jsx("h4",{style:{margin:"0.25rem 0",color:"#0f62fe"},children:"Question"}),e.jsx("div",{style:{whiteSpace:"pre-wrap"},children:a.question||"N/A"})]}),e.jsxs("section",{children:[e.jsx("h4",{style:{margin:"0.25rem 0",color:"#0f62fe"},children:"Ground truth SQL"}),(a.ground_truth_sql||[]).map((r,t)=>e.jsxs("div",{style:{marginBottom:"0.55rem"},children:[e.jsx("pre",{style:{margin:"0.3rem 0",padding:"0.6rem",background:"#f4f4f4",borderRadius:"4px",whiteSpace:"pre-wrap",border:"1px solid rgba(15,98,254,0.2)",color:"#161616"},children:e.jsx("code",{dangerouslySetInnerHTML:{__html:me(r)}})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(u,{kind:"ghost",size:"sm",onClick:()=>ie(r,`Ground truth SQL ${t+1}`),children:"Modify Query"})})]},`gt-sql-${t}`))]}),e.jsxs("section",{children:[e.jsx("h4",{style:{margin:"0.25rem 0",color:"#0f62fe"},children:"Predicted SQL"}),e.jsx("pre",{style:{margin:"0.3rem 0",padding:"0.6rem",background:"#f4f4f4",borderRadius:"4px",whiteSpace:"pre-wrap",border:"1px solid rgba(15,98,254,0.2)",color:"#161616"},children:e.jsx("code",{dangerouslySetInnerHTML:{__html:me(a.predicted_sql||"N/A")}})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(u,{kind:"ghost",size:"sm",disabled:!a.predicted_sql,onClick:()=>ie(a.predicted_sql||"","Predicted SQL"),children:"Modify Query"})})]}),e.jsxs("section",{children:[e.jsx("h4",{style:{margin:"0.25rem 0",color:"#0f62fe"},children:"Evaluation metrics"}),e.jsx("pre",{style:{margin:"0.3rem 0",padding:"0.6rem",background:"#f4f4f4",borderRadius:"4px",whiteSpace:"pre-wrap",color:"#161616"},children:$(a.evaluation_metrics)})]}),(a.ground_truth_results||[]).map((r,t)=>{var i;return e.jsx(V,{title:`Ground truth result ${t+1}`,rawData:r,totalRows:(i=a.ground_truth_result_row_counts)==null?void 0:i[t]},`gt-result-table-${t}`)}),e.jsx(V,{title:"Predicted result",rawData:a.predicted_result,totalRows:a.predicted_result_row_count}),e.jsxs("section",{children:[e.jsx("h4",{style:{margin:"0.25rem 0",color:"#0f62fe"},children:"Prompt"}),e.jsx("pre",{style:{margin:"0.3rem 0",padding:"0.6rem",background:"#f4f4f4",borderRadius:"4px",whiteSpace:"pre-wrap",color:"#161616"},children:a.prompt||"N/A"})]}),e.jsxs("section",{children:[e.jsx("h4",{style:{margin:"0.25rem 0",color:"#0f62fe"},children:"LLM judge"}),e.jsxs("div",{style:{marginBottom:"0.25rem"},children:["Score: ",a.llm_judge_score??"N/A"]}),e.jsx("pre",{style:{margin:"0.3rem 0",padding:"0.6rem",background:"#f4f4f4",borderRadius:"4px",whiteSpace:"pre-wrap",color:"#161616"},children:a.llm_judge_explanation||"N/A"})]}),(a.sql_execution_error||a.inference_error)&&e.jsxs("section",{children:[e.jsx("h4",{style:{margin:"0.25rem 0",color:"#0f62fe"},children:"Errors"}),e.jsx("pre",{style:{margin:"0.3rem 0",padding:"0.6rem",background:"#f4f4f4",borderRadius:"4px",whiteSpace:"pre-wrap",color:"#161616"},children:$({sql_execution_error:a.sql_execution_error,inference_error:a.inference_error})})]}),e.jsx("div",{style:{marginTop:"0.25rem",display:"flex",justifyContent:"flex-end"},children:e.jsx(u,{kind:"secondary",size:"sm",onClick:()=>void Ee(),children:"View Raw JSON"})})]})]})]})]})]})};export{Qe as PipelineDetailView};