orizu 0.5.19 → 0.5.21
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.
- package/README.md +23 -0
- package/dist/archive-artifacts-cli.d.ts +50 -0
- package/dist/archive-artifacts-cli.d.ts.map +1 -0
- package/dist/artifact-archive.d.ts +48 -0
- package/dist/artifact-archive.d.ts.map +1 -0
- package/dist/artifact-pull.d.ts +22 -0
- package/dist/artifact-pull.d.ts.map +1 -0
- package/dist/banner.d.ts +3 -0
- package/dist/banner.d.ts.map +1 -0
- package/dist/connectors-cli.d.ts +31 -0
- package/dist/connectors-cli.d.ts.map +1 -0
- package/dist/credentials.d.ts +46 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/csv.d.ts +49 -0
- package/dist/csv.d.ts.map +1 -0
- package/dist/dataset-download.d.ts +6 -0
- package/dist/dataset-download.d.ts.map +1 -0
- package/dist/dataset-edit-rows.d.ts +10 -0
- package/dist/dataset-edit-rows.d.ts.map +1 -0
- package/dist/dataset-upload-snapshot.d.ts +13 -0
- package/dist/dataset-upload-snapshot.d.ts.map +1 -0
- package/dist/daytona-slice-rehearsal.d.ts +89 -0
- package/dist/daytona-slice-rehearsal.d.ts.map +1 -0
- package/dist/daytona-slice.d.ts +106 -0
- package/dist/daytona-slice.d.ts.map +1 -0
- package/dist/deploy-key-merge-core.d.ts +121 -0
- package/dist/deploy-key-merge-core.d.ts.map +1 -0
- package/dist/diff-comments-cli.d.ts +12 -0
- package/dist/diff-comments-cli.d.ts.map +1 -0
- package/dist/diff-comments-cli.js +21 -2
- package/dist/egress-allowlist-cli.d.ts +23 -0
- package/dist/egress-allowlist-cli.d.ts.map +1 -0
- package/dist/egress-policy.d.ts +108 -0
- package/dist/egress-policy.d.ts.map +1 -0
- package/dist/error-response.d.ts +9 -0
- package/dist/error-response.d.ts.map +1 -0
- package/dist/file-parser.d.ts +5 -0
- package/dist/file-parser.d.ts.map +1 -0
- package/dist/gepa-engine-dispatch.d.ts +9 -0
- package/dist/gepa-engine-dispatch.d.ts.map +1 -0
- package/dist/gepa-engine-dispatch.js +307 -0
- package/dist/gepa-python-command.d.ts +6 -0
- package/dist/gepa-python-command.d.ts.map +1 -0
- package/dist/gepa-python-command.js +26 -0
- package/dist/gepa-python-paths.d.ts +6 -0
- package/dist/gepa-python-paths.d.ts.map +1 -0
- package/dist/gepa-python-paths.js +42 -0
- package/dist/git-credential.d.ts +69 -0
- package/dist/git-credential.d.ts.map +1 -0
- package/dist/git-recovery-environment.d.ts +31 -0
- package/dist/git-recovery-environment.d.ts.map +1 -0
- package/dist/github-setup.d.ts +122 -0
- package/dist/github-setup.d.ts.map +1 -0
- package/dist/global-flags.d.ts +12 -0
- package/dist/global-flags.d.ts.map +1 -0
- package/dist/help.d.ts +46 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +93 -25
- package/dist/hosted-boot.d.ts +273 -0
- package/dist/hosted-boot.d.ts.map +1 -0
- package/dist/hosted-bootstrap-rehearsal.d.ts +86 -0
- package/dist/hosted-bootstrap-rehearsal.d.ts.map +1 -0
- package/dist/hosted-bootstrap.d.ts +188 -0
- package/dist/hosted-bootstrap.d.ts.map +1 -0
- package/dist/hosted-broker-server.d.ts +50 -0
- package/dist/hosted-broker-server.d.ts.map +1 -0
- package/dist/hosted-git-http-server.d.ts +36 -0
- package/dist/hosted-git-http-server.d.ts.map +1 -0
- package/dist/hosted-harness-claude.d.ts +195 -0
- package/dist/hosted-harness-claude.d.ts.map +1 -0
- package/dist/hosted-harness-opencode.d.ts +227 -0
- package/dist/hosted-harness-opencode.d.ts.map +1 -0
- package/dist/hosted-harness.d.ts +118 -0
- package/dist/hosted-harness.d.ts.map +1 -0
- package/dist/hosted-harvest.d.ts +68 -0
- package/dist/hosted-harvest.d.ts.map +1 -0
- package/dist/hosted-headless.d.ts +72 -0
- package/dist/hosted-headless.d.ts.map +1 -0
- package/dist/hosted-loop-lifecycle.d.ts +206 -0
- package/dist/hosted-loop-lifecycle.d.ts.map +1 -0
- package/dist/hosted-loop.d.ts +170 -0
- package/dist/hosted-loop.d.ts.map +1 -0
- package/dist/hosted-run-event-sink.d.ts +222 -0
- package/dist/hosted-run-event-sink.d.ts.map +1 -0
- package/dist/hosted-runtime-assets.d.ts +186 -0
- package/dist/hosted-runtime-assets.d.ts.map +1 -0
- package/dist/hosted-session-cli.d.ts +258 -0
- package/dist/hosted-session-cli.d.ts.map +1 -0
- package/dist/hosted-skill-staging.d.ts +73 -0
- package/dist/hosted-skill-staging.d.ts.map +1 -0
- package/dist/http.d.ts +8 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +119 -129
- package/dist/instruction-set-gepa-launch.d.ts +3 -0
- package/dist/instruction-set-gepa-launch.d.ts.map +1 -0
- package/dist/instruction-set-gepa-launch.js +15 -0
- package/dist/instruction-set-loader.d.ts +6 -0
- package/dist/instruction-set-loader.d.ts.map +1 -0
- package/dist/instruction-set-loader.js +59 -0
- package/dist/instruction-set-manifest.d.ts +14 -0
- package/dist/instruction-set-manifest.d.ts.map +1 -0
- package/dist/instruction-set-manifest.js +162 -0
- package/dist/instruction-sets-cli.d.ts +40 -0
- package/dist/instruction-sets-cli.d.ts.map +1 -0
- package/dist/instruction-sets-cli.js +361 -0
- package/dist/json-response.d.ts +4 -0
- package/dist/json-response.d.ts.map +1 -0
- package/dist/jsonl-stream.d.ts +8 -0
- package/dist/jsonl-stream.d.ts.map +1 -0
- package/dist/kill-switch-cli.d.ts +30 -0
- package/dist/kill-switch-cli.d.ts.map +1 -0
- package/dist/loopback-serve.d.ts +25 -0
- package/dist/loopback-serve.d.ts.map +1 -0
- package/dist/manifests-cli.d.ts +22 -0
- package/dist/manifests-cli.d.ts.map +1 -0
- package/dist/markdown-report-input.d.ts +7 -0
- package/dist/markdown-report-input.d.ts.map +1 -0
- package/dist/markdown-report-input.js +15 -1
- package/dist/merge-job.d.ts +155 -0
- package/dist/merge-job.d.ts.map +1 -0
- package/dist/model-configs-cli.d.ts +19 -0
- package/dist/model-configs-cli.d.ts.map +1 -0
- package/dist/model-configs-cli.js +104 -0
- package/dist/optimization-export-cli.d.ts +19 -0
- package/dist/optimization-export-cli.d.ts.map +1 -0
- package/dist/optimizations-list-cli.d.ts +20 -0
- package/dist/optimizations-list-cli.d.ts.map +1 -0
- package/dist/optimizations-promote-cli.d.ts +8 -0
- package/dist/optimizations-promote-cli.d.ts.map +1 -0
- package/dist/optimizations-promote-cli.js +34 -0
- package/dist/option-validation.d.ts +15 -0
- package/dist/option-validation.d.ts.map +1 -0
- package/dist/preview-runtime.d.ts +63 -0
- package/dist/preview-runtime.d.ts.map +1 -0
- package/dist/prompt-draft-push.d.ts +60 -0
- package/dist/prompt-draft-push.d.ts.map +1 -0
- package/dist/prompt-label-cli.d.ts +11 -0
- package/dist/prompt-label-cli.d.ts.map +1 -0
- package/dist/prompt-label-cli.js +29 -0
- package/dist/prompt-length-wire.d.ts +28 -0
- package/dist/prompt-length-wire.d.ts.map +1 -0
- package/dist/prompt-length-wire.js +2 -2
- package/dist/prompt-report-cli.d.ts +10 -0
- package/dist/prompt-report-cli.d.ts.map +1 -0
- package/dist/prompt-report-cli.js +2 -2
- package/dist/prompt-summary-table.d.ts +15 -0
- package/dist/prompt-summary-table.d.ts.map +1 -0
- package/dist/prompt-summary-table.js +6 -0
- package/dist/registration-tag-warning.d.ts +32 -0
- package/dist/registration-tag-warning.d.ts.map +1 -0
- package/dist/report-comments-cli.d.ts +16 -0
- package/dist/report-comments-cli.d.ts.map +1 -0
- package/dist/report-markdown-blankness.d.ts +2 -0
- package/dist/report-markdown-blankness.d.ts.map +1 -0
- package/dist/report-markdown-blankness.js +6 -0
- package/dist/report-replacement-warning.d.ts +17 -0
- package/dist/report-replacement-warning.d.ts.map +1 -0
- package/dist/report-replacement-warning.js +31 -0
- package/dist/repository-backup-core.d.ts +225 -0
- package/dist/repository-backup-core.d.ts.map +1 -0
- package/dist/repository-recovery-manifest.d.ts +83 -0
- package/dist/repository-recovery-manifest.d.ts.map +1 -0
- package/dist/run-event-digest.d.ts +74 -0
- package/dist/run-event-digest.d.ts.map +1 -0
- package/dist/runner-dir-verify.d.ts +66 -0
- package/dist/runner-dir-verify.d.ts.map +1 -0
- package/dist/runner-instruction-set-contract.d.ts +24 -0
- package/dist/runner-instruction-set-contract.d.ts.map +1 -0
- package/dist/runner-instruction-set-contract.js +50 -0
- package/dist/sandbox-hygiene.d.ts +45 -0
- package/dist/sandbox-hygiene.d.ts.map +1 -0
- package/dist/sandbox-provider.d.ts +193 -0
- package/dist/sandbox-provider.d.ts.map +1 -0
- package/dist/scorer-draft-push.d.ts +50 -0
- package/dist/scorer-draft-push.d.ts.map +1 -0
- package/dist/scorers-cli.d.ts +20 -0
- package/dist/scorers-cli.d.ts.map +1 -0
- package/dist/scorers-cli.js +22 -0
- package/dist/scorers-verify-parity-bridge.d.ts +16 -0
- package/dist/scorers-verify-parity-bridge.d.ts.map +1 -0
- package/dist/scorers-verify-parity-bridge.js +90 -0
- package/dist/scorers-verify-parity.d.ts +81 -0
- package/dist/scorers-verify-parity.d.ts.map +1 -0
- package/dist/scorers-verify-parity.js +502 -0
- package/dist/scores-accept-cli.d.ts +21 -0
- package/dist/scores-accept-cli.d.ts.map +1 -0
- package/dist/secret-redaction.d.ts +47 -0
- package/dist/secret-redaction.d.ts.map +1 -0
- package/dist/session-timeline.d.ts +54 -0
- package/dist/session-timeline.d.ts.map +1 -0
- package/dist/setup-prompt.d.ts +5 -0
- package/dist/setup-prompt.d.ts.map +1 -0
- package/dist/skill-installer.d.ts +68 -0
- package/dist/skill-installer.d.ts.map +1 -0
- package/dist/skilled-proposer-launch.d.ts +7 -0
- package/dist/skilled-proposer-launch.d.ts.map +1 -0
- package/dist/skilled-proposer-launch.js +60 -0
- package/dist/smoke.d.ts +102 -0
- package/dist/smoke.d.ts.map +1 -0
- package/dist/start-intent.d.ts +12 -0
- package/dist/start-intent.d.ts.map +1 -0
- package/dist/task-assignment-manifest.d.ts +15 -0
- package/dist/task-assignment-manifest.d.ts.map +1 -0
- package/dist/task-create-error.d.ts +18 -0
- package/dist/task-create-error.d.ts.map +1 -0
- package/dist/team-connectors-cli.d.ts +29 -0
- package/dist/team-connectors-cli.d.ts.map +1 -0
- package/dist/types.d.ts +39 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/vercel-sandbox-provider.d.ts +156 -0
- package/dist/vercel-sandbox-provider.d.ts.map +1 -0
- package/dist/workbench-cli.d.ts +233 -0
- package/dist/workbench-cli.d.ts.map +1 -0
- package/dist/workspace-sync.d.ts +207 -0
- package/dist/workspace-sync.d.ts.map +1 -0
- package/dist/workspace.d.ts +92 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/zip-draft-push.d.ts +55 -0
- package/dist/zip-draft-push.d.ts.map +1 -0
- package/package.json +15 -2
- package/requirements/README.md +138 -0
- package/requirements/skilled-proposer.in +66 -0
- package/requirements/skilled-proposer.lock +265 -0
- package/scripts/build-cli-dist.mjs +30 -0
- package/scripts/ensure-skilled-proposer-venv.mjs +5 -0
- package/scripts/orizu-source-checkout.d.mts +1 -0
- package/scripts/orizu-source-checkout.mjs +10 -0
- package/scripts/refresh-skilled-proposer-lock.mjs +256 -0
- package/scripts/vendor-gepa-python.mjs +187 -4
- package/src/diff-comments-cli.ts +41 -3
- package/src/gepa-engine-dispatch.ts +340 -0
- package/src/gepa-python-command.ts +31 -0
- package/src/gepa-python-paths.ts +56 -0
- package/src/help.ts +95 -25
- package/src/index.ts +131 -166
- package/src/instruction-set-gepa-launch.ts +28 -0
- package/src/instruction-set-loader.ts +37 -0
- package/src/instruction-set-manifest.ts +120 -0
- package/src/instruction-sets-cli.ts +306 -0
- package/src/markdown-report-input.ts +19 -1
- package/src/model-configs-cli.ts +119 -0
- package/src/optimizations-promote-cli.ts +41 -0
- package/src/prompt-label-cli.ts +55 -0
- package/src/prompt-length-wire.ts +1 -1
- package/src/prompt-report-cli.ts +2 -2
- package/src/prompt-summary-table.ts +12 -0
- package/src/report-markdown-blankness.ts +6 -0
- package/src/report-replacement-warning.ts +35 -0
- package/src/runner-instruction-set-contract.ts +64 -0
- package/src/scorers-cli.ts +40 -0
- package/src/scorers-verify-parity-bridge.ts +90 -0
- package/src/scorers-verify-parity.ts +564 -0
- package/src/skilled-proposer-launch.ts +89 -0
- package/src/skilled-proposer-venv-manager.mjs +757 -0
- package/tsconfig.json +2 -0
- package/vendor/gepa-python/LICENSE +7 -0
- package/vendor/gepa-python/manifest.json +107 -0
- package/vendor/gepa-python/src/gepa/__init__.py +22 -0
- package/vendor/gepa-python/src/gepa/adapters/__init__.py +0 -0
- package/vendor/gepa-python/src/gepa/adapters/anymaths_adapter/__init__.py +1 -0
- package/vendor/gepa-python/src/gepa/adapters/anymaths_adapter/anymaths_adapter.py +174 -0
- package/vendor/gepa-python/src/gepa/adapters/confidence_adapter/__init__.py +26 -0
- package/vendor/gepa-python/src/gepa/adapters/confidence_adapter/confidence_adapter.py +618 -0
- package/vendor/gepa-python/src/gepa/adapters/confidence_adapter/scoring.py +206 -0
- package/vendor/gepa-python/src/gepa/adapters/default_adapter/__init__.py +0 -0
- package/vendor/gepa-python/src/gepa/adapters/default_adapter/default_adapter.py +206 -0
- package/vendor/gepa-python/src/gepa/adapters/dspy_adapter/__init__.py +0 -0
- package/vendor/gepa-python/src/gepa/adapters/dspy_adapter/dspy_adapter.py +525 -0
- package/vendor/gepa-python/src/gepa/adapters/dspy_adapter/instruction_proposal.py +500 -0
- package/vendor/gepa-python/src/gepa/adapters/dspy_full_program_adapter/__init__.py +6 -0
- package/vendor/gepa-python/src/gepa/adapters/dspy_full_program_adapter/dspy_program_proposal_signature.py +137 -0
- package/vendor/gepa-python/src/gepa/adapters/dspy_full_program_adapter/full_program_adapter.py +269 -0
- package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/__init__.py +56 -0
- package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/evaluation_metrics.py +226 -0
- package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/generic_rag_adapter.py +496 -0
- package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/rag_pipeline.py +238 -0
- package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/vector_store_interface.py +212 -0
- package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/vector_stores/__init__.py +2 -0
- package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/vector_stores/chroma_store.py +196 -0
- package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/vector_stores/lancedb_store.py +422 -0
- package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/vector_stores/milvus_store.py +409 -0
- package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/vector_stores/qdrant_store.py +368 -0
- package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/vector_stores/weaviate_store.py +418 -0
- package/vendor/gepa-python/src/gepa/adapters/langchain_adapter/__init__.py +11 -0
- package/vendor/gepa-python/src/gepa/adapters/langchain_adapter/langchain_adapter.py +261 -0
- package/vendor/gepa-python/src/gepa/adapters/mcp_adapter/__init__.py +37 -0
- package/vendor/gepa-python/src/gepa/adapters/mcp_adapter/mcp_adapter.py +693 -0
- package/vendor/gepa-python/src/gepa/adapters/mcp_adapter/mcp_client.py +364 -0
- package/vendor/gepa-python/src/gepa/adapters/optimize_anything_adapter/optimize_anything_adapter.py +879 -0
- package/vendor/gepa-python/src/gepa/adapters/terminal_bench_adapter/__init__.py +0 -0
- package/vendor/gepa-python/src/gepa/adapters/terminal_bench_adapter/terminal_bench_adapter.py +217 -0
- package/vendor/gepa-python/src/gepa/api.py +468 -0
- package/vendor/gepa-python/src/gepa/core/__init__.py +0 -0
- package/vendor/gepa-python/src/gepa/core/adapter.py +227 -0
- package/vendor/gepa-python/src/gepa/core/callbacks.py +551 -0
- package/vendor/gepa-python/src/gepa/core/data_loader.py +74 -0
- package/vendor/gepa-python/src/gepa/core/engine.py +1025 -0
- package/vendor/gepa-python/src/gepa/core/result.py +271 -0
- package/vendor/gepa-python/src/gepa/core/state.py +706 -0
- package/vendor/gepa-python/src/gepa/examples/__init__.py +0 -0
- package/vendor/gepa-python/src/gepa/examples/aime.py +24 -0
- package/vendor/gepa-python/src/gepa/examples/anymaths-bench/eval_default.py +111 -0
- package/vendor/gepa-python/src/gepa/examples/anymaths-bench/train_anymaths.py +177 -0
- package/vendor/gepa-python/src/gepa/examples/mcp_adapter/__init__.py +4 -0
- package/vendor/gepa-python/src/gepa/examples/mcp_adapter/mcp_optimization_example.py +456 -0
- package/vendor/gepa-python/src/gepa/examples/rag_adapter/__init__.py +9 -0
- package/vendor/gepa-python/src/gepa/examples/rag_adapter/rag_optimization.py +824 -0
- package/vendor/gepa-python/src/gepa/examples/terminal-bench/train_terminus.py +161 -0
- package/vendor/gepa-python/src/gepa/gepa_utils.py +117 -0
- package/vendor/gepa-python/src/gepa/gskill/__init__.py +1 -0
- package/vendor/gepa-python/src/gepa/gskill/gskill/__init__.py +0 -0
- package/vendor/gepa-python/src/gepa/gskill/gskill/cost_tracker.py +194 -0
- package/vendor/gepa-python/src/gepa/gskill/gskill/evaluate/__init__.py +0 -0
- package/vendor/gepa-python/src/gepa/gskill/gskill/evaluate/claude_code.py +1117 -0
- package/vendor/gepa-python/src/gepa/gskill/gskill/evaluate/claude_code_skills.py +613 -0
- package/vendor/gepa-python/src/gepa/gskill/gskill/evaluate/mini_swe_agent.py +440 -0
- package/vendor/gepa-python/src/gepa/gskill/gskill/experiment_logger.py +367 -0
- package/vendor/gepa-python/src/gepa/gskill/gskill/swe_fitness_fn.py +209 -0
- package/vendor/gepa-python/src/gepa/gskill/gskill/swe_harness.py +352 -0
- package/vendor/gepa-python/src/gepa/gskill/gskill/train_optimize_anything.py +830 -0
- package/vendor/gepa-python/src/gepa/image.py +104 -0
- package/vendor/gepa-python/src/gepa/lm.py +261 -0
- package/vendor/gepa-python/src/gepa/logging/__init__.py +0 -0
- package/vendor/gepa-python/src/gepa/logging/experiment_tracker.py +457 -0
- package/vendor/gepa-python/src/gepa/logging/logger.py +75 -0
- package/vendor/gepa-python/src/gepa/logging/utils.py +130 -0
- package/vendor/gepa-python/src/gepa/optimize_anything.py +1701 -0
- package/vendor/gepa-python/src/gepa/proposer/__init__.py +0 -0
- package/vendor/gepa-python/src/gepa/proposer/base.py +53 -0
- package/vendor/gepa-python/src/gepa/proposer/merge.py +403 -0
- package/vendor/gepa-python/src/gepa/proposer/reflective_mutation/__init__.py +0 -0
- package/vendor/gepa-python/src/gepa/proposer/reflective_mutation/base.py +64 -0
- package/vendor/gepa-python/src/gepa/proposer/reflective_mutation/reflection_lm.py +178 -0
- package/vendor/gepa-python/src/gepa/proposer/reflective_mutation/reflective_mutation.py +641 -0
- package/vendor/gepa-python/src/gepa/py.typed +0 -0
- package/vendor/gepa-python/src/gepa/strategies/__init__.py +0 -0
- package/vendor/gepa-python/src/gepa/strategies/acceptance.py +66 -0
- package/vendor/gepa-python/src/gepa/strategies/batch_sampler.py +103 -0
- package/vendor/gepa-python/src/gepa/strategies/candidate_selector.py +82 -0
- package/vendor/gepa-python/src/gepa/strategies/component_selector.py +36 -0
- package/vendor/gepa-python/src/gepa/strategies/eval_policy.py +64 -0
- package/vendor/gepa-python/src/gepa/strategies/instruction_proposal.py +153 -0
- package/vendor/gepa-python/src/gepa/strategies/proposal_sampling.py +128 -0
- package/vendor/gepa-python/src/gepa/strategies/proposal_selection.py +84 -0
- package/vendor/gepa-python/src/gepa/utils/__init__.py +63 -0
- package/vendor/gepa-python/src/gepa/utils/code_execution.py +626 -0
- package/vendor/gepa-python/src/gepa/utils/stdio_capture.py +145 -0
- package/vendor/gepa-python/src/gepa/utils/stop_condition.py +230 -0
- package/vendor/gepa-python/src/gepa/visualization.py +359 -0
- package/vendor/orizu-gepa/pyproject.toml +18 -0
- package/vendor/orizu-gepa/src/orizu_gepa_connector/__init__.py +9 -0
- package/vendor/orizu-gepa/src/orizu_gepa_connector/__main__.py +5 -0
- package/vendor/orizu-gepa/src/orizu_gepa_connector/adapter.py +138 -0
- package/vendor/orizu-gepa/src/orizu_gepa_connector/callbacks.py +666 -0
- package/vendor/orizu-gepa/src/orizu_gepa_connector/cli.py +7 -0
- package/vendor/orizu-gepa/src/orizu_gepa_connector/engine.py +269 -0
- package/vendor/orizu-gepa/src/orizu_gepa_connector/instruction_set_loader.py +52 -0
- package/vendor/orizu-gepa/src/orizu_gepa_connector/preflight.py +64 -0
- package/vendor/orizu-gepa/src/orizu_gepa_connector/reflection.py +186 -0
- package/vendor/orizu-gepa/src/orizu_gepa_connector/runtime.py +721 -0
- package/vendor/orizu-gepa/src/orizu_gepa_connector/skilled_proposer_bridge.py +381 -0
- package/vendor/orizu-gepa/src/orizu_gepa_connector/stop_conditions.py +55 -0
- package/vendor/orizu-gepa/src/orizu_gepa_connector/translator.py +203 -0
- package/vendor/orizu-gepa-python/pyproject.toml +1 -1
- package/vendor/orizu-gepa-python/src/orizu_gepa/cli.py +1 -0
- package/vendor/orizu-gepa-python/src/orizu_gepa/client.py +52 -7
- package/vendor/orizu-gepa-python/src/orizu_gepa/local_log.py +52 -0
- package/vendor/orizu-gepa-python/src/orizu_gepa/optimizer.py +10 -5
- package/vendor/orizu-gepa-python/src/orizu_gepa/reflection.py +323 -68
- package/vendor/orizu-gepa-python/src/orizu_gepa/runner.py +207 -13
- package/vendor/skills/orizu-cli/SKILL.md +3 -1
- package/vendor/skills/orizu-cli/references/cli-reference.md +85 -1
- package/vendor/skills/orizu-cli/references/migrate-existing-gepa-setup.md +303 -0
- package/vendor/skills/orizu-cli/references/optimization-reports.md +1 -1
- package/vendor/skills/orizu-cli/references/optimization-with-gepa.md +26 -1
- package/vendor/skills/orizu-cli/references/prompt-control-plane.md +113 -10
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import json
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
import litellm
|
|
6
|
+
from terminal_bench.agents.terminus_1 import AgentResult, Chat, FailureMode, Terminus
|
|
7
|
+
from terminal_bench.dataset.dataset import Dataset
|
|
8
|
+
from terminal_bench.terminal.tmux_session import TmuxSession
|
|
9
|
+
|
|
10
|
+
from gepa import optimize
|
|
11
|
+
from gepa.adapters.terminal_bench_adapter.terminal_bench_adapter import (
|
|
12
|
+
TerminalBenchTask,
|
|
13
|
+
TerminusAdapter,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
INSTRUCTION_PROMPT_PATH = Path(__file__).parent / "prompt-templates/instruction_prompt.txt"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class TerminusWrapper(Terminus):
|
|
20
|
+
def __init__(
|
|
21
|
+
self,
|
|
22
|
+
model_name: str,
|
|
23
|
+
max_episodes: int = 50,
|
|
24
|
+
api_base: str | None = None,
|
|
25
|
+
**kwargs,
|
|
26
|
+
):
|
|
27
|
+
self.PROMPT_TEMPLATE_PATH = Path(__file__).parent / "prompt-templates/terminus.txt"
|
|
28
|
+
self.instruction_prompt = INSTRUCTION_PROMPT_PATH.read_text()
|
|
29
|
+
super().__init__(model_name, max_episodes, api_base, **kwargs)
|
|
30
|
+
|
|
31
|
+
def perform_task(
|
|
32
|
+
self,
|
|
33
|
+
instruction: str,
|
|
34
|
+
session: TmuxSession,
|
|
35
|
+
logging_dir: Path | None = None,
|
|
36
|
+
):
|
|
37
|
+
chat = Chat(self._llm)
|
|
38
|
+
|
|
39
|
+
initial_prompt = self.instruction_prompt + self._prompt_template.format(
|
|
40
|
+
response_schema=self._response_schema,
|
|
41
|
+
instruction=instruction,
|
|
42
|
+
history="",
|
|
43
|
+
terminal_state=session.capture_pane(),
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
self._run_agent_loop(initial_prompt, session, chat, logging_dir)
|
|
47
|
+
|
|
48
|
+
return AgentResult(
|
|
49
|
+
total_input_tokens=chat.total_input_tokens,
|
|
50
|
+
total_output_tokens=chat.total_output_tokens,
|
|
51
|
+
failure_mode=FailureMode.NONE,
|
|
52
|
+
timestamped_markers=self._timestamped_markers,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
if __name__ == "__main__":
|
|
57
|
+
parser = argparse.ArgumentParser()
|
|
58
|
+
parser.add_argument("--model_name", type=str, default="gpt-4o-mini")
|
|
59
|
+
parser.add_argument("--n_concurrent", type=int, default=6)
|
|
60
|
+
args = parser.parse_args()
|
|
61
|
+
|
|
62
|
+
initial_prompt_from_terminus = """
|
|
63
|
+
You are an AI assistant tasked with solving command-line tasks in a Linux environment. You will be given a task instruction and the output from previously executed commands. Your goal is to solve the task by providing batches of shell commands.
|
|
64
|
+
|
|
65
|
+
For each response:
|
|
66
|
+
1. Analyze the current state based on any terminal output provided
|
|
67
|
+
2. Determine the next set of commands needed to make progress
|
|
68
|
+
3. Decide if you need to see the output of these commands before proceeding
|
|
69
|
+
|
|
70
|
+
Don't include markdown formatting.
|
|
71
|
+
|
|
72
|
+
Note that you operate directly on the terminal from inside a tmux session. Use tmux keystrokes like `C-x` or `Escape` to interactively navigate the terminal. If you would like to execute a command that you have written you will need to append a newline character to the end of your command.
|
|
73
|
+
|
|
74
|
+
For example, if you write "ls -la" you will need to append a newline character to the end of your command like this: `ls -la\n`.
|
|
75
|
+
|
|
76
|
+
One thing to be very careful about is handling interactive sessions like less, vim, or git diff. In these cases, you should not wait for the output of the command. Instead, you should send the keystrokes to the terminal as if you were typing them.
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
terminal_bench_dataset = Dataset(name="terminal-bench-core", version="head")
|
|
80
|
+
terminal_bench_dataset.sort_by_duration()
|
|
81
|
+
|
|
82
|
+
terminal_bench_tasks = terminal_bench_dataset._tasks[::-1]
|
|
83
|
+
|
|
84
|
+
trainset = [
|
|
85
|
+
TerminalBenchTask(task_id=task.name, model_name=args.model_name) for task in terminal_bench_tasks[30:50]
|
|
86
|
+
]
|
|
87
|
+
valset = [TerminalBenchTask(task_id=task.name, model_name=args.model_name) for task in terminal_bench_tasks[:30]]
|
|
88
|
+
|
|
89
|
+
testset = [
|
|
90
|
+
TerminalBenchTask(task_id=task.name, model_name=args.model_name)
|
|
91
|
+
for task in terminal_bench_tasks[50:]
|
|
92
|
+
if task.name != "chem-rf"
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
reflection_lm_name = "openai/gpt-5"
|
|
96
|
+
reflection_lm = (
|
|
97
|
+
lambda prompt: litellm.completion(
|
|
98
|
+
model=reflection_lm_name,
|
|
99
|
+
messages=[{"role": "user", "content": prompt}],
|
|
100
|
+
reasoning_effort="high",
|
|
101
|
+
)
|
|
102
|
+
.choices[0]
|
|
103
|
+
.message.content
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
adapter = TerminusAdapter(n_concurrent=args.n_concurrent, instruction_prompt_path=INSTRUCTION_PROMPT_PATH)
|
|
107
|
+
testset_results_no_prompt = adapter.evaluate(testset, {"instruction_prompt": ""}, capture_traces=True)
|
|
108
|
+
testset_results_before_opt = adapter.evaluate(
|
|
109
|
+
testset,
|
|
110
|
+
{"instruction_prompt": initial_prompt_from_terminus},
|
|
111
|
+
capture_traces=True,
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
with open("gepa_terminus/testset_results_no_prompt.json", "w") as f:
|
|
115
|
+
json.dump(
|
|
116
|
+
{
|
|
117
|
+
"score": sum(trajectory["success"] for trajectory in testset_results_no_prompt.trajectories),
|
|
118
|
+
"trajectories": testset_results_no_prompt.trajectories,
|
|
119
|
+
},
|
|
120
|
+
f,
|
|
121
|
+
indent=4,
|
|
122
|
+
)
|
|
123
|
+
with open("gepa_terminus/testset_results_before_opt.json", "w") as f:
|
|
124
|
+
json.dump(
|
|
125
|
+
{
|
|
126
|
+
"score": sum(trajectory["success"] for trajectory in testset_results_before_opt.trajectories),
|
|
127
|
+
"trajectories": testset_results_before_opt.trajectories,
|
|
128
|
+
},
|
|
129
|
+
f,
|
|
130
|
+
indent=4,
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
optimized_results = optimize(
|
|
134
|
+
seed_candidate={"instruction_prompt": initial_prompt_from_terminus},
|
|
135
|
+
trainset=trainset,
|
|
136
|
+
valset=valset,
|
|
137
|
+
adapter=adapter,
|
|
138
|
+
reflection_lm=reflection_lm,
|
|
139
|
+
use_wandb=True,
|
|
140
|
+
max_metric_calls=400,
|
|
141
|
+
reflection_minibatch_size=3,
|
|
142
|
+
perfect_score=1,
|
|
143
|
+
skip_perfect_score=False,
|
|
144
|
+
run_dir="gepa_terminus",
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
testset_results_after_opt = adapter.evaluate(
|
|
148
|
+
testset,
|
|
149
|
+
{"instruction_prompt": optimized_results.best_candidate["instruction_prompt"]},
|
|
150
|
+
capture_traces=True,
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
with open("gepa_terminus/optimized_results.json", "w") as f:
|
|
154
|
+
json.dump(
|
|
155
|
+
{
|
|
156
|
+
"score": sum(trajectory["success"] for trajectory in testset_results_after_opt.trajectories),
|
|
157
|
+
"trajectories": testset_results_after_opt.trajectories,
|
|
158
|
+
},
|
|
159
|
+
f,
|
|
160
|
+
indent=4,
|
|
161
|
+
)
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Copyright (c) 2025 Lakshya A Agrawal and the GEPA contributors
|
|
2
|
+
# https://github.com/gepa-ai/gepa
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
import random
|
|
6
|
+
from typing import Any, Mapping
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def json_default(x):
|
|
10
|
+
"""Default JSON encoder for objects that are not serializable by default."""
|
|
11
|
+
try:
|
|
12
|
+
return {**x}
|
|
13
|
+
except Exception:
|
|
14
|
+
return repr(x)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def idxmax(lst: list[float]) -> int:
|
|
18
|
+
"""Return the index of the maximum value in a list."""
|
|
19
|
+
max_val = max(lst)
|
|
20
|
+
return lst.index(max_val)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def is_dominated(y, programs, program_at_pareto_front_valset):
|
|
24
|
+
y_fronts = [front for front in program_at_pareto_front_valset.values() if y in front]
|
|
25
|
+
for front in y_fronts:
|
|
26
|
+
found_dominator_in_front = False
|
|
27
|
+
for other_prog in front:
|
|
28
|
+
if other_prog in programs:
|
|
29
|
+
found_dominator_in_front = True
|
|
30
|
+
break
|
|
31
|
+
if not found_dominator_in_front:
|
|
32
|
+
return False
|
|
33
|
+
|
|
34
|
+
return True
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def remove_dominated_programs(program_at_pareto_front_valset, scores=None):
|
|
38
|
+
freq = {}
|
|
39
|
+
for front in program_at_pareto_front_valset.values():
|
|
40
|
+
for p in front:
|
|
41
|
+
freq[p] = freq.get(p, 0) + 1
|
|
42
|
+
|
|
43
|
+
dominated = set()
|
|
44
|
+
programs = list(freq.keys())
|
|
45
|
+
|
|
46
|
+
if scores is None:
|
|
47
|
+
scores = dict.fromkeys(programs, 1)
|
|
48
|
+
|
|
49
|
+
programs = sorted(programs, key=lambda x: scores[x], reverse=False)
|
|
50
|
+
|
|
51
|
+
found_to_remove = True
|
|
52
|
+
while found_to_remove:
|
|
53
|
+
found_to_remove = False
|
|
54
|
+
for y in programs:
|
|
55
|
+
if y in dominated:
|
|
56
|
+
continue
|
|
57
|
+
if is_dominated(y, set(programs).difference({y}).difference(dominated), program_at_pareto_front_valset):
|
|
58
|
+
dominated.add(y)
|
|
59
|
+
found_to_remove = True
|
|
60
|
+
break
|
|
61
|
+
|
|
62
|
+
dominators = [p for p in programs if p not in dominated]
|
|
63
|
+
for front in program_at_pareto_front_valset.values():
|
|
64
|
+
if not front:
|
|
65
|
+
continue
|
|
66
|
+
assert any(p in front for p in dominators)
|
|
67
|
+
|
|
68
|
+
new_program_at_pareto_front_valset = {
|
|
69
|
+
val_id: {prog_idx for prog_idx in front if prog_idx in dominators}
|
|
70
|
+
for val_id, front in program_at_pareto_front_valset.items()
|
|
71
|
+
}
|
|
72
|
+
for val_id, front_new in new_program_at_pareto_front_valset.items():
|
|
73
|
+
assert front_new.issubset(program_at_pareto_front_valset[val_id])
|
|
74
|
+
|
|
75
|
+
return new_program_at_pareto_front_valset
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def find_dominator_programs(pareto_front_programs, train_val_weighted_agg_scores_for_all_programs):
|
|
79
|
+
train_val_pareto_front_programs = pareto_front_programs
|
|
80
|
+
new_program_at_pareto_front_valset = remove_dominated_programs(
|
|
81
|
+
train_val_pareto_front_programs, scores=train_val_weighted_agg_scores_for_all_programs
|
|
82
|
+
)
|
|
83
|
+
uniq_progs = []
|
|
84
|
+
for front in new_program_at_pareto_front_valset.values():
|
|
85
|
+
uniq_progs.extend(front)
|
|
86
|
+
uniq_progs = set(uniq_progs)
|
|
87
|
+
return list(uniq_progs)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def select_program_candidate_from_pareto_front(
|
|
91
|
+
pareto_front_programs: Mapping[Any, set[int]],
|
|
92
|
+
train_val_weighted_agg_scores_for_all_programs: list[float],
|
|
93
|
+
rng: random.Random,
|
|
94
|
+
) -> int:
|
|
95
|
+
train_val_pareto_front_programs = pareto_front_programs
|
|
96
|
+
new_program_at_pareto_front_valset = remove_dominated_programs(
|
|
97
|
+
train_val_pareto_front_programs, scores=train_val_weighted_agg_scores_for_all_programs
|
|
98
|
+
)
|
|
99
|
+
program_frequency_in_validation_pareto_front = {}
|
|
100
|
+
for testcase_pareto_front in new_program_at_pareto_front_valset.values():
|
|
101
|
+
for prog_idx in testcase_pareto_front:
|
|
102
|
+
if prog_idx not in program_frequency_in_validation_pareto_front:
|
|
103
|
+
program_frequency_in_validation_pareto_front[prog_idx] = 0
|
|
104
|
+
program_frequency_in_validation_pareto_front[prog_idx] += 1
|
|
105
|
+
|
|
106
|
+
sampling_list = [
|
|
107
|
+
prog_idx for prog_idx, freq in program_frequency_in_validation_pareto_front.items() for _ in range(freq)
|
|
108
|
+
]
|
|
109
|
+
|
|
110
|
+
# TODO: Determine if we need this fallback
|
|
111
|
+
# if not sampling_list:
|
|
112
|
+
# # No Pareto programs survived; fall back to the globally highest-scoring program.
|
|
113
|
+
# return idxmax(train_val_weighted_agg_scores_for_all_programs)
|
|
114
|
+
assert len(sampling_list) > 0
|
|
115
|
+
|
|
116
|
+
curr_prog_id = rng.choice(sampling_list)
|
|
117
|
+
return curr_prog_id
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# gskill: Learning Repository-Specific Skills for Coding Agents
|
|
File without changes
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Unified cost tracker for GEPA optimization.
|
|
3
|
+
Uses LiteLLM's built-in cost tracking for accuracy.
|
|
4
|
+
Thread-safe for parallel execution.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import json
|
|
8
|
+
import threading
|
|
9
|
+
from datetime import datetime
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
import litellm
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class UnifiedCostTracker:
|
|
16
|
+
"""
|
|
17
|
+
Thread-safe cost tracker that uses LiteLLM's built-in cost calculation.
|
|
18
|
+
Tracks agent and reflection costs separately.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(self, log_dir: str = "gepa_results/logs"):
|
|
22
|
+
self.log_dir = Path(log_dir)
|
|
23
|
+
self.log_dir.mkdir(parents=True, exist_ok=True)
|
|
24
|
+
|
|
25
|
+
self.session_start = datetime.now()
|
|
26
|
+
self._lock = threading.Lock()
|
|
27
|
+
|
|
28
|
+
# Counters
|
|
29
|
+
self.total_cost = 0.0
|
|
30
|
+
self.agent_cost = 0.0
|
|
31
|
+
self.reflection_cost = 0.0
|
|
32
|
+
self.call_count = 0
|
|
33
|
+
self.agent_calls = 0
|
|
34
|
+
self.reflection_calls = 0
|
|
35
|
+
self.total_tokens = 0
|
|
36
|
+
|
|
37
|
+
# Log files
|
|
38
|
+
timestamp = self.session_start.strftime("%Y%m%d_%H%M%S")
|
|
39
|
+
self.log_file = self.log_dir / f"cost_log_{timestamp}.jsonl"
|
|
40
|
+
self.summary_file = self.log_dir / "cost_summary.txt"
|
|
41
|
+
|
|
42
|
+
# Register LiteLLM callback
|
|
43
|
+
self._register_callback()
|
|
44
|
+
|
|
45
|
+
def _register_callback(self):
|
|
46
|
+
"""Register ourselves as a LiteLLM success callback."""
|
|
47
|
+
# Remove any existing callback to avoid duplicates
|
|
48
|
+
litellm.success_callback = [self._on_completion]
|
|
49
|
+
|
|
50
|
+
def _on_completion(self, kwargs, completion_response, start_time, end_time):
|
|
51
|
+
"""Called by LiteLLM after each successful completion."""
|
|
52
|
+
with self._lock:
|
|
53
|
+
self.call_count += 1
|
|
54
|
+
call_num = self.call_count
|
|
55
|
+
|
|
56
|
+
# Get model name
|
|
57
|
+
model = kwargs.get("model", "unknown")
|
|
58
|
+
|
|
59
|
+
# Calculate cost using LiteLLM's built-in function
|
|
60
|
+
try:
|
|
61
|
+
cost = litellm.completion_cost(completion_response=completion_response)
|
|
62
|
+
except Exception:
|
|
63
|
+
cost = 0.0
|
|
64
|
+
|
|
65
|
+
# Get token usage
|
|
66
|
+
tokens = 0
|
|
67
|
+
if hasattr(completion_response, "usage") and completion_response.usage:
|
|
68
|
+
tokens = getattr(completion_response.usage, "total_tokens", 0)
|
|
69
|
+
self.total_tokens += tokens
|
|
70
|
+
|
|
71
|
+
# Categorize: reflection models typically have "pro" in name
|
|
72
|
+
is_reflection = "pro" in model.lower() or "reflection" in kwargs.get("metadata", {}).get("type", "")
|
|
73
|
+
|
|
74
|
+
if is_reflection:
|
|
75
|
+
self.reflection_cost += cost
|
|
76
|
+
self.reflection_calls += 1
|
|
77
|
+
call_type = "REFLECTION"
|
|
78
|
+
else:
|
|
79
|
+
self.agent_cost += cost
|
|
80
|
+
self.agent_calls += 1
|
|
81
|
+
call_type = "AGENT"
|
|
82
|
+
|
|
83
|
+
self.total_cost += cost
|
|
84
|
+
|
|
85
|
+
# Log entry
|
|
86
|
+
entry = {
|
|
87
|
+
"timestamp": datetime.now().isoformat(),
|
|
88
|
+
"call_number": call_num,
|
|
89
|
+
"type": call_type,
|
|
90
|
+
"model": model,
|
|
91
|
+
"tokens": tokens,
|
|
92
|
+
"cost": cost,
|
|
93
|
+
"cumulative_cost": self.total_cost,
|
|
94
|
+
"agent_cost": self.agent_cost,
|
|
95
|
+
"reflection_cost": self.reflection_cost,
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
# Write to log file
|
|
99
|
+
try:
|
|
100
|
+
with open(self.log_file, "a") as f:
|
|
101
|
+
f.write(json.dumps(entry) + "\n")
|
|
102
|
+
except Exception:
|
|
103
|
+
pass
|
|
104
|
+
|
|
105
|
+
# Cost tracking is silent - check log file or call print_summary() for details
|
|
106
|
+
|
|
107
|
+
def write_summary(self) -> str:
|
|
108
|
+
"""Write human-readable summary to file and return it."""
|
|
109
|
+
with self._lock:
|
|
110
|
+
elapsed = (datetime.now() - self.session_start).total_seconds()
|
|
111
|
+
elapsed_min = elapsed / 60
|
|
112
|
+
|
|
113
|
+
summary = f"""
|
|
114
|
+
================================================================================
|
|
115
|
+
GEPA COST TRACKER - Experiment Summary
|
|
116
|
+
================================================================================
|
|
117
|
+
|
|
118
|
+
Session Start: {self.session_start.strftime("%Y-%m-%d %H:%M:%S")}
|
|
119
|
+
Elapsed Time: {elapsed_min:.1f} minutes
|
|
120
|
+
|
|
121
|
+
COST BREAKDOWN
|
|
122
|
+
--------------
|
|
123
|
+
Agent Calls: {self.agent_calls:,} calls | ${self.agent_cost:.4f}
|
|
124
|
+
Reflection Calls: {self.reflection_calls:,} calls | ${self.reflection_cost:.4f}
|
|
125
|
+
Total Calls: {self.call_count:,} calls | ${self.total_cost:.4f}
|
|
126
|
+
|
|
127
|
+
Total Tokens: {self.total_tokens:,}
|
|
128
|
+
|
|
129
|
+
RATES
|
|
130
|
+
-----
|
|
131
|
+
Cost Rate: ${self.total_cost / elapsed_min:.4f}/min
|
|
132
|
+
Call Rate: {self.call_count / elapsed_min:.1f} calls/min
|
|
133
|
+
|
|
134
|
+
PER-UNIT ESTIMATES
|
|
135
|
+
------------------
|
|
136
|
+
Per Agent Call: ${self.agent_cost / max(self.agent_calls, 1):.4f}
|
|
137
|
+
Per Reflection Call: ${self.reflection_cost / max(self.reflection_calls, 1):.4f}
|
|
138
|
+
|
|
139
|
+
Log file: {self.log_file}
|
|
140
|
+
================================================================================
|
|
141
|
+
"""
|
|
142
|
+
with open(self.summary_file, "w") as f:
|
|
143
|
+
f.write(summary)
|
|
144
|
+
|
|
145
|
+
return summary
|
|
146
|
+
|
|
147
|
+
def get_stats(self) -> dict:
|
|
148
|
+
"""Get current stats as a dictionary."""
|
|
149
|
+
with self._lock:
|
|
150
|
+
elapsed = (datetime.now() - self.session_start).total_seconds()
|
|
151
|
+
return {
|
|
152
|
+
"total_cost": self.total_cost,
|
|
153
|
+
"agent_cost": self.agent_cost,
|
|
154
|
+
"reflection_cost": self.reflection_cost,
|
|
155
|
+
"total_calls": self.call_count,
|
|
156
|
+
"agent_calls": self.agent_calls,
|
|
157
|
+
"reflection_calls": self.reflection_calls,
|
|
158
|
+
"total_tokens": self.total_tokens,
|
|
159
|
+
"elapsed_seconds": elapsed,
|
|
160
|
+
"cost_per_minute": self.total_cost / (elapsed / 60) if elapsed > 0 else 0,
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
def print_summary(self):
|
|
164
|
+
"""Print and save final summary."""
|
|
165
|
+
summary = self.write_summary()
|
|
166
|
+
print(summary)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
# Global tracker instance
|
|
170
|
+
_tracker: UnifiedCostTracker | None = None
|
|
171
|
+
_tracker_lock = threading.Lock()
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def get_tracker(log_dir: str = "gepa_results/logs") -> UnifiedCostTracker:
|
|
175
|
+
"""Get or create global tracker instance."""
|
|
176
|
+
global _tracker
|
|
177
|
+
with _tracker_lock:
|
|
178
|
+
if _tracker is None:
|
|
179
|
+
_tracker = UnifiedCostTracker(log_dir=log_dir)
|
|
180
|
+
return _tracker
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def reset_tracker(log_dir: str = "gepa_results/logs") -> UnifiedCostTracker:
|
|
184
|
+
"""Reset and create a new tracker instance."""
|
|
185
|
+
global _tracker
|
|
186
|
+
with _tracker_lock:
|
|
187
|
+
_tracker = UnifiedCostTracker(log_dir=log_dir)
|
|
188
|
+
return _tracker
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
# For backwards compatibility
|
|
192
|
+
def log_call(model_name, input_tokens, output_tokens, operation="unknown"):
|
|
193
|
+
"""Legacy function - now a no-op since LiteLLM callbacks handle tracking."""
|
|
194
|
+
pass # Tracking is now automatic via LiteLLM callbacks
|
|
File without changes
|