opik 0.1.1 → 0.1.2
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/{Client-VaP_If_d.d.cts → Client-DilyWTdT.d.cts} +59 -11
- package/dist/{Client-VaP_If_d.d.ts → Client-DilyWTdT.d.ts} +59 -11
- package/dist/{chunk-OC5DO255.js → chunk-ZB4ZJRLY.js} +99 -4
- package/dist/chunk-ZB4ZJRLY.js.map +1 -0
- package/dist/index.cjs +97 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/vercel/index.cjs +98 -3
- package/dist/vercel/index.cjs.map +1 -1
- package/dist/vercel/index.d.cts +1 -1
- package/dist/vercel/index.d.ts +1 -1
- package/dist/vercel/index.js +3 -3
- package/dist/vercel/index.js.map +1 -1
- package/package.json +9 -3
- package/dist/chunk-OC5DO255.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -12483,6 +12483,15 @@ var Span2 = class {
|
|
|
12483
12483
|
this.end = () => {
|
|
12484
12484
|
return this.update({ endTime: /* @__PURE__ */ new Date() });
|
|
12485
12485
|
};
|
|
12486
|
+
this.score = (score) => {
|
|
12487
|
+
var _a;
|
|
12488
|
+
this.opik.spanFeedbackScoresBatchQueue.create({
|
|
12489
|
+
...score,
|
|
12490
|
+
projectName: (_a = this.data.projectName) != null ? _a : this.opik.config.projectName,
|
|
12491
|
+
id: this.data.id,
|
|
12492
|
+
source: "sdk"
|
|
12493
|
+
});
|
|
12494
|
+
};
|
|
12486
12495
|
this.update = (updates) => {
|
|
12487
12496
|
var _a;
|
|
12488
12497
|
const spanUpdates = {
|
|
@@ -12507,6 +12516,15 @@ var Trace2 = class {
|
|
|
12507
12516
|
this.end = () => {
|
|
12508
12517
|
return this.update({ endTime: /* @__PURE__ */ new Date() });
|
|
12509
12518
|
};
|
|
12519
|
+
this.score = (score) => {
|
|
12520
|
+
var _a;
|
|
12521
|
+
this.opik.traceFeedbackScoresBatchQueue.create({
|
|
12522
|
+
...score,
|
|
12523
|
+
projectName: (_a = this.data.projectName) != null ? _a : this.opik.config.projectName,
|
|
12524
|
+
id: this.data.id,
|
|
12525
|
+
source: "sdk"
|
|
12526
|
+
});
|
|
12527
|
+
};
|
|
12510
12528
|
this.span = (spanData) => {
|
|
12511
12529
|
var _a, _b;
|
|
12512
12530
|
const projectName = (_b = (_a = this.data.projectName) != null ? _a : spanData.projectName) != null ? _b : this.opik.config.projectName;
|
|
@@ -12598,7 +12616,8 @@ var BatchQueue = class {
|
|
|
12598
12616
|
name = "BatchQueue"
|
|
12599
12617
|
}) {
|
|
12600
12618
|
this.create = (entity) => {
|
|
12601
|
-
this.
|
|
12619
|
+
const id = this.getId(entity);
|
|
12620
|
+
this.createQueue.add(id, entity);
|
|
12602
12621
|
};
|
|
12603
12622
|
this.get = async (id) => {
|
|
12604
12623
|
const entity = this.createQueue.queue.get(id);
|
|
@@ -12667,6 +12686,9 @@ var SpanBatchQueue = class extends BatchQueue {
|
|
|
12667
12686
|
super({ delay, enableDeleteBatch: false, name: "SpanBatchQueue" });
|
|
12668
12687
|
this.api = api;
|
|
12669
12688
|
}
|
|
12689
|
+
getId(entity) {
|
|
12690
|
+
return entity.id;
|
|
12691
|
+
}
|
|
12670
12692
|
async createEntities(spans) {
|
|
12671
12693
|
await this.api.spans.createSpans({ spans });
|
|
12672
12694
|
}
|
|
@@ -12683,12 +12705,46 @@ var SpanBatchQueue = class extends BatchQueue {
|
|
|
12683
12705
|
}
|
|
12684
12706
|
};
|
|
12685
12707
|
|
|
12708
|
+
// src/opik/client/SpanFeedbackScoresBatchQueue.ts
|
|
12709
|
+
var SpanFeedbackScoresBatchQueue = class extends BatchQueue {
|
|
12710
|
+
constructor(api, delay) {
|
|
12711
|
+
super({
|
|
12712
|
+
delay,
|
|
12713
|
+
enableDeleteBatch: false,
|
|
12714
|
+
name: "SpanFeedbackScoresBatchQueue"
|
|
12715
|
+
});
|
|
12716
|
+
this.api = api;
|
|
12717
|
+
}
|
|
12718
|
+
getId(entity) {
|
|
12719
|
+
return { id: entity.id, name: entity.name };
|
|
12720
|
+
}
|
|
12721
|
+
async createEntities(scores) {
|
|
12722
|
+
await this.api.spans.scoreBatchOfSpans({ scores });
|
|
12723
|
+
}
|
|
12724
|
+
async getEntity() {
|
|
12725
|
+
throw new Error("Not implemented");
|
|
12726
|
+
}
|
|
12727
|
+
async updateEntity() {
|
|
12728
|
+
throw new Error("Not implemented");
|
|
12729
|
+
}
|
|
12730
|
+
async deleteEntities(scoreIds) {
|
|
12731
|
+
for (const scoreId of scoreIds) {
|
|
12732
|
+
await this.api.spans.deleteSpanFeedbackScore(scoreId.id, {
|
|
12733
|
+
name: scoreId.name
|
|
12734
|
+
});
|
|
12735
|
+
}
|
|
12736
|
+
}
|
|
12737
|
+
};
|
|
12738
|
+
|
|
12686
12739
|
// src/opik/client/TraceBatchQueue.ts
|
|
12687
12740
|
var TraceBatchQueue = class extends BatchQueue {
|
|
12688
12741
|
constructor(api, delay) {
|
|
12689
12742
|
super({ delay, name: "TraceBatchQueue" });
|
|
12690
12743
|
this.api = api;
|
|
12691
12744
|
}
|
|
12745
|
+
getId(entity) {
|
|
12746
|
+
return entity.id;
|
|
12747
|
+
}
|
|
12692
12748
|
async createEntities(traces) {
|
|
12693
12749
|
await this.api.traces.createTraces({ traces });
|
|
12694
12750
|
}
|
|
@@ -12703,6 +12759,37 @@ var TraceBatchQueue = class extends BatchQueue {
|
|
|
12703
12759
|
}
|
|
12704
12760
|
};
|
|
12705
12761
|
|
|
12762
|
+
// src/opik/client/TraceFeedbackScoresBatchQueue.ts
|
|
12763
|
+
var TraceFeedbackScoresBatchQueue = class extends BatchQueue {
|
|
12764
|
+
constructor(api, delay) {
|
|
12765
|
+
super({
|
|
12766
|
+
delay,
|
|
12767
|
+
enableDeleteBatch: false,
|
|
12768
|
+
name: "TraceFeedbackScoresBatchQueue"
|
|
12769
|
+
});
|
|
12770
|
+
this.api = api;
|
|
12771
|
+
}
|
|
12772
|
+
getId(entity) {
|
|
12773
|
+
return { id: entity.id, name: entity.name };
|
|
12774
|
+
}
|
|
12775
|
+
async createEntities(scores) {
|
|
12776
|
+
await this.api.traces.scoreBatchOfTraces({ scores });
|
|
12777
|
+
}
|
|
12778
|
+
async getEntity() {
|
|
12779
|
+
throw new Error("Not implemented");
|
|
12780
|
+
}
|
|
12781
|
+
async updateEntity() {
|
|
12782
|
+
throw new Error("Not implemented");
|
|
12783
|
+
}
|
|
12784
|
+
async deleteEntities(scoreIds) {
|
|
12785
|
+
for (const scoreId of scoreIds) {
|
|
12786
|
+
await this.api.traces.deleteTraceFeedbackScore(scoreId.id, {
|
|
12787
|
+
name: scoreId.name
|
|
12788
|
+
});
|
|
12789
|
+
}
|
|
12790
|
+
}
|
|
12791
|
+
};
|
|
12792
|
+
|
|
12706
12793
|
// src/opik/client/Client.ts
|
|
12707
12794
|
var clients = [];
|
|
12708
12795
|
var OpikClient = class {
|
|
@@ -12725,6 +12812,8 @@ var OpikClient = class {
|
|
|
12725
12812
|
this.flush = async () => {
|
|
12726
12813
|
await this.traceBatchQueue.flush();
|
|
12727
12814
|
await this.spanBatchQueue.flush();
|
|
12815
|
+
await this.traceFeedbackScoresBatchQueue.flush();
|
|
12816
|
+
await this.spanFeedbackScoresBatchQueue.flush();
|
|
12728
12817
|
};
|
|
12729
12818
|
this.config = loadConfig(explicitConfig);
|
|
12730
12819
|
this.api = new OpikApiClient({
|
|
@@ -12734,6 +12823,12 @@ var OpikClient = class {
|
|
|
12734
12823
|
});
|
|
12735
12824
|
this.spanBatchQueue = new SpanBatchQueue(this.api);
|
|
12736
12825
|
this.traceBatchQueue = new TraceBatchQueue(this.api);
|
|
12826
|
+
this.spanFeedbackScoresBatchQueue = new SpanFeedbackScoresBatchQueue(
|
|
12827
|
+
this.api
|
|
12828
|
+
);
|
|
12829
|
+
this.traceFeedbackScoresBatchQueue = new TraceFeedbackScoresBatchQueue(
|
|
12830
|
+
this.api
|
|
12831
|
+
);
|
|
12737
12832
|
clients.push(this);
|
|
12738
12833
|
}
|
|
12739
12834
|
};
|
|
@@ -12898,7 +12993,7 @@ function track(optionsOrOriginalFunction, originalFunction) {
|
|
|
12898
12993
|
}
|
|
12899
12994
|
return executeTrack(options, originalMethod2);
|
|
12900
12995
|
}
|
|
12901
|
-
const [
|
|
12996
|
+
const [, , descriptor] = args;
|
|
12902
12997
|
if (!descriptor || typeof descriptor.value !== "function") {
|
|
12903
12998
|
throw new Error("track decorator can only be applied to methods");
|
|
12904
12999
|
}
|