orchestrated 0.1.16 → 0.1.18
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 +26 -6
- package/index.js.map +4 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -117068,7 +117068,9 @@ class S3FileManager {
|
|
|
117068
117068
|
body: content
|
|
117069
117069
|
});
|
|
117070
117070
|
if (!uploadResponse.ok) {
|
|
117071
|
-
|
|
117071
|
+
const errorBody = await uploadResponse.text();
|
|
117072
|
+
throw new Error(`Failed to upload batch file to S3 (${uploadResponse.status}): ${uploadResponse.statusText}
|
|
117073
|
+
${errorBody}`);
|
|
117072
117074
|
}
|
|
117073
117075
|
return `s3://${result.bucket}/${asset.s3Key}`;
|
|
117074
117076
|
}
|
|
@@ -118172,11 +118174,11 @@ function getEvaluationOptions(name, options, state) {
|
|
|
118172
118174
|
let batchClient;
|
|
118173
118175
|
let evalClient;
|
|
118174
118176
|
let openaiClient;
|
|
118177
|
+
const batchProcessor = merged.batchProcessor ?? "OPENAI";
|
|
118175
118178
|
if (execute === "batch") {
|
|
118176
118179
|
if (merged.batchClient) {
|
|
118177
118180
|
batchClient = merged.batchClient;
|
|
118178
118181
|
} else {
|
|
118179
|
-
const batchProcessor = merged.batchProcessor ?? "OPENAI";
|
|
118180
118182
|
if (batchProcessor === "BEDROCK_OPENAI") {
|
|
118181
118183
|
if (!state.bedrockRegion || !state.bedrockApiKey || !state.bedrockServiceRoleArn || !state.bedrockModelId || !state.bedrockS3Bucket) {
|
|
118182
118184
|
throw new Error(`Bedrock configuration is incomplete. Required: bedrockRegion, bedrockApiKey, bedrockServiceRoleArn, bedrockModelId, bedrockS3Bucket.
|
|
@@ -118192,6 +118194,15 @@ function getEvaluationOptions(name, options, state) {
|
|
|
118192
118194
|
s3Bucket: state.bedrockS3Bucket
|
|
118193
118195
|
}
|
|
118194
118196
|
});
|
|
118197
|
+
const OpenAI4 = __require("openai").default;
|
|
118198
|
+
openaiClient = new OpenAI4({
|
|
118199
|
+
baseURL: `https://bedrock-runtime.${state.bedrockRegion}.amazonaws.com/openai/v1`,
|
|
118200
|
+
apiKey: state.bedrockApiKey,
|
|
118201
|
+
defaultHeaders: {
|
|
118202
|
+
"X-Amzn-Bedrock-RoleArn": state.bedrockServiceRoleArn,
|
|
118203
|
+
"X-Amzn-Bedrock-ModelId": state.bedrockModelId
|
|
118204
|
+
}
|
|
118205
|
+
});
|
|
118195
118206
|
} else {
|
|
118196
118207
|
batchClient = new BatchClient;
|
|
118197
118208
|
}
|
|
@@ -118215,6 +118226,7 @@ function getEvaluationOptions(name, options, state) {
|
|
|
118215
118226
|
createProgressTracker: createProgressTracker || (() => new NullProgressTracker),
|
|
118216
118227
|
onPendingBatch,
|
|
118217
118228
|
execute,
|
|
118229
|
+
batchProcessor,
|
|
118218
118230
|
batchClient,
|
|
118219
118231
|
evalClient,
|
|
118220
118232
|
openaiClient,
|
|
@@ -118245,7 +118257,8 @@ async function evaluateDataCase(dataCase, evaluator, _ctx, options) {
|
|
|
118245
118257
|
expected: dataCase.expected,
|
|
118246
118258
|
tags: dataCase.tags,
|
|
118247
118259
|
id: caseId,
|
|
118248
|
-
client: client2
|
|
118260
|
+
client: client2,
|
|
118261
|
+
model: options.execute === "sync" && options.batchProcessor === "BEDROCK_OPENAI" ? _ctx.state.bedrockModelId : undefined
|
|
118249
118262
|
};
|
|
118250
118263
|
const fieldsToExclude = new Set(["state", "ctx", "tags", "id", "client"]);
|
|
118251
118264
|
const argsForStorage = Object.fromEntries(Object.entries(scorerArgs).filter(([key]) => !fieldsToExclude.has(key)));
|
|
@@ -118494,9 +118507,10 @@ async function runEval(name, evaluator, options) {
|
|
|
118494
118507
|
jsonl,
|
|
118495
118508
|
returnResults,
|
|
118496
118509
|
progress,
|
|
118497
|
-
|
|
118510
|
+
batchProcessor,
|
|
118498
118511
|
batchClient
|
|
118499
118512
|
} = options;
|
|
118513
|
+
let { execute } = options;
|
|
118500
118514
|
const ctx = init({
|
|
118501
118515
|
...evaluator.ctx ?? {},
|
|
118502
118516
|
state,
|
|
@@ -118508,6 +118522,11 @@ async function runEval(name, evaluator, options) {
|
|
|
118508
118522
|
[ATTR_DATASET_SOURCE_TYPE]: data.ctx.sourceType,
|
|
118509
118523
|
[ATTR_EVAL_EXECUTION_METADATA_TEST_CASE_COUNT]: data.ctx.caseCount
|
|
118510
118524
|
});
|
|
118525
|
+
const totalBatchRequests = data.dataset.length * evaluator.scores.length;
|
|
118526
|
+
if (execute === "batch" && batchProcessor === "BEDROCK_OPENAI" && totalBatchRequests < 100) {
|
|
118527
|
+
execute = "sync";
|
|
118528
|
+
iso.writeln(`ℹ ${totalBatchRequests} batch request(s) (${data.dataset.length} records × ${evaluator.scores.length} scorers) is below the 100 minimum for Bedrock batch. Falling back to sync mode.`);
|
|
118529
|
+
}
|
|
118511
118530
|
if (execute === "batch" && batchClient) {
|
|
118512
118531
|
await batchClient.initialize(name, data.ctx.checksum, data.ctx.dataSourceType);
|
|
118513
118532
|
if (batchClient.hasPendingBatch) {
|
|
@@ -118517,10 +118536,11 @@ async function runEval(name, evaluator, options) {
|
|
|
118517
118536
|
const results = [];
|
|
118518
118537
|
const errors6 = new Map;
|
|
118519
118538
|
progress.start(data.dataset.length);
|
|
118539
|
+
const effectiveOptions = execute !== options.execute ? { ...options, execute } : options;
|
|
118520
118540
|
for (const dataCase of data.dataset) {
|
|
118521
118541
|
const caseResult = await evaluateDataCase(dataCase, evaluator, ctx.mutate({
|
|
118522
118542
|
dataset: data.ctx
|
|
118523
|
-
}),
|
|
118543
|
+
}), effectiveOptions);
|
|
118524
118544
|
results.push(caseResult.result);
|
|
118525
118545
|
aggregateScorerErrors(errors6, caseResult.errors);
|
|
118526
118546
|
if (execute === "sync" && options.onResult) {
|
|
@@ -118995,4 +119015,4 @@ export {
|
|
|
118995
119015
|
Behavioral
|
|
118996
119016
|
};
|
|
118997
119017
|
|
|
118998
|
-
//# debugId=
|
|
119018
|
+
//# debugId=31E51C8DF22CA45F64756E2164756E21
|