evalrouter 0.3.2__tar.gz → 0.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {evalrouter-0.3.2 → evalrouter-0.3.4}/PKG-INFO +7 -5
  2. {evalrouter-0.3.2 → evalrouter-0.3.4}/README.md +6 -4
  3. {evalrouter-0.3.2 → evalrouter-0.3.4}/pyproject.toml +1 -1
  4. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/evalrouter_contracts/__init__.py +1 -1
  5. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/kimpton_evalrouter/__init__.py +1 -1
  6. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/kimpton_evalrouter/_account.py +87 -12
  7. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/kimpton_evalrouter/_boundary.py +14 -1
  8. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/kimpton_evalrouter/_guided.py +80 -2
  9. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/kimpton_evalrouter/cli.py +902 -60
  10. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/kimpton_evalrouter/render/live.py +31 -0
  11. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/kimpton_evalrouter/render/screens.py +93 -6
  12. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/kimpton_evalrouter/types.py +49 -2
  13. {evalrouter-0.3.2 → evalrouter-0.3.4}/LICENSE +0 -0
  14. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/evalrouter_contracts/bundle.py +0 -0
  15. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/evalrouter_contracts/components.py +0 -0
  16. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/evalrouter_contracts/models.py +0 -0
  17. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/evalrouter_contracts/protocol.py +0 -0
  18. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/evalrouter_contracts/py.typed +0 -0
  19. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/evalrouter_contracts/templates.py +0 -0
  20. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/evalrouter_contracts/validation.py +0 -0
  21. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/kimpton_evalrouter/__main__.py +0 -0
  22. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/kimpton_evalrouter/_helpers.py +0 -0
  23. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/kimpton_evalrouter/_listing.py +0 -0
  24. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/kimpton_evalrouter/_resources.py +0 -0
  25. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/kimpton_evalrouter/_transport.py +0 -0
  26. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/kimpton_evalrouter/py.typed +0 -0
  27. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/kimpton_evalrouter/render/__init__.py +0 -0
  28. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/kimpton_evalrouter/render/_console.py +0 -0
  29. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/kimpton_evalrouter/render/_theme.py +0 -0
  30. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/kimpton_evalrouter/render/_widgets.py +0 -0
  31. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/kimpton_evalrouter/render/picker.py +0 -0
  32. {evalrouter-0.3.2 → evalrouter-0.3.4}/src/kimpton_evalrouter/render/tables.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: evalrouter
3
- Version: 0.3.2
3
+ Version: 0.3.4
4
4
  Summary: Typed Kimpton evaluation client and command-line interface
5
5
  License-Expression: LicenseRef-Kimpton-EvalRouter-SDK
6
6
  License-File: LICENSE
@@ -38,7 +38,8 @@ the `kimpton_evalrouter` import and every API are unchanged. To switch, run
38
38
  `pip uninstall -y kimpton-evalrouter-sdk evalrouter`) and install `evalrouter`.
39
39
 
40
40
  The package supplies the `evalrouter` command; no repository checkout is needed.
41
- Run the browser sign-in below to sign in or create your account.
41
+ [Create an EvalRouter account](https://evalrouter.ai/register), verify your email,
42
+ and follow the browser sign-in below.
42
43
  Package installation does not grant account access or evaluation credit.
43
44
 
44
45
  Sign in with your account:
@@ -48,9 +49,10 @@ evalrouter login
48
49
  evalrouter whoami
49
50
  ```
50
51
 
51
- The browser guides you through sign-up or sign-in, email verification and
52
- terminal approval. The CLI resumes automatically and selects your only workspace.
53
- Production is the default API, with `--base-url` available for other environments.
52
+ Approve the browser code. New accounts finish setup on the website; the CLI
53
+ continues when that is complete. It selects your only workspace automatically.
54
+ Production is the default API; `evalrouter options` lists `--base-url` and the other
55
+ settings that apply to every command.
54
56
  No API key or credential-storage setup is needed for a normal sign-in.
55
57
 
56
58
  CI and services can use `EVALROUTER_API_KEY` and `EVALROUTER_WORKSPACE_ID` supplied
@@ -23,7 +23,8 @@ the `kimpton_evalrouter` import and every API are unchanged. To switch, run
23
23
  `pip uninstall -y kimpton-evalrouter-sdk evalrouter`) and install `evalrouter`.
24
24
 
25
25
  The package supplies the `evalrouter` command; no repository checkout is needed.
26
- Run the browser sign-in below to sign in or create your account.
26
+ [Create an EvalRouter account](https://evalrouter.ai/register), verify your email,
27
+ and follow the browser sign-in below.
27
28
  Package installation does not grant account access or evaluation credit.
28
29
 
29
30
  Sign in with your account:
@@ -33,9 +34,10 @@ evalrouter login
33
34
  evalrouter whoami
34
35
  ```
35
36
 
36
- The browser guides you through sign-up or sign-in, email verification and
37
- terminal approval. The CLI resumes automatically and selects your only workspace.
38
- Production is the default API, with `--base-url` available for other environments.
37
+ Approve the browser code. New accounts finish setup on the website; the CLI
38
+ continues when that is complete. It selects your only workspace automatically.
39
+ Production is the default API; `evalrouter options` lists `--base-url` and the other
40
+ settings that apply to every command.
39
41
  No API key or credential-storage setup is needed for a normal sign-in.
40
42
 
41
43
  CI and services can use `EVALROUTER_API_KEY` and `EVALROUTER_WORKSPACE_ID` supplied
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "evalrouter"
7
- version = "0.3.2"
7
+ version = "0.3.4"
8
8
  description = "Typed Kimpton evaluation client and command-line interface"
9
9
  readme = "README.md"
10
10
  license = "LicenseRef-Kimpton-EvalRouter-SDK"
@@ -8,4 +8,4 @@ computes digests and refuses invalid packages; it never imports contributed
8
8
  code, opens a network connection, signs anything or carries operator state.
9
9
  """
10
10
 
11
- __version__ = "0.3.2"
11
+ __version__ = "0.3.4"
@@ -26,7 +26,7 @@ __all__ = [
26
26
  "WaitCancelled",
27
27
  "types",
28
28
  ]
29
- __version__ = "0.3.2"
29
+ __version__ = "0.3.4"
30
30
 
31
31
 
32
32
  class Client(_Transport):
@@ -27,6 +27,7 @@ import getpass
27
27
  import json
28
28
  import os
29
29
  import re
30
+ import select
30
31
  import socket
31
32
  import stat
32
33
  import sys
@@ -604,6 +605,47 @@ def _tokens(value, now: float) -> dict:
604
605
  }
605
606
 
606
607
 
608
+ class _RestartDeviceLogin(Exception):
609
+ """The customer requested a new code; the pending request is abandoned."""
610
+
611
+
612
+ def _wait_for_login_restart(delay: float | None) -> bool:
613
+ """Wait for Enter without a reader thread that could outlive login.
614
+
615
+ Called only with interactive stdin/stderr, never for pipes or --json.
616
+ A timeout preserves OAuth polling cadence; EOF cannot trigger a retry loop.
617
+ """
618
+ if sys.platform == "win32":
619
+ import msvcrt
620
+
621
+ deadline = time.monotonic() + delay if delay is not None else None
622
+ while deadline is None or time.monotonic() < deadline:
623
+ if msvcrt.kbhit():
624
+ key = msvcrt.getwch()
625
+ if key in ("\r", "\n"):
626
+ return True
627
+ if key == "\x03":
628
+ raise KeyboardInterrupt
629
+ if key in ("\x00", "\xe0"):
630
+ msvcrt.getwch() # extended key, not an Enter request
631
+ remaining = max(0, deadline - time.monotonic()) if deadline is not None else 0.1
632
+ time.sleep(min(0.1, remaining))
633
+ return False
634
+ started = time.monotonic()
635
+ try:
636
+ ready, _, _ = select.select([sys.stdin], [], [], delay)
637
+ if not ready:
638
+ return False
639
+ if sys.stdin.readline():
640
+ return True
641
+ except (OSError, ValueError):
642
+ pass
643
+ # Closed/unsupported input must not shorten the provider's polling interval.
644
+ if delay is not None:
645
+ time.sleep(max(0, delay - (time.monotonic() - started)))
646
+ return False
647
+
648
+
607
649
  def poll_for_tokens(
608
650
  http: httpx.Client,
609
651
  config: dict,
@@ -612,6 +654,7 @@ def poll_for_tokens(
612
654
  sleep=time.sleep,
613
655
  clock=time.monotonic,
614
656
  wall=time.time,
657
+ wait_for_restart=None,
615
658
  ) -> dict:
616
659
  """Poll the token endpoint per RFC 8628, honoring slow_down and expiry."""
617
660
  interval = device.get("interval")
@@ -620,7 +663,10 @@ def poll_for_tokens(
620
663
  lifetime = float(lifetime) if isinstance(lifetime, (int, float)) and lifetime > 0 else 300
621
664
  deadline = clock() + lifetime
622
665
  while True:
623
- sleep(interval)
666
+ if wait_for_restart is None:
667
+ sleep(interval)
668
+ elif wait_for_restart(interval):
669
+ raise _RestartDeviceLogin
624
670
  if clock() >= deadline:
625
671
  raise ClientError(
626
672
  "login_expired", "The sign-in code expired. Run `evalrouter login` again."
@@ -1156,17 +1202,46 @@ def login(
1156
1202
  )
1157
1203
  store.update_server(base, login_advertised=True)
1158
1204
  config = auth0_config(base, advertisement)
1159
- device = start_device_authorization(http, config)
1160
- target = connect_target(base, device)
1161
- notice("Open this link to sign in or create an account:")
1162
- notice(target)
1163
- notice(f"Your terminal code: {device['user_code']}")
1164
- if not getattr(args, "no_browser", False) and _interactive():
1165
- with contextlib.suppress(Exception):
1166
- if open_browser(target):
1167
- notice("Opened your browser. Finish connecting there.")
1168
- notice("Waiting for you to finish in the browser...")
1169
- tokens = poll_for_tokens(http, config, device, sleep=sleep)
1205
+ interactive = _interactive() and not getattr(args, "json", False)
1206
+ while True:
1207
+ device = start_device_authorization(http, config)
1208
+ target = connect_target(base, device)
1209
+ notice("Open this link to sign in or create an account:")
1210
+ notice(target)
1211
+ notice(f"Your terminal code: {device['user_code']}")
1212
+ notice(f"Approval continues at {urlsplit(config['issuer']).netloc}:")
1213
+ notice(" 1. Confirm your terminal code.")
1214
+ notice(" 2. Sign in if asked, even if the website already recognizes you.")
1215
+ notice(" 3. Keep the tab open until it says Device connected.")
1216
+ notice("Confirming the code alone does not finish sign-in.")
1217
+ if not getattr(args, "no_browser", False) and _interactive():
1218
+ with contextlib.suppress(Exception):
1219
+ if open_browser(target):
1220
+ notice("Opened your browser. Finish connecting there.")
1221
+ notice("Waiting for browser approval...")
1222
+ if interactive:
1223
+ notice("Closed the tab or see an invalid code? Press Enter for a new code.")
1224
+ notice("Press Ctrl+C to cancel.")
1225
+ else:
1226
+ notice("Invalid or expired code? Restart `evalrouter login` for a new link.")
1227
+ try:
1228
+ tokens = poll_for_tokens(
1229
+ http, config, device, sleep=sleep,
1230
+ wait_for_restart=_wait_for_login_restart if interactive else None,
1231
+ )
1232
+ break
1233
+ except _RestartDeviceLogin:
1234
+ notice("Starting a new request. Close the earlier tab and use the new link.")
1235
+ except ClientError as error:
1236
+ if error.code != "login_expired" or not interactive:
1237
+ raise
1238
+ notice("This code expired. Press Enter for a new code, or Ctrl+C to cancel.")
1239
+ if not _wait_for_login_restart(None):
1240
+ raise
1241
+ except KeyboardInterrupt:
1242
+ raise ClientError(
1243
+ "login_cancelled", "Sign-in cancelled. You can close the browser tab."
1244
+ ) from None
1170
1245
  finally:
1171
1246
  if owned:
1172
1247
  http.close()
@@ -5,6 +5,9 @@ import re as _re
5
5
 
6
6
  from ._transport import ClientError
7
7
 
8
+ # Quote output formats (additive; the server resolves and freezes the choice).
9
+ OUTPUT_FORMATS = frozenset({"default", "leaderboard", "prompt_json", "native_json", "json_schema"})
10
+
8
11
 
9
12
  def validate_submission(resource, body):
10
13
  if resource == "agent_builds":
@@ -129,6 +132,16 @@ def validate_submission(resource, body):
129
132
  raise ClientError(
130
133
  "invalid_input", "Concurrency must be auto, max, or an integer from 1 to 100."
131
134
  )
135
+ if (
136
+ resource == "quotes"
137
+ and isinstance(body, dict)
138
+ and "output_format" in body
139
+ and body["output_format"] not in OUTPUT_FORMATS
140
+ ):
141
+ raise ClientError(
142
+ "invalid_input",
143
+ "Output format must be default, leaderboard, prompt_json, native_json or json_schema.",
144
+ )
132
145
  if resource == "quotes" and isinstance(body, dict) and "agent" in body:
133
146
  selection = body.get("selection")
134
147
  if (
@@ -145,7 +158,7 @@ def validate_submission(resource, body):
145
158
  )
146
159
  return body
147
160
  allowed = (
148
- {"selection", "model", "coverage", "max_charge_microusd", "concurrency"}
161
+ {"selection", "model", "coverage", "max_charge_microusd", "concurrency", "output_format"}
149
162
  if resource == "quotes"
150
163
  else {
151
164
  "model",
@@ -179,6 +179,7 @@ def add_run_arguments(run, concurrency_type) -> None:
179
179
  metavar="auto|max|1..100",
180
180
  help="Requested model-request ceiling for the new quote",
181
181
  )
182
+ add_format_argument(run)
182
183
  run.add_argument(
183
184
  "-y", "--yes", action="store_true", help="Start without asking (needs a cap off-terminal)"
184
185
  )
@@ -195,6 +196,23 @@ def add_run_arguments(run, concurrency_type) -> None:
195
196
  add_metrics_argument(run)
196
197
 
197
198
 
199
+ OUTPUT_FORMATS = ("default", "leaderboard", "prompt_json", "native_json", "json_schema")
200
+
201
+
202
+ def add_format_argument(parser) -> None:
203
+ """The output format for a benchmark version that declares selectable formats."""
204
+ parser.add_argument(
205
+ "--format",
206
+ dest="output_format",
207
+ choices=OUTPUT_FORMATS,
208
+ help=(
209
+ "Output format for versions that offer one (default: the version's default). "
210
+ "leaderboard runs native JSON and refuses a model without it; "
211
+ "results record the format and never mix formats"
212
+ ),
213
+ )
214
+
215
+
198
216
  def add_metrics_argument(parser) -> None:
199
217
  parser.add_argument(
200
218
  "--all-metrics",
@@ -227,6 +245,7 @@ def argument_conflict(args) -> str | None:
227
245
  ("--seed", args.seed),
228
246
  ("--max-cost", args.max_cost),
229
247
  ("--concurrency", args.concurrency),
248
+ ("--format", getattr(args, "output_format", None)),
230
249
  )
231
250
  if value not in (None, False)
232
251
  ]
@@ -714,6 +733,28 @@ def _version_record(client, slug: str, version: str | None) -> dict:
714
733
  )
715
734
 
716
735
 
736
+ #: A workspace-private benchmark created by `evalrouter benchmark create`.
737
+ PRIVATE_BENCHMARK = re.compile(
738
+ r"byob-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}@1"
739
+ )
740
+
741
+
742
+ def _private_record(client, term: str) -> dict:
743
+ value = client.request("GET", f"/private-benchmarks/{term}")
744
+ if not isinstance(value, dict) or value.get("id") != term:
745
+ raise ClientError("invalid_response", "The API returned another private benchmark.")
746
+ if value.get("status") != "active":
747
+ raise ClientError("benchmark_unavailable", f"{term} is archived and cannot start new runs.")
748
+ return {
749
+ "id": term,
750
+ "slug": term.split("@", 1)[0],
751
+ "version": "1",
752
+ "name": value.get("name"),
753
+ "task_count": value.get("row_count"),
754
+ "quote_availability": {"status": "ready_for_quote"},
755
+ }
756
+
757
+
717
758
  def resolve_benchmark(client, term: str | None, *, prompt: bool) -> dict:
718
759
  """One quotable benchmark profile record for a slug, name, `slug@version` or profile ID."""
719
760
  if not term and not prompt:
@@ -721,6 +762,9 @@ def resolve_benchmark(client, term: str | None, *, prompt: bool) -> dict:
721
762
  "benchmark_not_found",
722
763
  "Name a benchmark, for example: evalrouter run gpqa-diamond --model MODEL",
723
764
  )
765
+ if term and PRIVATE_BENCHMARK.fullmatch(term):
766
+ # Private benchmarks are never in the shared catalog listing.
767
+ return _private_record(client, term)
724
768
  if term and "@" in term:
725
769
  slug, _, version = term.partition("@")
726
770
  return _version_record(client, slug, version)
@@ -870,6 +914,21 @@ def _coverage_text(plan: dict) -> str:
870
914
  return text + (f", seed {seed}" if type(seed) is int else "")
871
915
 
872
916
 
917
+ def _format_text(plan: dict) -> str | None:
918
+ """The frozen output format(s) of a quote, when its versions declare one."""
919
+ selected = [
920
+ profile.get("output_format")
921
+ for profile in plan.get("profiles") or []
922
+ if isinstance(profile, dict) and isinstance(profile.get("output_format"), dict)
923
+ ]
924
+ names = list(dict.fromkeys(str(item.get("id")) for item in selected))
925
+ if not names:
926
+ return None
927
+ policies = {item.get("policy") for item in selected}
928
+ policy = "" if policies <= {"explicit", None} else f" ({', '.join(sorted(map(str, policies)))})"
929
+ return ", ".join(names) + policy
930
+
931
+
873
932
  def _concurrency_text(plan: dict) -> str | None:
874
933
  metadata = plan.get("concurrency")
875
934
  if not isinstance(metadata, dict):
@@ -950,7 +1009,14 @@ def parallel_note(quote: dict) -> str | None:
950
1009
  metadata = plan.get("concurrency") if isinstance(plan.get("concurrency"), dict) else None
951
1010
  if metadata is not None:
952
1011
  requested = metadata.get("requested")
953
- target = 4 if requested == "auto" else 100 if requested == "max" else requested
1012
+ # `auto` sizes itself from the route's latency (the admitted ceiling).
1013
+ target = (
1014
+ metadata.get("admitted_ceiling")
1015
+ if requested == "auto"
1016
+ else 100
1017
+ if requested == "max"
1018
+ else requested
1019
+ )
954
1020
  adapters = [
955
1021
  p.get("adapter_ceiling")
956
1022
  for p in metadata.get("profiles") or []
@@ -1021,7 +1087,14 @@ def quote_rows(
1021
1087
  ("Model", str(model or "unknown")),
1022
1088
  ("Coverage", _coverage_text(plan)),
1023
1089
  ]
1024
- if expected:
1090
+ quoted = render.screens.expected_costs(quote)
1091
+ if quoted is not None and (quoted[3] in {"measured", "planned"} or not expected):
1092
+ # The quote's own expected charge (measured usage) wins over the
1093
+ # derived figure from one earlier run.
1094
+ estimate, p50, p90, _ = quoted
1095
+ fmt = render.screens.format_cents
1096
+ rows.append(("Expected", f"~{fmt(estimate)} p50–p90 {fmt(p50)}–{fmt(p90)}"))
1097
+ elif expected:
1025
1098
  rows.append(
1026
1099
  (
1027
1100
  "Expected",
@@ -1062,6 +1135,9 @@ def quote_rows(
1062
1135
  concurrency = _concurrency_text(plan)
1063
1136
  if concurrency:
1064
1137
  rows.append(("Concurrency", concurrency))
1138
+ output_format = _format_text(plan)
1139
+ if output_format:
1140
+ rows.append(("Output format", output_format))
1065
1141
  rows.append(("Expires", _expires_text(quote.get("expires_at"))))
1066
1142
  return rows
1067
1143
 
@@ -1443,6 +1519,8 @@ def _request(client, args, prompt: bool) -> tuple[dict, dict]:
1443
1519
  }
1444
1520
  if args.concurrency is not None:
1445
1521
  request["concurrency"] = args.concurrency
1522
+ if getattr(args, "output_format", None) is not None:
1523
+ request["output_format"] = args.output_format
1446
1524
  labels = {"benchmark": benchmark_label(record), "slug": record.get("slug"), "model": model_text}
1447
1525
  return request, labels
1448
1526