datalab-python-sdk 0.9.2__tar.gz → 0.10.0__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 (61) hide show
  1. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/CHANGELOG.md +18 -0
  2. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/PKG-INFO +13 -2
  3. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/README.md +12 -1
  4. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/datalab_sdk/__init__.py +18 -0
  5. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/datalab_sdk/cli.py +243 -0
  6. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/datalab_sdk/client.py +328 -11
  7. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/datalab_sdk/models.py +180 -3
  8. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/pyproject.toml +1 -1
  9. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/tests/test_api_consistency.py +1 -0
  10. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/tests/test_cli_simple.py +16 -4
  11. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/tests/test_client_methods.py +7 -3
  12. datalab_python_sdk-0.10.0/tests/test_evals.py +431 -0
  13. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/tests/test_new_endpoints.py +30 -0
  14. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/tests/test_progress.py +24 -0
  15. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/uv.lock +1 -1
  16. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/.github/workflows/ci.yml +0 -0
  17. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/.gitignore +0 -0
  18. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/.pre-commit-config.yaml +0 -0
  19. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/.python-version +0 -0
  20. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/LICENSE +0 -0
  21. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/data/08-Lambda-Calculus.pptx +0 -0
  22. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/data/adversarial.pdf +0 -0
  23. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/data/bid_evaluation.docx +0 -0
  24. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/data/book_review.ppt +0 -0
  25. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/data/book_store.xls +0 -0
  26. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/data/chi_hind.png +0 -0
  27. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/data/how_to_read.doc +0 -0
  28. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/data/normandy.epub +0 -0
  29. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/data/sample-1-sheet.xlsx +0 -0
  30. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/data/thinkpython.pdf +0 -0
  31. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/data/vibe.html +0 -0
  32. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/datalab_sdk/auth.py +0 -0
  33. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/datalab_sdk/exceptions.py +0 -0
  34. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/datalab_sdk/mimetypes.py +0 -0
  35. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/datalab_sdk/settings.py +0 -0
  36. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/integration/README.md +0 -0
  37. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/integration/__init__.py +0 -0
  38. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/integration/test_live_api.py +0 -0
  39. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/integration/test_readme_examples.py +0 -0
  40. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/pytest.ini +0 -0
  41. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/recipes/workflows/README.md +0 -0
  42. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/recipes/workflows/end_to_end_workflow.py +0 -0
  43. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/recipes/workflows/workflow_api_tutorial/1_get_step_types.py +0 -0
  44. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/recipes/workflows/workflow_api_tutorial/2_get_workflows.py +0 -0
  45. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/recipes/workflows/workflow_api_tutorial/3_create_workflow.py +0 -0
  46. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/recipes/workflows/workflow_api_tutorial/4_execute_workflow.py +0 -0
  47. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/recipes/workflows/workflow_api_tutorial/5_poll_workflow.py +0 -0
  48. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/recipes/workflows/workflow_api_tutorial/README.md +0 -0
  49. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/recipes/workflows/workflow_definitions/README.md +0 -0
  50. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/recipes/workflows/workflow_definitions/eval_segmentation.json +0 -0
  51. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/recipes/workflows/workflow_definitions/parse_segment.json +0 -0
  52. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/recipes/workflows/workflow_definitions/segment_parallel_extract.json +0 -0
  53. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/recipes/workflows/workflow_definitions/slack_alert.json +0 -0
  54. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/tests/__init__.py +0 -0
  55. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/tests/conftest.py +0 -0
  56. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/tests/test_cli_options.py +0 -0
  57. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/tests/test_device_login.py +0 -0
  58. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/tests/test_errors.py +0 -0
  59. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/tests/test_results.py +0 -0
  60. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/tests/test_transport_audit.py +0 -0
  61. {datalab_python_sdk-0.9.2 → datalab_python_sdk-0.10.0}/tests/test_workflows.py +0 -0
@@ -3,6 +3,20 @@
3
3
  The newest release is at the top. Each export to this repository uses the
4
4
  top section as its commit message.
5
5
 
6
+ ## 0.10.0
7
+
8
+ New:
9
+
10
+ - **Open beta:** Evals on both clients and the CLI. `create_eval()` runs 2 to
11
+ 4 variants of a pipeline on the same files or collection and compares them;
12
+ `get_eval()`, `list_evals()`, and `get_eval_differences()` read the status,
13
+ results, and per-document differences; `wait_for_eval()` polls until the
14
+ Eval completes or fails. New models: `Eval`, `EvalVariant`,
15
+ `EvalVariantResult`, `EvalDocumentResult`, `EvalFile`, `EvalDifference`, and
16
+ `EvalDifferences`. New CLI commands: `datalab eval run`, `datalab eval get`,
17
+ `datalab eval list`, and `datalab eval differences`. The Eval API may
18
+ change.
19
+
6
20
  ## 0.9.2
7
21
 
8
22
  New:
@@ -39,6 +53,10 @@ New:
39
53
 
40
54
  Fixed:
41
55
 
56
+ - `run_pipeline()` and `get_pipeline_execution()` stop polling when an
57
+ execution ends as `needs_review` (its output is ready, but a blocking Check
58
+ failed or it reached its cost limit) and report it to `on_progress` as
59
+ complete. Before, they polled until `max_polls` ran out.
42
60
  - Synchronous calls propagate an operation's `RuntimeError` without attempting
43
61
  to rerun its coroutine. Calling the synchronous client inside an active event
44
62
  loop now directs callers to `AsyncDatalabClient`.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: datalab-python-sdk
3
- Version: 0.9.2
3
+ Version: 0.10.0
4
4
  Summary: SDK for the Datalab document intelligence API
5
5
  Project-URL: Homepage, https://www.datalab.to
6
6
  Project-URL: Documentation, https://documentation.datalab.to
@@ -125,6 +125,12 @@ print(result.extraction_schema_json, result.extraction_score_average)
125
125
 
126
126
  When you do not set the parse `mode`, the API picks the parse mode that matches `extraction_mode`.
127
127
 
128
+ **Open beta (SDK 0.9.2):** set `citation_granularity="phrase"` in
129
+ `ExtractOptions` for matching words, offsets and match scores. A citation includes
130
+ a box only when the phrase can be located; some citations keep only block/page
131
+ references. Phrase citations cost nothing extra. Turbo returns no citations. See the
132
+ [phrase citation guide](https://documentation.datalab.to/docs/recipes/structured-extraction/api-overview#phrase-level-citations).
133
+
128
134
  ## Redaction
129
135
 
130
136
  **Open beta (SDK 0.9.0):** the redaction API may change.
@@ -153,7 +159,7 @@ PDF, including one with failed verification. Redaction returns a typed result;
153
159
 
154
160
  | Method | Endpoint |
155
161
  | --- | --- |
156
- | `run_agent()` | **Beta:** run an existing published processor (`AgentOptions(processor="cp_...")`) |
162
+ | `run_agent()` | **Beta:** run an existing published processor (`AgentOptions(processor="cp_...")`, or built-in `jats` / `wcag`) |
157
163
  | `segment()` | Split a document into sections (`SegmentOptions`) |
158
164
  | `fill()` | Fill a PDF or image form (`FormFillingOptions`) |
159
165
  | `form_fields()` | Find the fillable fields in a PDF or image |
@@ -166,6 +172,11 @@ PDF, including one with failed verification. Redaction returns a typed result;
166
172
 
167
173
  `run_custom_processor()` and `ocr()` call deprecated API endpoints. Use `run_agent()` and `convert()` instead.
168
174
 
175
+ The published `jats` processor returns JATS XML; `wcag` returns an Accessible PDF.
176
+ Inspect `finished`, `verdict` and `verifier_metrics` before using either artifact.
177
+ [Fixed processor examples](https://documentation.datalab.to/docs/recipes/document-agent/jats-and-accessible-pdf)
178
+ show the result fields and version pinning.
179
+
169
180
  Published-agent execution is in open beta; the API may change. Processor design and raw-prompt execution are not included.
170
181
 
171
182
  ## Inputs, polling and errors
@@ -104,6 +104,12 @@ print(result.extraction_schema_json, result.extraction_score_average)
104
104
 
105
105
  When you do not set the parse `mode`, the API picks the parse mode that matches `extraction_mode`.
106
106
 
107
+ **Open beta (SDK 0.9.2):** set `citation_granularity="phrase"` in
108
+ `ExtractOptions` for matching words, offsets and match scores. A citation includes
109
+ a box only when the phrase can be located; some citations keep only block/page
110
+ references. Phrase citations cost nothing extra. Turbo returns no citations. See the
111
+ [phrase citation guide](https://documentation.datalab.to/docs/recipes/structured-extraction/api-overview#phrase-level-citations).
112
+
107
113
  ## Redaction
108
114
 
109
115
  **Open beta (SDK 0.9.0):** the redaction API may change.
@@ -132,7 +138,7 @@ PDF, including one with failed verification. Redaction returns a typed result;
132
138
 
133
139
  | Method | Endpoint |
134
140
  | --- | --- |
135
- | `run_agent()` | **Beta:** run an existing published processor (`AgentOptions(processor="cp_...")`) |
141
+ | `run_agent()` | **Beta:** run an existing published processor (`AgentOptions(processor="cp_...")`, or built-in `jats` / `wcag`) |
136
142
  | `segment()` | Split a document into sections (`SegmentOptions`) |
137
143
  | `fill()` | Fill a PDF or image form (`FormFillingOptions`) |
138
144
  | `form_fields()` | Find the fillable fields in a PDF or image |
@@ -145,6 +151,11 @@ PDF, including one with failed verification. Redaction returns a typed result;
145
151
 
146
152
  `run_custom_processor()` and `ocr()` call deprecated API endpoints. Use `run_agent()` and `convert()` instead.
147
153
 
154
+ The published `jats` processor returns JATS XML; `wcag` returns an Accessible PDF.
155
+ Inspect `finished`, `verdict` and `verifier_metrics` before using either artifact.
156
+ [Fixed processor examples](https://documentation.datalab.to/docs/recipes/document-agent/jats-and-accessible-pdf)
157
+ show the result fields and version pinning.
158
+
148
159
  Published-agent execution is in open beta; the API may change. Processor design and raw-prompt execution are not included.
149
160
 
150
161
  ## Inputs, polling and errors
@@ -52,6 +52,15 @@ from .models import (
52
52
  PipelineExecutionStepResult,
53
53
  CustomProcessor,
54
54
  CustomProcessorVersion,
55
+ Eval,
56
+ EvalDifference,
57
+ EvalDifferences,
58
+ EvalField,
59
+ EvalDocumentResult,
60
+ EvalFile,
61
+ EvalList,
62
+ EvalVariant,
63
+ EvalVariantResult,
55
64
  )
56
65
  from .settings import settings
57
66
 
@@ -102,4 +111,13 @@ __all__ = [
102
111
  "PipelineExecutionStepResult",
103
112
  "CustomProcessor",
104
113
  "CustomProcessorVersion",
114
+ "Eval",
115
+ "EvalDifference",
116
+ "EvalDifferences",
117
+ "EvalField",
118
+ "EvalDocumentResult",
119
+ "EvalFile",
120
+ "EvalList",
121
+ "EvalVariant",
122
+ "EvalVariantResult",
105
123
  ]
@@ -26,9 +26,11 @@ from datalab_sdk.models import (
26
26
  ProcessingOptions,
27
27
  WorkflowStep,
28
28
  InputConfig,
29
+ EvalVariant,
29
30
  )
30
31
  from datalab_sdk.exceptions import DatalabError
31
32
  from datalab_sdk.settings import settings
33
+ import dataclasses
32
34
  import json
33
35
 
34
36
 
@@ -963,10 +965,16 @@ def fill(
963
965
 
964
966
  @click.command("form-fields")
965
967
  @click.argument("path", type=click.Path(exists=True))
968
+ @click.option(
969
+ "--include_text",
970
+ is_flag=True,
971
+ help="Also read the page text and mark each field in it (slower)",
972
+ )
966
973
  @webhook_option
967
974
  @common_options
968
975
  def form_fields(
969
976
  path: str,
977
+ include_text: bool,
970
978
  webhook_url: Optional[str],
971
979
  api_key: str,
972
980
  output_dir: str,
@@ -985,6 +993,7 @@ def form_fields(
985
993
  max_pages=max_pages,
986
994
  page_range=page_range,
987
995
  skip_cache=skip_cache,
996
+ include_text=include_text,
988
997
  )
989
998
  process_documents(
990
999
  path=path,
@@ -1144,6 +1153,239 @@ def create_document(
1144
1153
  sys.exit(1)
1145
1154
 
1146
1155
 
1156
+ # Eval commands (open beta; the API may change)
1157
+
1158
+
1159
+ def _eval_client(api_key: Optional[str], base_url: str) -> DatalabClient:
1160
+ if api_key is None:
1161
+ api_key = settings.DATALAB_API_KEY
1162
+ if api_key is None:
1163
+ raise DatalabError(
1164
+ "You must either pass in an api key via --api_key or set the DATALAB_API_KEY env variable. "
1165
+ "Get a free API key at https://www.datalab.to/app/keys"
1166
+ )
1167
+ return DatalabClient(api_key=api_key, base_url=base_url)
1168
+
1169
+
1170
+ def _print_eval_summary(evaluation) -> None:
1171
+ click.echo(
1172
+ f"Eval {evaluation.eval_id}: {evaluation.status} "
1173
+ f"(pipeline {evaluation.pipeline_id}, compares {evaluation.compared_step})"
1174
+ )
1175
+ for variant in evaluation.variants:
1176
+ share = f"{variant.share * 100:.0f}%" if variant.share is not None else "n/a"
1177
+ rate = (
1178
+ f"${variant.rate_per_1000_pages_cents / 100:.2f}/1000 pages"
1179
+ if variant.rate_per_1000_pages_cents is not None
1180
+ else "n/a"
1181
+ )
1182
+ speed = (
1183
+ f"{variant.seconds_per_page:.2f}s/page"
1184
+ if variant.seconds_per_page is not None
1185
+ else "n/a"
1186
+ )
1187
+ click.echo(
1188
+ f" {variant.name}: share={share} decided={variant.decided} won={variant.won} "
1189
+ f"rate={rate} speed={speed}"
1190
+ )
1191
+
1192
+
1193
+ eval_option_api_key = click.option("--api_key", required=False, help="Datalab API key")
1194
+ eval_option_base_url = click.option(
1195
+ "--base_url", default=settings.DATALAB_HOST, help="API base URL"
1196
+ )
1197
+ eval_option_json = click.option(
1198
+ "--json", "json_output", is_flag=True, help="Print the raw result as JSON"
1199
+ )
1200
+
1201
+
1202
+ @click.group("eval")
1203
+ def eval_group():
1204
+ """[Open beta] Compare pipeline variants, head to head."""
1205
+ pass
1206
+
1207
+
1208
+ @eval_group.command("run")
1209
+ @click.argument("paths", nargs=-1, type=click.Path(exists=True))
1210
+ @click.option(
1211
+ "--pipeline",
1212
+ "pipeline_id",
1213
+ required=True,
1214
+ help="Pipeline ID to evaluate (pl_XXXXX)",
1215
+ )
1216
+ @click.option(
1217
+ "--collection_id",
1218
+ type=int,
1219
+ help="Collection ID to evaluate, instead of FILE paths",
1220
+ )
1221
+ @click.option(
1222
+ "--variant-json",
1223
+ "variants_json",
1224
+ help='Variants as JSON or a path to a JSON file: [{"name": "Accurate", '
1225
+ '"steps": {"convert": {"output_mode": "accurate"}}}, ...]. Omit to '
1226
+ "compare the default Fast/Balanced/Accurate modes.",
1227
+ )
1228
+ @click.option(
1229
+ "--version", type=int, help="Pipeline version to run (0=draft, omit=active)"
1230
+ )
1231
+ @click.option(
1232
+ "--wait", is_flag=True, help="Poll until the Eval finishes and print a summary"
1233
+ )
1234
+ @click.option(
1235
+ "--poll_interval", default=10, type=int, help="Seconds between polls with --wait"
1236
+ )
1237
+ @click.option(
1238
+ "--timeout", default=7200, type=int, help="Maximum seconds to wait with --wait"
1239
+ )
1240
+ @eval_option_json
1241
+ @eval_option_api_key
1242
+ @eval_option_base_url
1243
+ def eval_run(
1244
+ paths,
1245
+ pipeline_id: str,
1246
+ collection_id: Optional[int],
1247
+ variants_json: Optional[str],
1248
+ version: Optional[int],
1249
+ wait: bool,
1250
+ poll_interval: int,
1251
+ timeout: int,
1252
+ json_output: bool,
1253
+ api_key: Optional[str],
1254
+ base_url: str,
1255
+ ):
1256
+ """[Open beta] Run an Eval: compare pipeline variants on FILE paths or a collection."""
1257
+ try:
1258
+ if bool(paths) == bool(collection_id):
1259
+ raise click.UsageError(
1260
+ "Give either FILE paths or --collection_id, not both."
1261
+ )
1262
+ variants = None
1263
+ if variants_json is not None:
1264
+ data = _load_json_option(variants_json, "--variant-json")
1265
+ variants = [
1266
+ EvalVariant(name=v["name"], steps=v.get("steps", {})) for v in data
1267
+ ]
1268
+
1269
+ client = _eval_client(api_key, base_url)
1270
+ file_ids = None
1271
+ if paths:
1272
+ uploaded = client.upload_files(list(paths))
1273
+ if not isinstance(uploaded, list):
1274
+ uploaded = [uploaded]
1275
+ file_ids = [u.file_id for u in uploaded]
1276
+
1277
+ evaluation = client.create_eval(
1278
+ pipeline_id,
1279
+ file_ids=file_ids,
1280
+ collection_id=collection_id,
1281
+ variants=variants,
1282
+ version=version,
1283
+ )
1284
+ if wait:
1285
+ evaluation = client.wait_for_eval(
1286
+ evaluation.eval_id, poll_interval=poll_interval, timeout=timeout
1287
+ )
1288
+ if json_output:
1289
+ click.echo(json.dumps(dataclasses.asdict(evaluation), indent=2))
1290
+ else:
1291
+ _print_eval_summary(evaluation)
1292
+ elif json_output:
1293
+ click.echo(json.dumps(dataclasses.asdict(evaluation), indent=2))
1294
+ else:
1295
+ click.echo(f"Eval {evaluation.eval_id} started ({evaluation.status}).")
1296
+ click.echo(f"Check it with: datalab eval get {evaluation.eval_id}")
1297
+ except DatalabError as e:
1298
+ click.echo(f"Error: {e}", err=True)
1299
+ sys.exit(1)
1300
+
1301
+
1302
+ @eval_group.command("get")
1303
+ @click.argument("eval_id", type=int)
1304
+ @eval_option_json
1305
+ @eval_option_api_key
1306
+ @eval_option_base_url
1307
+ def eval_get(eval_id: int, json_output: bool, api_key: Optional[str], base_url: str):
1308
+ """[Open beta] Get an Eval's status and each variant's result."""
1309
+ try:
1310
+ client = _eval_client(api_key, base_url)
1311
+ evaluation = client.get_eval(eval_id)
1312
+ if json_output:
1313
+ click.echo(json.dumps(dataclasses.asdict(evaluation), indent=2))
1314
+ else:
1315
+ _print_eval_summary(evaluation)
1316
+ except DatalabError as e:
1317
+ click.echo(f"Error: {e}", err=True)
1318
+ sys.exit(1)
1319
+
1320
+
1321
+ @eval_group.command("list")
1322
+ @click.option("--pipeline_id", help="Only Evals of this pipeline")
1323
+ @click.option("--collection_id", type=int, help="Only Evals of this collection")
1324
+ @click.option("--limit", default=20, type=int, help="Maximum number to return")
1325
+ @click.option("--offset", default=0, type=int, help="Offset for pagination")
1326
+ @eval_option_json
1327
+ @eval_option_api_key
1328
+ @eval_option_base_url
1329
+ def eval_list(
1330
+ pipeline_id: Optional[str],
1331
+ collection_id: Optional[int],
1332
+ limit: int,
1333
+ offset: int,
1334
+ json_output: bool,
1335
+ api_key: Optional[str],
1336
+ base_url: str,
1337
+ ):
1338
+ """[Open beta] List the team's Evals, newest first."""
1339
+ try:
1340
+ client = _eval_client(api_key, base_url)
1341
+ result = client.list_evals(
1342
+ pipeline_id=pipeline_id,
1343
+ collection_id=collection_id,
1344
+ limit=limit,
1345
+ offset=offset,
1346
+ )
1347
+ if json_output:
1348
+ click.echo(json.dumps(dataclasses.asdict(result), indent=2))
1349
+ else:
1350
+ click.echo(f"{result.total} Eval(s):")
1351
+ for evaluation in result.evals:
1352
+ click.echo(
1353
+ f" {evaluation.eval_id}: {evaluation.status} (pipeline {evaluation.pipeline_id})"
1354
+ )
1355
+ except DatalabError as e:
1356
+ click.echo(f"Error: {e}", err=True)
1357
+ sys.exit(1)
1358
+
1359
+
1360
+ @eval_group.command("differences")
1361
+ @click.argument("eval_id", type=int)
1362
+ @click.argument("file_id", type=int)
1363
+ @eval_option_json
1364
+ @eval_option_api_key
1365
+ @eval_option_base_url
1366
+ def eval_differences(
1367
+ eval_id: int, file_id: int, json_output: bool, api_key: Optional[str], base_url: str
1368
+ ):
1369
+ """[Open beta] Show where an Eval's variants read one document differently."""
1370
+ try:
1371
+ client = _eval_client(api_key, base_url)
1372
+ result = client.get_eval_differences(eval_id, file_id)
1373
+ if json_output:
1374
+ click.echo(json.dumps(dataclasses.asdict(result), indent=2))
1375
+ else:
1376
+ click.echo(
1377
+ f"File {result.file_id}: variants {', '.join(result.variant_names)}"
1378
+ )
1379
+ for d in result.differences:
1380
+ label = d.question or d.before[:40]
1381
+ click.echo(
1382
+ f" page {d.page} [{d.verdict}] {label!r} -> winners {d.winners}"
1383
+ )
1384
+ except DatalabError as e:
1385
+ click.echo(f"Error: {e}", err=True)
1386
+ sys.exit(1)
1387
+
1388
+
1147
1389
  # Workflow commands
1148
1390
  def _echo_workflows_removed():
1149
1391
  click.echo(
@@ -1652,6 +1894,7 @@ cli.add_command(fill)
1652
1894
  cli.add_command(form_fields)
1653
1895
  cli.add_command(agent)
1654
1896
  cli.add_command(create_document)
1897
+ cli.add_command(eval_group)
1655
1898
  cli.add_command(create_workflow)
1656
1899
  cli.add_command(get_workflow)
1657
1900
  cli.add_command(get_step_types)