agentinputlab 0.1.0a1__py3-none-any.whl
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.
- agentinputlab/__init__.py +28 -0
- agentinputlab/algorithms/__init__.py +6 -0
- agentinputlab/algorithms/acquire/__init__.py +145 -0
- agentinputlab/algorithms/acquire/adaptive_rag/__init__.py +43 -0
- agentinputlab/algorithms/acquire/adaptive_rag/replay.py +367 -0
- agentinputlab/algorithms/acquire/adaptive_rag/runtime.py +1202 -0
- agentinputlab/algorithms/acquire/adaptive_rag_common_support.py +542 -0
- agentinputlab/algorithms/acquire/hyde.py +296 -0
- agentinputlab/algorithms/acquire/hyde_controlled.py +200 -0
- agentinputlab/algorithms/acquire/hyde_external.py +148 -0
- agentinputlab/algorithms/acquire/ircot.py +28 -0
- agentinputlab/algorithms/acquire/ircot_common_support.py +478 -0
- agentinputlab/algorithms/acquire/ircot_native.py +355 -0
- agentinputlab/algorithms/acquire/ircot_replay.py +327 -0
- agentinputlab/algorithms/acquire/qrag/__init__.py +79 -0
- agentinputlab/algorithms/acquire/qrag/bridge.py +828 -0
- agentinputlab/algorithms/acquire/qrag/common_support.py +891 -0
- agentinputlab/algorithms/acquire/qrag/native_axis.py +71 -0
- agentinputlab/algorithms/acquire/qrag/reader_adapter.py +139 -0
- agentinputlab/algorithms/acquire/r2ag/__init__.py +57 -0
- agentinputlab/algorithms/acquire/r2ag/bridge.py +1312 -0
- agentinputlab/algorithms/acquire/r2ag/common_support.py +1029 -0
- agentinputlab/algorithms/acquire/r2ag/socket_runtime.py +255 -0
- agentinputlab/algorithms/clarify/__init__.py +61 -0
- agentinputlab/algorithms/clarify/_structured.py +64 -0
- agentinputlab/algorithms/clarify/active_task_disambiguation.py +371 -0
- agentinputlab/algorithms/clarify/ask_or_assume/__init__.py +17 -0
- agentinputlab/algorithms/clarify/ask_or_assume/monitor.py +410 -0
- agentinputlab/algorithms/clarify/future_turns.py +379 -0
- agentinputlab/algorithms/clarify/udcs.py +255 -0
- agentinputlab/algorithms/clarify/udcs_deterministic.py +196 -0
- agentinputlab/algorithms/curate/__init__.py +65 -0
- agentinputlab/algorithms/curate/acon/__init__.py +27 -0
- agentinputlab/algorithms/curate/acon/common.py +284 -0
- agentinputlab/algorithms/curate/acon/common_support.py +136 -0
- agentinputlab/algorithms/curate/acon/history_bridge.py +309 -0
- agentinputlab/algorithms/curate/acon/observation_bridge.py +290 -0
- agentinputlab/algorithms/curate/llmlingua/__init__.py +30 -0
- agentinputlab/algorithms/curate/llmlingua/adapters.py +537 -0
- agentinputlab/algorithms/curate/llmlingua/budget.py +48 -0
- agentinputlab/algorithms/curate/llmlingua/controlled.py +175 -0
- agentinputlab/algorithms/curate/llmlingua/multilingual.py +105 -0
- agentinputlab/algorithms/curate/llmlingua/span_map.py +167 -0
- agentinputlab/algorithms/curate/recomp/__init__.py +47 -0
- agentinputlab/algorithms/curate/recomp/external.py +1129 -0
- agentinputlab/algorithms/curate/recomp/selective.py +304 -0
- agentinputlab/algorithms/decompose/__init__.py +107 -0
- agentinputlab/algorithms/decompose/decomp/__init__.py +53 -0
- agentinputlab/algorithms/decompose/decomp/common_support.py +478 -0
- agentinputlab/algorithms/decompose/decomp/planner_component.py +199 -0
- agentinputlab/algorithms/decompose/decomp/worker_bridge.py +416 -0
- agentinputlab/algorithms/decompose/llm_compiler/__init__.py +35 -0
- agentinputlab/algorithms/decompose/llm_compiler/bridge.py +520 -0
- agentinputlab/algorithms/decompose/llm_compiler/common_support.py +504 -0
- agentinputlab/algorithms/decompose/plan_and_budget/__init__.py +43 -0
- agentinputlab/algorithms/decompose/plan_and_budget/cached_soft_budget.py +362 -0
- agentinputlab/algorithms/decompose/plan_and_budget/decomposer_component.py +107 -0
- agentinputlab/algorithms/decompose/plan_and_budget/full.py +205 -0
- agentinputlab/algorithms/decompose/plan_and_budget/hard_cap.py +246 -0
- agentinputlab/algorithms/decompose/plan_and_budget/regenerated_soft_budget.py +448 -0
- agentinputlab/algorithms/decompose/plan_and_solve/__init__.py +33 -0
- agentinputlab/algorithms/decompose/plan_and_solve/plan_component.py +192 -0
- agentinputlab/algorithms/decompose/plan_and_solve/ps_prompt.py +127 -0
- agentinputlab/algorithms/decompose/self_ask/__init__.py +27 -0
- agentinputlab/algorithms/decompose/self_ask/loop.py +362 -0
- agentinputlab/algorithms/decompose/self_ask/planner_component.py +117 -0
- agentinputlab/algorithms/reformulate/__init__.py +85 -0
- agentinputlab/algorithms/reformulate/infocqr/__init__.py +40 -0
- agentinputlab/algorithms/reformulate/infocqr/cache_replay.py +362 -0
- agentinputlab/algorithms/reformulate/infocqr/external.py +675 -0
- agentinputlab/algorithms/reformulate/infocqr/student.py +189 -0
- agentinputlab/algorithms/reformulate/query2doc/__init__.py +42 -0
- agentinputlab/algorithms/reformulate/query2doc/controlled_live.py +190 -0
- agentinputlab/algorithms/reformulate/query2doc/models.py +95 -0
- agentinputlab/algorithms/reformulate/query2doc/official_cached.py +335 -0
- agentinputlab/algorithms/reformulate/query2doc/querygym_bridge.py +223 -0
- agentinputlab/algorithms/reformulate/query2doc/querygym_runtime.py +326 -0
- agentinputlab/algorithms/reformulate/reformer/__init__.py +23 -0
- agentinputlab/algorithms/reformulate/reformer/external.py +417 -0
- agentinputlab/algorithms/reformulate/rrr.py +696 -0
- agentinputlab/annotation/__init__.py +5 -0
- agentinputlab/annotation/independent.py +428 -0
- agentinputlab/annotation/server.py +233 -0
- agentinputlab/annotation/static/app.js +121 -0
- agentinputlab/annotation/static/index.html +60 -0
- agentinputlab/annotation/static/review.css +2 -0
- agentinputlab/annotation/static/review.html +10 -0
- agentinputlab/annotation/static/review.js +11 -0
- agentinputlab/annotation/static/styles.css +55 -0
- agentinputlab/annotation/store.py +444 -0
- agentinputlab/api.py +368 -0
- agentinputlab/artifacts/__init__.py +15 -0
- agentinputlab/artifacts/json_file.py +104 -0
- agentinputlab/artifacts/manifest.py +98 -0
- agentinputlab/artifacts/store.py +157 -0
- agentinputlab/backends/__init__.py +98 -0
- agentinputlab/backends/embedding/__init__.py +25 -0
- agentinputlab/backends/embedding/base.py +145 -0
- agentinputlab/backends/embedding/callable.py +75 -0
- agentinputlab/backends/embedding/replay.py +129 -0
- agentinputlab/backends/llm/__init__.py +31 -0
- agentinputlab/backends/llm/base.py +149 -0
- agentinputlab/backends/llm/callable.py +108 -0
- agentinputlab/backends/llm/decomp_completion.py +88 -0
- agentinputlab/backends/llm/final_content_stop.py +72 -0
- agentinputlab/backends/llm/gpt_oss_final_channel.py +84 -0
- agentinputlab/backends/llm/openai_compatible.py +332 -0
- agentinputlab/backends/llm/transformers.py +171 -0
- agentinputlab/backends/retrieval/__init__.py +35 -0
- agentinputlab/backends/retrieval/base.py +50 -0
- agentinputlab/backends/retrieval/dense.py +777 -0
- agentinputlab/backends/retrieval/memory.py +119 -0
- agentinputlab/backends/retrieval/sqlite_fts.py +155 -0
- agentinputlab/backends/user/__init__.py +15 -0
- agentinputlab/backends/user/base.py +66 -0
- agentinputlab/backends/user/callable.py +54 -0
- agentinputlab/backends/user/replay.py +89 -0
- agentinputlab/backends/vector.py +38 -0
- agentinputlab/benchmarks/__init__.py +246 -0
- agentinputlab/benchmarks/acquisition.py +106 -0
- agentinputlab/benchmarks/ale.py +540 -0
- agentinputlab/benchmarks/appworld_ul.py +669 -0
- agentinputlab/benchmarks/assets.py +226 -0
- agentinputlab/benchmarks/base.py +68 -0
- agentinputlab/benchmarks/beir_archive.py +235 -0
- agentinputlab/benchmarks/beir_sample.py +269 -0
- agentinputlab/benchmarks/bfcl_native.py +245 -0
- agentinputlab/benchmarks/bfcl_v3.py +607 -0
- agentinputlab/benchmarks/cache.py +218 -0
- agentinputlab/benchmarks/clariq.py +203 -0
- agentinputlab/benchmarks/data/registry.json +321 -0
- agentinputlab/benchmarks/data/smoke_assets.json +511 -0
- agentinputlab/benchmarks/data/statebench_v0_8_1_task_ids.json +475 -0
- agentinputlab/benchmarks/data/toolsandbox_165848b_scenario_names.json +1 -0
- agentinputlab/benchmarks/execution.py +1111 -0
- agentinputlab/benchmarks/interactive.py +257 -0
- agentinputlab/benchmarks/ir_query.py +204 -0
- agentinputlab/benchmarks/longbench.py +203 -0
- agentinputlab/benchmarks/paired_replay.py +479 -0
- agentinputlab/benchmarks/preprocess.py +2313 -0
- agentinputlab/benchmarks/production.py +236 -0
- agentinputlab/benchmarks/qa.py +963 -0
- agentinputlab/benchmarks/registry.py +110 -0
- agentinputlab/benchmarks/retrieval.py +459 -0
- agentinputlab/benchmarks/runtime.py +509 -0
- agentinputlab/benchmarks/statebench.py +938 -0
- agentinputlab/benchmarks/tau3.py +725 -0
- agentinputlab/benchmarks/toolsandbox.py +626 -0
- agentinputlab/benchmarks/trec_dl_sample.py +263 -0
- agentinputlab/campaign.py +654 -0
- agentinputlab/campaign_runner.py +953 -0
- agentinputlab/cli/__init__.py +6 -0
- agentinputlab/cli/main.py +933 -0
- agentinputlab/connectors/__init__.py +46 -0
- agentinputlab/connectors/knowledge/__init__.py +4 -0
- agentinputlab/connectors/tools/__init__.py +30 -0
- agentinputlab/connectors/tools/base.py +57 -0
- agentinputlab/connectors/tools/mcp.py +222 -0
- agentinputlab/connectors/tools/memory.py +41 -0
- agentinputlab/connectors/tools/openapi.py +695 -0
- agentinputlab/connectors/tools/schema.py +102 -0
- agentinputlab/contracts/__init__.py +91 -0
- agentinputlab/contracts/availability.py +24 -0
- agentinputlab/contracts/dependency.py +58 -0
- agentinputlab/contracts/enums.py +82 -0
- agentinputlab/contracts/errors.py +63 -0
- agentinputlab/contracts/evidence.py +43 -0
- agentinputlab/contracts/intent.py +110 -0
- agentinputlab/contracts/lifecycle.py +164 -0
- agentinputlab/contracts/patch.py +167 -0
- agentinputlab/contracts/serialization.py +93 -0
- agentinputlab/contracts/state.py +127 -0
- agentinputlab/contracts/trace.py +59 -0
- agentinputlab/contracts/worker.py +42 -0
- agentinputlab/core/__init__.py +7 -0
- agentinputlab/data/__init__.py +32 -0
- agentinputlab/data/checksums.py +9 -0
- agentinputlab/data/downloader.py +235 -0
- agentinputlab/data/http.py +171 -0
- agentinputlab/data/index.py +21 -0
- agentinputlab/data/overlap.py +28 -0
- agentinputlab/data/preprocess.py +32 -0
- agentinputlab/data/storage.py +57 -0
- agentinputlab/data/trec_sample.py +427 -0
- agentinputlab/evaluation/__init__.py +5 -0
- agentinputlab/evaluation/outcomes.py +32 -0
- agentinputlab/experiments/__init__.py +278 -0
- agentinputlab/experiments/analysis.py +981 -0
- agentinputlab/experiments/artifacts.py +687 -0
- agentinputlab/experiments/automatic_measurement.py +678 -0
- agentinputlab/experiments/auxiliary_matrix.py +203 -0
- agentinputlab/experiments/bindings.py +430 -0
- agentinputlab/experiments/blueprints.py +147 -0
- agentinputlab/experiments/builders/__init__.py +45 -0
- agentinputlab/experiments/builders/executable_external_payload.py +423 -0
- agentinputlab/experiments/builders/external_process_arena.py +1018 -0
- agentinputlab/experiments/builders/registry_intervention.py +463 -0
- agentinputlab/experiments/cli.py +158 -0
- agentinputlab/experiments/controls.py +340 -0
- agentinputlab/experiments/driver_guard.py +205 -0
- agentinputlab/experiments/drivers/__init__.py +89 -0
- agentinputlab/experiments/drivers/external_arena.py +2908 -0
- agentinputlab/experiments/drivers/method_process.py +662 -0
- agentinputlab/experiments/drivers/parity_process.py +1484 -0
- agentinputlab/experiments/drivers/static_production.py +1574 -0
- agentinputlab/experiments/executor.py +448 -0
- agentinputlab/experiments/loader.py +605 -0
- agentinputlab/experiments/measurement.py +675 -0
- agentinputlab/experiments/paper_analysis.py +1818 -0
- agentinputlab/experiments/parity_identity.py +605 -0
- agentinputlab/experiments/plan.py +277 -0
- agentinputlab/experiments/production_builders.py +3739 -0
- agentinputlab/experiments/readiness.py +432 -0
- agentinputlab/experiments/schema.py +514 -0
- agentinputlab/experiments/secrets.py +177 -0
- agentinputlab/experiments/stateful_analysis.py +1738 -0
- agentinputlab/experiments/transfer_analysis.py +1316 -0
- agentinputlab/experiments/unseen_analysis.py +1025 -0
- agentinputlab/integrations/__init__.py +1 -0
- agentinputlab/integrations/action_space/__init__.py +1 -0
- agentinputlab/integrations/external_workers/__init__.py +76 -0
- agentinputlab/integrations/external_workers/ace.py +431 -0
- agentinputlab/integrations/external_workers/base.py +181 -0
- agentinputlab/integrations/external_workers/decomp_live.py +249 -0
- agentinputlab/integrations/external_workers/decomp_planner.py +30 -0
- agentinputlab/integrations/external_workers/infocqr_student.py +280 -0
- agentinputlab/integrations/external_workers/ircot.py +576 -0
- agentinputlab/integrations/external_workers/llmcompiler_live.py +360 -0
- agentinputlab/integrations/external_workers/longllmlingua.py +162 -0
- agentinputlab/integrations/external_workers/method.py +314 -0
- agentinputlab/integrations/external_workers/process.py +678 -0
- agentinputlab/integrations/external_workers/supervisor.py +1071 -0
- agentinputlab/integrations/full_architecture/__init__.py +1 -0
- agentinputlab/integrations/full_architecture/hyde.py +212 -0
- agentinputlab/integrations/full_architecture/plan_and_budget.py +188 -0
- agentinputlab/integrations/live_history.py +222 -0
- agentinputlab/integrations/prompt_optimization/__init__.py +1 -0
- agentinputlab/integrations/training/__init__.py +1 -0
- agentinputlab/metrics/__init__.py +50 -0
- agentinputlab/metrics/catalog.py +313 -0
- agentinputlab/metrics/harm.py +95 -0
- agentinputlab/metrics/paired.py +40 -0
- agentinputlab/metrics/qa.py +76 -0
- agentinputlab/metrics/text.py +33 -0
- agentinputlab/metrics/third_party.py +161 -0
- agentinputlab/models/__init__.py +4 -0
- agentinputlab/observability/__init__.py +56 -0
- agentinputlab/observability/budget.py +316 -0
- agentinputlab/observability/instrumentation.py +754 -0
- agentinputlab/observability/models.py +403 -0
- agentinputlab/observability/monitor.py +380 -0
- agentinputlab/optimizers/__init__.py +1 -0
- agentinputlab/optimizers/clarify/__init__.py +12 -0
- agentinputlab/optimizers/context/__init__.py +22 -0
- agentinputlab/optimizers/decompose/__init__.py +64 -0
- agentinputlab/optimizers/evidence/__init__.py +22 -0
- agentinputlab/optimizers/rewrite/__init__.py +30 -0
- agentinputlab/parity/__init__.py +5 -0
- agentinputlab/parity/base.py +206 -0
- agentinputlab/production_campaign.py +763 -0
- agentinputlab/py.typed +1 -0
- agentinputlab/recipes/__init__.py +333 -0
- agentinputlab/recipes/ace.py +418 -0
- agentinputlab/recipes/ace_bfcl.py +273 -0
- agentinputlab/recipes/ace_common_support.py +169 -0
- agentinputlab/recipes/ace_native_plan.py +322 -0
- agentinputlab/recipes/ace_online.py +711 -0
- agentinputlab/recipes/ace_retrieval.py +330 -0
- agentinputlab/recipes/ace_statebench.py +382 -0
- agentinputlab/recipes/ace_tau.py +463 -0
- agentinputlab/recipes/ace_toolsandbox.py +432 -0
- agentinputlab/recipes/acon_guideline.py +22 -0
- agentinputlab/recipes/adaptive_rag.py +822 -0
- agentinputlab/recipes/llmlingua2_inference.py +146 -0
- agentinputlab/recipes/llmlingua2_training.py +796 -0
- agentinputlab/recipes/mce.py +1486 -0
- agentinputlab/recipes/mce_final.py +335 -0
- agentinputlab/recipes/mce_text_fit.py +499 -0
- agentinputlab/recipes/mce_text_only.py +298 -0
- agentinputlab/recipes/qrag.py +729 -0
- agentinputlab/recipes/qrag_inference.py +364 -0
- agentinputlab/recipes/r2ag_features.py +236 -0
- agentinputlab/recipes/r2ag_inference.py +503 -0
- agentinputlab/recipes/r2ag_training.py +948 -0
- agentinputlab/recipes/recomp_abstractive.py +592 -0
- agentinputlab/recipes/recomp_extractive.py +525 -0
- agentinputlab/recipes/reformer.py +17 -0
- agentinputlab/recipes/rqrag.py +1516 -0
- agentinputlab/recipes/rqrag_common_support.py +193 -0
- agentinputlab/recipes/rqrag_completion.py +147 -0
- agentinputlab/recipes/skillopt.py +462 -0
- agentinputlab/recipes/skillopt_common_support.py +154 -0
- agentinputlab/recipes/skillopt_environment.py +165 -0
- agentinputlab/recipes/skillopt_environment_cli.py +5 -0
- agentinputlab/recipes/skillopt_retrieval.py +188 -0
- agentinputlab/recipes/smartsearch.py +897 -0
- agentinputlab/recipes/smartsearch_curriculum.py +283 -0
- agentinputlab/recipes/smartsearch_grpo_contracts.py +58 -0
- agentinputlab/recipes/smartsearch_grpo_data.py +314 -0
- agentinputlab/recipes/smartsearch_grpo_meter.py +324 -0
- agentinputlab/recipes/smartsearch_grpo_prefix.py +144 -0
- agentinputlab/recipes/smartsearch_grpo_rollout.py +119 -0
- agentinputlab/recipes/smartsearch_grpo_tools.py +364 -0
- agentinputlab/recipes/smartsearch_grpo_training.py +305 -0
- agentinputlab/recipes/smartsearch_grpo_transport.py +248 -0
- agentinputlab/recipes/smartsearch_grpo_worker.py +364 -0
- agentinputlab/recipes/smartsearch_inference.py +524 -0
- agentinputlab/recipes/smartsearch_native_data.py +172 -0
- agentinputlab/recipes/smartsearch_policy.py +616 -0
- agentinputlab/recipes/smartsearch_policy_worker.py +9 -0
- agentinputlab/recipes/smartsearch_sampling.py +232 -0
- agentinputlab/recipes/smartsearch_teacher.py +203 -0
- agentinputlab/recipes/smartsearch_training.py +265 -0
- agentinputlab/registry/__init__.py +46 -0
- agentinputlab/registry/beta.py +727 -0
- agentinputlab/registry/data/algorithms.json +1959 -0
- agentinputlab/registry/data/auxiliary_method_profiles.json +34 -0
- agentinputlab/registry/loader.py +100 -0
- agentinputlab/registry/result_manifest.py +184 -0
- agentinputlab/registry/runtime.py +195 -0
- agentinputlab/registry/schema.py +449 -0
- agentinputlab/runner/__init__.py +30 -0
- agentinputlab/runner/balance.py +248 -0
- agentinputlab/runner/cache.py +135 -0
- agentinputlab/runner/composite.py +130 -0
- agentinputlab/runner/engine.py +285 -0
- agentinputlab/runner/runtime_guard.py +268 -0
- agentinputlab/runner/worker.py +80 -0
- agentinputlab/runtime_bootstrap.py +288 -0
- agentinputlab/selectors/__init__.py +196 -0
- agentinputlab/selectors/advanced.py +1514 -0
- agentinputlab/selectors/artifacts.py +1087 -0
- agentinputlab/selectors/base.py +112 -0
- agentinputlab/selectors/campaigns.py +1893 -0
- agentinputlab/selectors/catalog.py +86 -0
- agentinputlab/selectors/discovery.py +1860 -0
- agentinputlab/selectors/evaluation.py +1348 -0
- agentinputlab/selectors/features.py +383 -0
- agentinputlab/selectors/learned.py +502 -0
- agentinputlab/selectors/no_op.py +28 -0
- agentinputlab/selectors/outcome_table.py +475 -0
- agentinputlab/selectors/producer.py +853 -0
- agentinputlab/selectors/rules.py +109 -0
- agentinputlab/selectors/runtime.py +420 -0
- agentinputlab/studies/__init__.py +16 -0
- agentinputlab/studies/design.py +165 -0
- agentinputlab/studies/paired.py +322 -0
- agentinputlab/studio/__init__.py +6 -0
- agentinputlab/studio/campaigns.py +819 -0
- agentinputlab/studio/engine.py +1408 -0
- agentinputlab/studio/model_backends.py +425 -0
- agentinputlab/studio/prepared.py +410 -0
- agentinputlab/studio/server.py +613 -0
- agentinputlab/studio/static/app.js +397 -0
- agentinputlab/studio/static/campaigns.html +175 -0
- agentinputlab/studio/static/campaigns.js +426 -0
- agentinputlab/studio/static/index.html +192 -0
- agentinputlab/studio/static/result.html +103 -0
- agentinputlab/studio/static/result.js +273 -0
- agentinputlab/studio/static/styles.css +467 -0
- agentinputlab-0.1.0a1.data/data/share/agentinputlab/CITATION.cff +22 -0
- agentinputlab-0.1.0a1.dist-info/METADATA +392 -0
- agentinputlab-0.1.0a1.dist-info/RECORD +469 -0
- agentinputlab-0.1.0a1.dist-info/WHEEL +5 -0
- agentinputlab-0.1.0a1.dist-info/entry_points.txt +6 -0
- agentinputlab-0.1.0a1.dist-info/licenses/LICENSE +21 -0
- agentinputlab-0.1.0a1.dist-info/licenses/NOTICE +31 -0
- agentinputlab-0.1.0a1.dist-info/licenses/THIRD_PARTY_NOTICES.md +94 -0
- agentinputlab-0.1.0a1.dist-info/top_level.txt +2 -0
- workers/README.md +94 -0
- workers/ace/README.md +261 -0
- workers/ace/__init__.py +1 -0
- workers/ace/compatibility_manifest.json +39 -0
- workers/ace/driver.py +1682 -0
- workers/acon/README.md +215 -0
- workers/acon/__init__.py +5 -0
- workers/acon/compatibility_manifest.json +93 -0
- workers/acon/driver.py +1859 -0
- workers/acon/fitted.py +395 -0
- workers/acon/guideline.py +470 -0
- workers/acon/guideline_source_manifest.json +20 -0
- workers/adaptive_rag/README.md +96 -0
- workers/adaptive_rag/__init__.py +15 -0
- workers/adaptive_rag/compatibility_manifest.json +61 -0
- workers/adaptive_rag/driver.py +1470 -0
- workers/adaptive_rag/fixture_runtime.py +163 -0
- workers/adaptive_rag/runtime.py +252 -0
- workers/ask_or_assume/README.md +124 -0
- workers/ask_or_assume/__init__.py +1 -0
- workers/ask_or_assume/compatibility_manifest.json +36 -0
- workers/ask_or_assume/driver.py +1227 -0
- workers/decomp/README.md +133 -0
- workers/decomp/UPSTREAM_LICENSE.Apache-2.0.txt +201 -0
- workers/decomp/__init__.py +5 -0
- workers/decomp/compatibility_manifest.json +205 -0
- workers/decomp/driver.py +1015 -0
- workers/decomp/live.py +137 -0
- workers/decomp/runtime.py +231 -0
- workers/infocqr/README.md +106 -0
- workers/infocqr/__init__.py +1 -0
- workers/infocqr/compatibility_manifest.json +84 -0
- workers/infocqr/driver.py +1766 -0
- workers/ircot/README.md +167 -0
- workers/ircot/__init__.py +7 -0
- workers/ircot/compatibility_manifest.json +121 -0
- workers/ircot/controlled.py +457 -0
- workers/ircot/driver.py +1373 -0
- workers/ircot/fixture_bindings.json +39 -0
- workers/ircot/fixture_config.json +48 -0
- workers/ircot/fixture_prompt.txt +2 -0
- workers/ircot/native_qa.py +398 -0
- workers/ircot/qa_compatibility_manifest.json +57 -0
- workers/ircot/runtime.py +97 -0
- workers/llmcompiler/README.md +160 -0
- workers/llmcompiler/__init__.py +1 -0
- workers/llmcompiler/compatibility_manifest.json +45 -0
- workers/llmcompiler/driver.py +1514 -0
- workers/llmcompiler/export_prompts.py +74 -0
- workers/llmcompiler/live.py +174 -0
- workers/llmcompiler/patch_manifest.json +147 -0
- workers/mce/README.md +198 -0
- workers/mce/__init__.py +29 -0
- workers/mce/compatibility_manifest.json +115 -0
- workers/mce/driver.py +2585 -0
- workers/mce/final_eval.py +173 -0
- workers/official_arenas/README.md +25 -0
- workers/official_arenas/__init__.py +1 -0
- workers/official_arenas/capture_records.py +110 -0
- workers/official_arenas/driver.py +619 -0
- workers/official_arenas/protocol.py +334 -0
- workers/official_arenas/providers/__init__.py +1 -0
- workers/official_arenas/providers/_live_history.py +228 -0
- workers/official_arenas/providers/_message_compat.py +77 -0
- workers/official_arenas/providers/appworld_ul.py +196 -0
- workers/official_arenas/providers/fixture.py +112 -0
- workers/official_arenas/providers/statebench.py +960 -0
- workers/official_arenas/providers/tau3.py +1672 -0
- workers/official_arenas/providers/tau_retail.py +586 -0
- workers/official_arenas/providers/toolsandbox.py +1321 -0
- workers/official_arenas/providers/tooltalk.py +699 -0
- workers/official_arenas/retail_capture.py +188 -0
- workers/official_arenas/retail_driver.py +275 -0
- workers/qrag/README.md +172 -0
- workers/qrag/__init__.py +1 -0
- workers/qrag/compatibility_manifest.json +64 -0
- workers/qrag/driver.py +673 -0
- workers/r2ag/README.md +154 -0
- workers/r2ag/__init__.py +5 -0
- workers/r2ag/compatibility_manifest.json +55 -0
- workers/r2ag/driver.py +1287 -0
- workers/r2ag/feature_schema.json +8 -0
- workers/r2ag/runtime.py +589 -0
- workers/recomp/README.md +120 -0
- workers/recomp/__init__.py +1 -0
- workers/recomp/compatibility_manifest.json +43 -0
- workers/recomp/driver.py +1653 -0
- workers/reformer/README.md +125 -0
- workers/reformer/__init__.py +1 -0
- workers/reformer/compatibility_manifest.json +68 -0
- workers/reformer/driver.py +1459 -0
- workers/reformer/induction.py +457 -0
- workers/rrr/README.md +126 -0
- workers/rrr/__init__.py +1 -0
- workers/rrr/compatibility_manifest.json +57 -0
- workers/rrr/driver.py +1133 -0
- workers/smartsearch/README.md +331 -0
- workers/smartsearch/__init__.py +1 -0
- workers/smartsearch/compatibility_manifest.json +41 -0
- workers/smartsearch/driver.py +1643 -0
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
"""Gold-isolated BFCL v3 simple-Python adapter and external scorer bridge.
|
|
2
|
+
|
|
3
|
+
The official v1.3 source archive supplies the prompt, possible answers, model
|
|
4
|
+
decoders, and AST checker. AgentInputLab separates prompts and evaluator gold.
|
|
5
|
+
Callers can bind an explicit non-attested callback or a source-verified Python
|
|
6
|
+
function-calling bridge. Case-level source verification does not assert the
|
|
7
|
+
full official CLI/aggregate leaderboard workflow.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import json
|
|
13
|
+
import math
|
|
14
|
+
import re
|
|
15
|
+
from collections.abc import Callable, Mapping
|
|
16
|
+
from dataclasses import dataclass, field
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
from types import MappingProxyType
|
|
19
|
+
from typing import Any, Protocol, runtime_checkable
|
|
20
|
+
|
|
21
|
+
from agentinputlab.artifacts import sha256_file
|
|
22
|
+
from agentinputlab.contracts.errors import ArtifactError, ValidationError
|
|
23
|
+
from agentinputlab.contracts.serialization import canonical_json, freeze_mapping
|
|
24
|
+
|
|
25
|
+
from .assets import BenchmarkSmokeAssetRegistry
|
|
26
|
+
from .base import BenchmarkExample
|
|
27
|
+
from .preprocess import PreparedBenchmark, load_prepared_benchmark
|
|
28
|
+
|
|
29
|
+
BFCL_V3_OFFICIAL_SOURCE_REVISION = "ea13468e4423454d0c213704fb87cf7cb3990433"
|
|
30
|
+
BFCL_V3_SOURCE_ARCHIVE_SHA256 = "57854157e82aed5723a1458d2a4ac426e3256959ded4a20ddc4d627c22edb7fe"
|
|
31
|
+
BFCL_V3_SCORER_ID = (
|
|
32
|
+
"bfcl_eval.eval_checker.eval_runner:ast_file_runner+"
|
|
33
|
+
"bfcl_eval.eval_checker.ast_eval.ast_checker:ast_checker"
|
|
34
|
+
)
|
|
35
|
+
BFCL_V3_SCORER_REVISION = "31f1420ae78709920d2fc49ceb93ea3dc451379cf5f320ac0b02b9845d0cbb36"
|
|
36
|
+
BFCL_V3_AST_CHECKER_REVISION = "58a8a1d8a42ec4f7e0f340a8bf11ab4035c54d38d933ae2621f22bbc7c8d1c9b"
|
|
37
|
+
|
|
38
|
+
_BENCHMARK_ID = "bfcl.v3.simple_python"
|
|
39
|
+
_ASSET_ID = "bfcl.v3.simple_python.v1_3"
|
|
40
|
+
_PROCESSOR = "bfcl_v3_simple_tar_v1"
|
|
41
|
+
_SPLIT = "test"
|
|
42
|
+
_CALLER_ASSERTED = "caller_asserted"
|
|
43
|
+
_EXTERNAL_BRIDGE = "external_bridge"
|
|
44
|
+
_SHA256 = re.compile(r"^[0-9a-f]{64}$")
|
|
45
|
+
_LOADER_CONSTRUCTION_TOKEN = object()
|
|
46
|
+
_EXPECTED_IDS = frozenset(f"simple_{index}" for index in range(400))
|
|
47
|
+
_EXPECTED_COUNTS = {
|
|
48
|
+
"audit": 1,
|
|
49
|
+
"functions": 400,
|
|
50
|
+
"gold": 400,
|
|
51
|
+
"ground_truth_candidates": 400,
|
|
52
|
+
"inputs": 400,
|
|
53
|
+
"source_files": 8,
|
|
54
|
+
}
|
|
55
|
+
_INPUT_FIELDS = {
|
|
56
|
+
"id",
|
|
57
|
+
"instruction",
|
|
58
|
+
"query",
|
|
59
|
+
"visible_metadata",
|
|
60
|
+
"visible_tool_names",
|
|
61
|
+
}
|
|
62
|
+
_VISIBLE_METADATA_FIELDS = {
|
|
63
|
+
"benchmark_cell",
|
|
64
|
+
"bfcl_category",
|
|
65
|
+
"function",
|
|
66
|
+
"source_split",
|
|
67
|
+
}
|
|
68
|
+
_FUNCTION_FIELDS = {"description", "name", "parameters"}
|
|
69
|
+
_GOLD_FIELDS = {"ground_truth", "id"}
|
|
70
|
+
BFCL_V3_SELECTED_SOURCE_SHA256: Mapping[str, str] = MappingProxyType(
|
|
71
|
+
{
|
|
72
|
+
"LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4",
|
|
73
|
+
(
|
|
74
|
+
"berkeley-function-call-leaderboard/bfcl_eval/constants/category_mapping.py"
|
|
75
|
+
): "c08dfe14283990bc4f67333183d8c14a2506da6d99ac00c6ef5f018dd44757fc",
|
|
76
|
+
(
|
|
77
|
+
"berkeley-function-call-leaderboard/bfcl_eval/data/BFCL_v3_simple.json"
|
|
78
|
+
): "fbc37b2ad252bf9af985582e0e07b456173fe627d957491472ea9cef5fb83158",
|
|
79
|
+
(
|
|
80
|
+
"berkeley-function-call-leaderboard/bfcl_eval/data/possible_answer/BFCL_v3_simple.json"
|
|
81
|
+
): "2911a2bc00df82c4f999ffa64fedb0164cb88e96212ffa5972087eb91fd496ee",
|
|
82
|
+
(
|
|
83
|
+
"berkeley-function-call-leaderboard/bfcl_eval/eval_checker/ast_eval/ast_checker.py"
|
|
84
|
+
): BFCL_V3_AST_CHECKER_REVISION,
|
|
85
|
+
(
|
|
86
|
+
"berkeley-function-call-leaderboard/bfcl_eval/eval_checker/eval_runner.py"
|
|
87
|
+
): BFCL_V3_SCORER_REVISION,
|
|
88
|
+
(
|
|
89
|
+
"berkeley-function-call-leaderboard/bfcl_eval/model_handler/base_handler.py"
|
|
90
|
+
): "4a2f4e677d1f6930f396dbc92c50138f56268f970de7e4f815fb801607cafad1",
|
|
91
|
+
(
|
|
92
|
+
"berkeley-function-call-leaderboard/pyproject.toml"
|
|
93
|
+
): "20d86859dc988e442c13a6c4f3567094bd8f2d4a269d59015337bdf6aeba7dd3",
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
@dataclass(frozen=True, slots=True)
|
|
99
|
+
class BFCLV3EvaluationResult:
|
|
100
|
+
"""One caller-asserted official-AST validity bit."""
|
|
101
|
+
|
|
102
|
+
ast_accuracy: float
|
|
103
|
+
provenance_status: str = field(init=False, default=_CALLER_ASSERTED)
|
|
104
|
+
evaluation_scope: str = field(init=False, default=_EXTERNAL_BRIDGE)
|
|
105
|
+
official_runtime_verified: bool = field(init=False, default=False)
|
|
106
|
+
|
|
107
|
+
def __post_init__(self) -> None:
|
|
108
|
+
if isinstance(self.ast_accuracy, bool) or not isinstance(self.ast_accuracy, (int, float)):
|
|
109
|
+
raise ValidationError("BFCL v3 ast_accuracy must be numeric")
|
|
110
|
+
numeric = float(self.ast_accuracy)
|
|
111
|
+
if not math.isfinite(numeric) or numeric not in {0.0, 1.0}:
|
|
112
|
+
raise ValidationError("BFCL v3 case-level ast_accuracy must be exactly 0 or 1")
|
|
113
|
+
object.__setattr__(self, "ast_accuracy", numeric)
|
|
114
|
+
|
|
115
|
+
@property
|
|
116
|
+
def metrics(self) -> Mapping[str, float]:
|
|
117
|
+
return MappingProxyType({"ast_accuracy": self.ast_accuracy})
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@runtime_checkable
|
|
121
|
+
class BFCLV3ScorerBridge(Protocol):
|
|
122
|
+
"""Revision-bound external BFCL decoder/scorer contract."""
|
|
123
|
+
|
|
124
|
+
bfcl_bridge_contract: str
|
|
125
|
+
benchmark_id: str
|
|
126
|
+
source_revision: str
|
|
127
|
+
scorer_id: str
|
|
128
|
+
scorer_revision: str
|
|
129
|
+
ast_checker_revision: str
|
|
130
|
+
model_handler_id: str
|
|
131
|
+
model_handler_revision: str
|
|
132
|
+
bridge_id: str
|
|
133
|
+
bridge_revision: str
|
|
134
|
+
test_category: str
|
|
135
|
+
language: str
|
|
136
|
+
provenance_status: str
|
|
137
|
+
evaluation_scope: str
|
|
138
|
+
official_runtime_verified: bool
|
|
139
|
+
|
|
140
|
+
def evaluate(
|
|
141
|
+
self,
|
|
142
|
+
evaluator_payload: Mapping[str, Any],
|
|
143
|
+
prediction: Any,
|
|
144
|
+
) -> BFCLV3EvaluationResult: ...
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
@dataclass(frozen=True, slots=True)
|
|
148
|
+
class CallerAssertedBFCLV3ScorerBridge:
|
|
149
|
+
"""Explicit wrapper for a non-attested external BFCL v1.3 callback."""
|
|
150
|
+
|
|
151
|
+
bridge_id: str
|
|
152
|
+
bridge_revision: str
|
|
153
|
+
model_handler_id: str
|
|
154
|
+
model_handler_revision: str
|
|
155
|
+
callback: Callable[
|
|
156
|
+
[Mapping[str, Any], Any],
|
|
157
|
+
BFCLV3EvaluationResult,
|
|
158
|
+
] = field(repr=False)
|
|
159
|
+
bfcl_bridge_contract: str = field(init=False, default="bfcl_v3_scorer_bridge_v1")
|
|
160
|
+
benchmark_id: str = field(init=False, default=_BENCHMARK_ID)
|
|
161
|
+
source_revision: str = field(init=False, default=BFCL_V3_OFFICIAL_SOURCE_REVISION)
|
|
162
|
+
scorer_id: str = field(init=False, default=BFCL_V3_SCORER_ID)
|
|
163
|
+
scorer_revision: str = field(init=False, default=BFCL_V3_SCORER_REVISION)
|
|
164
|
+
ast_checker_revision: str = field(
|
|
165
|
+
init=False,
|
|
166
|
+
default=BFCL_V3_AST_CHECKER_REVISION,
|
|
167
|
+
)
|
|
168
|
+
test_category: str = field(init=False, default="simple")
|
|
169
|
+
language: str = field(init=False, default="Python")
|
|
170
|
+
provenance_status: str = field(init=False, default=_CALLER_ASSERTED)
|
|
171
|
+
evaluation_scope: str = field(init=False, default=_EXTERNAL_BRIDGE)
|
|
172
|
+
official_runtime_verified: bool = field(init=False, default=False)
|
|
173
|
+
|
|
174
|
+
def __post_init__(self) -> None:
|
|
175
|
+
for label in ("bridge_id", "model_handler_id"):
|
|
176
|
+
value = getattr(self, label)
|
|
177
|
+
if not isinstance(value, str) or not value.strip() or value != value.strip():
|
|
178
|
+
raise ValidationError(f"BFCL v3 scorer bridge {label} must be non-empty")
|
|
179
|
+
for label in ("bridge_revision", "model_handler_revision"):
|
|
180
|
+
value = getattr(self, label)
|
|
181
|
+
if not isinstance(value, str) or _SHA256.fullmatch(value) is None:
|
|
182
|
+
raise ValidationError(f"BFCL v3 scorer bridge {label} must be a lowercase SHA-256")
|
|
183
|
+
if not callable(self.callback):
|
|
184
|
+
raise TypeError("BFCL v3 scorer bridge callback must be callable")
|
|
185
|
+
|
|
186
|
+
def evaluate(
|
|
187
|
+
self,
|
|
188
|
+
evaluator_payload: Mapping[str, Any],
|
|
189
|
+
prediction: Any,
|
|
190
|
+
) -> BFCLV3EvaluationResult:
|
|
191
|
+
result = self.callback(evaluator_payload, prediction)
|
|
192
|
+
if not isinstance(result, BFCLV3EvaluationResult):
|
|
193
|
+
raise ValidationError(
|
|
194
|
+
"BFCL v3 scorer callback must return BFCLV3EvaluationResult; "
|
|
195
|
+
"bare metrics are not accepted"
|
|
196
|
+
)
|
|
197
|
+
if (
|
|
198
|
+
result.provenance_status != self.provenance_status
|
|
199
|
+
or result.evaluation_scope != self.evaluation_scope
|
|
200
|
+
or result.official_runtime_verified is not False
|
|
201
|
+
):
|
|
202
|
+
raise ValidationError(
|
|
203
|
+
"BFCL v3 evaluation result provenance differs from its caller-asserted bridge"
|
|
204
|
+
)
|
|
205
|
+
return result
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
class PreparedBFCLV3SimpleAdapter:
|
|
209
|
+
"""Loader-only production adapter for the locked BFCL v3 simple-Python cell."""
|
|
210
|
+
|
|
211
|
+
benchmark_id = _BENCHMARK_ID
|
|
212
|
+
adapter_metric_names = ("ast_accuracy",)
|
|
213
|
+
split = _SPLIT
|
|
214
|
+
pairing_mode = "stateless_score_twice"
|
|
215
|
+
|
|
216
|
+
def __init__(
|
|
217
|
+
self,
|
|
218
|
+
prepared: PreparedBenchmark,
|
|
219
|
+
*,
|
|
220
|
+
evaluation_bridge: BFCLV3ScorerBridge,
|
|
221
|
+
_construction_token: object | None = None,
|
|
222
|
+
) -> None:
|
|
223
|
+
if _construction_token is not _LOADER_CONSTRUCTION_TOKEN:
|
|
224
|
+
raise ValidationError(
|
|
225
|
+
"BFCL v3 production adapters must be constructed with load_bfcl_v3_simple_adapter()"
|
|
226
|
+
)
|
|
227
|
+
if not isinstance(prepared, PreparedBenchmark):
|
|
228
|
+
raise TypeError("prepared must be a PreparedBenchmark")
|
|
229
|
+
if not isinstance(evaluation_bridge, BFCLV3ScorerBridge):
|
|
230
|
+
raise TypeError(
|
|
231
|
+
"evaluation_bridge must implement BFCLV3ScorerBridge; wrap external "
|
|
232
|
+
"callbacks with CallerAssertedBFCLV3ScorerBridge"
|
|
233
|
+
)
|
|
234
|
+
_validate_prepared_identity(prepared)
|
|
235
|
+
_validate_scorer_bridge(evaluation_bridge)
|
|
236
|
+
_verify_prepared_file_hashes(prepared)
|
|
237
|
+
|
|
238
|
+
input_rows = _records_by_id(prepared.inputs_path, label="BFCL v3 prepared inputs")
|
|
239
|
+
gold_rows = _records_by_id(prepared.gold_path, label="BFCL v3 evaluator gold")
|
|
240
|
+
audit_rows = _read_jsonl(prepared.audit_path, label="BFCL v3 source audit")
|
|
241
|
+
if set(input_rows) != _EXPECTED_IDS or set(gold_rows) != _EXPECTED_IDS:
|
|
242
|
+
raise ArtifactError("BFCL v3 simple IDs differ from the audited 400-case cell")
|
|
243
|
+
if len(audit_rows) != 1:
|
|
244
|
+
raise ArtifactError("BFCL v3 source audit must contain exactly one record")
|
|
245
|
+
_validate_source_audit(audit_rows[0])
|
|
246
|
+
|
|
247
|
+
examples: list[BenchmarkExample] = []
|
|
248
|
+
for index in range(400):
|
|
249
|
+
example_id = f"simple_{index}"
|
|
250
|
+
visible = input_rows[example_id]
|
|
251
|
+
gold = gold_rows[example_id]
|
|
252
|
+
if set(visible) != _INPUT_FIELDS:
|
|
253
|
+
raise ArtifactError("BFCL v3 prepared input schema differs from the lock")
|
|
254
|
+
if set(gold) != _GOLD_FIELDS or gold.get("id") != example_id:
|
|
255
|
+
raise ArtifactError("BFCL v3 evaluator gold schema differs from the lock")
|
|
256
|
+
query = _required_text(visible, "query", label="BFCL v3 prepared input")
|
|
257
|
+
instruction = _required_text(
|
|
258
|
+
visible,
|
|
259
|
+
"instruction",
|
|
260
|
+
label="BFCL v3 prepared input",
|
|
261
|
+
)
|
|
262
|
+
metadata = _validated_visible_metadata(visible["visible_metadata"])
|
|
263
|
+
function = metadata["function"]
|
|
264
|
+
if not isinstance(function, Mapping): # pragma: no cover - validation invariant
|
|
265
|
+
raise ArtifactError("BFCL v3 function metadata is invalid")
|
|
266
|
+
tool_names = visible["visible_tool_names"]
|
|
267
|
+
if not isinstance(tool_names, list) or tool_names != [function["name"]]:
|
|
268
|
+
raise ArtifactError(
|
|
269
|
+
"BFCL v3 visible tool names must contain the prompt function exactly"
|
|
270
|
+
)
|
|
271
|
+
ground_truth = gold["ground_truth"]
|
|
272
|
+
if (
|
|
273
|
+
not isinstance(ground_truth, list)
|
|
274
|
+
or len(ground_truth) != 1
|
|
275
|
+
or not isinstance(ground_truth[0], Mapping)
|
|
276
|
+
):
|
|
277
|
+
raise ArtifactError("BFCL v3 simple evaluator gold must contain one answer object")
|
|
278
|
+
examples.append(
|
|
279
|
+
BenchmarkExample(
|
|
280
|
+
example_id=example_id,
|
|
281
|
+
query=query,
|
|
282
|
+
instruction=instruction,
|
|
283
|
+
visible_metadata=metadata,
|
|
284
|
+
visible_tool_names=(function["name"],),
|
|
285
|
+
evaluator_gold=_frozen_mapping(
|
|
286
|
+
{"ground_truth": ground_truth},
|
|
287
|
+
label="BFCL v3 evaluator gold",
|
|
288
|
+
),
|
|
289
|
+
)
|
|
290
|
+
)
|
|
291
|
+
|
|
292
|
+
self.prepared = prepared
|
|
293
|
+
self._evaluation_bridge = evaluation_bridge
|
|
294
|
+
self._examples = tuple(examples)
|
|
295
|
+
self._examples_by_id = {example.example_id: example for example in examples}
|
|
296
|
+
self._expected_file_sha256 = MappingProxyType(dict(prepared.file_sha256))
|
|
297
|
+
|
|
298
|
+
def verify_integrity(self) -> None:
|
|
299
|
+
"""Re-hash all prepared files before exposure or scoring."""
|
|
300
|
+
|
|
301
|
+
if dict(self.prepared.file_sha256) != dict(self._expected_file_sha256):
|
|
302
|
+
raise ArtifactError("prepared BFCL v3 declared file hashes changed after loading")
|
|
303
|
+
_verify_prepared_file_hashes(self.prepared)
|
|
304
|
+
|
|
305
|
+
def examples(self, split: str) -> tuple[BenchmarkExample, ...]:
|
|
306
|
+
if split != self.split:
|
|
307
|
+
raise ValidationError(
|
|
308
|
+
f"BFCL v3 simple adapter exposes split {self.split!r}, not {split!r}"
|
|
309
|
+
)
|
|
310
|
+
self.verify_integrity()
|
|
311
|
+
return self._examples
|
|
312
|
+
|
|
313
|
+
def example(self, split: str, example_id: str) -> BenchmarkExample:
|
|
314
|
+
if split != self.split:
|
|
315
|
+
raise ValidationError(
|
|
316
|
+
f"BFCL v3 simple adapter exposes split {self.split!r}, not {split!r}"
|
|
317
|
+
)
|
|
318
|
+
self.verify_integrity()
|
|
319
|
+
try:
|
|
320
|
+
return self._examples_by_id[example_id]
|
|
321
|
+
except KeyError as exc:
|
|
322
|
+
raise ValidationError(f"unknown BFCL v3 simple example {example_id!r}") from exc
|
|
323
|
+
|
|
324
|
+
def function_tools(self, example: BenchmarkExample) -> tuple[Mapping[str, Any], ...]:
|
|
325
|
+
"""Expose the bound handler's native function schema, including name conversion."""
|
|
326
|
+
if self._examples_by_id.get(getattr(example, "example_id", None)) is not example:
|
|
327
|
+
raise ValidationError("benchmark example does not belong to this BFCL v3 adapter")
|
|
328
|
+
self.verify_integrity()
|
|
329
|
+
convert = getattr(self._evaluation_bridge, "tools", None)
|
|
330
|
+
if not callable(convert):
|
|
331
|
+
raise ValidationError("this BFCL scorer bridge does not expose native function tools")
|
|
332
|
+
tools = tuple(convert(example.visible_metadata["function"]))
|
|
333
|
+
if not tools or any(not isinstance(tool, Mapping) for tool in tools):
|
|
334
|
+
raise ValidationError("BFCL native schema converter returned invalid tools")
|
|
335
|
+
return tools
|
|
336
|
+
|
|
337
|
+
def score(self, example: BenchmarkExample, prediction: Any) -> Mapping[str, float]:
|
|
338
|
+
if not isinstance(example, BenchmarkExample):
|
|
339
|
+
raise TypeError("example must be a BenchmarkExample")
|
|
340
|
+
if self._examples_by_id.get(example.example_id) is not example:
|
|
341
|
+
raise ValidationError("benchmark example does not belong to this BFCL v3 adapter")
|
|
342
|
+
self.verify_integrity()
|
|
343
|
+
function = example.visible_metadata.get("function")
|
|
344
|
+
if not isinstance(function, Mapping): # pragma: no cover - construction invariant
|
|
345
|
+
raise ArtifactError("BFCL v3 example function metadata is invalid")
|
|
346
|
+
ground_truth = example.evaluator_gold.get("ground_truth")
|
|
347
|
+
if not isinstance(ground_truth, tuple): # frozen by construction
|
|
348
|
+
raise ArtifactError("BFCL v3 example evaluator gold is invalid")
|
|
349
|
+
evaluator_payload = _frozen_mapping(
|
|
350
|
+
{
|
|
351
|
+
"benchmark_id": self.benchmark_id,
|
|
352
|
+
"function": function,
|
|
353
|
+
"ground_truth": ground_truth,
|
|
354
|
+
"language": self._evaluation_bridge.language,
|
|
355
|
+
"source_revision": BFCL_V3_OFFICIAL_SOURCE_REVISION,
|
|
356
|
+
"test_category": self._evaluation_bridge.test_category,
|
|
357
|
+
},
|
|
358
|
+
label="BFCL v3 evaluator payload",
|
|
359
|
+
)
|
|
360
|
+
result = self._evaluation_bridge.evaluate(evaluator_payload, prediction)
|
|
361
|
+
if not isinstance(result, BFCLV3EvaluationResult):
|
|
362
|
+
raise ValidationError("BFCL v3 scorer bridge returned an invalid result type")
|
|
363
|
+
return result.metrics
|
|
364
|
+
|
|
365
|
+
@property
|
|
366
|
+
def evaluation_provenance(self) -> Mapping[str, Any]:
|
|
367
|
+
"""Return explicit scorer/decoder identities and evaluation scope."""
|
|
368
|
+
|
|
369
|
+
return _frozen_mapping(
|
|
370
|
+
{
|
|
371
|
+
"ast_checker_revision": self._evaluation_bridge.ast_checker_revision,
|
|
372
|
+
"benchmark_id": self._evaluation_bridge.benchmark_id,
|
|
373
|
+
"bridge_id": self._evaluation_bridge.bridge_id,
|
|
374
|
+
"bridge_revision": self._evaluation_bridge.bridge_revision,
|
|
375
|
+
"evaluation_scope": self._evaluation_bridge.evaluation_scope,
|
|
376
|
+
"language": self._evaluation_bridge.language,
|
|
377
|
+
"model_handler_id": self._evaluation_bridge.model_handler_id,
|
|
378
|
+
"model_handler_revision": self._evaluation_bridge.model_handler_revision,
|
|
379
|
+
"official_runtime_verified": self._evaluation_bridge.official_runtime_verified,
|
|
380
|
+
"provenance_status": self._evaluation_bridge.provenance_status,
|
|
381
|
+
"scorer_id": self._evaluation_bridge.scorer_id,
|
|
382
|
+
"scorer_revision": self._evaluation_bridge.scorer_revision,
|
|
383
|
+
"source_revision": self._evaluation_bridge.source_revision,
|
|
384
|
+
"test_category": self._evaluation_bridge.test_category,
|
|
385
|
+
},
|
|
386
|
+
label="BFCL v3 evaluation provenance",
|
|
387
|
+
)
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
def load_bfcl_v3_simple_adapter(
|
|
391
|
+
prepared_root: str | Path,
|
|
392
|
+
*,
|
|
393
|
+
evaluation_bridge: BFCLV3ScorerBridge,
|
|
394
|
+
) -> PreparedBFCLV3SimpleAdapter:
|
|
395
|
+
"""Load the exact checksum-pinned BFCL cell and its typed scorer bridge."""
|
|
396
|
+
|
|
397
|
+
asset = BenchmarkSmokeAssetRegistry.default().get(_ASSET_ID)
|
|
398
|
+
if asset.cell_id != _BENCHMARK_ID or asset.sha256 != BFCL_V3_SOURCE_ARCHIVE_SHA256:
|
|
399
|
+
raise ArtifactError("registered BFCL v3 source identity differs from the production lock")
|
|
400
|
+
prepared = load_prepared_benchmark(asset, prepared_root)
|
|
401
|
+
return _construct_bfcl_v3_simple_adapter(
|
|
402
|
+
prepared,
|
|
403
|
+
evaluation_bridge=evaluation_bridge,
|
|
404
|
+
_construction_token=_LOADER_CONSTRUCTION_TOKEN,
|
|
405
|
+
)
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
def _construct_bfcl_v3_simple_adapter(
|
|
409
|
+
prepared: PreparedBenchmark,
|
|
410
|
+
*,
|
|
411
|
+
evaluation_bridge: BFCLV3ScorerBridge,
|
|
412
|
+
_construction_token: object,
|
|
413
|
+
) -> PreparedBFCLV3SimpleAdapter:
|
|
414
|
+
"""Internal seam shared only by the verified loader and isolated unit fixtures."""
|
|
415
|
+
|
|
416
|
+
if _construction_token is not _LOADER_CONSTRUCTION_TOKEN:
|
|
417
|
+
raise ValidationError("invalid BFCL v3 loader construction token")
|
|
418
|
+
return PreparedBFCLV3SimpleAdapter(
|
|
419
|
+
prepared,
|
|
420
|
+
evaluation_bridge=evaluation_bridge,
|
|
421
|
+
_construction_token=_construction_token,
|
|
422
|
+
)
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
def _validate_prepared_identity(prepared: PreparedBenchmark) -> None:
|
|
426
|
+
expected = {
|
|
427
|
+
"asset_id": _ASSET_ID,
|
|
428
|
+
"cell_id": _BENCHMARK_ID,
|
|
429
|
+
"processor": _PROCESSOR,
|
|
430
|
+
"processor_revision": "1",
|
|
431
|
+
"source_revision": BFCL_V3_OFFICIAL_SOURCE_REVISION,
|
|
432
|
+
"source_sha256": BFCL_V3_SOURCE_ARCHIVE_SHA256,
|
|
433
|
+
"split": _SPLIT,
|
|
434
|
+
}
|
|
435
|
+
for name, value in expected.items():
|
|
436
|
+
if getattr(prepared, name) != value:
|
|
437
|
+
raise ArtifactError(f"prepared BFCL v3 identity mismatch for {name}")
|
|
438
|
+
if dict(prepared.counts) != _EXPECTED_COUNTS:
|
|
439
|
+
raise ArtifactError("prepared BFCL v3 counts differ from the audited cell")
|
|
440
|
+
if set(prepared.file_sha256) != {"audit.jsonl", "gold.jsonl", "inputs.jsonl"}:
|
|
441
|
+
raise ArtifactError("prepared BFCL v3 file set is incomplete")
|
|
442
|
+
if prepared.audit_path is None:
|
|
443
|
+
raise ArtifactError("prepared BFCL v3 source audit is missing")
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
def _validate_scorer_bridge(bridge: BFCLV3ScorerBridge) -> None:
|
|
447
|
+
from .bfcl_native import BFCL_NATIVE_SCOPE, BFCL_NATIVE_SCORER_ID, SourceVerifiedBFCLV3ASTBridge
|
|
448
|
+
if isinstance(bridge,SourceVerifiedBFCLV3ASTBridge):
|
|
449
|
+
if (getattr(bridge,'_verified_source_sha256',None)!=BFCL_V3_SOURCE_ARCHIVE_SHA256
|
|
450
|
+
or bridge.provenance_status!='source_verified' or bridge.evaluation_scope!=BFCL_NATIVE_SCOPE
|
|
451
|
+
or bridge.scorer_id!=BFCL_NATIVE_SCORER_ID or bridge.official_runtime_verified is not False):
|
|
452
|
+
raise ValidationError('BFCL native source/scoring scope differs')
|
|
453
|
+
return
|
|
454
|
+
expected = {
|
|
455
|
+
"ast_checker_revision": BFCL_V3_AST_CHECKER_REVISION,
|
|
456
|
+
"benchmark_id": _BENCHMARK_ID,
|
|
457
|
+
"bfcl_bridge_contract": "bfcl_v3_scorer_bridge_v1",
|
|
458
|
+
"evaluation_scope": _EXTERNAL_BRIDGE,
|
|
459
|
+
"language": "Python",
|
|
460
|
+
"provenance_status": _CALLER_ASSERTED,
|
|
461
|
+
"scorer_id": BFCL_V3_SCORER_ID,
|
|
462
|
+
"scorer_revision": BFCL_V3_SCORER_REVISION,
|
|
463
|
+
"source_revision": BFCL_V3_OFFICIAL_SOURCE_REVISION,
|
|
464
|
+
"test_category": "simple",
|
|
465
|
+
}
|
|
466
|
+
for name, value in expected.items():
|
|
467
|
+
if getattr(bridge, name) != value:
|
|
468
|
+
raise ValidationError(f"BFCL v3 scorer bridge identity mismatch for {name}")
|
|
469
|
+
if bridge.official_runtime_verified is not False:
|
|
470
|
+
raise ValidationError("current BFCL v3 bridge cannot claim official runtime verification")
|
|
471
|
+
for label in ("bridge_id", "model_handler_id"):
|
|
472
|
+
value = getattr(bridge, label)
|
|
473
|
+
if not isinstance(value, str) or not value.strip() or value != value.strip():
|
|
474
|
+
raise ValidationError(f"BFCL v3 scorer bridge {label} must be non-empty")
|
|
475
|
+
for label in ("bridge_revision", "model_handler_revision"):
|
|
476
|
+
value = getattr(bridge, label)
|
|
477
|
+
if not isinstance(value, str) or _SHA256.fullmatch(value) is None:
|
|
478
|
+
raise ValidationError(f"BFCL v3 scorer bridge {label} must be a lowercase SHA-256")
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
def _validate_source_audit(audit: Mapping[str, Any]) -> None:
|
|
482
|
+
expected_fields = {
|
|
483
|
+
"category",
|
|
484
|
+
"evaluation_boundary",
|
|
485
|
+
"id",
|
|
486
|
+
"license_id",
|
|
487
|
+
"official_cli",
|
|
488
|
+
"selected_source_sha256",
|
|
489
|
+
"source_revision",
|
|
490
|
+
"source_tag",
|
|
491
|
+
}
|
|
492
|
+
if set(audit) != expected_fields:
|
|
493
|
+
raise ArtifactError("BFCL v3 source audit schema differs from the production lock")
|
|
494
|
+
expected = {
|
|
495
|
+
"category": "simple",
|
|
496
|
+
"id": "bfcl-v3-simple-source-audit",
|
|
497
|
+
"license_id": "Apache-2.0",
|
|
498
|
+
"official_cli": "bfcl evaluate --test-category simple",
|
|
499
|
+
"source_revision": BFCL_V3_OFFICIAL_SOURCE_REVISION,
|
|
500
|
+
"source_tag": "v1.3",
|
|
501
|
+
}
|
|
502
|
+
for key, value in expected.items():
|
|
503
|
+
if audit.get(key) != value:
|
|
504
|
+
raise ArtifactError(f"BFCL v3 source audit identity mismatch for {key}")
|
|
505
|
+
if dict(audit.get("selected_source_sha256", {})) != dict(BFCL_V3_SELECTED_SOURCE_SHA256):
|
|
506
|
+
raise ArtifactError("BFCL v3 selected source hashes differ from the audited lock")
|
|
507
|
+
boundary = audit.get("evaluation_boundary")
|
|
508
|
+
if (
|
|
509
|
+
not isinstance(boundary, str)
|
|
510
|
+
or "evaluator-only" not in boundary
|
|
511
|
+
or "does not execute BFCL" not in boundary
|
|
512
|
+
):
|
|
513
|
+
raise ArtifactError("BFCL v3 source audit does not preserve the evaluation boundary")
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
def _validated_visible_metadata(value: Any) -> Mapping[str, Any]:
|
|
517
|
+
if not isinstance(value, Mapping) or set(value) != _VISIBLE_METADATA_FIELDS:
|
|
518
|
+
raise ArtifactError("BFCL v3 visible metadata schema differs from the lock")
|
|
519
|
+
if (
|
|
520
|
+
value.get("benchmark_cell") != _BENCHMARK_ID
|
|
521
|
+
or value.get("bfcl_category") != "simple"
|
|
522
|
+
or value.get("source_split") != _SPLIT
|
|
523
|
+
):
|
|
524
|
+
raise ArtifactError("BFCL v3 visible metadata identity differs from the lock")
|
|
525
|
+
function = value.get("function")
|
|
526
|
+
if not isinstance(function, Mapping) or set(function) != _FUNCTION_FIELDS:
|
|
527
|
+
raise ArtifactError("BFCL v3 function schema differs from the lock")
|
|
528
|
+
_required_text(function, "name", label="BFCL v3 function")
|
|
529
|
+
_required_text(function, "description", label="BFCL v3 function")
|
|
530
|
+
if not isinstance(function.get("parameters"), Mapping):
|
|
531
|
+
raise ArtifactError("BFCL v3 function parameters must be an object")
|
|
532
|
+
return _frozen_mapping(value, label="BFCL v3 visible metadata")
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
def _verify_prepared_file_hashes(prepared: PreparedBenchmark) -> None:
|
|
536
|
+
for name, expected in sorted(prepared.file_sha256.items()):
|
|
537
|
+
if not isinstance(expected, str) or _SHA256.fullmatch(expected) is None:
|
|
538
|
+
raise ArtifactError(f"prepared BFCL v3 hash is invalid for {name}")
|
|
539
|
+
try:
|
|
540
|
+
actual = sha256_file(prepared.root / name)
|
|
541
|
+
except OSError as exc:
|
|
542
|
+
raise ArtifactError(f"prepared BFCL v3 file cannot be verified: {name}") from exc
|
|
543
|
+
if actual != expected:
|
|
544
|
+
raise ArtifactError(f"prepared BFCL v3 file hash mismatch: {name}")
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
def _records_by_id(path: Path, *, label: str) -> dict[str, dict[str, Any]]:
|
|
548
|
+
indexed: dict[str, dict[str, Any]] = {}
|
|
549
|
+
for row in _read_jsonl(path, label=label):
|
|
550
|
+
row_id = _required_text(row, "id", label=label)
|
|
551
|
+
if row_id in indexed:
|
|
552
|
+
raise ArtifactError(f"{label} contains duplicate IDs")
|
|
553
|
+
indexed[row_id] = row
|
|
554
|
+
return indexed
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
def _read_jsonl(path: Path | None, *, label: str) -> list[dict[str, Any]]:
|
|
558
|
+
if path is None:
|
|
559
|
+
raise ArtifactError(f"{label} is missing")
|
|
560
|
+
try:
|
|
561
|
+
lines = path.read_text(encoding="utf-8").splitlines()
|
|
562
|
+
except (OSError, UnicodeError) as exc:
|
|
563
|
+
raise ArtifactError(f"{label} cannot be read as UTF-8") from exc
|
|
564
|
+
rows: list[dict[str, Any]] = []
|
|
565
|
+
for line_number, line in enumerate(lines, start=1):
|
|
566
|
+
if not line.strip():
|
|
567
|
+
raise ArtifactError(f"{label} contains a blank line at {line_number}")
|
|
568
|
+
try:
|
|
569
|
+
value = json.loads(line)
|
|
570
|
+
except json.JSONDecodeError as exc:
|
|
571
|
+
raise ArtifactError(f"{label} contains invalid JSON at line {line_number}") from exc
|
|
572
|
+
if not isinstance(value, dict):
|
|
573
|
+
raise ArtifactError(f"{label} rows must be objects")
|
|
574
|
+
rows.append(value)
|
|
575
|
+
if not rows:
|
|
576
|
+
raise ArtifactError(f"{label} must not be empty")
|
|
577
|
+
return rows
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
def _required_text(record: Mapping[str, Any], key: str, *, label: str) -> str:
|
|
581
|
+
value = record.get(key)
|
|
582
|
+
if not isinstance(value, str) or not value.strip():
|
|
583
|
+
raise ArtifactError(f"{label} field {key!r} must be a non-empty string")
|
|
584
|
+
return value
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
def _frozen_mapping(value: Mapping[str, Any], *, label: str) -> Mapping[str, Any]:
|
|
588
|
+
try:
|
|
589
|
+
detached = json.loads(canonical_json(value))
|
|
590
|
+
return freeze_mapping(detached)
|
|
591
|
+
except (TypeError, ValueError) as exc:
|
|
592
|
+
raise ArtifactError(f"{label} must be canonically serializable") from exc
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
__all__ = [
|
|
596
|
+
"BFCL_V3_AST_CHECKER_REVISION",
|
|
597
|
+
"BFCL_V3_OFFICIAL_SOURCE_REVISION",
|
|
598
|
+
"BFCL_V3_SCORER_ID",
|
|
599
|
+
"BFCL_V3_SCORER_REVISION",
|
|
600
|
+
"BFCL_V3_SELECTED_SOURCE_SHA256",
|
|
601
|
+
"BFCL_V3_SOURCE_ARCHIVE_SHA256",
|
|
602
|
+
"BFCLV3EvaluationResult",
|
|
603
|
+
"BFCLV3ScorerBridge",
|
|
604
|
+
"CallerAssertedBFCLV3ScorerBridge",
|
|
605
|
+
"PreparedBFCLV3SimpleAdapter",
|
|
606
|
+
"load_bfcl_v3_simple_adapter",
|
|
607
|
+
]
|