eval harness: API keys from a file, mock-server tests for both API providers
--key-file / key_file: first line is the key, never recorded (only its source). Self-tests run the openai and anthropic providers against a local mock server: request translation, extras, token parameter, auth, tool loop, token accounting, and no key in the record.
This commit is contained in:
1 parent
d7bb9273f3
commit
2c1fdf1cc6
3 files changed
+100
-11
No files matched your search
@@ -31,7 +31,7 @@ def cmd_run(a):
|
||||
a.task, a.language, a.provider, a.model, a.out, model_class=a.model_class, seed=a.seed, sandbox_kind=a.sandbox,
|
||||
evaluator=shlex.split(a.evaluator) if a.evaluator else None, evaluator_hash_path=a.evaluator_hash_path,
|
||||
pricing=load_pricing(a.pricing), base_url=a.base_url, max_tokens=a.max_tokens, temperature=a.temperature,
|
||||
provider_options={k: v for k, v in {"extra": json.loads(a.extra) if a.extra else None, "key_env": a.key_env, "token_param": a.token_param}.items() if v})
|
||||
provider_options={k: v for k, v in {"extra": json.loads(a.extra) if a.extra else None, "key_env": a.key_env, "key_file": a.key_file, "token_param": a.token_param}.items() if v})
|
||||
m = rec["metrics"]
|
||||
print(json.dumps({"run": run_dir, "termination": m["termination"], "accepted": rec["accepted"], "tool_calls": m["tool_calls"],
|
||||
"input_tokens": m["input_tokens"], "output_tokens": m["output_tokens"], "cost_usd": rec["cost_usd"]}))
|
||||
@@ -66,7 +66,7 @@ def cmd_matrix(a):
|
||||
sandbox_kind=plan.get("sandbox", "bwrap"), evaluator=evaluator, evaluator_hash_path=hash_path,
|
||||
pricing=pricing, base_url=mdl.get("base_url"), max_tokens=mdl.get("max_tokens", 8192), temperature=mdl.get("temperature"),
|
||||
limits=plan.get("limits"),
|
||||
provider_options={k: mdl[k] for k in ("extra", "key_env", "token_param") if k in mdl})
|
||||
provider_options={k: mdl[k] for k in ("extra", "key_env", "key_file", "token_param") if k in mdl})
|
||||
print(f" -> {rec['metrics']['termination']}, accepted={rec['accepted']}", file=sys.stderr)
|
||||
report.print_report([out])
|
||||
|
||||
@@ -100,6 +100,7 @@ def main(argv=None):
|
||||
r.add_argument("--temperature", type=float)
|
||||
r.add_argument("--extra", help='JSON merged into every request body, e.g. {"reasoning_effort": "medium"}')
|
||||
r.add_argument("--key-env", help="name of the environment variable holding the API key (openai provider)")
|
||||
r.add_argument("--key-file", help="file whose first line is the API key (never recorded)")
|
||||
r.add_argument("--token-param", help="max_tokens or max_completion_tokens (openai provider)")
|
||||
r.set_defaults(fn=cmd_run)
|
||||
|
||||
|
||||
Reference in new issue
Block a user