opik 2.0.37 → 2.0.39
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/chunk-EHVVWQKE.js +404 -0
- package/dist/index.cjs +36 -36
- package/dist/index.d.cts +121 -111
- package/dist/index.d.ts +121 -111
- package/dist/index.js +1 -1
- package/dist/{suite-LY5NBW4K.js → suite-QT7UL6WD.js} +1 -1
- package/package.json +1 -1
- package/dist/chunk-B3U3O5P5.js +0 -404
package/dist/index.d.cts
CHANGED
|
@@ -6253,6 +6253,8 @@ interface ServiceTogglesConfig {
|
|
|
6253
6253
|
bedrockProviderEnabled: boolean;
|
|
6254
6254
|
customllmProviderEnabled: boolean;
|
|
6255
6255
|
ollamaProviderEnabled: boolean;
|
|
6256
|
+
ollieEnabled: boolean;
|
|
6257
|
+
agenticToolsEnabled?: boolean;
|
|
6256
6258
|
v2WorkspaceAllowlistIds: string[];
|
|
6257
6259
|
v1WorkspaceAllowlistIds: string[];
|
|
6258
6260
|
forceWorkspaceVersion: string;
|
|
@@ -11966,6 +11968,7 @@ interface OpikConfig {
|
|
|
11966
11968
|
requestOptions?: RequestOptions;
|
|
11967
11969
|
batchDelayMs?: number;
|
|
11968
11970
|
holdUntilFlush?: boolean;
|
|
11971
|
+
promptCacheTtlSeconds?: number;
|
|
11969
11972
|
}
|
|
11970
11973
|
interface ConstructorOpikConfig extends Omit<OpikConfig, "environment"> {
|
|
11971
11974
|
headers?: Record<string, string>;
|
|
@@ -12305,113 +12308,6 @@ declare abstract class BasePrompt {
|
|
|
12305
12308
|
abstract syncWithBackend(): Promise<BasePrompt>;
|
|
12306
12309
|
}
|
|
12307
12310
|
|
|
12308
|
-
interface PromptData extends BasePromptData {
|
|
12309
|
-
prompt: string;
|
|
12310
|
-
}
|
|
12311
|
-
/**
|
|
12312
|
-
* Domain object representing a versioned text prompt template.
|
|
12313
|
-
* Provides immutable access to prompt properties and template formatting.
|
|
12314
|
-
* Integrates with backend for persistence and version management.
|
|
12315
|
-
*/
|
|
12316
|
-
declare class Prompt extends BasePrompt {
|
|
12317
|
-
readonly prompt: string;
|
|
12318
|
-
/**
|
|
12319
|
-
* Creates a new Prompt instance.
|
|
12320
|
-
* All operations work seamlessly without requiring manual configuration.
|
|
12321
|
-
*/
|
|
12322
|
-
constructor(data: PromptData);
|
|
12323
|
-
/** @deprecated Passing an opik client is deprecated. */
|
|
12324
|
-
constructor(data: PromptData, opik: OpikClient);
|
|
12325
|
-
private _performSync;
|
|
12326
|
-
/**
|
|
12327
|
-
* Returns the template string for this text prompt.
|
|
12328
|
-
* Alias for the `prompt` property for consistency with ChatPrompt.
|
|
12329
|
-
*/
|
|
12330
|
-
get template(): string;
|
|
12331
|
-
/**
|
|
12332
|
-
* Formats prompt template by substituting variables.
|
|
12333
|
-
* Validates that all template placeholders are provided (for Mustache templates).
|
|
12334
|
-
*
|
|
12335
|
-
* @param variables - Object with values to substitute into template
|
|
12336
|
-
* @returns Formatted prompt text with variables substituted
|
|
12337
|
-
* @throws PromptValidationError if template processing or validation fails
|
|
12338
|
-
*
|
|
12339
|
-
* @example
|
|
12340
|
-
* ```typescript
|
|
12341
|
-
* const prompt = new Prompt({
|
|
12342
|
-
* name: "greeting",
|
|
12343
|
-
* prompt: "Hello {{name}}, your score is {{score}}",
|
|
12344
|
-
* type: "mustache"
|
|
12345
|
-
* }, client);
|
|
12346
|
-
*
|
|
12347
|
-
* // Valid - all placeholders provided
|
|
12348
|
-
* prompt.format({ name: "Alice", score: 95 });
|
|
12349
|
-
* // Returns: "Hello Alice, your score is 95"
|
|
12350
|
-
*
|
|
12351
|
-
* // Invalid - missing 'score' placeholder
|
|
12352
|
-
* prompt.format({ name: "Alice" });
|
|
12353
|
-
* // Throws: PromptValidationError
|
|
12354
|
-
* ```
|
|
12355
|
-
*/
|
|
12356
|
-
format(variables: PromptVariables): string;
|
|
12357
|
-
/**
|
|
12358
|
-
* Static factory method to create Prompt from backend API response.
|
|
12359
|
-
*
|
|
12360
|
-
* @param name - Name of the prompt
|
|
12361
|
-
* @param apiResponse - REST API PromptVersionDetail response
|
|
12362
|
-
* @param opik - OpikClient instance
|
|
12363
|
-
* @param promptPublicData - Optional PromptPublic data containing description and tags
|
|
12364
|
-
* @returns Prompt instance constructed from response data
|
|
12365
|
-
* @throws PromptValidationError if response structure invalid
|
|
12366
|
-
*/
|
|
12367
|
-
static fromApiResponse(promptData: PromptPublic, apiResponse: PromptVersionDetail, opik: OpikClient, projectName?: string): Prompt;
|
|
12368
|
-
/**
|
|
12369
|
-
* Restores a specific version by creating a new version with content from the specified version.
|
|
12370
|
-
* The version must be obtained from the backend (e.g., via getVersions()).
|
|
12371
|
-
* Returns a new Prompt instance with the restored content as the latest version.
|
|
12372
|
-
*
|
|
12373
|
-
* @param version - PromptVersion object to restore (must be from backend)
|
|
12374
|
-
* @returns Promise resolving to a new Prompt instance with the restored version
|
|
12375
|
-
* @throws OpikApiError if REST API call fails
|
|
12376
|
-
*
|
|
12377
|
-
* @example
|
|
12378
|
-
* ```typescript
|
|
12379
|
-
* const prompt = await client.getPrompt({ name: "my-prompt" });
|
|
12380
|
-
*
|
|
12381
|
-
* // Get all versions
|
|
12382
|
-
* const versions = await prompt.getVersions();
|
|
12383
|
-
*
|
|
12384
|
-
* // Restore a specific version
|
|
12385
|
-
* const targetVersion = versions.find(v => v.commit === "abc123de");
|
|
12386
|
-
* if (targetVersion) {
|
|
12387
|
-
* const restoredPrompt = await prompt.useVersion(targetVersion);
|
|
12388
|
-
* console.log(`Restored to commit: ${restoredPrompt.commit}`);
|
|
12389
|
-
* console.log(`New template: ${restoredPrompt.prompt}`);
|
|
12390
|
-
*
|
|
12391
|
-
* // Continue using the restored prompt
|
|
12392
|
-
* const formatted = restoredPrompt.format({ name: "World" });
|
|
12393
|
-
* }
|
|
12394
|
-
* ```
|
|
12395
|
-
*/
|
|
12396
|
-
useVersion(version: PromptVersion): Promise<Prompt>;
|
|
12397
|
-
/**
|
|
12398
|
-
* Synchronize the prompt with the backend.
|
|
12399
|
-
*
|
|
12400
|
-
* Creates or updates the prompt on the Opik server. If the sync fails,
|
|
12401
|
-
* a warning is logged and the same (unsynced) instance is returned.
|
|
12402
|
-
*
|
|
12403
|
-
* @returns Promise resolving to a new synced Prompt instance, or this instance if sync fails
|
|
12404
|
-
*/
|
|
12405
|
-
syncWithBackend(): Promise<Prompt>;
|
|
12406
|
-
/**
|
|
12407
|
-
* Get a Prompt with a specific version by commit hash.
|
|
12408
|
-
*
|
|
12409
|
-
* @param commit - Commit hash (8-char short form or full)
|
|
12410
|
-
* @returns Prompt instance representing that version, or null if not found
|
|
12411
|
-
*/
|
|
12412
|
-
getVersion(commit: string): Promise<Prompt | null>;
|
|
12413
|
-
}
|
|
12414
|
-
|
|
12415
12311
|
/**
|
|
12416
12312
|
* A feedback score for batch operations.
|
|
12417
12313
|
*
|
|
@@ -12432,14 +12328,16 @@ type FeedbackScoreData = Omit<FeedbackScoreBatchItem, "source" | "projectId" | "
|
|
|
12432
12328
|
* Allows associating prompt versions with trace updates.
|
|
12433
12329
|
*/
|
|
12434
12330
|
interface TraceUpdateData extends Omit<TraceUpdate, "projectId"> {
|
|
12435
|
-
prompts?:
|
|
12331
|
+
prompts?: BasePrompt[];
|
|
12332
|
+
appendPrompts?: boolean;
|
|
12436
12333
|
}
|
|
12437
12334
|
/**
|
|
12438
12335
|
* Extended SpanUpdate type that includes prompts field.
|
|
12439
12336
|
* Allows associating prompt versions with span updates.
|
|
12440
12337
|
*/
|
|
12441
12338
|
interface SpanUpdateData extends Omit<SpanUpdate$1, "traceId" | "parentSpanId" | "projectId" | "projectName"> {
|
|
12442
|
-
prompts?:
|
|
12339
|
+
prompts?: BasePrompt[];
|
|
12340
|
+
appendPrompts?: boolean;
|
|
12443
12341
|
}
|
|
12444
12342
|
|
|
12445
12343
|
interface SavedSpan extends Span$1 {
|
|
@@ -13151,6 +13049,113 @@ declare function buildSuiteResult(evalResult: EvaluationResult, options?: {
|
|
|
13151
13049
|
totalTime?: number;
|
|
13152
13050
|
}): TestSuiteResult;
|
|
13153
13051
|
|
|
13052
|
+
interface PromptData extends BasePromptData {
|
|
13053
|
+
prompt: string;
|
|
13054
|
+
}
|
|
13055
|
+
/**
|
|
13056
|
+
* Domain object representing a versioned text prompt template.
|
|
13057
|
+
* Provides immutable access to prompt properties and template formatting.
|
|
13058
|
+
* Integrates with backend for persistence and version management.
|
|
13059
|
+
*/
|
|
13060
|
+
declare class Prompt extends BasePrompt {
|
|
13061
|
+
readonly prompt: string;
|
|
13062
|
+
/**
|
|
13063
|
+
* Creates a new Prompt instance.
|
|
13064
|
+
* All operations work seamlessly without requiring manual configuration.
|
|
13065
|
+
*/
|
|
13066
|
+
constructor(data: PromptData);
|
|
13067
|
+
/** @deprecated Passing an opik client is deprecated. */
|
|
13068
|
+
constructor(data: PromptData, opik: OpikClient);
|
|
13069
|
+
private _performSync;
|
|
13070
|
+
/**
|
|
13071
|
+
* Returns the template string for this text prompt.
|
|
13072
|
+
* Alias for the `prompt` property for consistency with ChatPrompt.
|
|
13073
|
+
*/
|
|
13074
|
+
get template(): string;
|
|
13075
|
+
/**
|
|
13076
|
+
* Formats prompt template by substituting variables.
|
|
13077
|
+
* Validates that all template placeholders are provided (for Mustache templates).
|
|
13078
|
+
*
|
|
13079
|
+
* @param variables - Object with values to substitute into template
|
|
13080
|
+
* @returns Formatted prompt text with variables substituted
|
|
13081
|
+
* @throws PromptValidationError if template processing or validation fails
|
|
13082
|
+
*
|
|
13083
|
+
* @example
|
|
13084
|
+
* ```typescript
|
|
13085
|
+
* const prompt = new Prompt({
|
|
13086
|
+
* name: "greeting",
|
|
13087
|
+
* prompt: "Hello {{name}}, your score is {{score}}",
|
|
13088
|
+
* type: "mustache"
|
|
13089
|
+
* }, client);
|
|
13090
|
+
*
|
|
13091
|
+
* // Valid - all placeholders provided
|
|
13092
|
+
* prompt.format({ name: "Alice", score: 95 });
|
|
13093
|
+
* // Returns: "Hello Alice, your score is 95"
|
|
13094
|
+
*
|
|
13095
|
+
* // Invalid - missing 'score' placeholder
|
|
13096
|
+
* prompt.format({ name: "Alice" });
|
|
13097
|
+
* // Throws: PromptValidationError
|
|
13098
|
+
* ```
|
|
13099
|
+
*/
|
|
13100
|
+
format(variables: PromptVariables): string;
|
|
13101
|
+
/**
|
|
13102
|
+
* Static factory method to create Prompt from backend API response.
|
|
13103
|
+
*
|
|
13104
|
+
* @param name - Name of the prompt
|
|
13105
|
+
* @param apiResponse - REST API PromptVersionDetail response
|
|
13106
|
+
* @param opik - OpikClient instance
|
|
13107
|
+
* @param promptPublicData - Optional PromptPublic data containing description and tags
|
|
13108
|
+
* @returns Prompt instance constructed from response data
|
|
13109
|
+
* @throws PromptValidationError if response structure invalid
|
|
13110
|
+
*/
|
|
13111
|
+
static fromApiResponse(promptData: PromptPublic, apiResponse: PromptVersionDetail, opik: OpikClient, projectName?: string): Prompt;
|
|
13112
|
+
/**
|
|
13113
|
+
* Restores a specific version by creating a new version with content from the specified version.
|
|
13114
|
+
* The version must be obtained from the backend (e.g., via getVersions()).
|
|
13115
|
+
* Returns a new Prompt instance with the restored content as the latest version.
|
|
13116
|
+
*
|
|
13117
|
+
* @param version - PromptVersion object to restore (must be from backend)
|
|
13118
|
+
* @returns Promise resolving to a new Prompt instance with the restored version
|
|
13119
|
+
* @throws OpikApiError if REST API call fails
|
|
13120
|
+
*
|
|
13121
|
+
* @example
|
|
13122
|
+
* ```typescript
|
|
13123
|
+
* const prompt = await client.getPrompt({ name: "my-prompt" });
|
|
13124
|
+
*
|
|
13125
|
+
* // Get all versions
|
|
13126
|
+
* const versions = await prompt.getVersions();
|
|
13127
|
+
*
|
|
13128
|
+
* // Restore a specific version
|
|
13129
|
+
* const targetVersion = versions.find(v => v.commit === "abc123de");
|
|
13130
|
+
* if (targetVersion) {
|
|
13131
|
+
* const restoredPrompt = await prompt.useVersion(targetVersion);
|
|
13132
|
+
* console.log(`Restored to commit: ${restoredPrompt.commit}`);
|
|
13133
|
+
* console.log(`New template: ${restoredPrompt.prompt}`);
|
|
13134
|
+
*
|
|
13135
|
+
* // Continue using the restored prompt
|
|
13136
|
+
* const formatted = restoredPrompt.format({ name: "World" });
|
|
13137
|
+
* }
|
|
13138
|
+
* ```
|
|
13139
|
+
*/
|
|
13140
|
+
useVersion(version: PromptVersion): Promise<Prompt>;
|
|
13141
|
+
/**
|
|
13142
|
+
* Synchronize the prompt with the backend.
|
|
13143
|
+
*
|
|
13144
|
+
* Creates or updates the prompt on the Opik server. If the sync fails,
|
|
13145
|
+
* a warning is logged and the same (unsynced) instance is returned.
|
|
13146
|
+
*
|
|
13147
|
+
* @returns Promise resolving to a new synced Prompt instance, or this instance if sync fails
|
|
13148
|
+
*/
|
|
13149
|
+
syncWithBackend(): Promise<Prompt>;
|
|
13150
|
+
/**
|
|
13151
|
+
* Get a Prompt with a specific version by commit hash.
|
|
13152
|
+
*
|
|
13153
|
+
* @param commit - Commit hash (8-char short form or full)
|
|
13154
|
+
* @returns Prompt instance representing that version, or null if not found
|
|
13155
|
+
*/
|
|
13156
|
+
getVersion(commit: string): Promise<Prompt | null>;
|
|
13157
|
+
}
|
|
13158
|
+
|
|
13154
13159
|
interface EvaluateTestSuiteOptions<T = Record<string, unknown>> {
|
|
13155
13160
|
/** The dataset to evaluate against */
|
|
13156
13161
|
dataset: Dataset<T extends DatasetItemData ? T : DatasetItemData & T>;
|
|
@@ -14103,7 +14108,9 @@ declare class OpikClient {
|
|
|
14103
14108
|
createChatPrompt: (options: CreateChatPromptOptions) => Promise<ChatPrompt>;
|
|
14104
14109
|
/**
|
|
14105
14110
|
* Retrieves a text prompt by name and optional version.
|
|
14106
|
-
*
|
|
14111
|
+
* Results are cached client-side (TTL configurable via OPIK_PROMPT_CACHE_TTL_SECONDS,
|
|
14112
|
+
* default 300s). Pinned commits are cached indefinitely. When called inside a track()
|
|
14113
|
+
* context the prompt reference is injected into the active trace/span metadata.
|
|
14107
14114
|
*
|
|
14108
14115
|
* @param options - Prompt name and optional commit hash
|
|
14109
14116
|
* @returns Promise resolving to Prompt or null if not found
|
|
@@ -14112,7 +14119,9 @@ declare class OpikClient {
|
|
|
14112
14119
|
getPrompt: (options: GetPromptOptions) => Promise<Prompt | null>;
|
|
14113
14120
|
/**
|
|
14114
14121
|
* Retrieves a chat prompt by name and optional version.
|
|
14115
|
-
*
|
|
14122
|
+
* Results are cached client-side (TTL configurable via OPIK_PROMPT_CACHE_TTL_SECONDS,
|
|
14123
|
+
* default 300s). Pinned commits are cached indefinitely. When called inside a track()
|
|
14124
|
+
* context the prompt reference is injected into the active trace/span metadata.
|
|
14116
14125
|
*
|
|
14117
14126
|
* @param options - Prompt name and optional commit hash
|
|
14118
14127
|
* @returns Promise resolving to ChatPrompt or null if not found
|
|
@@ -14127,6 +14136,7 @@ declare class OpikClient {
|
|
|
14127
14136
|
* ```
|
|
14128
14137
|
*/
|
|
14129
14138
|
getChatPrompt: (options: GetPromptOptions) => Promise<ChatPrompt | null>;
|
|
14139
|
+
private getPromptWithCache;
|
|
14130
14140
|
/**
|
|
14131
14141
|
* Searches prompts with optional OQL filtering.
|
|
14132
14142
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -6253,6 +6253,8 @@ interface ServiceTogglesConfig {
|
|
|
6253
6253
|
bedrockProviderEnabled: boolean;
|
|
6254
6254
|
customllmProviderEnabled: boolean;
|
|
6255
6255
|
ollamaProviderEnabled: boolean;
|
|
6256
|
+
ollieEnabled: boolean;
|
|
6257
|
+
agenticToolsEnabled?: boolean;
|
|
6256
6258
|
v2WorkspaceAllowlistIds: string[];
|
|
6257
6259
|
v1WorkspaceAllowlistIds: string[];
|
|
6258
6260
|
forceWorkspaceVersion: string;
|
|
@@ -11966,6 +11968,7 @@ interface OpikConfig {
|
|
|
11966
11968
|
requestOptions?: RequestOptions;
|
|
11967
11969
|
batchDelayMs?: number;
|
|
11968
11970
|
holdUntilFlush?: boolean;
|
|
11971
|
+
promptCacheTtlSeconds?: number;
|
|
11969
11972
|
}
|
|
11970
11973
|
interface ConstructorOpikConfig extends Omit<OpikConfig, "environment"> {
|
|
11971
11974
|
headers?: Record<string, string>;
|
|
@@ -12305,113 +12308,6 @@ declare abstract class BasePrompt {
|
|
|
12305
12308
|
abstract syncWithBackend(): Promise<BasePrompt>;
|
|
12306
12309
|
}
|
|
12307
12310
|
|
|
12308
|
-
interface PromptData extends BasePromptData {
|
|
12309
|
-
prompt: string;
|
|
12310
|
-
}
|
|
12311
|
-
/**
|
|
12312
|
-
* Domain object representing a versioned text prompt template.
|
|
12313
|
-
* Provides immutable access to prompt properties and template formatting.
|
|
12314
|
-
* Integrates with backend for persistence and version management.
|
|
12315
|
-
*/
|
|
12316
|
-
declare class Prompt extends BasePrompt {
|
|
12317
|
-
readonly prompt: string;
|
|
12318
|
-
/**
|
|
12319
|
-
* Creates a new Prompt instance.
|
|
12320
|
-
* All operations work seamlessly without requiring manual configuration.
|
|
12321
|
-
*/
|
|
12322
|
-
constructor(data: PromptData);
|
|
12323
|
-
/** @deprecated Passing an opik client is deprecated. */
|
|
12324
|
-
constructor(data: PromptData, opik: OpikClient);
|
|
12325
|
-
private _performSync;
|
|
12326
|
-
/**
|
|
12327
|
-
* Returns the template string for this text prompt.
|
|
12328
|
-
* Alias for the `prompt` property for consistency with ChatPrompt.
|
|
12329
|
-
*/
|
|
12330
|
-
get template(): string;
|
|
12331
|
-
/**
|
|
12332
|
-
* Formats prompt template by substituting variables.
|
|
12333
|
-
* Validates that all template placeholders are provided (for Mustache templates).
|
|
12334
|
-
*
|
|
12335
|
-
* @param variables - Object with values to substitute into template
|
|
12336
|
-
* @returns Formatted prompt text with variables substituted
|
|
12337
|
-
* @throws PromptValidationError if template processing or validation fails
|
|
12338
|
-
*
|
|
12339
|
-
* @example
|
|
12340
|
-
* ```typescript
|
|
12341
|
-
* const prompt = new Prompt({
|
|
12342
|
-
* name: "greeting",
|
|
12343
|
-
* prompt: "Hello {{name}}, your score is {{score}}",
|
|
12344
|
-
* type: "mustache"
|
|
12345
|
-
* }, client);
|
|
12346
|
-
*
|
|
12347
|
-
* // Valid - all placeholders provided
|
|
12348
|
-
* prompt.format({ name: "Alice", score: 95 });
|
|
12349
|
-
* // Returns: "Hello Alice, your score is 95"
|
|
12350
|
-
*
|
|
12351
|
-
* // Invalid - missing 'score' placeholder
|
|
12352
|
-
* prompt.format({ name: "Alice" });
|
|
12353
|
-
* // Throws: PromptValidationError
|
|
12354
|
-
* ```
|
|
12355
|
-
*/
|
|
12356
|
-
format(variables: PromptVariables): string;
|
|
12357
|
-
/**
|
|
12358
|
-
* Static factory method to create Prompt from backend API response.
|
|
12359
|
-
*
|
|
12360
|
-
* @param name - Name of the prompt
|
|
12361
|
-
* @param apiResponse - REST API PromptVersionDetail response
|
|
12362
|
-
* @param opik - OpikClient instance
|
|
12363
|
-
* @param promptPublicData - Optional PromptPublic data containing description and tags
|
|
12364
|
-
* @returns Prompt instance constructed from response data
|
|
12365
|
-
* @throws PromptValidationError if response structure invalid
|
|
12366
|
-
*/
|
|
12367
|
-
static fromApiResponse(promptData: PromptPublic, apiResponse: PromptVersionDetail, opik: OpikClient, projectName?: string): Prompt;
|
|
12368
|
-
/**
|
|
12369
|
-
* Restores a specific version by creating a new version with content from the specified version.
|
|
12370
|
-
* The version must be obtained from the backend (e.g., via getVersions()).
|
|
12371
|
-
* Returns a new Prompt instance with the restored content as the latest version.
|
|
12372
|
-
*
|
|
12373
|
-
* @param version - PromptVersion object to restore (must be from backend)
|
|
12374
|
-
* @returns Promise resolving to a new Prompt instance with the restored version
|
|
12375
|
-
* @throws OpikApiError if REST API call fails
|
|
12376
|
-
*
|
|
12377
|
-
* @example
|
|
12378
|
-
* ```typescript
|
|
12379
|
-
* const prompt = await client.getPrompt({ name: "my-prompt" });
|
|
12380
|
-
*
|
|
12381
|
-
* // Get all versions
|
|
12382
|
-
* const versions = await prompt.getVersions();
|
|
12383
|
-
*
|
|
12384
|
-
* // Restore a specific version
|
|
12385
|
-
* const targetVersion = versions.find(v => v.commit === "abc123de");
|
|
12386
|
-
* if (targetVersion) {
|
|
12387
|
-
* const restoredPrompt = await prompt.useVersion(targetVersion);
|
|
12388
|
-
* console.log(`Restored to commit: ${restoredPrompt.commit}`);
|
|
12389
|
-
* console.log(`New template: ${restoredPrompt.prompt}`);
|
|
12390
|
-
*
|
|
12391
|
-
* // Continue using the restored prompt
|
|
12392
|
-
* const formatted = restoredPrompt.format({ name: "World" });
|
|
12393
|
-
* }
|
|
12394
|
-
* ```
|
|
12395
|
-
*/
|
|
12396
|
-
useVersion(version: PromptVersion): Promise<Prompt>;
|
|
12397
|
-
/**
|
|
12398
|
-
* Synchronize the prompt with the backend.
|
|
12399
|
-
*
|
|
12400
|
-
* Creates or updates the prompt on the Opik server. If the sync fails,
|
|
12401
|
-
* a warning is logged and the same (unsynced) instance is returned.
|
|
12402
|
-
*
|
|
12403
|
-
* @returns Promise resolving to a new synced Prompt instance, or this instance if sync fails
|
|
12404
|
-
*/
|
|
12405
|
-
syncWithBackend(): Promise<Prompt>;
|
|
12406
|
-
/**
|
|
12407
|
-
* Get a Prompt with a specific version by commit hash.
|
|
12408
|
-
*
|
|
12409
|
-
* @param commit - Commit hash (8-char short form or full)
|
|
12410
|
-
* @returns Prompt instance representing that version, or null if not found
|
|
12411
|
-
*/
|
|
12412
|
-
getVersion(commit: string): Promise<Prompt | null>;
|
|
12413
|
-
}
|
|
12414
|
-
|
|
12415
12311
|
/**
|
|
12416
12312
|
* A feedback score for batch operations.
|
|
12417
12313
|
*
|
|
@@ -12432,14 +12328,16 @@ type FeedbackScoreData = Omit<FeedbackScoreBatchItem, "source" | "projectId" | "
|
|
|
12432
12328
|
* Allows associating prompt versions with trace updates.
|
|
12433
12329
|
*/
|
|
12434
12330
|
interface TraceUpdateData extends Omit<TraceUpdate, "projectId"> {
|
|
12435
|
-
prompts?:
|
|
12331
|
+
prompts?: BasePrompt[];
|
|
12332
|
+
appendPrompts?: boolean;
|
|
12436
12333
|
}
|
|
12437
12334
|
/**
|
|
12438
12335
|
* Extended SpanUpdate type that includes prompts field.
|
|
12439
12336
|
* Allows associating prompt versions with span updates.
|
|
12440
12337
|
*/
|
|
12441
12338
|
interface SpanUpdateData extends Omit<SpanUpdate$1, "traceId" | "parentSpanId" | "projectId" | "projectName"> {
|
|
12442
|
-
prompts?:
|
|
12339
|
+
prompts?: BasePrompt[];
|
|
12340
|
+
appendPrompts?: boolean;
|
|
12443
12341
|
}
|
|
12444
12342
|
|
|
12445
12343
|
interface SavedSpan extends Span$1 {
|
|
@@ -13151,6 +13049,113 @@ declare function buildSuiteResult(evalResult: EvaluationResult, options?: {
|
|
|
13151
13049
|
totalTime?: number;
|
|
13152
13050
|
}): TestSuiteResult;
|
|
13153
13051
|
|
|
13052
|
+
interface PromptData extends BasePromptData {
|
|
13053
|
+
prompt: string;
|
|
13054
|
+
}
|
|
13055
|
+
/**
|
|
13056
|
+
* Domain object representing a versioned text prompt template.
|
|
13057
|
+
* Provides immutable access to prompt properties and template formatting.
|
|
13058
|
+
* Integrates with backend for persistence and version management.
|
|
13059
|
+
*/
|
|
13060
|
+
declare class Prompt extends BasePrompt {
|
|
13061
|
+
readonly prompt: string;
|
|
13062
|
+
/**
|
|
13063
|
+
* Creates a new Prompt instance.
|
|
13064
|
+
* All operations work seamlessly without requiring manual configuration.
|
|
13065
|
+
*/
|
|
13066
|
+
constructor(data: PromptData);
|
|
13067
|
+
/** @deprecated Passing an opik client is deprecated. */
|
|
13068
|
+
constructor(data: PromptData, opik: OpikClient);
|
|
13069
|
+
private _performSync;
|
|
13070
|
+
/**
|
|
13071
|
+
* Returns the template string for this text prompt.
|
|
13072
|
+
* Alias for the `prompt` property for consistency with ChatPrompt.
|
|
13073
|
+
*/
|
|
13074
|
+
get template(): string;
|
|
13075
|
+
/**
|
|
13076
|
+
* Formats prompt template by substituting variables.
|
|
13077
|
+
* Validates that all template placeholders are provided (for Mustache templates).
|
|
13078
|
+
*
|
|
13079
|
+
* @param variables - Object with values to substitute into template
|
|
13080
|
+
* @returns Formatted prompt text with variables substituted
|
|
13081
|
+
* @throws PromptValidationError if template processing or validation fails
|
|
13082
|
+
*
|
|
13083
|
+
* @example
|
|
13084
|
+
* ```typescript
|
|
13085
|
+
* const prompt = new Prompt({
|
|
13086
|
+
* name: "greeting",
|
|
13087
|
+
* prompt: "Hello {{name}}, your score is {{score}}",
|
|
13088
|
+
* type: "mustache"
|
|
13089
|
+
* }, client);
|
|
13090
|
+
*
|
|
13091
|
+
* // Valid - all placeholders provided
|
|
13092
|
+
* prompt.format({ name: "Alice", score: 95 });
|
|
13093
|
+
* // Returns: "Hello Alice, your score is 95"
|
|
13094
|
+
*
|
|
13095
|
+
* // Invalid - missing 'score' placeholder
|
|
13096
|
+
* prompt.format({ name: "Alice" });
|
|
13097
|
+
* // Throws: PromptValidationError
|
|
13098
|
+
* ```
|
|
13099
|
+
*/
|
|
13100
|
+
format(variables: PromptVariables): string;
|
|
13101
|
+
/**
|
|
13102
|
+
* Static factory method to create Prompt from backend API response.
|
|
13103
|
+
*
|
|
13104
|
+
* @param name - Name of the prompt
|
|
13105
|
+
* @param apiResponse - REST API PromptVersionDetail response
|
|
13106
|
+
* @param opik - OpikClient instance
|
|
13107
|
+
* @param promptPublicData - Optional PromptPublic data containing description and tags
|
|
13108
|
+
* @returns Prompt instance constructed from response data
|
|
13109
|
+
* @throws PromptValidationError if response structure invalid
|
|
13110
|
+
*/
|
|
13111
|
+
static fromApiResponse(promptData: PromptPublic, apiResponse: PromptVersionDetail, opik: OpikClient, projectName?: string): Prompt;
|
|
13112
|
+
/**
|
|
13113
|
+
* Restores a specific version by creating a new version with content from the specified version.
|
|
13114
|
+
* The version must be obtained from the backend (e.g., via getVersions()).
|
|
13115
|
+
* Returns a new Prompt instance with the restored content as the latest version.
|
|
13116
|
+
*
|
|
13117
|
+
* @param version - PromptVersion object to restore (must be from backend)
|
|
13118
|
+
* @returns Promise resolving to a new Prompt instance with the restored version
|
|
13119
|
+
* @throws OpikApiError if REST API call fails
|
|
13120
|
+
*
|
|
13121
|
+
* @example
|
|
13122
|
+
* ```typescript
|
|
13123
|
+
* const prompt = await client.getPrompt({ name: "my-prompt" });
|
|
13124
|
+
*
|
|
13125
|
+
* // Get all versions
|
|
13126
|
+
* const versions = await prompt.getVersions();
|
|
13127
|
+
*
|
|
13128
|
+
* // Restore a specific version
|
|
13129
|
+
* const targetVersion = versions.find(v => v.commit === "abc123de");
|
|
13130
|
+
* if (targetVersion) {
|
|
13131
|
+
* const restoredPrompt = await prompt.useVersion(targetVersion);
|
|
13132
|
+
* console.log(`Restored to commit: ${restoredPrompt.commit}`);
|
|
13133
|
+
* console.log(`New template: ${restoredPrompt.prompt}`);
|
|
13134
|
+
*
|
|
13135
|
+
* // Continue using the restored prompt
|
|
13136
|
+
* const formatted = restoredPrompt.format({ name: "World" });
|
|
13137
|
+
* }
|
|
13138
|
+
* ```
|
|
13139
|
+
*/
|
|
13140
|
+
useVersion(version: PromptVersion): Promise<Prompt>;
|
|
13141
|
+
/**
|
|
13142
|
+
* Synchronize the prompt with the backend.
|
|
13143
|
+
*
|
|
13144
|
+
* Creates or updates the prompt on the Opik server. If the sync fails,
|
|
13145
|
+
* a warning is logged and the same (unsynced) instance is returned.
|
|
13146
|
+
*
|
|
13147
|
+
* @returns Promise resolving to a new synced Prompt instance, or this instance if sync fails
|
|
13148
|
+
*/
|
|
13149
|
+
syncWithBackend(): Promise<Prompt>;
|
|
13150
|
+
/**
|
|
13151
|
+
* Get a Prompt with a specific version by commit hash.
|
|
13152
|
+
*
|
|
13153
|
+
* @param commit - Commit hash (8-char short form or full)
|
|
13154
|
+
* @returns Prompt instance representing that version, or null if not found
|
|
13155
|
+
*/
|
|
13156
|
+
getVersion(commit: string): Promise<Prompt | null>;
|
|
13157
|
+
}
|
|
13158
|
+
|
|
13154
13159
|
interface EvaluateTestSuiteOptions<T = Record<string, unknown>> {
|
|
13155
13160
|
/** The dataset to evaluate against */
|
|
13156
13161
|
dataset: Dataset<T extends DatasetItemData ? T : DatasetItemData & T>;
|
|
@@ -14103,7 +14108,9 @@ declare class OpikClient {
|
|
|
14103
14108
|
createChatPrompt: (options: CreateChatPromptOptions) => Promise<ChatPrompt>;
|
|
14104
14109
|
/**
|
|
14105
14110
|
* Retrieves a text prompt by name and optional version.
|
|
14106
|
-
*
|
|
14111
|
+
* Results are cached client-side (TTL configurable via OPIK_PROMPT_CACHE_TTL_SECONDS,
|
|
14112
|
+
* default 300s). Pinned commits are cached indefinitely. When called inside a track()
|
|
14113
|
+
* context the prompt reference is injected into the active trace/span metadata.
|
|
14107
14114
|
*
|
|
14108
14115
|
* @param options - Prompt name and optional commit hash
|
|
14109
14116
|
* @returns Promise resolving to Prompt or null if not found
|
|
@@ -14112,7 +14119,9 @@ declare class OpikClient {
|
|
|
14112
14119
|
getPrompt: (options: GetPromptOptions) => Promise<Prompt | null>;
|
|
14113
14120
|
/**
|
|
14114
14121
|
* Retrieves a chat prompt by name and optional version.
|
|
14115
|
-
*
|
|
14122
|
+
* Results are cached client-side (TTL configurable via OPIK_PROMPT_CACHE_TTL_SECONDS,
|
|
14123
|
+
* default 300s). Pinned commits are cached indefinitely. When called inside a track()
|
|
14124
|
+
* context the prompt reference is injected into the active trace/span metadata.
|
|
14116
14125
|
*
|
|
14117
14126
|
* @param options - Prompt name and optional commit hash
|
|
14118
14127
|
* @returns Promise resolving to ChatPrompt or null if not found
|
|
@@ -14127,6 +14136,7 @@ declare class OpikClient {
|
|
|
14127
14136
|
* ```
|
|
14128
14137
|
*/
|
|
14129
14138
|
getChatPrompt: (options: GetPromptOptions) => Promise<ChatPrompt | null>;
|
|
14139
|
+
private getPromptWithCache;
|
|
14130
14140
|
/**
|
|
14131
14141
|
* Searches prompts with optional OQL filtering.
|
|
14132
14142
|
*
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {Fa}from'./chunk-
|
|
1
|
+
import {Fa}from'./chunk-EHVVWQKE.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-EHVVWQKE.js';Fa();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {za}from'./chunk-
|
|
1
|
+
import {za}from'./chunk-EHVVWQKE.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-EHVVWQKE.js';za();
|