feat: Support LLM_API_KEY environment variable override for benchmark configs #302
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for overriding the
api_keyin LLM configuration files via theLLM_API_KEYenvironment variable. This allows cloud environments to inject the API key via secrets (e.g.,secrets.LLM_API_KEY_EVAL) without modifying the config files.Fixes #301
Changes
New utility function: Added
benchmarks/utils/llm_config.pywithload_llm_config()function that:LLM_API_KEYenvironment variableapi_keyin the config with the environment variable valueLLMinstanceUpdated all benchmark run_infer.py files to use the new utility:
benchmarks/swebench/run_infer.pybenchmarks/swtbench/run_infer.pybenchmarks/gaia/run_infer.pybenchmarks/commit0/run_infer.pybenchmarks/multiswebench/run_infer.pybenchmarks/swebenchmultimodal/run_infer.pybenchmarks/openagentsafety/run_infer.pyUpdated validate_cfg.py to use the new utility for consistency
Added comprehensive tests in
tests/test_llm_config.py:LLM_API_KEYenv var overrides the config file api_keyUsage
When running benchmarks in the cloud, set the
LLM_API_KEYenvironment variable:The benchmark will automatically use this value instead of the
api_keyin the JSON config file.Testing
@simonrosenberg can click here to continue refining the PR