opik 2.0.50 → 2.0.52

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.
package/dist/index.d.cts CHANGED
@@ -6055,6 +6055,8 @@ interface PromptVersionDetail {
6055
6055
  type?: PromptVersionDetailType;
6056
6056
  /** version type discriminator; defaults to prompt_version */
6057
6057
  versionType?: PromptVersionDetailVersionType;
6058
+ /** Deprecated: use 'environments' instead */
6059
+ environment?: string;
6058
6060
  environments?: string[];
6059
6061
  changeDescription?: string;
6060
6062
  tags?: string[];
@@ -6087,6 +6089,8 @@ type PromptVersionDetailVersionType = (typeof PromptVersionDetailVersionType)[ke
6087
6089
  interface PromptVersionLink {
6088
6090
  id: string;
6089
6091
  commit?: string;
6092
+ /** sequential version number in the format v<N>; null for masks */
6093
+ versionNumber?: string;
6090
6094
  promptId?: string;
6091
6095
  promptName?: string;
6092
6096
  }
@@ -6123,6 +6127,8 @@ interface PromptVersionPublic {
6123
6127
  type?: PromptVersionPublicType;
6124
6128
  /** version type discriminator; defaults to prompt_version */
6125
6129
  versionType?: PromptVersionPublicVersionType;
6130
+ /** Deprecated: use 'environments' instead */
6131
+ environment?: string;
6126
6132
  environments?: string[];
6127
6133
  changeDescription?: string;
6128
6134
  tags?: string[];
@@ -12182,6 +12188,11 @@ interface GetPromptOptions {
12182
12188
  version?: string;
12183
12189
  /** Optional project name to scope the lookup. */
12184
12190
  projectName?: string;
12191
+ /**
12192
+ * Optional environment name. Resolves to the version currently owned by that
12193
+ * workspace environment. Mutually exclusive with `commit`.
12194
+ */
12195
+ environment?: string;
12185
12196
  }
12186
12197
  /**
12187
12198
  * Variables to be substituted into prompt template.
@@ -12258,7 +12269,6 @@ declare class PromptVersion {
12258
12269
  readonly commit: string;
12259
12270
  /**
12260
12271
  * Sequential version identifier of this prompt version (e.g. `"v3"`).
12261
- * Undefined for mask versions, which do not carry a version number.
12262
12272
  */
12263
12273
  readonly version?: string;
12264
12274
  readonly type: PromptType;
@@ -12279,7 +12289,7 @@ declare class PromptVersion {
12279
12289
  /**
12280
12290
  * Get formatted version information string.
12281
12291
  * Format: "[v3] YYYY-MM-DD by user@email.com - Change description"
12282
- * (falls back to the commit hash for mask versions, which have no version number).
12292
+ * (falls back to the commit hash when no version number is present).
12283
12293
  */
12284
12294
  getVersionInfo(): string;
12285
12295
  /**
@@ -12333,6 +12343,8 @@ interface BasePromptData {
12333
12343
  templateStructure?: PromptTemplateStructure;
12334
12344
  synced?: boolean;
12335
12345
  projectName?: string;
12346
+ /** Optional environments that own this prompt version. */
12347
+ environments?: string[];
12336
12348
  }
12337
12349
  /**
12338
12350
  * Abstract base class for all prompt types.
@@ -12346,6 +12358,7 @@ declare abstract class BasePrompt {
12346
12358
  private _synced;
12347
12359
  private _changeDescription;
12348
12360
  private _projectName;
12361
+ private _environments;
12349
12362
  readonly type: PromptType;
12350
12363
  readonly templateStructure: PromptTemplateStructure;
12351
12364
  protected _name: string;
@@ -12363,6 +12376,11 @@ declare abstract class BasePrompt {
12363
12376
  get synced(): boolean;
12364
12377
  get changeDescription(): string | undefined;
12365
12378
  get projectName(): string | undefined;
12379
+ /**
12380
+ * The environments that own this prompt version. Returns an empty array
12381
+ * if the version is not associated with any environment.
12382
+ */
12383
+ get environments(): readonly string[];
12366
12384
  constructor(data: BasePromptData, opik?: OpikClient);
12367
12385
  /**
12368
12386
  * Updates internal state after a successful background sync.
@@ -12375,6 +12393,7 @@ declare abstract class BasePrompt {
12375
12393
  changeDescription?: string;
12376
12394
  tags?: string[];
12377
12395
  projectName?: string;
12396
+ environments?: string[];
12378
12397
  }): void;
12379
12398
  /**
12380
12399
  * Shared background-sync helper for subclass constructors.
@@ -14310,14 +14329,18 @@ declare class OpikClient {
14310
14329
  * default 300s). When called inside a track() context the prompt reference
14311
14330
  * is injected into the active trace/span metadata.
14312
14331
  *
14313
- * @param options - Prompt name and optional version pin
14332
+ * @param options - Prompt name and optional version pin or environment
14314
14333
  * @param options.name - Name of the prompt
14315
14334
  * @param options.version - Sequential version identifier (e.g. `"v3"`). If not
14316
14335
  * provided, the latest version is returned.
14317
14336
  * @param options.commit - **Deprecated.** Use `version` instead.
14318
14337
  * @param options.projectName - Optional project scope.
14338
+ * @param options.environment - Optional environment name. Resolves to the version
14339
+ * currently owned by that workspace environment. Mutually exclusive with both
14340
+ * `commit` and `version`.
14319
14341
  * @returns Promise resolving to Prompt or null if not found
14320
- * @throws Error if both `commit` and `version` are provided
14342
+ * @throws Error if both `commit` and `version` are provided, or if `environment` is
14343
+ * combined with either `commit` or `version`
14321
14344
  * @throws PromptTemplateStructureMismatch if prompt exists but is a chat prompt
14322
14345
  */
14323
14346
  getPrompt: (options: GetPromptOptions) => Promise<Prompt | null>;
@@ -14327,14 +14350,18 @@ declare class OpikClient {
14327
14350
  * default 300s). When called inside a track() context the prompt reference
14328
14351
  * is injected into the active trace/span metadata.
14329
14352
  *
14330
- * @param options - Prompt name and optional version pin
14353
+ * @param options - Prompt name and optional version pin or environment
14331
14354
  * @param options.name - Name of the prompt
14332
14355
  * @param options.version - Sequential version identifier (e.g. `"v3"`). If not
14333
14356
  * provided, the latest version is returned.
14334
14357
  * @param options.commit - **Deprecated.** Use `version` instead.
14335
14358
  * @param options.projectName - Optional project scope.
14359
+ * @param options.environment - Optional environment name. Resolves to the version
14360
+ * currently owned by that workspace environment. Mutually exclusive with both
14361
+ * `commit` and `version`.
14336
14362
  * @returns Promise resolving to ChatPrompt or null if not found
14337
- * @throws Error if both `commit` and `version` are provided
14363
+ * @throws Error if both `commit` and `version` are provided, or if `environment` is
14364
+ * combined with either `commit` or `version`
14338
14365
  * @throws PromptTemplateStructureMismatch if prompt exists but is a text prompt
14339
14366
  *
14340
14367
  * @example
@@ -14405,6 +14432,30 @@ declare class OpikClient {
14405
14432
  * @param ids - Array of prompt container IDs to delete
14406
14433
  */
14407
14434
  deletePrompts: (ids: string[]) => Promise<void>;
14435
+ /**
14436
+ * Assigns a prompt version to an environment, or clears the assignment.
14437
+ *
14438
+ * Replace the full set of environments owned by a prompt version. The
14439
+ * provided list becomes the resolved version's complete set of environments.
14440
+ * Pass an empty array to clear all environments. Any other version of the
14441
+ * same prompt that previously owned one of the listed environments is
14442
+ * cleared. Existing prompt objects already in memory are not mutated —
14443
+ * re-fetch with `client.getPrompt(...)` to see the change.
14444
+ *
14445
+ * @param options.promptName - Name of the prompt
14446
+ * @param options.environments - Environments to assign. Each must already be registered in the workspace. Pass `[]` to clear.
14447
+ * @param options.version - Sequential version selector in the wire format `"v<N>"` (e.g. `"v3"`). Defaults to the latest version.
14448
+ * @param options.projectName - Project the prompt belongs to. Defaults to the client's project.
14449
+ *
14450
+ * @throws {PromptNotFoundError} The prompt name (or the supplied `version`) does not exist in the resolved project.
14451
+ * @throws {EnvironmentNotFoundError} One of `environments` is not registered in the workspace.
14452
+ */
14453
+ setPromptEnvironments: (options: {
14454
+ promptName: string;
14455
+ environments: string[];
14456
+ version?: string;
14457
+ projectName?: string;
14458
+ }) => Promise<void>;
14408
14459
  /**
14409
14460
  * Search for traces in the given project. Optionally, you can wait for at least a certain number of traces
14410
14461
  * to be found before returning within the specified timeout.
@@ -14596,6 +14647,7 @@ declare class OpikClient {
14596
14647
  color?: string;
14597
14648
  }) => Promise<EnvironmentPublic>;
14598
14649
  getEnvironments: () => Promise<EnvironmentPublic[]>;
14650
+ private static readonly BUILTIN_ENVIRONMENT_NAMES;
14599
14651
  updateEnvironment: (name: string, options?: {
14600
14652
  description?: string;
14601
14653
  color?: string;
package/dist/index.d.ts CHANGED
@@ -6055,6 +6055,8 @@ interface PromptVersionDetail {
6055
6055
  type?: PromptVersionDetailType;
6056
6056
  /** version type discriminator; defaults to prompt_version */
6057
6057
  versionType?: PromptVersionDetailVersionType;
6058
+ /** Deprecated: use 'environments' instead */
6059
+ environment?: string;
6058
6060
  environments?: string[];
6059
6061
  changeDescription?: string;
6060
6062
  tags?: string[];
@@ -6087,6 +6089,8 @@ type PromptVersionDetailVersionType = (typeof PromptVersionDetailVersionType)[ke
6087
6089
  interface PromptVersionLink {
6088
6090
  id: string;
6089
6091
  commit?: string;
6092
+ /** sequential version number in the format v<N>; null for masks */
6093
+ versionNumber?: string;
6090
6094
  promptId?: string;
6091
6095
  promptName?: string;
6092
6096
  }
@@ -6123,6 +6127,8 @@ interface PromptVersionPublic {
6123
6127
  type?: PromptVersionPublicType;
6124
6128
  /** version type discriminator; defaults to prompt_version */
6125
6129
  versionType?: PromptVersionPublicVersionType;
6130
+ /** Deprecated: use 'environments' instead */
6131
+ environment?: string;
6126
6132
  environments?: string[];
6127
6133
  changeDescription?: string;
6128
6134
  tags?: string[];
@@ -12182,6 +12188,11 @@ interface GetPromptOptions {
12182
12188
  version?: string;
12183
12189
  /** Optional project name to scope the lookup. */
12184
12190
  projectName?: string;
12191
+ /**
12192
+ * Optional environment name. Resolves to the version currently owned by that
12193
+ * workspace environment. Mutually exclusive with `commit`.
12194
+ */
12195
+ environment?: string;
12185
12196
  }
12186
12197
  /**
12187
12198
  * Variables to be substituted into prompt template.
@@ -12258,7 +12269,6 @@ declare class PromptVersion {
12258
12269
  readonly commit: string;
12259
12270
  /**
12260
12271
  * Sequential version identifier of this prompt version (e.g. `"v3"`).
12261
- * Undefined for mask versions, which do not carry a version number.
12262
12272
  */
12263
12273
  readonly version?: string;
12264
12274
  readonly type: PromptType;
@@ -12279,7 +12289,7 @@ declare class PromptVersion {
12279
12289
  /**
12280
12290
  * Get formatted version information string.
12281
12291
  * Format: "[v3] YYYY-MM-DD by user@email.com - Change description"
12282
- * (falls back to the commit hash for mask versions, which have no version number).
12292
+ * (falls back to the commit hash when no version number is present).
12283
12293
  */
12284
12294
  getVersionInfo(): string;
12285
12295
  /**
@@ -12333,6 +12343,8 @@ interface BasePromptData {
12333
12343
  templateStructure?: PromptTemplateStructure;
12334
12344
  synced?: boolean;
12335
12345
  projectName?: string;
12346
+ /** Optional environments that own this prompt version. */
12347
+ environments?: string[];
12336
12348
  }
12337
12349
  /**
12338
12350
  * Abstract base class for all prompt types.
@@ -12346,6 +12358,7 @@ declare abstract class BasePrompt {
12346
12358
  private _synced;
12347
12359
  private _changeDescription;
12348
12360
  private _projectName;
12361
+ private _environments;
12349
12362
  readonly type: PromptType;
12350
12363
  readonly templateStructure: PromptTemplateStructure;
12351
12364
  protected _name: string;
@@ -12363,6 +12376,11 @@ declare abstract class BasePrompt {
12363
12376
  get synced(): boolean;
12364
12377
  get changeDescription(): string | undefined;
12365
12378
  get projectName(): string | undefined;
12379
+ /**
12380
+ * The environments that own this prompt version. Returns an empty array
12381
+ * if the version is not associated with any environment.
12382
+ */
12383
+ get environments(): readonly string[];
12366
12384
  constructor(data: BasePromptData, opik?: OpikClient);
12367
12385
  /**
12368
12386
  * Updates internal state after a successful background sync.
@@ -12375,6 +12393,7 @@ declare abstract class BasePrompt {
12375
12393
  changeDescription?: string;
12376
12394
  tags?: string[];
12377
12395
  projectName?: string;
12396
+ environments?: string[];
12378
12397
  }): void;
12379
12398
  /**
12380
12399
  * Shared background-sync helper for subclass constructors.
@@ -14310,14 +14329,18 @@ declare class OpikClient {
14310
14329
  * default 300s). When called inside a track() context the prompt reference
14311
14330
  * is injected into the active trace/span metadata.
14312
14331
  *
14313
- * @param options - Prompt name and optional version pin
14332
+ * @param options - Prompt name and optional version pin or environment
14314
14333
  * @param options.name - Name of the prompt
14315
14334
  * @param options.version - Sequential version identifier (e.g. `"v3"`). If not
14316
14335
  * provided, the latest version is returned.
14317
14336
  * @param options.commit - **Deprecated.** Use `version` instead.
14318
14337
  * @param options.projectName - Optional project scope.
14338
+ * @param options.environment - Optional environment name. Resolves to the version
14339
+ * currently owned by that workspace environment. Mutually exclusive with both
14340
+ * `commit` and `version`.
14319
14341
  * @returns Promise resolving to Prompt or null if not found
14320
- * @throws Error if both `commit` and `version` are provided
14342
+ * @throws Error if both `commit` and `version` are provided, or if `environment` is
14343
+ * combined with either `commit` or `version`
14321
14344
  * @throws PromptTemplateStructureMismatch if prompt exists but is a chat prompt
14322
14345
  */
14323
14346
  getPrompt: (options: GetPromptOptions) => Promise<Prompt | null>;
@@ -14327,14 +14350,18 @@ declare class OpikClient {
14327
14350
  * default 300s). When called inside a track() context the prompt reference
14328
14351
  * is injected into the active trace/span metadata.
14329
14352
  *
14330
- * @param options - Prompt name and optional version pin
14353
+ * @param options - Prompt name and optional version pin or environment
14331
14354
  * @param options.name - Name of the prompt
14332
14355
  * @param options.version - Sequential version identifier (e.g. `"v3"`). If not
14333
14356
  * provided, the latest version is returned.
14334
14357
  * @param options.commit - **Deprecated.** Use `version` instead.
14335
14358
  * @param options.projectName - Optional project scope.
14359
+ * @param options.environment - Optional environment name. Resolves to the version
14360
+ * currently owned by that workspace environment. Mutually exclusive with both
14361
+ * `commit` and `version`.
14336
14362
  * @returns Promise resolving to ChatPrompt or null if not found
14337
- * @throws Error if both `commit` and `version` are provided
14363
+ * @throws Error if both `commit` and `version` are provided, or if `environment` is
14364
+ * combined with either `commit` or `version`
14338
14365
  * @throws PromptTemplateStructureMismatch if prompt exists but is a text prompt
14339
14366
  *
14340
14367
  * @example
@@ -14405,6 +14432,30 @@ declare class OpikClient {
14405
14432
  * @param ids - Array of prompt container IDs to delete
14406
14433
  */
14407
14434
  deletePrompts: (ids: string[]) => Promise<void>;
14435
+ /**
14436
+ * Assigns a prompt version to an environment, or clears the assignment.
14437
+ *
14438
+ * Replace the full set of environments owned by a prompt version. The
14439
+ * provided list becomes the resolved version's complete set of environments.
14440
+ * Pass an empty array to clear all environments. Any other version of the
14441
+ * same prompt that previously owned one of the listed environments is
14442
+ * cleared. Existing prompt objects already in memory are not mutated —
14443
+ * re-fetch with `client.getPrompt(...)` to see the change.
14444
+ *
14445
+ * @param options.promptName - Name of the prompt
14446
+ * @param options.environments - Environments to assign. Each must already be registered in the workspace. Pass `[]` to clear.
14447
+ * @param options.version - Sequential version selector in the wire format `"v<N>"` (e.g. `"v3"`). Defaults to the latest version.
14448
+ * @param options.projectName - Project the prompt belongs to. Defaults to the client's project.
14449
+ *
14450
+ * @throws {PromptNotFoundError} The prompt name (or the supplied `version`) does not exist in the resolved project.
14451
+ * @throws {EnvironmentNotFoundError} One of `environments` is not registered in the workspace.
14452
+ */
14453
+ setPromptEnvironments: (options: {
14454
+ promptName: string;
14455
+ environments: string[];
14456
+ version?: string;
14457
+ projectName?: string;
14458
+ }) => Promise<void>;
14408
14459
  /**
14409
14460
  * Search for traces in the given project. Optionally, you can wait for at least a certain number of traces
14410
14461
  * to be found before returning within the specified timeout.
@@ -14596,6 +14647,7 @@ declare class OpikClient {
14596
14647
  color?: string;
14597
14648
  }) => Promise<EnvironmentPublic>;
14598
14649
  getEnvironments: () => Promise<EnvironmentPublic[]>;
14650
+ private static readonly BUILTIN_ENVIRONMENT_NAMES;
14599
14651
  updateEnvironment: (name: string, options?: {
14600
14652
  description?: string;
14601
14653
  color?: string;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import {Fa}from'./chunk-SYHXKICU.js';export{sa as AgentTaskCompletionJudge,ra as AgentToolCorrectnessJudge,fa as AnswerRelevance,ba as BaseLLMJudgeMetric,C as BaseMetric,D as BaseSuiteEvaluator,p as ChatPrompt,ua as ComplianceRiskJudge,i as ConfigMismatchError,h as ConfigNotFoundError,_ as Contains,y as DEFAULT_EXECUTION_POLICY,j as Dataset,f as DatasetVersion,g as DatasetVersionNotFoundError,ma as DemographicBiasJudge,ka as DialogueHelpfulnessJudge,Z as ExactMatch,ga as GEval,ha as GEvalPreset,oa as GenderBiasJudge,ea as Hallucination,aa as IsJson,Q as LLMJudge,H as ModelConfigurationError,F as ModelError,G as ModelGenerationError,ca as Moderation,Ca as OPIK_PARENT_SPAN_ID_HEADER,Ba as OPIK_TRACE_ID_HEADER,Aa as Opik,E as OpikBaseModel,q as OpikQueryLanguage,d as OpikSpanType,na as PoliticalBiasJudge,o as Prompt,k as PromptType,ta as PromptUncertaintyJudge,la as QARelevanceJudge,$ as RegexMatch,qa as RegionalBiasJudge,pa as ReligiousBiasJudge,P as ResponseSchema,N as SYSTEM_PROMPT,ja as SummarizationCoherenceJudge,ia as SummarizationConsistencyJudge,B as TASK_ERROR_SCORE_NAME,ya as TestSuite,z as TestSuiteResult,s as ThreadsAnnotationQueue,r as TracesAnnotationQueue,O as USER_PROMPT_TEMPLATE,da as Usefulness,J as VercelAIChatModel,v as activateRunner,t as agentConfigContext,A as buildSuiteResult,K as createModel,L as createModelFromInstance,S as deserializeEvaluators,I as detectProvider,c as disableLogger,X as evaluate,Y as evaluatePrompt,V as evaluateTestSuite,u as flushAll,e as generateId,Da as getDistributedTraceHeaders,l as getGlobalClient,w as getTrackContext,a as logger,n as resetGlobalClient,va as resolveEvaluators,T as resolveExecutionPolicy,U as resolveItemExecutionPolicy,M as resolveModel,W as runTests,R as serializeEvaluators,m as setGlobalClient,b as setLoggerLevel,x as track,wa as validateEvaluators,xa as validateExecutionPolicy,Ea as z}from'./chunk-SYHXKICU.js';Fa();
1
+ import {Fa}from'./chunk-ESJEX6P3.js';export{sa as AgentTaskCompletionJudge,ra as AgentToolCorrectnessJudge,fa as AnswerRelevance,ba as BaseLLMJudgeMetric,C as BaseMetric,D as BaseSuiteEvaluator,p as ChatPrompt,ua as ComplianceRiskJudge,i as ConfigMismatchError,h as ConfigNotFoundError,_ as Contains,y as DEFAULT_EXECUTION_POLICY,j as Dataset,f as DatasetVersion,g as DatasetVersionNotFoundError,ma as DemographicBiasJudge,ka as DialogueHelpfulnessJudge,Z as ExactMatch,ga as GEval,ha as GEvalPreset,oa as GenderBiasJudge,ea as Hallucination,aa as IsJson,Q as LLMJudge,H as ModelConfigurationError,F as ModelError,G as ModelGenerationError,ca as Moderation,Ca as OPIK_PARENT_SPAN_ID_HEADER,Ba as OPIK_TRACE_ID_HEADER,Aa as Opik,E as OpikBaseModel,q as OpikQueryLanguage,d as OpikSpanType,na as PoliticalBiasJudge,o as Prompt,k as PromptType,ta as PromptUncertaintyJudge,la as QARelevanceJudge,$ as RegexMatch,qa as RegionalBiasJudge,pa as ReligiousBiasJudge,P as ResponseSchema,N as SYSTEM_PROMPT,ja as SummarizationCoherenceJudge,ia as SummarizationConsistencyJudge,B as TASK_ERROR_SCORE_NAME,ya as TestSuite,z as TestSuiteResult,s as ThreadsAnnotationQueue,r as TracesAnnotationQueue,O as USER_PROMPT_TEMPLATE,da as Usefulness,J as VercelAIChatModel,v as activateRunner,t as agentConfigContext,A as buildSuiteResult,K as createModel,L as createModelFromInstance,S as deserializeEvaluators,I as detectProvider,c as disableLogger,X as evaluate,Y as evaluatePrompt,V as evaluateTestSuite,u as flushAll,e as generateId,Da as getDistributedTraceHeaders,l as getGlobalClient,w as getTrackContext,a as logger,n as resetGlobalClient,va as resolveEvaluators,T as resolveExecutionPolicy,U as resolveItemExecutionPolicy,M as resolveModel,W as runTests,R as serializeEvaluators,m as setGlobalClient,b as setLoggerLevel,x as track,wa as validateEvaluators,xa as validateExecutionPolicy,Ea as z}from'./chunk-ESJEX6P3.js';Fa();
@@ -1 +1 @@
1
- import {za}from'./chunk-SYHXKICU.js';export{y as DEFAULT_EXECUTION_POLICY,ya as TestSuite,z as TestSuiteResult,A as buildSuiteResult,S as deserializeEvaluators,V as evaluateTestSuite,T as resolveExecutionPolicy,U as resolveItemExecutionPolicy,W as runTests,R as serializeEvaluators}from'./chunk-SYHXKICU.js';za();
1
+ import {za}from'./chunk-ESJEX6P3.js';export{y as DEFAULT_EXECUTION_POLICY,ya as TestSuite,z as TestSuiteResult,A as buildSuiteResult,S as deserializeEvaluators,V as evaluateTestSuite,T as resolveExecutionPolicy,U as resolveItemExecutionPolicy,W as runTests,R as serializeEvaluators}from'./chunk-ESJEX6P3.js';za();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opik",
3
3
  "description": "Opik TypeScript and JavaScript SDK",
4
- "version": "2.0.50",
4
+ "version": "2.0.52",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/comet-ml/opik.git",