opik 1.7.26 → 1.7.28

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.
@@ -388,6 +388,26 @@ interface ExperimentItemsDelete {
388
388
  ids: string[];
389
389
  }
390
390
 
391
+ /**
392
+ * This file was auto-generated by Fern from our API Definition.
393
+ */
394
+
395
+ /**
396
+ * @example
397
+ * {
398
+ * experimentName: "experiment_name",
399
+ * datasetName: "dataset_name",
400
+ * items: [{
401
+ * datasetItemId: "dataset_item_id"
402
+ * }]
403
+ * }
404
+ */
405
+ interface ExperimentItemBulkUploadExperimentItemBulkWriteView {
406
+ experimentName: string;
407
+ datasetName: string;
408
+ items: ExperimentItemBulkRecordExperimentItemBulkWriteView[];
409
+ }
410
+
391
411
  /**
392
412
  * This file was auto-generated by Fern from our API Definition.
393
413
  */
@@ -489,16 +509,6 @@ interface ProviderApiKeyUpdate {
489
509
  name?: string;
490
510
  }
491
511
 
492
- /**
493
- * This file was auto-generated by Fern from our API Definition.
494
- */
495
- type OptimizationWriteStatus = "running" | "completed" | "cancelled";
496
- declare const OptimizationWriteStatus: {
497
- readonly Running: "running";
498
- readonly Completed: "completed";
499
- readonly Cancelled: "cancelled";
500
- };
501
-
502
512
  /**
503
513
  * This file was auto-generated by Fern from our API Definition.
504
514
  */
@@ -524,27 +534,6 @@ interface FindOptimizationsRequest {
524
534
  datasetDeleted?: boolean;
525
535
  }
526
536
 
527
- /**
528
- * This file was auto-generated by Fern from our API Definition.
529
- */
530
-
531
- /**
532
- * @example
533
- * {
534
- * datasetName: "dataset_name",
535
- * objectiveName: "objective_name",
536
- * status: "running"
537
- * }
538
- */
539
- interface OptimizationWrite {
540
- id?: string;
541
- name?: string;
542
- datasetName: string;
543
- objectiveName: string;
544
- status: OptimizationWriteStatus;
545
- metadata?: JsonNodeWrite;
546
- }
547
-
548
537
  /**
549
538
  * This file was auto-generated by Fern from our API Definition.
550
539
  */
@@ -807,6 +796,17 @@ declare const GetSpansByProjectRequestType: {
807
796
  readonly Guardrail: "guardrail";
808
797
  };
809
798
 
799
+ /**
800
+ * This file was auto-generated by Fern from our API Definition.
801
+ */
802
+ type SpanUpdateType = "general" | "tool" | "llm" | "guardrail";
803
+ declare const SpanUpdateType: {
804
+ readonly General: "general";
805
+ readonly Tool: "tool";
806
+ readonly Llm: "llm";
807
+ readonly Guardrail: "guardrail";
808
+ };
809
+
810
810
  /**
811
811
  * This file was auto-generated by Fern from our API Definition.
812
812
  */
@@ -870,8 +870,6 @@ interface GetSpansByProjectRequest {
870
870
  * {
871
871
  * spans: [{
872
872
  * traceId: "trace_id",
873
- * name: "name",
874
- * type: "general",
875
873
  * startTime: "2024-01-15T09:30:00Z"
876
874
  * }]
877
875
  * }
@@ -897,6 +895,8 @@ interface SpanUpdate$1 {
897
895
  projectId?: string;
898
896
  traceId: string;
899
897
  parentSpanId?: string;
898
+ name?: string;
899
+ type?: SpanUpdateType;
900
900
  endTime?: Date;
901
901
  input?: JsonListString;
902
902
  output?: JsonListString;
@@ -2365,6 +2365,250 @@ interface DeleteIdsHolder {
2365
2365
  ids: string[];
2366
2366
  }
2367
2367
 
2368
+ /**
2369
+ * This file was auto-generated by Fern from our API Definition.
2370
+ */
2371
+ type CheckName = "TOPIC" | "PII";
2372
+ declare const CheckName: {
2373
+ readonly Topic: "TOPIC";
2374
+ readonly Pii: "PII";
2375
+ };
2376
+
2377
+ /**
2378
+ * This file was auto-generated by Fern from our API Definition.
2379
+ */
2380
+ type CheckResult = "passed" | "failed";
2381
+ declare const CheckResult: {
2382
+ readonly Passed: "passed";
2383
+ readonly Failed: "failed";
2384
+ };
2385
+
2386
+ /**
2387
+ * This file was auto-generated by Fern from our API Definition.
2388
+ */
2389
+
2390
+ interface Check$1 {
2391
+ name?: CheckName;
2392
+ result?: CheckResult;
2393
+ }
2394
+
2395
+ /**
2396
+ * This file was auto-generated by Fern from our API Definition.
2397
+ */
2398
+ interface ErrorInfo {
2399
+ exceptionType: string;
2400
+ message?: string;
2401
+ traceback: string;
2402
+ }
2403
+
2404
+ /**
2405
+ * This file was auto-generated by Fern from our API Definition.
2406
+ */
2407
+
2408
+ interface GuardrailsValidation {
2409
+ spanId?: string;
2410
+ checks?: Check$1[];
2411
+ }
2412
+
2413
+ /**
2414
+ * This file was auto-generated by Fern from our API Definition.
2415
+ */
2416
+ type SpanType = "general" | "tool" | "llm" | "guardrail";
2417
+ declare const SpanType: {
2418
+ readonly General: "general";
2419
+ readonly Tool: "tool";
2420
+ readonly Llm: "llm";
2421
+ readonly Guardrail: "guardrail";
2422
+ };
2423
+
2424
+ /**
2425
+ * This file was auto-generated by Fern from our API Definition.
2426
+ */
2427
+
2428
+ interface Span$1 {
2429
+ id?: string;
2430
+ /** If null, the default project is used */
2431
+ projectName?: string;
2432
+ projectId?: string;
2433
+ traceId: string;
2434
+ parentSpanId?: string;
2435
+ name?: string;
2436
+ type?: SpanType;
2437
+ startTime: Date;
2438
+ endTime?: Date;
2439
+ input?: JsonListString;
2440
+ output?: JsonListString;
2441
+ metadata?: JsonNode;
2442
+ model?: string;
2443
+ provider?: string;
2444
+ tags?: string[];
2445
+ usage?: Record<string, number>;
2446
+ errorInfo?: ErrorInfo;
2447
+ createdAt?: Date;
2448
+ lastUpdatedAt?: Date;
2449
+ createdBy?: string;
2450
+ lastUpdatedBy?: string;
2451
+ feedbackScores?: FeedbackScore[];
2452
+ comments?: Comment[];
2453
+ totalEstimatedCost?: number;
2454
+ totalEstimatedCostVersion?: string;
2455
+ /** Duration in milliseconds as a decimal number to support sub-millisecond precision */
2456
+ duration?: number;
2457
+ }
2458
+
2459
+ /**
2460
+ * This file was auto-generated by Fern from our API Definition.
2461
+ */
2462
+ type TraceVisibilityMode = "default" | "hidden";
2463
+ declare const TraceVisibilityMode: {
2464
+ readonly Default: "default";
2465
+ readonly Hidden: "hidden";
2466
+ };
2467
+
2468
+ /**
2469
+ * This file was auto-generated by Fern from our API Definition.
2470
+ */
2471
+
2472
+ interface Trace$1 {
2473
+ id?: string;
2474
+ /** If null, the default project is used */
2475
+ projectName?: string;
2476
+ projectId?: string;
2477
+ name?: string;
2478
+ startTime: Date;
2479
+ endTime?: Date;
2480
+ input?: JsonListString;
2481
+ output?: JsonListString;
2482
+ metadata?: JsonNode;
2483
+ tags?: string[];
2484
+ errorInfo?: ErrorInfo;
2485
+ usage?: Record<string, number>;
2486
+ createdAt?: Date;
2487
+ lastUpdatedAt?: Date;
2488
+ createdBy?: string;
2489
+ lastUpdatedBy?: string;
2490
+ feedbackScores?: FeedbackScore[];
2491
+ comments?: Comment[];
2492
+ guardrailsValidations?: GuardrailsValidation[];
2493
+ totalEstimatedCost?: number;
2494
+ spanCount?: number;
2495
+ /** Duration in milliseconds as a decimal number to support sub-millisecond precision */
2496
+ duration?: number;
2497
+ threadId?: string;
2498
+ visibilityMode?: TraceVisibilityMode;
2499
+ }
2500
+
2501
+ /**
2502
+ * This file was auto-generated by Fern from our API Definition.
2503
+ */
2504
+ interface ErrorInfoExperimentItemBulkWriteView {
2505
+ exceptionType: string;
2506
+ message?: string;
2507
+ traceback: string;
2508
+ }
2509
+
2510
+ /**
2511
+ * This file was auto-generated by Fern from our API Definition.
2512
+ */
2513
+
2514
+ interface ExperimentItemBulkRecordExperimentItemBulkWriteView {
2515
+ datasetItemId: string;
2516
+ trace?: TraceExperimentItemBulkWriteView;
2517
+ spans?: SpanExperimentItemBulkWriteView[];
2518
+ feedbackScores?: FeedbackScoreExperimentItemBulkWriteView[];
2519
+ }
2520
+
2521
+ /**
2522
+ * This file was auto-generated by Fern from our API Definition.
2523
+ */
2524
+ type FeedbackScoreExperimentItemBulkWriteViewSource = "ui" | "sdk" | "online_scoring";
2525
+ declare const FeedbackScoreExperimentItemBulkWriteViewSource: {
2526
+ readonly Ui: "ui";
2527
+ readonly Sdk: "sdk";
2528
+ readonly OnlineScoring: "online_scoring";
2529
+ };
2530
+
2531
+ /**
2532
+ * This file was auto-generated by Fern from our API Definition.
2533
+ */
2534
+
2535
+ interface FeedbackScoreExperimentItemBulkWriteView {
2536
+ name: string;
2537
+ categoryName?: string;
2538
+ value: number;
2539
+ reason?: string;
2540
+ source: FeedbackScoreExperimentItemBulkWriteViewSource;
2541
+ createdAt?: Date;
2542
+ lastUpdatedAt?: Date;
2543
+ createdBy?: string;
2544
+ lastUpdatedBy?: string;
2545
+ }
2546
+
2547
+ /**
2548
+ * This file was auto-generated by Fern from our API Definition.
2549
+ */
2550
+ type JsonListStringExperimentItemBulkWriteView = Record<string, unknown> | Record<string, unknown>[] | string;
2551
+
2552
+ /**
2553
+ * This file was auto-generated by Fern from our API Definition.
2554
+ */
2555
+ type JsonNodeExperimentItemBulkWriteView = Record<string, unknown>;
2556
+
2557
+ /**
2558
+ * This file was auto-generated by Fern from our API Definition.
2559
+ */
2560
+ type SpanExperimentItemBulkWriteViewType = "general" | "tool" | "llm" | "guardrail";
2561
+ declare const SpanExperimentItemBulkWriteViewType: {
2562
+ readonly General: "general";
2563
+ readonly Tool: "tool";
2564
+ readonly Llm: "llm";
2565
+ readonly Guardrail: "guardrail";
2566
+ };
2567
+
2568
+ /**
2569
+ * This file was auto-generated by Fern from our API Definition.
2570
+ */
2571
+
2572
+ interface SpanExperimentItemBulkWriteView {
2573
+ id?: string;
2574
+ parentSpanId?: string;
2575
+ name?: string;
2576
+ type?: SpanExperimentItemBulkWriteViewType;
2577
+ startTime: Date;
2578
+ endTime?: Date;
2579
+ input?: JsonListStringExperimentItemBulkWriteView;
2580
+ output?: JsonListStringExperimentItemBulkWriteView;
2581
+ metadata?: JsonNodeExperimentItemBulkWriteView;
2582
+ model?: string;
2583
+ provider?: string;
2584
+ tags?: string[];
2585
+ usage?: Record<string, number>;
2586
+ errorInfo?: ErrorInfoExperimentItemBulkWriteView;
2587
+ lastUpdatedAt?: Date;
2588
+ totalEstimatedCost?: number;
2589
+ totalEstimatedCostVersion?: string;
2590
+ }
2591
+
2592
+ /**
2593
+ * This file was auto-generated by Fern from our API Definition.
2594
+ */
2595
+
2596
+ interface TraceExperimentItemBulkWriteView {
2597
+ id?: string;
2598
+ /** If null, the default project is used */
2599
+ projectName?: string;
2600
+ name?: string;
2601
+ startTime: Date;
2602
+ endTime?: Date;
2603
+ input?: JsonListStringExperimentItemBulkWriteView;
2604
+ output?: JsonListStringExperimentItemBulkWriteView;
2605
+ metadata?: JsonNodeExperimentItemBulkWriteView;
2606
+ tags?: string[];
2607
+ errorInfo?: ErrorInfoExperimentItemBulkWriteView;
2608
+ lastUpdatedAt?: Date;
2609
+ threadId?: string;
2610
+ }
2611
+
2368
2612
  /**
2369
2613
  * This file was auto-generated by Fern from our API Definition.
2370
2614
  */
@@ -2708,18 +2952,42 @@ declare const ProviderApiKeyPublicProvider: {
2708
2952
  * This file was auto-generated by Fern from our API Definition.
2709
2953
  */
2710
2954
 
2711
- interface ProviderApiKeyPublic {
2955
+ interface ProviderApiKeyPublic {
2956
+ id?: string;
2957
+ provider: ProviderApiKeyPublicProvider;
2958
+ apiKey: string;
2959
+ name?: string;
2960
+ headers?: Record<string, string>;
2961
+ configuration?: Record<string, string>;
2962
+ baseUrl?: string;
2963
+ createdAt?: Date;
2964
+ createdBy?: string;
2965
+ lastUpdatedAt?: Date;
2966
+ lastUpdatedBy?: string;
2967
+ }
2968
+
2969
+ /**
2970
+ * This file was auto-generated by Fern from our API Definition.
2971
+ */
2972
+ type OptimizationWriteStatus = "running" | "completed" | "cancelled";
2973
+ declare const OptimizationWriteStatus: {
2974
+ readonly Running: "running";
2975
+ readonly Completed: "completed";
2976
+ readonly Cancelled: "cancelled";
2977
+ };
2978
+
2979
+ /**
2980
+ * This file was auto-generated by Fern from our API Definition.
2981
+ */
2982
+
2983
+ interface OptimizationWrite {
2712
2984
  id?: string;
2713
- provider: ProviderApiKeyPublicProvider;
2714
- apiKey: string;
2715
2985
  name?: string;
2716
- headers?: Record<string, string>;
2717
- configuration?: Record<string, string>;
2718
- baseUrl?: string;
2719
- createdAt?: Date;
2720
- createdBy?: string;
2986
+ datasetName: string;
2987
+ objectiveName: string;
2988
+ status: OptimizationWriteStatus;
2989
+ metadata?: JsonNodeWrite;
2721
2990
  lastUpdatedAt?: Date;
2722
- lastUpdatedBy?: string;
2723
2991
  }
2724
2992
 
2725
2993
  /**
@@ -2884,6 +3152,7 @@ interface ProjectStatsSummaryItem {
2884
3152
  feedbackScores?: FeedbackScoreAverage[];
2885
3153
  duration?: PercentageValues;
2886
3154
  totalEstimatedCost?: number;
3155
+ totalEstimatedCostSum?: number;
2887
3156
  usage?: Record<string, number>;
2888
3157
  traceCount?: number;
2889
3158
  guardrailsFailedCount?: number;
@@ -2932,6 +3201,7 @@ interface ProjectDetailed {
2932
3201
  feedbackScores?: FeedbackScoreAverageDetailed[];
2933
3202
  duration?: PercentageValuesDetailed;
2934
3203
  totalEstimatedCost?: number;
3204
+ totalEstimatedCostSum?: number;
2935
3205
  usage?: Record<string, number>;
2936
3206
  traceCount?: number;
2937
3207
  guardrailsFailedCount?: number;
@@ -3057,61 +3327,6 @@ interface ServiceTogglesConfig {
3057
3327
  guardrailsEnabled: boolean;
3058
3328
  }
3059
3329
 
3060
- /**
3061
- * This file was auto-generated by Fern from our API Definition.
3062
- */
3063
- interface ErrorInfo {
3064
- exceptionType: string;
3065
- message?: string;
3066
- traceback: string;
3067
- }
3068
-
3069
- /**
3070
- * This file was auto-generated by Fern from our API Definition.
3071
- */
3072
- type SpanType = "general" | "tool" | "llm" | "guardrail";
3073
- declare const SpanType: {
3074
- readonly General: "general";
3075
- readonly Tool: "tool";
3076
- readonly Llm: "llm";
3077
- readonly Guardrail: "guardrail";
3078
- };
3079
-
3080
- /**
3081
- * This file was auto-generated by Fern from our API Definition.
3082
- */
3083
-
3084
- interface Span$1 {
3085
- id?: string;
3086
- /** If null, the default project is used */
3087
- projectName?: string;
3088
- projectId?: string;
3089
- traceId: string;
3090
- parentSpanId?: string;
3091
- name: string;
3092
- type: SpanType;
3093
- startTime: Date;
3094
- endTime?: Date;
3095
- input?: JsonListString;
3096
- output?: JsonListString;
3097
- metadata?: JsonNode;
3098
- model?: string;
3099
- provider?: string;
3100
- tags?: string[];
3101
- usage?: Record<string, number>;
3102
- errorInfo?: ErrorInfo;
3103
- createdAt?: Date;
3104
- lastUpdatedAt?: Date;
3105
- createdBy?: string;
3106
- lastUpdatedBy?: string;
3107
- feedbackScores?: FeedbackScore[];
3108
- comments?: Comment[];
3109
- totalEstimatedCost?: number;
3110
- totalEstimatedCostVersion?: string;
3111
- /** Duration in milliseconds as a decimal number to support sub-millisecond precision */
3112
- duration?: number;
3113
- }
3114
-
3115
3330
  /**
3116
3331
  * This file was auto-generated by Fern from our API Definition.
3117
3332
  */
@@ -3147,8 +3362,8 @@ interface SpanWrite {
3147
3362
  projectName?: string;
3148
3363
  traceId: string;
3149
3364
  parentSpanId?: string;
3150
- name: string;
3151
- type: SpanWriteType;
3365
+ name?: string;
3366
+ type?: SpanWriteType;
3152
3367
  startTime: Date;
3153
3368
  endTime?: Date;
3154
3369
  input?: JsonListStringWrite;
@@ -3233,8 +3448,8 @@ interface SpanPublic {
3233
3448
  projectId?: string;
3234
3449
  traceId: string;
3235
3450
  parentSpanId?: string;
3236
- name: string;
3237
- type: SpanPublicType;
3451
+ name?: string;
3452
+ type?: SpanPublicType;
3238
3453
  startTime: Date;
3239
3454
  endTime?: Date;
3240
3455
  input?: JsonListStringPublic;
@@ -3382,74 +3597,6 @@ interface SpanFilterPublic {
3382
3597
  value?: string;
3383
3598
  }
3384
3599
 
3385
- /**
3386
- * This file was auto-generated by Fern from our API Definition.
3387
- */
3388
- type CheckName = "TOPIC" | "PII";
3389
- declare const CheckName: {
3390
- readonly Topic: "TOPIC";
3391
- readonly Pii: "PII";
3392
- };
3393
-
3394
- /**
3395
- * This file was auto-generated by Fern from our API Definition.
3396
- */
3397
- type CheckResult = "passed" | "failed";
3398
- declare const CheckResult: {
3399
- readonly Passed: "passed";
3400
- readonly Failed: "failed";
3401
- };
3402
-
3403
- /**
3404
- * This file was auto-generated by Fern from our API Definition.
3405
- */
3406
-
3407
- interface Check$1 {
3408
- name?: CheckName;
3409
- result?: CheckResult;
3410
- }
3411
-
3412
- /**
3413
- * This file was auto-generated by Fern from our API Definition.
3414
- */
3415
-
3416
- interface GuardrailsValidation {
3417
- spanId?: string;
3418
- checks?: Check$1[];
3419
- }
3420
-
3421
- /**
3422
- * This file was auto-generated by Fern from our API Definition.
3423
- */
3424
-
3425
- interface Trace$1 {
3426
- id?: string;
3427
- /** If null, the default project is used */
3428
- projectName?: string;
3429
- projectId?: string;
3430
- name?: string;
3431
- startTime: Date;
3432
- endTime?: Date;
3433
- input?: JsonListString;
3434
- output?: JsonListString;
3435
- metadata?: JsonNode;
3436
- tags?: string[];
3437
- errorInfo?: ErrorInfo;
3438
- usage?: Record<string, number>;
3439
- createdAt?: Date;
3440
- lastUpdatedAt?: Date;
3441
- createdBy?: string;
3442
- lastUpdatedBy?: string;
3443
- feedbackScores?: FeedbackScore[];
3444
- comments?: Comment[];
3445
- guardrailsValidations?: GuardrailsValidation[];
3446
- totalEstimatedCost?: number;
3447
- spanCount?: number;
3448
- /** Duration in milliseconds as a decimal number to support sub-millisecond precision */
3449
- duration?: number;
3450
- threadId?: string;
3451
- }
3452
-
3453
3600
  /**
3454
3601
  * This file was auto-generated by Fern from our API Definition.
3455
3602
  */
@@ -3506,6 +3653,15 @@ interface GuardrailsValidationPublic {
3506
3653
  checks?: CheckPublic[];
3507
3654
  }
3508
3655
 
3656
+ /**
3657
+ * This file was auto-generated by Fern from our API Definition.
3658
+ */
3659
+ type TracePublicVisibilityMode = "default" | "hidden";
3660
+ declare const TracePublicVisibilityMode: {
3661
+ readonly Default: "default";
3662
+ readonly Hidden: "hidden";
3663
+ };
3664
+
3509
3665
  /**
3510
3666
  * This file was auto-generated by Fern from our API Definition.
3511
3667
  */
@@ -3534,6 +3690,7 @@ interface TracePublic {
3534
3690
  /** Duration in milliseconds as a decimal number to support sub-millisecond precision */
3535
3691
  duration?: number;
3536
3692
  threadId?: string;
3693
+ visibilityMode?: TracePublicVisibilityMode;
3537
3694
  }
3538
3695
 
3539
3696
  /**
@@ -4502,6 +4659,26 @@ declare class Experiments {
4502
4659
  */
4503
4660
  deleteExperimentsById(request: DeleteIdsHolder, requestOptions?: Experiments.RequestOptions): HttpResponsePromise<void>;
4504
4661
  private __deleteExperimentsById;
4662
+ /**
4663
+ * Record experiment items in bulk with traces, spans, and feedback scores. Maximum request size is 4MB.
4664
+ *
4665
+ * @param {OpikApi.ExperimentItemBulkUploadExperimentItemBulkWriteView} request
4666
+ * @param {Experiments.RequestOptions} requestOptions - Request-specific configuration.
4667
+ *
4668
+ * @throws {@link OpikApi.BadRequestError}
4669
+ * @throws {@link OpikApi.UnprocessableEntityError}
4670
+ *
4671
+ * @example
4672
+ * await client.experiments.experimentItemsBulk({
4673
+ * experimentName: "experiment_name",
4674
+ * datasetName: "dataset_name",
4675
+ * items: [{
4676
+ * datasetItemId: "dataset_item_id"
4677
+ * }]
4678
+ * })
4679
+ */
4680
+ experimentItemsBulk(request: ExperimentItemBulkUploadExperimentItemBulkWriteView, requestOptions?: Experiments.RequestOptions): HttpResponsePromise<void>;
4681
+ private __experimentItemsBulk;
4505
4682
  /**
4506
4683
  * Find Feedback Score names
4507
4684
  *
@@ -4957,6 +5134,21 @@ declare class Optimizations {
4957
5134
  */
4958
5135
  createOptimization(request: OptimizationWrite, requestOptions?: Optimizations.RequestOptions): HttpResponsePromise<void>;
4959
5136
  private __createOptimization;
5137
+ /**
5138
+ * Upsert optimization
5139
+ *
5140
+ * @param {OpikApi.OptimizationWrite} request
5141
+ * @param {Optimizations.RequestOptions} requestOptions - Request-specific configuration.
5142
+ *
5143
+ * @example
5144
+ * await client.optimizations.upsertOptimization({
5145
+ * datasetName: "dataset_name",
5146
+ * objectiveName: "objective_name",
5147
+ * status: "running"
5148
+ * })
5149
+ */
5150
+ upsertOptimization(request: OptimizationWrite, requestOptions?: Optimizations.RequestOptions): HttpResponsePromise<void>;
5151
+ private __upsertOptimization;
4960
5152
  /**
4961
5153
  * Delete optimizations by id
4962
5154
  *
@@ -5496,8 +5688,6 @@ declare class Spans {
5496
5688
  * @example
5497
5689
  * await client.spans.createSpan({
5498
5690
  * traceId: "trace_id",
5499
- * name: "name",
5500
- * type: "general",
5501
5691
  * startTime: "2024-01-15T09:30:00Z"
5502
5692
  * })
5503
5693
  */
@@ -5513,8 +5703,6 @@ declare class Spans {
5513
5703
  * await client.spans.createSpans({
5514
5704
  * spans: [{
5515
5705
  * traceId: "trace_id",
5516
- * name: "name",
5517
- * type: "general",
5518
5706
  * startTime: "2024-01-15T09:30:00Z"
5519
5707
  * }]
5520
5708
  * })
@@ -6275,6 +6463,133 @@ declare class TraceFeedbackScoresBatchQueue extends BatchQueue<FeedbackScoreBatc
6275
6463
  protected deleteEntities(scoreIds: FeedbackScoreId[]): Promise<void>;
6276
6464
  }
6277
6465
 
6466
+ /**
6467
+ * Batch queue for dataset operations that allows efficient batching of dataset CRUD operations.
6468
+ * Extends the generic BatchQueue to provide specific implementations for dataset resources.
6469
+ */
6470
+ declare class DatasetBatchQueue extends BatchQueue<DatasetWrite> {
6471
+ private readonly api;
6472
+ /**
6473
+ * Creates a new DatasetBatchQueue instance.
6474
+ *
6475
+ * @param api The OpikApiClient instance used to communicate with the API
6476
+ * @param delay Optional delay in milliseconds before flushing the queue (defaults to 300ms)
6477
+ */
6478
+ constructor(api: OpikApiClient, delay?: number);
6479
+ /**
6480
+ * Gets the ID of a dataset entity.
6481
+ *
6482
+ * @param entity The dataset entity
6483
+ * @returns The ID of the dataset
6484
+ */
6485
+ protected getId(entity: DatasetWrite): string;
6486
+ /**
6487
+ * Creates multiple dataset entities in a batch.
6488
+ *
6489
+ * @param datasets The array of datasets to create
6490
+ */
6491
+ protected createEntities(datasets: DatasetWrite[]): Promise<void>;
6492
+ /**
6493
+ * Retrieves a dataset by its ID.
6494
+ *
6495
+ * @param id The ID of the dataset to retrieve
6496
+ * @returns The retrieved dataset or undefined if not found
6497
+ */
6498
+ protected getEntity(id: string): Promise<DatasetPublic | undefined>;
6499
+ /**
6500
+ * Updates a dataset by its ID with the provided updates.
6501
+ *
6502
+ * @param id The ID of the dataset to update
6503
+ * @param updates Partial dataset properties to update
6504
+ */
6505
+ protected updateEntity(id: string, updates: Partial<DatasetWrite>): Promise<void>;
6506
+ /**
6507
+ * Deletes multiple datasets by their IDs.
6508
+ *
6509
+ * @param ids Array of dataset IDs to delete
6510
+ */
6511
+ protected deleteEntities(ids: string[]): Promise<void>;
6512
+ }
6513
+
6514
+ type DatasetItemData = JsonNode & {
6515
+ id?: string;
6516
+ };
6517
+
6518
+ interface DatasetData {
6519
+ name: string;
6520
+ description?: string;
6521
+ id?: string;
6522
+ }
6523
+ declare class Dataset<T extends DatasetItemData = DatasetItemData> {
6524
+ private opik;
6525
+ readonly id: string;
6526
+ readonly name: string;
6527
+ readonly description?: string;
6528
+ private idToHash;
6529
+ private hashes;
6530
+ /**
6531
+ * Configuration object for creating a new Dataset instance.
6532
+ * This should not be created directly, use static factory methods instead.
6533
+ */
6534
+ constructor({ name, description, id }: DatasetData, opik: OpikClient);
6535
+ /**
6536
+ * Insert new items into the dataset.
6537
+ *
6538
+ * @param items List of objects to add to the dataset
6539
+ */
6540
+ insert(items: T[]): Promise<void>;
6541
+ /**
6542
+ * Update existing items in the dataset.
6543
+ * You need to provide the full item object as it will override what has been supplied previously.
6544
+ *
6545
+ * @param items List of objects to update in the dataset
6546
+ */
6547
+ update(items: T[]): Promise<void>;
6548
+ /**
6549
+ * Delete items from the dataset.
6550
+ *
6551
+ * @param itemIds List of item ids to delete
6552
+ */
6553
+ delete(itemIds: string[]): Promise<void>;
6554
+ /**
6555
+ * Delete all items from the dataset.
6556
+ */
6557
+ clear(): Promise<void>;
6558
+ /**
6559
+ * Retrieve a fixed number of dataset items.
6560
+ *
6561
+ * @param nbSamples The number of samples to retrieve. If not set - all items are returned
6562
+ * @param lastRetrievedId Optional ID of the last retrieved item for pagination
6563
+ * @returns A list of objects representing the dataset items
6564
+ */
6565
+ getItems(nbSamples?: number, lastRetrievedId?: string): Promise<(T & {
6566
+ id: string;
6567
+ })[]>;
6568
+ private getItemsAsDataclasses;
6569
+ /**
6570
+ * Insert items from a JSON string array into the dataset.
6571
+ *
6572
+ * @param jsonArray JSON string of format: "[{...}, {...}, {...}]" where every object is transformed into a dataset item
6573
+ * @param keysMapping Optional dictionary that maps JSON keys to dataset item field names (e.g., {'Expected output': 'expected_output'})
6574
+ * @param ignoreKeys Optional array of keys that should be ignored when constructing dataset items
6575
+ */
6576
+ insertFromJson(jsonArray: string, keysMapping?: Record<string, string>, ignoreKeys?: string[]): Promise<void>;
6577
+ /**
6578
+ * Convert the dataset to a JSON string.
6579
+ *
6580
+ * @param keysMapping Optional dictionary that maps dataset item field names to output JSON keys
6581
+ * @returns A JSON string representation of all items in the dataset
6582
+ */
6583
+ toJson(keysMapping?: Record<string, string>): Promise<string>;
6584
+ /**
6585
+ * Retrieves all items from the dataset, deduplicates them, and returns them.
6586
+ *
6587
+ * @returns A list of deduplicated dataset items
6588
+ */
6589
+ private getDeduplicatedItems;
6590
+ syncHashes(): Promise<void>;
6591
+ }
6592
+
6278
6593
  interface TraceData extends Omit<Trace$1, "startTime"> {
6279
6594
  startTime?: Date;
6280
6595
  }
@@ -6285,10 +6600,48 @@ declare class OpikClient {
6285
6600
  traceBatchQueue: TraceBatchQueue;
6286
6601
  spanFeedbackScoresBatchQueue: SpanFeedbackScoresBatchQueue;
6287
6602
  traceFeedbackScoresBatchQueue: TraceFeedbackScoresBatchQueue;
6603
+ datasetBatchQueue: DatasetBatchQueue;
6288
6604
  private lastProjectNameLogged;
6289
6605
  constructor(explicitConfig?: Partial<OpikConfig>);
6290
6606
  private displayTraceLog;
6291
6607
  trace: (traceData: TraceData) => Trace;
6608
+ /**
6609
+ * Retrieves an existing dataset by name
6610
+ *
6611
+ * @param name The name of the dataset to retrieve
6612
+ * @returns A Dataset object associated with the specified name
6613
+ * @throws Error if the dataset doesn't exist
6614
+ */
6615
+ getDataset: <T extends DatasetItemData = DatasetItemData>(name: string) => Promise<Dataset<T>>;
6616
+ /**
6617
+ * Creates a new dataset with the given name and optional description
6618
+ *
6619
+ * @param name The name of the dataset
6620
+ * @param description Optional description of the dataset
6621
+ * @returns The created Dataset object
6622
+ */
6623
+ createDataset: <T extends DatasetItemData = DatasetItemData>(name: string, description?: string) => Promise<Dataset<T>>;
6624
+ /**
6625
+ * Retrieves an existing dataset by name or creates a new one if it doesn't exist.
6626
+ *
6627
+ * @param name The name of the dataset
6628
+ * @param description Optional description of the dataset (used if created)
6629
+ * @returns A promise that resolves to the existing or newly created Dataset object
6630
+ */
6631
+ getOrCreateDataset: <T extends DatasetItemData = DatasetItemData>(name: string, description?: string) => Promise<Dataset<T>>;
6632
+ /**
6633
+ * Returns all datasets up to the specified limit
6634
+ *
6635
+ * @param maxResults Maximum number of datasets to return (default: 100)
6636
+ * @returns List of Dataset objects
6637
+ */
6638
+ getDatasets: <T extends DatasetItemData = DatasetItemData>(maxResults?: number) => Promise<Dataset<T>[]>;
6639
+ /**
6640
+ * Deletes a dataset by name
6641
+ *
6642
+ * @param name The name of the dataset to delete
6643
+ */
6644
+ deleteDataset: (name: string) => Promise<void>;
6292
6645
  flush: () => Promise<void>;
6293
6646
  }
6294
6647