@gammatech/aijsx 0.4.1-beta.2 → 0.4.1-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +4 -11
- package/dist/index.mjs +4 -11
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -73,13 +73,11 @@ declare class AISpanProcessor extends EnrichingSpanProcessor {
|
|
|
73
73
|
};
|
|
74
74
|
constructor(exporter: SpanExporter, opts?: {
|
|
75
75
|
costFn?: CostFn;
|
|
76
|
-
parentSpanId?: string;
|
|
77
76
|
});
|
|
78
77
|
onTraceComplete(rootSpan: ReadableSpan): Promise<void>;
|
|
79
78
|
enrichSpan(span: ReadableSpan): Promise<ReadableSpan>;
|
|
80
79
|
protected computeCost(span: ReadableSpan): Promise<ReadableSpan>;
|
|
81
80
|
protected updateUsage(span: ReadableSpan): Promise<ReadableSpan>;
|
|
82
|
-
protected attachParentSpanId(span: ReadableSpan): Promise<ReadableSpan>;
|
|
83
81
|
protected evaluatePrompt(span: ReadableSpan): Promise<ReadableSpan>;
|
|
84
82
|
}
|
|
85
83
|
|
package/dist/index.d.ts
CHANGED
|
@@ -73,13 +73,11 @@ declare class AISpanProcessor extends EnrichingSpanProcessor {
|
|
|
73
73
|
};
|
|
74
74
|
constructor(exporter: SpanExporter, opts?: {
|
|
75
75
|
costFn?: CostFn;
|
|
76
|
-
parentSpanId?: string;
|
|
77
76
|
});
|
|
78
77
|
onTraceComplete(rootSpan: ReadableSpan): Promise<void>;
|
|
79
78
|
enrichSpan(span: ReadableSpan): Promise<ReadableSpan>;
|
|
80
79
|
protected computeCost(span: ReadableSpan): Promise<ReadableSpan>;
|
|
81
80
|
protected updateUsage(span: ReadableSpan): Promise<ReadableSpan>;
|
|
82
|
-
protected attachParentSpanId(span: ReadableSpan): Promise<ReadableSpan>;
|
|
83
81
|
protected evaluatePrompt(span: ReadableSpan): Promise<ReadableSpan>;
|
|
84
82
|
}
|
|
85
83
|
|
package/dist/index.js
CHANGED
|
@@ -1476,11 +1476,10 @@ var AISpanProcessor = class extends EnrichingSpanProcessor {
|
|
|
1476
1476
|
rootSpan.attributes.totalUsage = this.totalUsage;
|
|
1477
1477
|
}
|
|
1478
1478
|
async enrichSpan(span) {
|
|
1479
|
-
const result1 = await this.
|
|
1480
|
-
const result2 = await this.
|
|
1481
|
-
const result3 = await this.
|
|
1482
|
-
|
|
1483
|
-
return result4;
|
|
1479
|
+
const result1 = await this.evaluatePrompt(span);
|
|
1480
|
+
const result2 = await this.computeCost(result1);
|
|
1481
|
+
const result3 = await this.updateUsage(result2);
|
|
1482
|
+
return result3;
|
|
1484
1483
|
}
|
|
1485
1484
|
async computeCost(span) {
|
|
1486
1485
|
if (!this.opts.costFn) {
|
|
@@ -1518,12 +1517,6 @@ var AISpanProcessor = class extends EnrichingSpanProcessor {
|
|
|
1518
1517
|
this.totalUsage.total += tokensUsed.total;
|
|
1519
1518
|
return span;
|
|
1520
1519
|
}
|
|
1521
|
-
async attachParentSpanId(span) {
|
|
1522
|
-
if (span.parentSpanId == null && this.opts.parentSpanId) {
|
|
1523
|
-
span.parentSpanId = this.opts.parentSpanId;
|
|
1524
|
-
}
|
|
1525
|
-
return span;
|
|
1526
|
-
}
|
|
1527
1520
|
async evaluatePrompt(span) {
|
|
1528
1521
|
const { prompt, variables, output } = span.attributes;
|
|
1529
1522
|
if (!isPrompt2(prompt)) {
|
package/dist/index.mjs
CHANGED
|
@@ -1380,11 +1380,10 @@ var AISpanProcessor = class extends EnrichingSpanProcessor {
|
|
|
1380
1380
|
rootSpan.attributes.totalUsage = this.totalUsage;
|
|
1381
1381
|
}
|
|
1382
1382
|
async enrichSpan(span) {
|
|
1383
|
-
const result1 = await this.
|
|
1384
|
-
const result2 = await this.
|
|
1385
|
-
const result3 = await this.
|
|
1386
|
-
|
|
1387
|
-
return result4;
|
|
1383
|
+
const result1 = await this.evaluatePrompt(span);
|
|
1384
|
+
const result2 = await this.computeCost(result1);
|
|
1385
|
+
const result3 = await this.updateUsage(result2);
|
|
1386
|
+
return result3;
|
|
1388
1387
|
}
|
|
1389
1388
|
async computeCost(span) {
|
|
1390
1389
|
if (!this.opts.costFn) {
|
|
@@ -1422,12 +1421,6 @@ var AISpanProcessor = class extends EnrichingSpanProcessor {
|
|
|
1422
1421
|
this.totalUsage.total += tokensUsed.total;
|
|
1423
1422
|
return span;
|
|
1424
1423
|
}
|
|
1425
|
-
async attachParentSpanId(span) {
|
|
1426
|
-
if (span.parentSpanId == null && this.opts.parentSpanId) {
|
|
1427
|
-
span.parentSpanId = this.opts.parentSpanId;
|
|
1428
|
-
}
|
|
1429
|
-
return span;
|
|
1430
|
-
}
|
|
1431
1424
|
async evaluatePrompt(span) {
|
|
1432
1425
|
const { prompt, variables, output } = span.attributes;
|
|
1433
1426
|
if (!isPrompt2(prompt)) {
|