发布

  • [OPIK-4963] [SDK] feat: add projectName parameter to TypeScript SDK (#5829)

    frostbyte_neo 发布于 2026-03-25 17:58:01 +00:00

    • [OPIK-4963] [SDK] feat: add projectName parameter to TypeScript SDK

    Add projectName support to datasets, experiments, and prompts in the
    TypeScript SDK, matching the Python SDK changes from PR #5684.

    Key changes:

    • Add resolveProjectName() helper with fallback to client config
    • Add optional projectName parameter to all dataset, experiment, and
      prompt methods
    • Add compatibility_v1 integration tests (frozen pre-projectName API)
    • Add dedicated CI workflow for compatibility V1 tests
    • Add unit-level contract and backward compatibility tests

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

    • [OPIK-4963] [SDK] feat: add example script and compatibility_v1 prompt tests

    Add project_name_example.ts demonstrating projectName usage with datasets,
    experiments, and prompts. Add frozen text prompt compatibility_v1 tests to
    ensure backward compatibility for users who never specify projectName.

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

    • fix(sdk): address PR review comments for projectName handling
    • Make resolveProjectName public for use by EvaluationSuite
    • Resolve projectName in EvaluationSuite.create via client.resolveProjectName()
    • Handle missing project gracefully in getDatasets (fallback to unfiltered list)
    • Add projectId filter to getPrompts calls in getPrompt/getChatPrompt

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

    • fix(sdk): pass projectName to dataset item creation (OPIK-5237)

    Dataset.insert() now passes this.projectName to createOrUpdateDatasetItems,
    ensuring dataset items are associated with the correct project.

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

    • test(sdk): add unit tests for dataset item insert projectName propagation

    Verify that Dataset.insert() passes projectName to createOrUpdateDatasetItems
    for both explicit project and client default scenarios.

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

    • fix(test): mock streamDatasetItems with proper ReadableStream

    The insert tests were hitting the real API because syncHashes uses
    streamDatasetItems (not getDatasetItems). Mock with an empty
    ReadableStream to match the expected type.

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

    • fix(sdk): use type-only export for LLMJudgeModelSettings interface

    LLMJudgeModelSettings is an interface (type-only) but was re-exported
    with a value export, causing Node ESM to fail at runtime. Split into
    separate export and export type statements. Also fix example script
    import to use package name.

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

    • chore(example): comment out cleanup to keep entities for inspection

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

    • feat(example): add evaluation suite run example with projectName

    Demonstrates creating an EvaluationSuite with assertions and execution
    policy, adding test items, running an evaluation task, and printing results.

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

    • fix(example): use correct EvaluationSuiteResult fields

    itemsFailed doesn't exist on the result type. Use itemsPassed,
    allItemsPassed, and handle undefined passRate.

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

    • fix(sdk): fix double /api/api/ in redirect URLs

    createUrl used new URL() which silently replaced the last path segment
    of the base URL, producing incorrect results when the base had a
    trailing slash. Replace with explicit string concatenation that strips
    the /api suffix from the base (since URL_PATHS already include it)
    and normalizes trailing slashes.

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

    • fix(sdk): read OPENAI_ORG_ID from environment for OpenAI provider

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

    • fix(sdk): spread options before resolved env values in provider detection

    Prevents caller-provided undefined from clobbering env-resolved apiKey
    and organization via object spread order.

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

    • fix(ci): add test:compatibility script to package.json

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


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

    下载附件