@wix/evalforge-evaluator 0.207.0 → 0.209.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/build/index.js CHANGED
@@ -10966,7 +10966,14 @@ function calculateFromPricing(modelId, tokenUsage) {
10966
10966
  return tokenUsage.prompt / 1e6 * pricing.input + tokenUsage.completion / 1e6 * pricing.output;
10967
10967
  }
10968
10968
  function calculateStepCost(step, modelId, provider, tokenUsage) {
10969
- return extractGatewayCost(step, provider) ?? calculateFromPricing(modelId, tokenUsage);
10969
+ const gatewayCost = extractGatewayCost(step, provider);
10970
+ if (gatewayCost !== void 0) {
10971
+ return gatewayCost;
10972
+ }
10973
+ console.warn(
10974
+ `[cost-calculation] gateway cost missing; using list-price fallback (provider=${provider}, model=${modelId}, promptTokens=${tokenUsage.prompt}, completionTokens=${tokenUsage.completion})`
10975
+ );
10976
+ return calculateFromPricing(modelId, tokenUsage);
10970
10977
  }
10971
10978
 
10972
10979
  // src/run-scenario/agents/simple-agent/build-conversation.ts
@@ -11246,13 +11253,13 @@ async function executeWithAiSdk(context) {
11246
11253
  [text, steps, rawUsage] = await Promise.all([
11247
11254
  stream.text,
11248
11255
  stream.steps,
11249
- stream.usage
11256
+ stream.totalUsage
11250
11257
  ]);
11251
11258
  } else {
11252
11259
  const result = await (0, import_ai.generateText)(sdkParams);
11253
11260
  text = result.text;
11254
11261
  steps = result.steps;
11255
- rawUsage = result.usage;
11262
+ rawUsage = result.totalUsage;
11256
11263
  }
11257
11264
  const durationMs = Date.now() - startTime;
11258
11265
  const usage = {
@@ -11263,7 +11270,6 @@ async function executeWithAiSdk(context) {
11263
11270
  const llmTrace = buildLLMTrace2(
11264
11271
  steps,
11265
11272
  durationMs,
11266
- usage,
11267
11273
  modelId,
11268
11274
  provider,
11269
11275
  startTime,
@@ -11412,7 +11418,7 @@ function findToolResultError(step) {
11412
11418
  }
11413
11419
  return null;
11414
11420
  }
11415
- function buildLLMTrace2(steps, totalDurationMs, totalUsage, modelId, provider, executionStartMs, stepTimestamps) {
11421
+ function buildLLMTrace2(steps, totalDurationMs, modelId, provider, executionStartMs, stepTimestamps) {
11416
11422
  const traceSteps = steps.map((step, i) => {
11417
11423
  const stepFinishedAt = stepTimestamps[i] ?? executionStartMs;
11418
11424
  const stepStartedAt = i === 0 ? executionStartMs : stepTimestamps[i - 1] ?? executionStartMs;
@@ -11444,11 +11450,14 @@ function buildLLMTrace2(steps, totalDurationMs, totalUsage, modelId, provider, e
11444
11450
  };
11445
11451
  });
11446
11452
  const totalCostUsd = traceSteps.reduce((sum, s) => sum + s.costUsd, 0);
11447
- const finalTokens = {
11448
- prompt: totalUsage.inputTokens,
11449
- completion: totalUsage.outputTokens,
11450
- total: totalUsage.totalTokens
11451
- };
11453
+ const finalTokens = traceSteps.reduce(
11454
+ (acc, s) => ({
11455
+ prompt: acc.prompt + s.tokenUsage.prompt,
11456
+ completion: acc.completion + s.tokenUsage.completion,
11457
+ total: acc.total + s.tokenUsage.total
11458
+ }),
11459
+ { prompt: 0, completion: 0, total: 0 }
11460
+ );
11452
11461
  return {
11453
11462
  id: (0, import_crypto4.randomUUID)(),
11454
11463
  steps: traceSteps,