opik 0.0.7 → 0.1.0

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.cjs CHANGED
@@ -1,10 +1,15 @@
1
- "use strict";
2
- var __create = Object.create;
1
+ 'use strict';
2
+
3
+ var qs = require('qs');
4
+ var uuid = require('uuid');
5
+ var async_hooks = require('async_hooks');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var qs__default = /*#__PURE__*/_interopDefault(qs);
10
+
3
11
  var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
12
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
13
  var __esm = (fn, res) => function __init() {
9
14
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
15
  };
@@ -12,23 +17,6 @@ var __export = (target, all) => {
12
17
  for (var name in all)
13
18
  __defProp(target, name, { get: all[name], enumerable: true });
14
19
  };
15
- var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from))
18
- if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
- }
21
- return to;
22
- };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
- // If the importer is in node compatibility mode or this is not an ESM
25
- // file that has been converted to a CommonJS file using a Babel-
26
- // compatible transform (i.e. "__esModule" has not been set), then set
27
- // "default" to the CommonJS "module.exports" for node compatibility.
28
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
- mod
30
- ));
31
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
20
 
33
21
  // src/opik/rest_api/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts
34
22
  var Node18UniversalStreamWrapper_exports = {};
@@ -38,7 +26,6 @@ __export(Node18UniversalStreamWrapper_exports, {
38
26
  var Node18UniversalStreamWrapper;
39
27
  var init_Node18UniversalStreamWrapper = __esm({
40
28
  "src/opik/rest_api/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts"() {
41
- "use strict";
42
29
  Node18UniversalStreamWrapper = class _Node18UniversalStreamWrapper {
43
30
  constructor(readableStream) {
44
31
  this.readableStream = readableStream;
@@ -260,7 +247,6 @@ __export(UndiciStreamWrapper_exports, {
260
247
  var UndiciStreamWrapper;
261
248
  var init_UndiciStreamWrapper = __esm({
262
249
  "src/opik/rest_api/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts"() {
263
- "use strict";
264
250
  UndiciStreamWrapper = class _UndiciStreamWrapper {
265
251
  constructor(readableStream) {
266
252
  this.readableStream = readableStream;
@@ -470,7 +456,6 @@ __export(NodePre18StreamWrapper_exports, {
470
456
  var NodePre18StreamWrapper;
471
457
  var init_NodePre18StreamWrapper = __esm({
472
458
  "src/opik/rest_api/core/fetcher/stream-wrappers/NodePre18StreamWrapper.ts"() {
473
- "use strict";
474
459
  NodePre18StreamWrapper = class {
475
460
  constructor(readableStream) {
476
461
  this.readableStream = readableStream;
@@ -556,17 +541,6 @@ var init_NodePre18StreamWrapper = __esm({
556
541
  }
557
542
  });
558
543
 
559
- // src/opik/index.ts
560
- var index_exports = {};
561
- __export(index_exports, {
562
- Opik: () => OpikClient,
563
- flushAll: () => flushAll,
564
- track: () => track,
565
- trackOpikClient: () => trackOpikClient,
566
- withTrack: () => withTrack
567
- });
568
- module.exports = __toCommonJS(index_exports);
569
-
570
544
  // src/opik/config/Config.ts
571
545
  var DEFAULT_CONFIG = {
572
546
  apiKey: "",
@@ -1170,11 +1144,8 @@ var NotImplementedError = class _NotImplementedError extends OpikApiError {
1170
1144
  var OpikApiEnvironment = {
1171
1145
  Default: "http://localhost:5173/api"
1172
1146
  };
1173
-
1174
- // src/opik/rest_api/core/fetcher/createRequestUrl.ts
1175
- var import_qs = __toESM(require("qs"), 1);
1176
1147
  function createRequestUrl(baseUrl, queryParameters) {
1177
- return Object.keys(queryParameters != null ? queryParameters : {}).length > 0 ? `${baseUrl}?${import_qs.default.stringify(queryParameters, { arrayFormat: "repeat" })}` : baseUrl;
1148
+ return Object.keys(queryParameters != null ? queryParameters : {}).length > 0 ? `${baseUrl}?${qs__default.default.stringify(queryParameters, { arrayFormat: "repeat" })}` : baseUrl;
1178
1149
  }
1179
1150
 
1180
1151
  // src/opik/rest_api/core/runtime/runtime.ts
@@ -1246,12 +1217,12 @@ async function getFetchFn() {
1246
1217
  return fetch;
1247
1218
  }
1248
1219
  if (RUNTIME.type === "node") {
1249
- return (await import("node-fetch")).default;
1220
+ return (await import('node-fetch')).default;
1250
1221
  }
1251
1222
  if (typeof fetch == "function") {
1252
1223
  return fetch;
1253
1224
  }
1254
- return (await import("node-fetch")).default;
1225
+ return (await import('node-fetch')).default;
1255
1226
  }
1256
1227
 
1257
1228
  // src/opik/rest_api/core/fetcher/getRequestBody.ts
@@ -3195,7 +3166,6 @@ __export(serialization_exports, {
3195
3166
  TraceWrite: () => TraceWrite,
3196
3167
  Usage: () => Usage,
3197
3168
  WorkspaceTraceCount: () => WorkspaceTraceCount,
3198
- automationRuleEvaluators: () => automationRuleEvaluators_exports2,
3199
3169
  chatCompletions: () => chatCompletions_exports2,
3200
3170
  datasets: () => datasets_exports2,
3201
3171
  experiments: () => experiments_exports2,
@@ -3626,52 +3596,6 @@ var TraceUpdate = schemas_exports.object({
3626
3596
  errorInfo: schemas_exports.property("error_info", ErrorInfo.optional())
3627
3597
  });
3628
3598
 
3629
- // src/opik/rest_api/serialization/resources/automationRuleEvaluators/index.ts
3630
- var automationRuleEvaluators_exports2 = {};
3631
- __export(automationRuleEvaluators_exports2, {
3632
- AutomationRuleEvaluatorUpdate: () => AutomationRuleEvaluatorUpdate
3633
- });
3634
-
3635
- // src/opik/rest_api/serialization/types/LlmAsJudgeModelParameters.ts
3636
- var LlmAsJudgeModelParameters = schemas_exports.object({
3637
- name: schemas_exports.string(),
3638
- temperature: schemas_exports.number()
3639
- });
3640
-
3641
- // src/opik/rest_api/serialization/types/LlmAsJudgeMessageRole.ts
3642
- var LlmAsJudgeMessageRole2 = schemas_exports.enum_(["SYSTEM", "USER", "AI", "TOOL_EXECUTION_RESULT"]);
3643
-
3644
- // src/opik/rest_api/serialization/types/LlmAsJudgeMessage.ts
3645
- var LlmAsJudgeMessage = schemas_exports.object({
3646
- role: LlmAsJudgeMessageRole2,
3647
- content: schemas_exports.string()
3648
- });
3649
-
3650
- // src/opik/rest_api/serialization/types/LlmAsJudgeOutputSchemaType.ts
3651
- var LlmAsJudgeOutputSchemaType2 = schemas_exports.enum_(["BOOLEAN", "INTEGER", "DOUBLE"]);
3652
-
3653
- // src/opik/rest_api/serialization/types/LlmAsJudgeOutputSchema.ts
3654
- var LlmAsJudgeOutputSchema = schemas_exports.object({
3655
- name: schemas_exports.string(),
3656
- type: LlmAsJudgeOutputSchemaType2,
3657
- description: schemas_exports.string()
3658
- });
3659
-
3660
- // src/opik/rest_api/serialization/types/LlmAsJudgeCode.ts
3661
- var LlmAsJudgeCode = schemas_exports.object({
3662
- model: LlmAsJudgeModelParameters,
3663
- messages: schemas_exports.list(LlmAsJudgeMessage),
3664
- variables: schemas_exports.record(schemas_exports.string(), schemas_exports.string()),
3665
- schema: schemas_exports.list(LlmAsJudgeOutputSchema)
3666
- });
3667
-
3668
- // src/opik/rest_api/serialization/resources/automationRuleEvaluators/client/requests/AutomationRuleEvaluatorUpdate.ts
3669
- var AutomationRuleEvaluatorUpdate = schemas_exports.object({
3670
- name: schemas_exports.string(),
3671
- code: LlmAsJudgeCode,
3672
- samplingRate: schemas_exports.property("sampling_rate", schemas_exports.number())
3673
- });
3674
-
3675
3599
  // src/opik/rest_api/serialization/resources/chatCompletions/index.ts
3676
3600
  var chatCompletions_exports2 = {};
3677
3601
  __export(chatCompletions_exports2, {
@@ -3876,6 +3800,39 @@ var ErrorMessage = schemas_exports.object({
3876
3800
  // src/opik/rest_api/serialization/types/AuthDetailsHolder.ts
3877
3801
  var AuthDetailsHolder = schemas_exports.record(schemas_exports.string(), schemas_exports.unknown());
3878
3802
 
3803
+ // src/opik/rest_api/serialization/types/LlmAsJudgeModelParameters.ts
3804
+ var LlmAsJudgeModelParameters = schemas_exports.object({
3805
+ name: schemas_exports.string(),
3806
+ temperature: schemas_exports.number()
3807
+ });
3808
+
3809
+ // src/opik/rest_api/serialization/types/LlmAsJudgeMessageRole.ts
3810
+ var LlmAsJudgeMessageRole2 = schemas_exports.enum_(["SYSTEM", "USER", "AI", "TOOL_EXECUTION_RESULT"]);
3811
+
3812
+ // src/opik/rest_api/serialization/types/LlmAsJudgeMessage.ts
3813
+ var LlmAsJudgeMessage = schemas_exports.object({
3814
+ role: LlmAsJudgeMessageRole2,
3815
+ content: schemas_exports.string()
3816
+ });
3817
+
3818
+ // src/opik/rest_api/serialization/types/LlmAsJudgeOutputSchemaType.ts
3819
+ var LlmAsJudgeOutputSchemaType2 = schemas_exports.enum_(["BOOLEAN", "INTEGER", "DOUBLE"]);
3820
+
3821
+ // src/opik/rest_api/serialization/types/LlmAsJudgeOutputSchema.ts
3822
+ var LlmAsJudgeOutputSchema = schemas_exports.object({
3823
+ name: schemas_exports.string(),
3824
+ type: LlmAsJudgeOutputSchemaType2,
3825
+ description: schemas_exports.string()
3826
+ });
3827
+
3828
+ // src/opik/rest_api/serialization/types/LlmAsJudgeCode.ts
3829
+ var LlmAsJudgeCode = schemas_exports.object({
3830
+ model: LlmAsJudgeModelParameters,
3831
+ messages: schemas_exports.list(LlmAsJudgeMessage),
3832
+ variables: schemas_exports.record(schemas_exports.string(), schemas_exports.string()),
3833
+ schema: schemas_exports.list(LlmAsJudgeOutputSchema)
3834
+ });
3835
+
3879
3836
  // src/opik/rest_api/serialization/types/AutomationRuleEvaluatorLlmAsJudge.ts
3880
3837
  var AutomationRuleEvaluatorLlmAsJudge = schemas_exports.object({
3881
3838
  code: LlmAsJudgeCode.optional()
@@ -3940,6 +3897,7 @@ var AutomationRuleEvaluatorLlmAsJudgeWrite = schemas_exports.object({
3940
3897
 
3941
3898
  // src/opik/rest_api/serialization/types/AutomationRuleEvaluatorWrite.ts
3942
3899
  var _Base2 = schemas_exports.object({
3900
+ projectId: schemas_exports.property("project_id", schemas_exports.string().optional()),
3943
3901
  name: schemas_exports.string(),
3944
3902
  samplingRate: schemas_exports.property("sampling_rate", schemas_exports.number().optional()),
3945
3903
  action: schemas_exports.stringLiteral("evaluator").optional()
@@ -4060,6 +4018,14 @@ var LogPage = schemas_exports.object({
4060
4018
  total: schemas_exports.number().optional()
4061
4019
  });
4062
4020
 
4021
+ // src/opik/rest_api/serialization/types/AutomationRuleEvaluatorUpdate.ts
4022
+ var AutomationRuleEvaluatorUpdate = schemas_exports.object({
4023
+ name: schemas_exports.string(),
4024
+ code: LlmAsJudgeCode,
4025
+ samplingRate: schemas_exports.property("sampling_rate", schemas_exports.number()),
4026
+ projectId: schemas_exports.property("project_id", schemas_exports.string().optional())
4027
+ });
4028
+
4063
4029
  // src/opik/rest_api/serialization/types/AssistantMessageRole.ts
4064
4030
  var AssistantMessageRole2 = schemas_exports.enum_(["system", "user", "assistant", "tool", "function"]);
4065
4031
 
@@ -5529,14 +5495,436 @@ var AutomationRuleEvaluators = class {
5529
5495
  /**
5530
5496
  * Find project Evaluators
5531
5497
  *
5532
- * @param {string} projectId
5533
5498
  * @param {OpikApi.FindEvaluatorsRequest} request
5534
5499
  * @param {AutomationRuleEvaluators.RequestOptions} requestOptions - Request-specific configuration.
5535
5500
  *
5536
5501
  * @example
5537
- * await client.automationRuleEvaluators.findEvaluators("projectId")
5502
+ * await client.automationRuleEvaluators.findEvaluators()
5503
+ */
5504
+ async findEvaluators(request = {}, requestOptions) {
5505
+ var _a, _b;
5506
+ const { projectId, name, page, size } = request;
5507
+ const _queryParams = {};
5508
+ if (projectId != null) {
5509
+ _queryParams["project_id"] = projectId;
5510
+ }
5511
+ if (name != null) {
5512
+ _queryParams["name"] = name;
5513
+ }
5514
+ if (page != null) {
5515
+ _queryParams["page"] = page.toString();
5516
+ }
5517
+ if (size != null) {
5518
+ _queryParams["size"] = size.toString();
5519
+ }
5520
+ const _response = await fetcher({
5521
+ url: urlJoin(
5522
+ (_b = (_a = await Supplier.get(this._options.baseUrl)) != null ? _a : await Supplier.get(this._options.environment)) != null ? _b : OpikApiEnvironment.Default,
5523
+ "v1/private/automations/evaluators"
5524
+ ),
5525
+ method: "GET",
5526
+ headers: {
5527
+ "Comet-Workspace": await Supplier.get(this._options.workspaceName) != null ? await Supplier.get(this._options.workspaceName) : void 0,
5528
+ "X-Fern-Language": "JavaScript",
5529
+ "X-Fern-Runtime": RUNTIME.type,
5530
+ "X-Fern-Runtime-Version": RUNTIME.version,
5531
+ ...await this._getCustomAuthorizationHeaders(),
5532
+ ...requestOptions == null ? void 0 : requestOptions.headers
5533
+ },
5534
+ contentType: "application/json",
5535
+ queryParameters: _queryParams,
5536
+ requestType: "json",
5537
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
5538
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
5539
+ withCredentials: true,
5540
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
5541
+ });
5542
+ if (_response.ok) {
5543
+ return AutomationRuleEvaluatorPagePublic.parseOrThrow(_response.body, {
5544
+ unrecognizedObjectKeys: "passthrough",
5545
+ allowUnrecognizedUnionMembers: true,
5546
+ allowUnrecognizedEnumValues: true,
5547
+ breadcrumbsPrefix: ["response"]
5548
+ });
5549
+ }
5550
+ if (_response.error.reason === "status-code") {
5551
+ throw new OpikApiError({
5552
+ statusCode: _response.error.statusCode,
5553
+ body: _response.error.body
5554
+ });
5555
+ }
5556
+ switch (_response.error.reason) {
5557
+ case "non-json":
5558
+ throw new OpikApiError({
5559
+ statusCode: _response.error.statusCode,
5560
+ body: _response.error.rawBody
5561
+ });
5562
+ case "timeout":
5563
+ throw new OpikApiTimeoutError(
5564
+ "Timeout exceeded when calling GET /v1/private/automations/evaluators."
5565
+ );
5566
+ case "unknown":
5567
+ throw new OpikApiError({
5568
+ message: _response.error.errorMessage
5569
+ });
5570
+ }
5571
+ }
5572
+ /**
5573
+ * Create automation rule evaluator
5574
+ *
5575
+ * @param {OpikApi.AutomationRuleEvaluatorWrite} request
5576
+ * @param {AutomationRuleEvaluators.RequestOptions} requestOptions - Request-specific configuration.
5577
+ *
5578
+ * @example
5579
+ * await client.automationRuleEvaluators.createAutomationRuleEvaluator({
5580
+ * type: "llm_as_judge"
5581
+ * })
5582
+ */
5583
+ async createAutomationRuleEvaluator(request, requestOptions) {
5584
+ var _a, _b;
5585
+ const _response = await fetcher({
5586
+ url: urlJoin(
5587
+ (_b = (_a = await Supplier.get(this._options.baseUrl)) != null ? _a : await Supplier.get(this._options.environment)) != null ? _b : OpikApiEnvironment.Default,
5588
+ "v1/private/automations/evaluators"
5589
+ ),
5590
+ method: "POST",
5591
+ headers: {
5592
+ "Comet-Workspace": await Supplier.get(this._options.workspaceName) != null ? await Supplier.get(this._options.workspaceName) : void 0,
5593
+ "X-Fern-Language": "JavaScript",
5594
+ "X-Fern-Runtime": RUNTIME.type,
5595
+ "X-Fern-Runtime-Version": RUNTIME.version,
5596
+ ...await this._getCustomAuthorizationHeaders(),
5597
+ ...requestOptions == null ? void 0 : requestOptions.headers
5598
+ },
5599
+ contentType: "application/json",
5600
+ requestType: "json",
5601
+ body: AutomationRuleEvaluatorWrite.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
5602
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
5603
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
5604
+ withCredentials: true,
5605
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
5606
+ });
5607
+ if (_response.ok) {
5608
+ return;
5609
+ }
5610
+ if (_response.error.reason === "status-code") {
5611
+ throw new OpikApiError({
5612
+ statusCode: _response.error.statusCode,
5613
+ body: _response.error.body
5614
+ });
5615
+ }
5616
+ switch (_response.error.reason) {
5617
+ case "non-json":
5618
+ throw new OpikApiError({
5619
+ statusCode: _response.error.statusCode,
5620
+ body: _response.error.rawBody
5621
+ });
5622
+ case "timeout":
5623
+ throw new OpikApiTimeoutError(
5624
+ "Timeout exceeded when calling POST /v1/private/automations/evaluators."
5625
+ );
5626
+ case "unknown":
5627
+ throw new OpikApiError({
5628
+ message: _response.error.errorMessage
5629
+ });
5630
+ }
5631
+ }
5632
+ /**
5633
+ * Delete automation rule evaluators batch
5634
+ *
5635
+ * @param {OpikApi.DeleteAutomationRuleEvaluatorBatchRequest} request
5636
+ * @param {AutomationRuleEvaluators.RequestOptions} requestOptions - Request-specific configuration.
5637
+ *
5638
+ * @example
5639
+ * await client.automationRuleEvaluators.deleteAutomationRuleEvaluatorBatch({
5640
+ * projectId: "project_id",
5641
+ * body: {
5642
+ * ids: ["ids"]
5643
+ * }
5644
+ * })
5645
+ */
5646
+ async deleteAutomationRuleEvaluatorBatch(request, requestOptions) {
5647
+ var _a, _b;
5648
+ const { projectId, body: _body } = request;
5649
+ const _queryParams = {};
5650
+ _queryParams["project_id"] = projectId;
5651
+ const _response = await fetcher({
5652
+ url: urlJoin(
5653
+ (_b = (_a = await Supplier.get(this._options.baseUrl)) != null ? _a : await Supplier.get(this._options.environment)) != null ? _b : OpikApiEnvironment.Default,
5654
+ "v1/private/automations/evaluators/delete"
5655
+ ),
5656
+ method: "POST",
5657
+ headers: {
5658
+ "Comet-Workspace": await Supplier.get(this._options.workspaceName) != null ? await Supplier.get(this._options.workspaceName) : void 0,
5659
+ "X-Fern-Language": "JavaScript",
5660
+ "X-Fern-Runtime": RUNTIME.type,
5661
+ "X-Fern-Runtime-Version": RUNTIME.version,
5662
+ ...await this._getCustomAuthorizationHeaders(),
5663
+ ...requestOptions == null ? void 0 : requestOptions.headers
5664
+ },
5665
+ contentType: "application/json",
5666
+ queryParameters: _queryParams,
5667
+ requestType: "json",
5668
+ body: BatchDelete.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip" }),
5669
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
5670
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
5671
+ withCredentials: true,
5672
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
5673
+ });
5674
+ if (_response.ok) {
5675
+ return;
5676
+ }
5677
+ if (_response.error.reason === "status-code") {
5678
+ throw new OpikApiError({
5679
+ statusCode: _response.error.statusCode,
5680
+ body: _response.error.body
5681
+ });
5682
+ }
5683
+ switch (_response.error.reason) {
5684
+ case "non-json":
5685
+ throw new OpikApiError({
5686
+ statusCode: _response.error.statusCode,
5687
+ body: _response.error.rawBody
5688
+ });
5689
+ case "timeout":
5690
+ throw new OpikApiTimeoutError(
5691
+ "Timeout exceeded when calling POST /v1/private/automations/evaluators/delete."
5692
+ );
5693
+ case "unknown":
5694
+ throw new OpikApiError({
5695
+ message: _response.error.errorMessage
5696
+ });
5697
+ }
5698
+ }
5699
+ /**
5700
+ * Get automation rule by id
5701
+ *
5702
+ * @param {string} id
5703
+ * @param {OpikApi.GetEvaluatorByIdRequest} request
5704
+ * @param {AutomationRuleEvaluators.RequestOptions} requestOptions - Request-specific configuration.
5705
+ *
5706
+ * @example
5707
+ * await client.automationRuleEvaluators.getEvaluatorById("id")
5538
5708
  */
5539
- async findEvaluators(projectId, request = {}, requestOptions) {
5709
+ async getEvaluatorById(id, request = {}, requestOptions) {
5710
+ var _a, _b;
5711
+ const { projectId } = request;
5712
+ const _queryParams = {};
5713
+ if (projectId != null) {
5714
+ _queryParams["project_id"] = projectId;
5715
+ }
5716
+ const _response = await fetcher({
5717
+ url: urlJoin(
5718
+ (_b = (_a = await Supplier.get(this._options.baseUrl)) != null ? _a : await Supplier.get(this._options.environment)) != null ? _b : OpikApiEnvironment.Default,
5719
+ `v1/private/automations/evaluators/${encodeURIComponent(id)}`
5720
+ ),
5721
+ method: "GET",
5722
+ headers: {
5723
+ "Comet-Workspace": await Supplier.get(this._options.workspaceName) != null ? await Supplier.get(this._options.workspaceName) : void 0,
5724
+ "X-Fern-Language": "JavaScript",
5725
+ "X-Fern-Runtime": RUNTIME.type,
5726
+ "X-Fern-Runtime-Version": RUNTIME.version,
5727
+ ...await this._getCustomAuthorizationHeaders(),
5728
+ ...requestOptions == null ? void 0 : requestOptions.headers
5729
+ },
5730
+ contentType: "application/json",
5731
+ queryParameters: _queryParams,
5732
+ requestType: "json",
5733
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
5734
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
5735
+ withCredentials: true,
5736
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
5737
+ });
5738
+ if (_response.ok) {
5739
+ return AutomationRuleEvaluatorPublic.parseOrThrow(_response.body, {
5740
+ unrecognizedObjectKeys: "passthrough",
5741
+ allowUnrecognizedUnionMembers: true,
5742
+ allowUnrecognizedEnumValues: true,
5743
+ breadcrumbsPrefix: ["response"]
5744
+ });
5745
+ }
5746
+ if (_response.error.reason === "status-code") {
5747
+ throw new OpikApiError({
5748
+ statusCode: _response.error.statusCode,
5749
+ body: _response.error.body
5750
+ });
5751
+ }
5752
+ switch (_response.error.reason) {
5753
+ case "non-json":
5754
+ throw new OpikApiError({
5755
+ statusCode: _response.error.statusCode,
5756
+ body: _response.error.rawBody
5757
+ });
5758
+ case "timeout":
5759
+ throw new OpikApiTimeoutError(
5760
+ "Timeout exceeded when calling GET /v1/private/automations/evaluators/{id}."
5761
+ );
5762
+ case "unknown":
5763
+ throw new OpikApiError({
5764
+ message: _response.error.errorMessage
5765
+ });
5766
+ }
5767
+ }
5768
+ /**
5769
+ * update Automation Rule Evaluator by id
5770
+ *
5771
+ * @param {string} id
5772
+ * @param {OpikApi.AutomationRuleEvaluatorUpdate} request
5773
+ * @param {AutomationRuleEvaluators.RequestOptions} requestOptions - Request-specific configuration.
5774
+ *
5775
+ * @example
5776
+ * await client.automationRuleEvaluators.updateAutomationRuleEvaluator("id", {
5777
+ * name: "name",
5778
+ * code: {
5779
+ * model: {
5780
+ * name: "name",
5781
+ * temperature: 1.1
5782
+ * },
5783
+ * messages: [{
5784
+ * role: "SYSTEM",
5785
+ * content: "content"
5786
+ * }],
5787
+ * variables: {
5788
+ * "key": "value"
5789
+ * },
5790
+ * schema: [{
5791
+ * name: "name",
5792
+ * type: "BOOLEAN",
5793
+ * description: "description"
5794
+ * }]
5795
+ * },
5796
+ * samplingRate: 1.1
5797
+ * })
5798
+ */
5799
+ async updateAutomationRuleEvaluator(id, request, requestOptions) {
5800
+ var _a, _b;
5801
+ const _response = await fetcher({
5802
+ url: urlJoin(
5803
+ (_b = (_a = await Supplier.get(this._options.baseUrl)) != null ? _a : await Supplier.get(this._options.environment)) != null ? _b : OpikApiEnvironment.Default,
5804
+ `v1/private/automations/evaluators/${encodeURIComponent(id)}`
5805
+ ),
5806
+ method: "PATCH",
5807
+ headers: {
5808
+ "Comet-Workspace": await Supplier.get(this._options.workspaceName) != null ? await Supplier.get(this._options.workspaceName) : void 0,
5809
+ "X-Fern-Language": "JavaScript",
5810
+ "X-Fern-Runtime": RUNTIME.type,
5811
+ "X-Fern-Runtime-Version": RUNTIME.version,
5812
+ ...await this._getCustomAuthorizationHeaders(),
5813
+ ...requestOptions == null ? void 0 : requestOptions.headers
5814
+ },
5815
+ contentType: "application/json",
5816
+ requestType: "json",
5817
+ body: AutomationRuleEvaluatorUpdate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
5818
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
5819
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
5820
+ withCredentials: true,
5821
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
5822
+ });
5823
+ if (_response.ok) {
5824
+ return;
5825
+ }
5826
+ if (_response.error.reason === "status-code") {
5827
+ throw new OpikApiError({
5828
+ statusCode: _response.error.statusCode,
5829
+ body: _response.error.body
5830
+ });
5831
+ }
5832
+ switch (_response.error.reason) {
5833
+ case "non-json":
5834
+ throw new OpikApiError({
5835
+ statusCode: _response.error.statusCode,
5836
+ body: _response.error.rawBody
5837
+ });
5838
+ case "timeout":
5839
+ throw new OpikApiTimeoutError(
5840
+ "Timeout exceeded when calling PATCH /v1/private/automations/evaluators/{id}."
5841
+ );
5842
+ case "unknown":
5843
+ throw new OpikApiError({
5844
+ message: _response.error.errorMessage
5845
+ });
5846
+ }
5847
+ }
5848
+ /**
5849
+ * Get automation rule evaluator logs by id
5850
+ *
5851
+ * @param {string} id
5852
+ * @param {OpikApi.GetEvaluatorLogsByIdRequest} request
5853
+ * @param {AutomationRuleEvaluators.RequestOptions} requestOptions - Request-specific configuration.
5854
+ *
5855
+ * @example
5856
+ * await client.automationRuleEvaluators.getEvaluatorLogsById("id")
5857
+ */
5858
+ async getEvaluatorLogsById(id, request = {}, requestOptions) {
5859
+ var _a, _b;
5860
+ const { size } = request;
5861
+ const _queryParams = {};
5862
+ if (size != null) {
5863
+ _queryParams["size"] = size.toString();
5864
+ }
5865
+ const _response = await fetcher({
5866
+ url: urlJoin(
5867
+ (_b = (_a = await Supplier.get(this._options.baseUrl)) != null ? _a : await Supplier.get(this._options.environment)) != null ? _b : OpikApiEnvironment.Default,
5868
+ `v1/private/automations/evaluators/${encodeURIComponent(id)}/logs`
5869
+ ),
5870
+ method: "GET",
5871
+ headers: {
5872
+ "Comet-Workspace": await Supplier.get(this._options.workspaceName) != null ? await Supplier.get(this._options.workspaceName) : void 0,
5873
+ "X-Fern-Language": "JavaScript",
5874
+ "X-Fern-Runtime": RUNTIME.type,
5875
+ "X-Fern-Runtime-Version": RUNTIME.version,
5876
+ ...await this._getCustomAuthorizationHeaders(),
5877
+ ...requestOptions == null ? void 0 : requestOptions.headers
5878
+ },
5879
+ contentType: "application/json",
5880
+ queryParameters: _queryParams,
5881
+ requestType: "json",
5882
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
5883
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
5884
+ withCredentials: true,
5885
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
5886
+ });
5887
+ if (_response.ok) {
5888
+ return LogPage.parseOrThrow(_response.body, {
5889
+ unrecognizedObjectKeys: "passthrough",
5890
+ allowUnrecognizedUnionMembers: true,
5891
+ allowUnrecognizedEnumValues: true,
5892
+ breadcrumbsPrefix: ["response"]
5893
+ });
5894
+ }
5895
+ if (_response.error.reason === "status-code") {
5896
+ throw new OpikApiError({
5897
+ statusCode: _response.error.statusCode,
5898
+ body: _response.error.body
5899
+ });
5900
+ }
5901
+ switch (_response.error.reason) {
5902
+ case "non-json":
5903
+ throw new OpikApiError({
5904
+ statusCode: _response.error.statusCode,
5905
+ body: _response.error.rawBody
5906
+ });
5907
+ case "timeout":
5908
+ throw new OpikApiTimeoutError(
5909
+ "Timeout exceeded when calling GET /v1/private/automations/evaluators/{id}/logs."
5910
+ );
5911
+ case "unknown":
5912
+ throw new OpikApiError({
5913
+ message: _response.error.errorMessage
5914
+ });
5915
+ }
5916
+ }
5917
+ /**
5918
+ * Find project Evaluators Deprecated
5919
+ *
5920
+ * @param {string} projectId
5921
+ * @param {OpikApi.FindEvaluatorsDeprecatedRequest} request
5922
+ * @param {AutomationRuleEvaluators.RequestOptions} requestOptions - Request-specific configuration.
5923
+ *
5924
+ * @example
5925
+ * await client.automationRuleEvaluators.findEvaluatorsDeprecated("projectId")
5926
+ */
5927
+ async findEvaluatorsDeprecated(projectId, request = {}, requestOptions) {
5540
5928
  var _a, _b;
5541
5929
  const { name, page, size } = request;
5542
5930
  const _queryParams = {};
@@ -5602,18 +5990,18 @@ var AutomationRuleEvaluators = class {
5602
5990
  }
5603
5991
  }
5604
5992
  /**
5605
- * Create automation rule evaluator
5993
+ * Create automation rule evaluator Deprecated
5606
5994
  *
5607
5995
  * @param {string} projectId
5608
5996
  * @param {OpikApi.AutomationRuleEvaluatorWrite} request
5609
5997
  * @param {AutomationRuleEvaluators.RequestOptions} requestOptions - Request-specific configuration.
5610
5998
  *
5611
5999
  * @example
5612
- * await client.automationRuleEvaluators.createAutomationRuleEvaluator("projectId", {
6000
+ * await client.automationRuleEvaluators.createAutomationRuleEvaluatorDeprecated("projectId", {
5613
6001
  * type: "llm_as_judge"
5614
6002
  * })
5615
6003
  */
5616
- async createAutomationRuleEvaluator(projectId, request, requestOptions) {
6004
+ async createAutomationRuleEvaluatorDeprecated(projectId, request, requestOptions) {
5617
6005
  var _a, _b;
5618
6006
  const _response = await fetcher({
5619
6007
  url: urlJoin(
@@ -5663,18 +6051,18 @@ var AutomationRuleEvaluators = class {
5663
6051
  }
5664
6052
  }
5665
6053
  /**
5666
- * Delete automation rule evaluators batch
6054
+ * Delete automation rule evaluators batch Deprecated
5667
6055
  *
5668
6056
  * @param {string} projectId
5669
6057
  * @param {OpikApi.BatchDelete} request
5670
6058
  * @param {AutomationRuleEvaluators.RequestOptions} requestOptions - Request-specific configuration.
5671
6059
  *
5672
6060
  * @example
5673
- * await client.automationRuleEvaluators.deleteAutomationRuleEvaluatorBatch("projectId", {
6061
+ * await client.automationRuleEvaluators.deleteAutomationRuleEvaluatorBatchDeprecated("projectId", {
5674
6062
  * ids: ["ids"]
5675
6063
  * })
5676
6064
  */
5677
- async deleteAutomationRuleEvaluatorBatch(projectId, request, requestOptions) {
6065
+ async deleteAutomationRuleEvaluatorBatchDeprecated(projectId, request, requestOptions) {
5678
6066
  var _a, _b;
5679
6067
  const _response = await fetcher({
5680
6068
  url: urlJoin(
@@ -5724,16 +6112,16 @@ var AutomationRuleEvaluators = class {
5724
6112
  }
5725
6113
  }
5726
6114
  /**
5727
- * Get automation rule by id
6115
+ * Get automation rule by id Deprecated
5728
6116
  *
5729
6117
  * @param {string} projectId
5730
6118
  * @param {string} id
5731
6119
  * @param {AutomationRuleEvaluators.RequestOptions} requestOptions - Request-specific configuration.
5732
6120
  *
5733
6121
  * @example
5734
- * await client.automationRuleEvaluators.getEvaluatorById("projectId", "id")
6122
+ * await client.automationRuleEvaluators.getEvaluatorByIdDeprecated("projectId", "id")
5735
6123
  */
5736
- async getEvaluatorById(projectId, id, requestOptions) {
6124
+ async getEvaluatorByIdDeprecated(projectId, id, requestOptions) {
5737
6125
  var _a, _b;
5738
6126
  const _response = await fetcher({
5739
6127
  url: urlJoin(
@@ -5787,7 +6175,7 @@ var AutomationRuleEvaluators = class {
5787
6175
  }
5788
6176
  }
5789
6177
  /**
5790
- * update Automation Rule Evaluator by id
6178
+ * update Automation Rule Evaluator by id Deprecated
5791
6179
  *
5792
6180
  * @param {string} id
5793
6181
  * @param {string} projectId
@@ -5795,7 +6183,7 @@ var AutomationRuleEvaluators = class {
5795
6183
  * @param {AutomationRuleEvaluators.RequestOptions} requestOptions - Request-specific configuration.
5796
6184
  *
5797
6185
  * @example
5798
- * await client.automationRuleEvaluators.updateAutomationRuleEvaluator("id", "projectId", {
6186
+ * await client.automationRuleEvaluators.updateAutomationRuleEvaluatorDeprecated("id", "projectId", {
5799
6187
  * name: "name",
5800
6188
  * code: {
5801
6189
  * model: {
@@ -5818,7 +6206,7 @@ var AutomationRuleEvaluators = class {
5818
6206
  * samplingRate: 1.1
5819
6207
  * })
5820
6208
  */
5821
- async updateAutomationRuleEvaluator(id, projectId, request, requestOptions) {
6209
+ async updateAutomationRuleEvaluatorDeprecated(id, projectId, request, requestOptions) {
5822
6210
  var _a, _b;
5823
6211
  const _response = await fetcher({
5824
6212
  url: urlJoin(
@@ -5868,17 +6256,17 @@ var AutomationRuleEvaluators = class {
5868
6256
  }
5869
6257
  }
5870
6258
  /**
5871
- * Get automation rule evaluator logs by id
6259
+ * Get automation rule evaluator logs by id Deprecated
5872
6260
  *
5873
6261
  * @param {string} projectId
5874
6262
  * @param {string} id
5875
- * @param {OpikApi.GetEvaluatorLogsByIdRequest} request
6263
+ * @param {OpikApi.GetEvaluatorLogsByIdDeprecatedRequest} request
5876
6264
  * @param {AutomationRuleEvaluators.RequestOptions} requestOptions - Request-specific configuration.
5877
6265
  *
5878
6266
  * @example
5879
- * await client.automationRuleEvaluators.getEvaluatorLogsById("projectId", "id")
6267
+ * await client.automationRuleEvaluators.getEvaluatorLogsByIdDeprecated("projectId", "id")
5880
6268
  */
5881
- async getEvaluatorLogsById(projectId, id, request = {}, requestOptions) {
6269
+ async getEvaluatorLogsByIdDeprecated(projectId, id, request = {}, requestOptions) {
5882
6270
  var _a, _b;
5883
6271
  const { size } = request;
5884
6272
  const _queryParams = {};
@@ -12087,9 +12475,6 @@ var OpikApiClient = class {
12087
12475
  }
12088
12476
  };
12089
12477
 
12090
- // src/opik/tracer/Trace.ts
12091
- var import_uuid = require("uuid");
12092
-
12093
12478
  // src/opik/tracer/Span.ts
12094
12479
  var Span2 = class {
12095
12480
  constructor(data, opik) {
@@ -12126,7 +12511,7 @@ var Trace2 = class {
12126
12511
  var _a, _b;
12127
12512
  const projectName = (_b = (_a = this.data.projectName) != null ? _a : spanData.projectName) != null ? _b : this.opik.config.projectName;
12128
12513
  const spanWithId = {
12129
- id: (0, import_uuid.v7)(),
12514
+ id: uuid.v7(),
12130
12515
  startTime: /* @__PURE__ */ new Date(),
12131
12516
  ...spanData,
12132
12517
  projectName,
@@ -12150,9 +12535,6 @@ var Trace2 = class {
12150
12535
  }
12151
12536
  };
12152
12537
 
12153
- // src/opik/client/Client.ts
12154
- var import_uuid2 = require("uuid");
12155
-
12156
12538
  // src/opik/client/BatchQueue.ts
12157
12539
  var DEFAULT_DEBOUNCE_BATCH_DELAY = 300;
12158
12540
  var DEFAULT_BATCH_SIZE = 100;
@@ -12330,7 +12712,7 @@ var OpikClient = class {
12330
12712
  const projectName = (_a = traceData.projectName) != null ? _a : this.config.projectName;
12331
12713
  const trace = new Trace2(
12332
12714
  {
12333
- id: (0, import_uuid2.v7)(),
12715
+ id: uuid.v7(),
12334
12716
  startTime: /* @__PURE__ */ new Date(),
12335
12717
  ...traceData,
12336
12718
  projectName
@@ -12355,10 +12737,7 @@ var OpikClient = class {
12355
12737
  clients.push(this);
12356
12738
  }
12357
12739
  };
12358
-
12359
- // src/opik/decorators/track.ts
12360
- var import_node_async_hooks = require("async_hooks");
12361
- var trackStorage = new import_node_async_hooks.AsyncLocalStorage();
12740
+ var trackStorage = new async_hooks.AsyncLocalStorage();
12362
12741
  function isPromise(obj) {
12363
12742
  return !!obj && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";
12364
12743
  }
@@ -12466,11 +12845,11 @@ var flushAll = async () => {
12466
12845
  ...clients.map((c) => c.flush())
12467
12846
  ]);
12468
12847
  };
12469
- // Annotate the CommonJS export names for ESM import in node:
12470
- 0 && (module.exports = {
12471
- Opik,
12472
- flushAll,
12473
- track,
12474
- trackOpikClient,
12475
- withTrack
12476
- });
12848
+
12849
+ exports.Opik = OpikClient;
12850
+ exports.flushAll = flushAll;
12851
+ exports.track = track;
12852
+ exports.trackOpikClient = trackOpikClient;
12853
+ exports.withTrack = withTrack;
12854
+ //# sourceMappingURL=index.cjs.map
12855
+ //# sourceMappingURL=index.cjs.map