orchestrated 0.1.31 → 0.1.32
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/index.js +65 -27
- package/index.js.map +5 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -58842,6 +58842,7 @@ async function getDataset(datasetName, source, options) {
|
|
|
58842
58842
|
cursor = hasExplicitLimit ? undefined : data.nextCursor;
|
|
58843
58843
|
latestHasMore = data.hasMore ?? Boolean(data.nextCursor);
|
|
58844
58844
|
latestLastEvalTimestamp = data.lastEvalTimestamp ?? null;
|
|
58845
|
+
console.log(`[dataset:${datasetName}] page fetched: pageCount=${data.data.length}, runningTotal=${allResults.length}, hasMore=${latestHasMore}, lastEvalTimestamp=${latestLastEvalTimestamp}`);
|
|
58845
58846
|
} catch (error48) {
|
|
58846
58847
|
clearTimeout(timeoutId);
|
|
58847
58848
|
if (error48 instanceof Error && error48.name === "AbortError") {
|
|
@@ -58856,6 +58857,7 @@ async function getDataset(datasetName, source, options) {
|
|
|
58856
58857
|
hasMore: latestHasMore,
|
|
58857
58858
|
lastEvalTimestamp: latestLastEvalTimestamp
|
|
58858
58859
|
};
|
|
58860
|
+
console.log(`[dataset:${datasetName}] pull complete: total=${allResults.length}, hasMore=${latestHasMore}, lastEvalTimestamp=${latestLastEvalTimestamp}`);
|
|
58859
58861
|
return allResults;
|
|
58860
58862
|
}
|
|
58861
58863
|
var getApiUrl = () => {
|
|
@@ -114213,30 +114215,30 @@ class BatchClient {
|
|
|
114213
114215
|
}
|
|
114214
114216
|
console.log(`BatchClient.initialize: ${matchingBatches.length} matching batch(es): ${JSON.stringify(matchingBatches.map((b) => ({ id: b.id, status: b.status })))}`);
|
|
114215
114217
|
const pendingBatches = matchingBatches.filter((batch) => !this.isBatchComplete(batch));
|
|
114216
|
-
const
|
|
114218
|
+
const resultBearingBatches = matchingBatches.filter((batch) => batch.status === "completed" || batch.status === "expired" || batch.status === "cancelled");
|
|
114217
114219
|
if (pendingBatches.length > 0) {
|
|
114218
114220
|
console.log(`BatchClient.initialize: ${pendingBatches.length} pending batch(es), waiting`);
|
|
114219
114221
|
this.hasPendingBatch = true;
|
|
114220
114222
|
this.pendingBatches = pendingBatches;
|
|
114221
114223
|
return;
|
|
114222
114224
|
}
|
|
114223
|
-
if (
|
|
114224
|
-
console.log(`BatchClient.initialize: loading results from ${
|
|
114225
|
+
if (resultBearingBatches.length > 0) {
|
|
114226
|
+
console.log(`BatchClient.initialize: loading results from ${resultBearingBatches.length} batch(es): ${JSON.stringify(resultBearingBatches.map((b) => ({ id: b.id, status: b.status })))}`);
|
|
114225
114227
|
this.hasCompletedBatch = true;
|
|
114226
|
-
this.completedBatches =
|
|
114228
|
+
this.completedBatches = resultBearingBatches;
|
|
114227
114229
|
const allResponses = [];
|
|
114228
|
-
for (const batch of
|
|
114230
|
+
for (const batch of resultBearingBatches) {
|
|
114229
114231
|
try {
|
|
114230
114232
|
const results = await this.getBatchResults(batch.id);
|
|
114231
|
-
console.log(`BatchClient.initialize: loaded ${results.length}
|
|
114233
|
+
console.log(`BatchClient.initialize: loaded ${results.length} result(s) from batch ${batch.id} (status=${batch.status})`);
|
|
114232
114234
|
allResponses.push(...results);
|
|
114233
114235
|
} catch (error48) {
|
|
114234
114236
|
console.warn(`Failed to load results from batch ${batch.id}:`, error48);
|
|
114235
114237
|
}
|
|
114236
114238
|
}
|
|
114237
114239
|
this.responses = allResponses;
|
|
114238
|
-
if (
|
|
114239
|
-
iso.writeln(`${colors.gray}Loaded ${allResponses.length} total results from ${
|
|
114240
|
+
if (resultBearingBatches.length > 1) {
|
|
114241
|
+
iso.writeln(`${colors.gray}Loaded ${allResponses.length} total results from ${resultBearingBatches.length} batches`);
|
|
114240
114242
|
}
|
|
114241
114243
|
}
|
|
114242
114244
|
}
|
|
@@ -115079,6 +115081,7 @@ var traced = {
|
|
|
115079
115081
|
};
|
|
115080
115082
|
|
|
115081
115083
|
// src/evaluator/core.ts
|
|
115084
|
+
var BATCH_MIN_RECORDS = 100;
|
|
115082
115085
|
function deterministicStringify(obj) {
|
|
115083
115086
|
if (obj === null)
|
|
115084
115087
|
return "null";
|
|
@@ -115232,9 +115235,28 @@ function getEvaluationOptions(name, options, state) {
|
|
|
115232
115235
|
let evalClient;
|
|
115233
115236
|
let openaiClient;
|
|
115234
115237
|
const batchProcessor = merged.batchProcessor ?? "OPENAI";
|
|
115238
|
+
const createSyncFallbackClient = () => {
|
|
115239
|
+
if (batchProcessor === "BEDROCK_OPENAI") {
|
|
115240
|
+
if (!state.bedrockRegion || !state.bedrockApiKey || !state.bedrockServiceRoleArn || !state.bedrockModelId) {
|
|
115241
|
+
return;
|
|
115242
|
+
}
|
|
115243
|
+
const { BedrockOpenAI: BedrockOpenAI2 } = (init_bedrock_openai_client(), __toCommonJS(exports_bedrock_openai_client));
|
|
115244
|
+
return new BedrockOpenAI2({
|
|
115245
|
+
baseURL: `https://bedrock-mantle.${state.bedrockRegion}.api.aws/v1`,
|
|
115246
|
+
apiKey: state.bedrockApiKey,
|
|
115247
|
+
defaultHeaders: {
|
|
115248
|
+
"X-Amzn-Bedrock-RoleArn": state.bedrockServiceRoleArn,
|
|
115249
|
+
"X-Amzn-Bedrock-ModelId": state.bedrockModelId
|
|
115250
|
+
}
|
|
115251
|
+
});
|
|
115252
|
+
}
|
|
115253
|
+
const OpenAI5 = __require("openai").default;
|
|
115254
|
+
return new OpenAI5;
|
|
115255
|
+
};
|
|
115235
115256
|
if (execute === "batch") {
|
|
115236
115257
|
if (merged.batchClient) {
|
|
115237
115258
|
batchClient = merged.batchClient;
|
|
115259
|
+
openaiClient = merged.openaiClient ?? createSyncFallbackClient();
|
|
115238
115260
|
} else {
|
|
115239
115261
|
if (batchProcessor === "BEDROCK_OPENAI") {
|
|
115240
115262
|
if (!state.bedrockRegion || !state.bedrockApiKey || !state.bedrockServiceRoleArn || !state.bedrockModelId || !state.bedrockS3Bucket) {
|
|
@@ -115251,19 +115273,10 @@ function getEvaluationOptions(name, options, state) {
|
|
|
115251
115273
|
s3Bucket: state.bedrockS3Bucket
|
|
115252
115274
|
}
|
|
115253
115275
|
});
|
|
115254
|
-
|
|
115255
|
-
openaiClient = new BedrockOpenAI2({
|
|
115256
|
-
baseURL: `https://bedrock-mantle.${state.bedrockRegion}.api.aws/v1`,
|
|
115257
|
-
apiKey: state.bedrockApiKey,
|
|
115258
|
-
defaultHeaders: {
|
|
115259
|
-
"X-Amzn-Bedrock-RoleArn": state.bedrockServiceRoleArn,
|
|
115260
|
-
"X-Amzn-Bedrock-ModelId": state.bedrockModelId
|
|
115261
|
-
}
|
|
115262
|
-
});
|
|
115276
|
+
openaiClient = createSyncFallbackClient();
|
|
115263
115277
|
} else {
|
|
115264
115278
|
batchClient = new BatchClient;
|
|
115265
|
-
|
|
115266
|
-
openaiClient = new OpenAI5;
|
|
115279
|
+
openaiClient = createSyncFallbackClient();
|
|
115267
115280
|
}
|
|
115268
115281
|
}
|
|
115269
115282
|
evalClient = merged.evalClient || new EvalClient({
|
|
@@ -115584,13 +115597,12 @@ async function runEval(name, evaluator, options) {
|
|
|
115584
115597
|
[ATTR_DATASET_SOURCE_TYPE]: data.ctx.sourceType,
|
|
115585
115598
|
[ATTR_EVAL_EXECUTION_METADATA_TEST_CASE_COUNT]: data.ctx.caseCount
|
|
115586
115599
|
});
|
|
115587
|
-
|
|
115588
|
-
execute = "sync";
|
|
115589
|
-
iso.writeln(`ℹ ${data.dataset.length} record(s) is below the 100-record threshold for batch mode. Falling back to sync (individual requests).`);
|
|
115590
|
-
}
|
|
115600
|
+
iso.writeln(`ℹ [batch-trace] dataset resolved: ${data.dataset.length} case(s), sourceType="${data.ctx.sourceType}", dataSourceType="${data.ctx.dataSourceType}", checksum="${data.ctx.checksum}", execute="${execute}", batchProcessor="${batchProcessor}", scorers=${evaluator.scores.length}.`);
|
|
115591
115601
|
if (execute === "batch" && batchClient) {
|
|
115592
115602
|
await batchClient.initialize(name, data.ctx.checksum, data.ctx.dataSourceType);
|
|
115603
|
+
iso.writeln(`ℹ [batch-trace] after initialize: ${batchClient.responses.length} cached response(s) loaded from prior batch(es), hasPendingBatch=${batchClient.hasPendingBatch}, hasCompletedBatch=${batchClient.hasCompletedBatch}.`);
|
|
115593
115604
|
if (batchClient.hasPendingBatch) {
|
|
115605
|
+
iso.writeln("ℹ [batch-trace] a prior batch is still pending — returning early to wait/retry (no new work this run).");
|
|
115594
115606
|
return batchClient.getPending();
|
|
115595
115607
|
}
|
|
115596
115608
|
}
|
|
@@ -115615,11 +115627,37 @@ async function runEval(name, evaluator, options) {
|
|
|
115615
115627
|
if (!jsonl) {
|
|
115616
115628
|
progress.stop();
|
|
115617
115629
|
}
|
|
115630
|
+
if (execute === "batch" && batchClient) {
|
|
115631
|
+
const pendingSoFar = results.filter((r) => r.hasPendingBatch).length;
|
|
115632
|
+
const erroredSoFar = results.filter((r) => r.error).length;
|
|
115633
|
+
const resolvedSoFar = results.length - pendingSoFar - erroredSoFar;
|
|
115634
|
+
iso.writeln(`ℹ [batch-trace] after scoring loop: ${results.length} case(s) processed → ${resolvedSoFar} resolved from cache, ${pendingSoFar} pending (new/changed), ${erroredSoFar} errored. Accumulated ${batchClient.requests.length} batch record(s) across ${evaluator.scores.length} scorer(s)/case, ${batchClient.duplicateCount} duplicate request(s) skipped.`);
|
|
115635
|
+
}
|
|
115618
115636
|
let batch;
|
|
115619
115637
|
if (execute === "batch" && batchClient) {
|
|
115620
|
-
|
|
115621
|
-
|
|
115622
|
-
|
|
115638
|
+
const pendingRequestCount = batchClient.requests.length;
|
|
115639
|
+
const pendingCaseCount = results.filter((r) => r.hasPendingBatch).length;
|
|
115640
|
+
iso.writeln(`ℹ Batch submit decision: ${pendingCaseCount} pending case(s) → ${pendingRequestCount} batch record(s) (minimum ${BATCH_MIN_RECORDS}, sync-fallback client ${options.openaiClient ? "available" : "MISSING"}).`);
|
|
115641
|
+
if (pendingRequestCount > 0 && pendingRequestCount < BATCH_MIN_RECORDS && options.openaiClient) {
|
|
115642
|
+
iso.writeln(`ℹ ${pendingRequestCount} pending request(s) is below the ${BATCH_MIN_RECORDS}-record batch minimum. Running pending case(s) synchronously.`);
|
|
115643
|
+
const syncOptions = { ...effectiveOptions, execute: "sync" };
|
|
115644
|
+
let reranCount = 0;
|
|
115645
|
+
for (let i2 = 0;i2 < results.length; i2++) {
|
|
115646
|
+
if (!results[i2].hasPendingBatch) {
|
|
115647
|
+
continue;
|
|
115648
|
+
}
|
|
115649
|
+
const caseResult = await evaluateDataCase(data.dataset[i2], evaluator, ctx.mutate({ dataset: data.ctx }), syncOptions);
|
|
115650
|
+
results[i2] = caseResult.result;
|
|
115651
|
+
aggregateScorerErrors(errors6, caseResult.errors);
|
|
115652
|
+
reranCount++;
|
|
115653
|
+
}
|
|
115654
|
+
iso.writeln(`ℹ [batch-trace] SYNC-FALLBACK path: re-ran ${reranCount} pending case(s) synchronously; no batch submitted.`);
|
|
115655
|
+
} else {
|
|
115656
|
+
iso.writeln(`ℹ [batch-trace] SUBMIT path: sending ${pendingRequestCount} record(s) to a new batch${options.openaiClient ? "" : " (sync-fallback unavailable, could not run synchronously)"}.`);
|
|
115657
|
+
batch = await batchClient.submit();
|
|
115658
|
+
if (verbose) {
|
|
115659
|
+
console.log(batch);
|
|
115660
|
+
}
|
|
115623
115661
|
}
|
|
115624
115662
|
}
|
|
115625
115663
|
const summary = createEvaluationSummary(name, results, errors6);
|
|
@@ -116080,4 +116118,4 @@ export {
|
|
|
116080
116118
|
Behavioral
|
|
116081
116119
|
};
|
|
116082
116120
|
|
|
116083
|
-
//# debugId=
|
|
116121
|
+
//# debugId=E69C9539C2C08B5A64756E2164756E21
|