@valerypopoff/rivet2-evaluations 2.7.0 → 2.9.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.
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export function createEvaluationEventCollector(attemptFormat) {
|
|
2
|
+
const metrics = {
|
|
3
|
+
durationMs: 0,
|
|
4
|
+
modelCallCount: 0,
|
|
5
|
+
toolCallCount: 0,
|
|
6
|
+
toolFailureCount: 0,
|
|
7
|
+
};
|
|
8
|
+
const providerAttempts = [];
|
|
9
|
+
return {
|
|
10
|
+
metrics,
|
|
11
|
+
providerAttempts,
|
|
12
|
+
llmCallFinished(event) {
|
|
13
|
+
metrics.modelCallCount = (metrics.modelCallCount ?? 0) + 1;
|
|
14
|
+
metrics.inputTokens = (metrics.inputTokens ?? 0) + (event.normalizedUsage?.promptTokens ?? 0);
|
|
15
|
+
metrics.outputTokens = (metrics.outputTokens ?? 0) + (event.normalizedUsage?.completionTokens ?? 0);
|
|
16
|
+
metrics.cachedInputTokens = (metrics.cachedInputTokens ?? 0) + (event.normalizedUsage?.cachedTokens ?? 0);
|
|
17
|
+
metrics.reasoningTokens = (metrics.reasoningTokens ?? 0) + (event.normalizedUsage?.reasoningTokens ?? 0);
|
|
18
|
+
if (event.pricing.status === 'known') {
|
|
19
|
+
metrics.costUsd = (metrics.costUsd ?? 0) + (event.pricing.costUsd ?? 0);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
metrics.hasUnknownCost = true;
|
|
23
|
+
}
|
|
24
|
+
providerAttempts.push({
|
|
25
|
+
kind: 'provider-call',
|
|
26
|
+
provider: event.provider,
|
|
27
|
+
model: event.model,
|
|
28
|
+
customProviderApi: event.customProviderApi ?? null,
|
|
29
|
+
outcome: event.outcome,
|
|
30
|
+
...(attemptFormat === 'full' ? { finishReason: event.finishReason ?? null } : {}),
|
|
31
|
+
profileIndex: event.profileIndex ?? null,
|
|
32
|
+
...(attemptFormat === 'full' ? { profileName: event.profileName ?? null } : {}),
|
|
33
|
+
attemptIndex: event.attemptIndex,
|
|
34
|
+
roundIndex: event.roundIndex ?? null,
|
|
35
|
+
durationMs: event.durationMs ?? null,
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
llmProfileAttempt(event) {
|
|
39
|
+
providerAttempts.push({
|
|
40
|
+
kind: 'profile-decision',
|
|
41
|
+
provider: event.provider,
|
|
42
|
+
model: event.model,
|
|
43
|
+
customProviderApi: event.customProviderApi ?? null,
|
|
44
|
+
stage: event.stage,
|
|
45
|
+
outcome: event.outcome,
|
|
46
|
+
profileIndex: event.profileIndex ?? null,
|
|
47
|
+
...(attemptFormat === 'full' ? { profileName: event.profileName ?? null } : {}),
|
|
48
|
+
attemptIndex: event.attemptIndex ?? null,
|
|
49
|
+
roundIndex: event.roundIndex,
|
|
50
|
+
status: event.status ?? null,
|
|
51
|
+
healthState: event.healthState ?? null,
|
|
52
|
+
healthDisposition: event.healthDisposition ?? null,
|
|
53
|
+
timeoutKind: event.timeoutKind ?? null,
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
toolCallFinished(event) {
|
|
57
|
+
metrics.toolCallCount = (metrics.toolCallCount ?? 0) + 1;
|
|
58
|
+
if (event.outcome !== 'success')
|
|
59
|
+
metrics.toolFailureCount = (metrics.toolFailureCount ?? 0) + 1;
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ChatV2CallTraceEvent, LLMProfileAttemptTraceEvent, ToolCallFinishedEvent } from '@valerypopoff/rivet2-core';
|
|
2
|
+
import type { EvaluationExecutionMetrics, PortableJson } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The evidence shape used by evaluation runners. The CLI intentionally keeps
|
|
5
|
+
* its long-standing compact evidence contract, while interactive and hosted
|
|
6
|
+
* runners retain the additional display-oriented provider fields.
|
|
7
|
+
*/
|
|
8
|
+
export type EvaluationProviderAttemptFormat = 'full' | 'cli';
|
|
9
|
+
/**
|
|
10
|
+
* Per-graph physical provider and tool accounting for an evaluation run.
|
|
11
|
+
* Duration belongs to the owning runner because it also includes graph work
|
|
12
|
+
* that does not emit a provider or tool event.
|
|
13
|
+
*/
|
|
14
|
+
export type EvaluationEventCollector = {
|
|
15
|
+
readonly metrics: EvaluationExecutionMetrics;
|
|
16
|
+
readonly providerAttempts: PortableJson[];
|
|
17
|
+
llmCallFinished(event: ChatV2CallTraceEvent): void;
|
|
18
|
+
llmProfileAttempt(event: LLMProfileAttemptTraceEvent): void;
|
|
19
|
+
toolCallFinished(event: ToolCallFinishedEvent): void;
|
|
20
|
+
};
|
|
21
|
+
export declare function createEvaluationEventCollector(attemptFormat: EvaluationProviderAttemptFormat): EvaluationEventCollector;
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@valerypopoff/rivet2-evaluations",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/cjs/bundle.cjs",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@valerypopoff/rivet2-core": "^2.
|
|
39
|
+
"@valerypopoff/rivet2-core": "^2.9.0",
|
|
40
40
|
"yaml": "^2.9.0"
|
|
41
41
|
}
|
|
42
42
|
}
|