发布

  • [OPIK-4149] [SDK] Add DatasetVersion support to TypeScript SDK (#5068)

    frostbyte_neo 发布于 2026-02-09 15:04:03 +00:00

    • [OPIK-4149] [SDK] Add DatasetVersion support to TypeScript SDK

    Add dataset versioning capabilities allowing users to work with specific
    snapshots of datasets. This enables reproducible evaluations by pinning
    to a specific version.

    Changes:

    • Add DatasetVersion class for read-only version views
    • Add Dataset.getVersionView(), getCurrentVersionName(), getVersionInfo()
    • Support DatasetVersion in evaluate() with version tracking
    • Add DatasetVersionNotFoundError for version lookup failures
    • Export Dataset, DatasetVersion, DatasetVersionNotFoundError from SDK
    • Add comprehensive unit tests (32 tests) and integration tests (3 tests)
    • Address PR review comments
    • Remove redundant if wrapper in toJson keysMapping loop
    • Export DatasetVersionPublic type from SDK public API
    • Update test imports to use public SDK exports

    Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com

    • Add DatasetVersion documentation to TypeScript SDK
    • Add "Working with Dataset Versions" section to datasets.mdx with examples
      for getVersionView, getCurrentVersionName, and getVersionInfo methods
    • Document DatasetVersion class properties and methods in API reference
    • Update evaluate.mdx to show Dataset | DatasetVersion parameter type
    • Add TypeScript version selection example to manage_datasets.mdx

    Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com

    • Fix DatasetVersion to use versionHash for item streaming

    The backend's resolveVersionId method looks up versions by hash or tag,
    not by versionName. Changed to pass versionHash instead of versionName
    to match Python SDK behavior and fix E2E test failures.

    Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com

    • Fix E2E test for DatasetVersion evaluation

    Add scoringKeyMapping to map 'expected' to 'expected_output' field
    in the dataset items, matching the pattern used in other evaluation tests.

    Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com

    • Add lastRetrievedId parameter to DatasetVersion.getItems for pagination parity

    Adds the lastRetrievedId parameter to DatasetVersion.getItems() to match
    the Dataset.getItems() API. This allows manual pagination for datasets
    with more than 2000 items.

    Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com

    • Add auto-pagination to Dataset and DatasetVersion getItems methods

    This adds automatic pagination support for retrieving large datasets:

    • Dataset.getItemsAsDataclasses() now fetches all items automatically
    • DatasetVersion.getItemsAsDataclasses() uses the same pagination pattern
    • Both use cursor-based pagination with lastRetrievedId
    • Maximum batch size of 2000 items per request (API limit)
    • Pagination continues until all requested items are retrieved

    This provides parity with the Python SDK's auto-pagination behavior.

    Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com

    • Fix nbSamples=0 edge case in Dataset and DatasetVersion getItems

    Return empty array immediately when nbSamples === 0 to avoid API call
    with invalid steamLimit = 0 (API requires steamLimit >= 1).

    Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com

    • Apply conciseness improvements from code review

    Simplify streamLimit calculation using nullish coalescing operator.

    Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com

    • Fix race condition in experiment creation

    Add await to createExperiment API call to ensure experiment exists
    before evaluation completes. This fixes the 404 error when nbSamples=0.

    Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com

    • OPIK-4149 refactor

    • OPIK-4149 Merge duplicate dataset versions docs sections

    Remove the shorter duplicate "Working with dataset versions programmatically"
    section and add a TypeScript tab to the remaining detailed section.

    Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com


    Co-authored-by: Claude Opus 4.5 noreply@anthropic.com

    下载附件