orchestrated 0.1.29 → 0.1.31
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.d.ts +2 -0
- package/index.js +57 -11
- package/index.js.map +8 -8
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -815,6 +815,7 @@ declare const InteractionsDatasetOptionsSchema: z.ZodObject<{
|
|
|
815
815
|
month: z.ZodOptional<z.ZodString>;
|
|
816
816
|
startDate: z.ZodOptional<z.ZodString>;
|
|
817
817
|
endDate: z.ZodOptional<z.ZodString>;
|
|
818
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
818
819
|
timeout: z.ZodOptional<z.ZodNumber>;
|
|
819
820
|
}, z.core.$strip>;
|
|
820
821
|
|
|
@@ -1287,6 +1288,7 @@ declare const SessionsDatasetOptionsSchema: z.ZodObject<{
|
|
|
1287
1288
|
month: z.ZodOptional<z.ZodString>;
|
|
1288
1289
|
startDate: z.ZodOptional<z.ZodString>;
|
|
1289
1290
|
endDate: z.ZodOptional<z.ZodString>;
|
|
1291
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
1290
1292
|
timeout: z.ZodOptional<z.ZodNumber>;
|
|
1291
1293
|
}, z.core.$strip>;
|
|
1292
1294
|
|
package/index.js
CHANGED
|
@@ -21230,6 +21230,7 @@ function resetState() {
|
|
|
21230
21230
|
globalState = null;
|
|
21231
21231
|
isInitialized = false;
|
|
21232
21232
|
globalThis.__ORCHESTRATED_LAZY_LOAD__ = undefined;
|
|
21233
|
+
if (false) {}
|
|
21233
21234
|
}
|
|
21234
21235
|
function isStateInitialized() {
|
|
21235
21236
|
return isInitialized || globalThis.__ORCHESTRATED_SHARED_STATE__ !== undefined;
|
|
@@ -58802,6 +58803,9 @@ async function getDataset(datasetName, source, options) {
|
|
|
58802
58803
|
const timeout = options.timeout ?? 30000;
|
|
58803
58804
|
const allResults = [];
|
|
58804
58805
|
let cursor;
|
|
58806
|
+
let latestHasMore = false;
|
|
58807
|
+
let latestLastEvalTimestamp = null;
|
|
58808
|
+
const hasExplicitLimit = typeof options.limit === "number" && options.limit > 0;
|
|
58805
58809
|
do {
|
|
58806
58810
|
const controller = new AbortController;
|
|
58807
58811
|
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
@@ -58835,7 +58839,9 @@ async function getDataset(datasetName, source, options) {
|
|
|
58835
58839
|
const rawData = await response.json();
|
|
58836
58840
|
const data = DatasetResponseSchema.parse(rawData);
|
|
58837
58841
|
allResults.push(...data.data);
|
|
58838
|
-
cursor = data.nextCursor;
|
|
58842
|
+
cursor = hasExplicitLimit ? undefined : data.nextCursor;
|
|
58843
|
+
latestHasMore = data.hasMore ?? Boolean(data.nextCursor);
|
|
58844
|
+
latestLastEvalTimestamp = data.lastEvalTimestamp ?? null;
|
|
58839
58845
|
} catch (error48) {
|
|
58840
58846
|
clearTimeout(timeoutId);
|
|
58841
58847
|
if (error48 instanceof Error && error48.name === "AbortError") {
|
|
@@ -58844,11 +58850,17 @@ async function getDataset(datasetName, source, options) {
|
|
|
58844
58850
|
throw error48;
|
|
58845
58851
|
}
|
|
58846
58852
|
} while (cursor);
|
|
58853
|
+
globalThis[DATASET_METADATA_KEY] = {
|
|
58854
|
+
datasetName,
|
|
58855
|
+
count: allResults.length,
|
|
58856
|
+
hasMore: latestHasMore,
|
|
58857
|
+
lastEvalTimestamp: latestLastEvalTimestamp
|
|
58858
|
+
};
|
|
58847
58859
|
return allResults;
|
|
58848
58860
|
}
|
|
58849
58861
|
var getApiUrl = () => {
|
|
58850
58862
|
return getState().apiUrl;
|
|
58851
|
-
}, DatasetResponseSchema;
|
|
58863
|
+
}, DatasetResponseSchema, DATASET_METADATA_KEY = "__ORCHESTRATED_DATASET_METADATA__";
|
|
58852
58864
|
var init_data_source = __esm(() => {
|
|
58853
58865
|
init_zod();
|
|
58854
58866
|
DatasetResponseSchema = exports_external.object({
|
|
@@ -58860,7 +58872,9 @@ var init_data_source = __esm(() => {
|
|
|
58860
58872
|
input: exports_external.string(),
|
|
58861
58873
|
output: exports_external.string()
|
|
58862
58874
|
}).loose()),
|
|
58863
|
-
nextCursor: exports_external.string().optional()
|
|
58875
|
+
nextCursor: exports_external.string().optional(),
|
|
58876
|
+
hasMore: exports_external.boolean().optional(),
|
|
58877
|
+
lastEvalTimestamp: exports_external.string().nullable().optional()
|
|
58864
58878
|
}).passthrough();
|
|
58865
58879
|
});
|
|
58866
58880
|
|
|
@@ -113999,8 +114013,27 @@ class S3FileManager {
|
|
|
113999
114013
|
async upload(content, key) {
|
|
114000
114014
|
const { getState: getState2 } = await Promise.resolve().then(() => exports_state);
|
|
114001
114015
|
const state = getState2();
|
|
114016
|
+
if (state.awsAccessKeyId && state.awsSecretAccessKey) {
|
|
114017
|
+
const { PutObjectCommand, S3Client } = require_dist_cjs79();
|
|
114018
|
+
const s3Key = state.tenantId && state.serviceName ? `${state.tenantId}/${state.serviceName}/${key}` : key;
|
|
114019
|
+
const s3Client = new S3Client({
|
|
114020
|
+
region: this.region,
|
|
114021
|
+
credentials: {
|
|
114022
|
+
accessKeyId: state.awsAccessKeyId,
|
|
114023
|
+
secretAccessKey: state.awsSecretAccessKey,
|
|
114024
|
+
sessionToken: state.awsSessionToken || undefined
|
|
114025
|
+
}
|
|
114026
|
+
});
|
|
114027
|
+
await s3Client.send(new PutObjectCommand({
|
|
114028
|
+
Bucket: this.bucket,
|
|
114029
|
+
Key: s3Key,
|
|
114030
|
+
Body: content,
|
|
114031
|
+
ContentType: "application/jsonl"
|
|
114032
|
+
}));
|
|
114033
|
+
return `s3://${this.bucket}/${s3Key}`;
|
|
114034
|
+
}
|
|
114002
114035
|
if (!state.accessToken) {
|
|
114003
|
-
throw new Error("No access token found. Please run 'orcha login' to authenticate before using Bedrock batch mode.");
|
|
114036
|
+
throw new Error("No AWS credentials or access token found. Please run 'orcha login' to authenticate before using Bedrock batch mode.");
|
|
114004
114037
|
}
|
|
114005
114038
|
if (!state.tenantId || !state.serviceName) {
|
|
114006
114039
|
throw new Error("tenantId and serviceName are required for Bedrock batch uploads.");
|
|
@@ -114155,13 +114188,16 @@ class BatchClient {
|
|
|
114155
114188
|
fs.mkdirSync(this.tempDir, { recursive: true });
|
|
114156
114189
|
}
|
|
114157
114190
|
}
|
|
114158
|
-
async initialize(name, checksum, dataSourceType, maxAgeDays =
|
|
114191
|
+
async initialize(name, checksum, dataSourceType, maxAgeDays = 2) {
|
|
114159
114192
|
this.metadata = { name, checksum };
|
|
114160
|
-
|
|
114193
|
+
console.log(`BatchClient.initialize: searching for name="${name}", checksum="${checksum}", mode=${this.mode}, dataSourceType=${dataSourceType ?? "unknown"}`);
|
|
114194
|
+
const batches = await this.listBatches(100);
|
|
114195
|
+
console.log(`BatchClient.initialize: listBatches returned ${batches.length} batch(es): ${JSON.stringify(batches.map((b) => ({ id: b.id, status: b.status, created_at: b.created_at, metadata: b.metadata })))}`);
|
|
114161
114196
|
const maxAgeMs = maxAgeDays * 24 * 60 * 60 * 1000;
|
|
114162
114197
|
const cutoff = Date.now() - maxAgeMs;
|
|
114163
114198
|
const matchingBatches = batches.filter((batch) => {
|
|
114164
|
-
|
|
114199
|
+
const createdAtMs = this.mode === "OPENAI" ? batch.created_at * 1000 : batch.created_at;
|
|
114200
|
+
if (createdAtMs < cutoff) {
|
|
114165
114201
|
return false;
|
|
114166
114202
|
}
|
|
114167
114203
|
const nameMatches = batch.metadata?.name === this.metadata?.name;
|
|
@@ -114172,22 +114208,27 @@ class BatchClient {
|
|
|
114172
114208
|
}
|
|
114173
114209
|
});
|
|
114174
114210
|
if (matchingBatches.length === 0) {
|
|
114211
|
+
console.log("BatchClient.initialize: no matching batches found");
|
|
114175
114212
|
return;
|
|
114176
114213
|
}
|
|
114214
|
+
console.log(`BatchClient.initialize: ${matchingBatches.length} matching batch(es): ${JSON.stringify(matchingBatches.map((b) => ({ id: b.id, status: b.status })))}`);
|
|
114177
114215
|
const pendingBatches = matchingBatches.filter((batch) => !this.isBatchComplete(batch));
|
|
114178
114216
|
const successfulBatches = matchingBatches.filter((batch) => batch.status === "completed");
|
|
114179
114217
|
if (pendingBatches.length > 0) {
|
|
114218
|
+
console.log(`BatchClient.initialize: ${pendingBatches.length} pending batch(es), waiting`);
|
|
114180
114219
|
this.hasPendingBatch = true;
|
|
114181
114220
|
this.pendingBatches = pendingBatches;
|
|
114182
114221
|
return;
|
|
114183
114222
|
}
|
|
114184
114223
|
if (successfulBatches.length > 0) {
|
|
114224
|
+
console.log(`BatchClient.initialize: loading results from ${successfulBatches.length} completed batch(es)`);
|
|
114185
114225
|
this.hasCompletedBatch = true;
|
|
114186
114226
|
this.completedBatches = successfulBatches;
|
|
114187
114227
|
const allResponses = [];
|
|
114188
114228
|
for (const batch of successfulBatches) {
|
|
114189
114229
|
try {
|
|
114190
114230
|
const results = await this.getBatchResults(batch.id);
|
|
114231
|
+
console.log(`BatchClient.initialize: loaded ${results.length} results from batch ${batch.id}`);
|
|
114191
114232
|
allResponses.push(...results);
|
|
114192
114233
|
} catch (error48) {
|
|
114193
114234
|
console.warn(`Failed to load results from batch ${batch.id}:`, error48);
|
|
@@ -115221,6 +115262,8 @@ function getEvaluationOptions(name, options, state) {
|
|
|
115221
115262
|
});
|
|
115222
115263
|
} else {
|
|
115223
115264
|
batchClient = new BatchClient;
|
|
115265
|
+
const OpenAI5 = __require("openai").default;
|
|
115266
|
+
openaiClient = new OpenAI5;
|
|
115224
115267
|
}
|
|
115225
115268
|
}
|
|
115226
115269
|
evalClient = merged.evalClient || new EvalClient({
|
|
@@ -115541,10 +115584,9 @@ async function runEval(name, evaluator, options) {
|
|
|
115541
115584
|
[ATTR_DATASET_SOURCE_TYPE]: data.ctx.sourceType,
|
|
115542
115585
|
[ATTR_EVAL_EXECUTION_METADATA_TEST_CASE_COUNT]: data.ctx.caseCount
|
|
115543
115586
|
});
|
|
115544
|
-
|
|
115545
|
-
if (execute === "batch" && batchProcessor === "BEDROCK_OPENAI" && totalBatchRequests < 100) {
|
|
115587
|
+
if (execute === "batch" && data.dataset.length < 100) {
|
|
115546
115588
|
execute = "sync";
|
|
115547
|
-
iso.writeln(`ℹ ${
|
|
115589
|
+
iso.writeln(`ℹ ${data.dataset.length} record(s) is below the 100-record threshold for batch mode. Falling back to sync (individual requests).`);
|
|
115548
115590
|
}
|
|
115549
115591
|
if (execute === "batch" && batchClient) {
|
|
115550
115592
|
await batchClient.initialize(name, data.ctx.checksum, data.ctx.dataSourceType);
|
|
@@ -115762,6 +115804,7 @@ var InteractionsDatasetOptionsSchema = exports_external.object({
|
|
|
115762
115804
|
month: exports_external.string().optional(),
|
|
115763
115805
|
startDate: exports_external.string().optional(),
|
|
115764
115806
|
endDate: exports_external.string().optional(),
|
|
115807
|
+
limit: exports_external.number().optional(),
|
|
115765
115808
|
timeout: exports_external.number().optional()
|
|
115766
115809
|
});
|
|
115767
115810
|
function interactions(options = {}) {
|
|
@@ -115784,6 +115827,7 @@ function interactions(options = {}) {
|
|
|
115784
115827
|
month: options.month,
|
|
115785
115828
|
startDate: options.startDate,
|
|
115786
115829
|
endDate: options.endDate,
|
|
115830
|
+
limit: options.limit,
|
|
115787
115831
|
timeout: options.timeout
|
|
115788
115832
|
},
|
|
115789
115833
|
args: argsJsonSchema
|
|
@@ -115798,6 +115842,7 @@ var SessionsDatasetOptionsSchema = exports_external.object({
|
|
|
115798
115842
|
month: exports_external.string().optional(),
|
|
115799
115843
|
startDate: exports_external.string().optional(),
|
|
115800
115844
|
endDate: exports_external.string().optional(),
|
|
115845
|
+
limit: exports_external.number().optional(),
|
|
115801
115846
|
timeout: exports_external.number().optional()
|
|
115802
115847
|
});
|
|
115803
115848
|
function sessions(options = {}) {
|
|
@@ -115820,6 +115865,7 @@ function sessions(options = {}) {
|
|
|
115820
115865
|
month: options.month,
|
|
115821
115866
|
startDate: options.startDate,
|
|
115822
115867
|
endDate: options.endDate,
|
|
115868
|
+
limit: options.limit,
|
|
115823
115869
|
timeout: options.timeout
|
|
115824
115870
|
},
|
|
115825
115871
|
args: argsJsonSchema
|
|
@@ -116034,4 +116080,4 @@ export {
|
|
|
116034
116080
|
Behavioral
|
|
116035
116081
|
};
|
|
116036
116082
|
|
|
116037
|
-
//# debugId=
|
|
116083
|
+
//# debugId=26267E7384DF594064756E2164756E21
|