@axiom-lattice/gateway 3.0.3 → 3.0.5
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/dist/index.js +31 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -6261,6 +6261,7 @@ var EvalRunner = class {
|
|
|
6261
6261
|
input: { message: c.inputMessage, files: c.inputFiles },
|
|
6262
6262
|
steps: c.steps,
|
|
6263
6263
|
output: { type: "message_content" },
|
|
6264
|
+
interruptPolicy: c.interruptPolicy,
|
|
6264
6265
|
eval: {
|
|
6265
6266
|
content_assertion: c.contentAssertion,
|
|
6266
6267
|
eval_rubrics: c.rubrics?.map((r) => ({
|
|
@@ -6317,13 +6318,14 @@ var EvalRunner = class {
|
|
|
6317
6318
|
concurrency
|
|
6318
6319
|
};
|
|
6319
6320
|
const abortController = new AbortController();
|
|
6320
|
-
const stats = { passed: 0, failed: 0, totalScore: 0 };
|
|
6321
|
+
const stats = { passed: 0, failed: 0, interrupted: 0, totalScore: 0 };
|
|
6321
6322
|
const onCaseComplete = async (result, suiteName) => {
|
|
6322
6323
|
const passed = result.result?.pass ?? false;
|
|
6323
6324
|
const score = result.result?.final_score ?? 0;
|
|
6324
6325
|
if (passed) stats.passed++;
|
|
6325
6326
|
else stats.failed++;
|
|
6326
6327
|
stats.totalScore += score;
|
|
6328
|
+
if (result.interrupted) stats.interrupted++;
|
|
6327
6329
|
const completedCount = stats.passed + stats.failed;
|
|
6328
6330
|
await store.createRunResult(tenantId, runId, uuidv43(), {
|
|
6329
6331
|
suiteName,
|
|
@@ -6339,18 +6341,20 @@ var EvalRunner = class {
|
|
|
6339
6341
|
durationMs: result.duration_ms,
|
|
6340
6342
|
messages: result.messages,
|
|
6341
6343
|
logs: mapLogs(result.logs),
|
|
6342
|
-
error: result.error
|
|
6344
|
+
error: result.error,
|
|
6345
|
+
interrupted: result.interrupted
|
|
6343
6346
|
});
|
|
6344
6347
|
const avgScore = completedCount > 0 ? stats.totalScore / completedCount : 0;
|
|
6345
6348
|
await store.updateRunStatus(tenantId, runId, {
|
|
6346
6349
|
passedCases: stats.passed,
|
|
6347
6350
|
failedCases: stats.failed,
|
|
6351
|
+
interruptedCases: stats.interrupted,
|
|
6348
6352
|
avgScore
|
|
6349
6353
|
});
|
|
6350
6354
|
this.eventEmitter.emit(`run:${runId}`, {
|
|
6351
6355
|
type: "progress",
|
|
6352
6356
|
runId,
|
|
6353
|
-
data: { suiteName, caseId: result.caseId, pass: passed, score, completed: completedCount, total: totalCases }
|
|
6357
|
+
data: { suiteName, caseId: result.caseId, pass: passed, score, interrupted: result.interrupted ?? false, completed: completedCount, total: totalCases }
|
|
6354
6358
|
});
|
|
6355
6359
|
};
|
|
6356
6360
|
const runPromise = (async () => {
|
|
@@ -6376,6 +6380,7 @@ var EvalRunner = class {
|
|
|
6376
6380
|
completedAt: /* @__PURE__ */ new Date(),
|
|
6377
6381
|
passedCases: stats.passed,
|
|
6378
6382
|
failedCases: stats.failed,
|
|
6383
|
+
interruptedCases: stats.interrupted,
|
|
6379
6384
|
avgScore: completedCount > 0 ? stats.totalScore / completedCount : 0
|
|
6380
6385
|
});
|
|
6381
6386
|
this.eventEmitter.emit(`run:${runId}`, {
|
|
@@ -6417,6 +6422,12 @@ var EvalRunner = class {
|
|
|
6417
6422
|
await store.updateRunStatus(ctx.tenantId, runId, { status: "aborted", completedAt: /* @__PURE__ */ new Date() });
|
|
6418
6423
|
return true;
|
|
6419
6424
|
}
|
|
6425
|
+
async waitForRun(runId) {
|
|
6426
|
+
const ctx = this.runs.get(runId);
|
|
6427
|
+
if (!ctx) throw new Error("Run not found or no longer in memory");
|
|
6428
|
+
const { report } = await ctx.promise;
|
|
6429
|
+
return report;
|
|
6430
|
+
}
|
|
6420
6431
|
isRunning(runId) {
|
|
6421
6432
|
return this.runs.has(runId);
|
|
6422
6433
|
}
|
|
@@ -6443,6 +6454,13 @@ async function createProject(request, reply) {
|
|
|
6443
6454
|
const store = getEvalStore();
|
|
6444
6455
|
const id = uuidv44();
|
|
6445
6456
|
const data = request.body;
|
|
6457
|
+
const existing = await store.getProjectsByTenant(tenantId);
|
|
6458
|
+
if (existing.some((p) => p.name === data.name)) {
|
|
6459
|
+
return reply.status(409).send({
|
|
6460
|
+
success: false,
|
|
6461
|
+
message: `Eval project with name "${data.name}" already exists`
|
|
6462
|
+
});
|
|
6463
|
+
}
|
|
6446
6464
|
const serverCfg = data.targetServerConfig || {};
|
|
6447
6465
|
const judgeCfg = data.judgeModelConfig || {};
|
|
6448
6466
|
const modelKey = judgeCfg.modelKey || "";
|
|
@@ -6474,6 +6492,14 @@ async function createProject(request, reply) {
|
|
|
6474
6492
|
});
|
|
6475
6493
|
} catch (err) {
|
|
6476
6494
|
const message = err instanceof Error ? err.message : "Failed to create project";
|
|
6495
|
+
const code = err.code;
|
|
6496
|
+
const isUniqueViolation = code === "23505" || typeof message === "string" && message.includes("UNIQUE constraint failed");
|
|
6497
|
+
if (isUniqueViolation) {
|
|
6498
|
+
return reply.status(409).send({
|
|
6499
|
+
success: false,
|
|
6500
|
+
message: `Eval project with name "${request.body.name}" already exists`
|
|
6501
|
+
});
|
|
6502
|
+
}
|
|
6477
6503
|
return reply.status(500).send({ success: false, message });
|
|
6478
6504
|
}
|
|
6479
6505
|
}
|
|
@@ -6671,7 +6697,8 @@ async function createCase(request, reply) {
|
|
|
6671
6697
|
steps: data.steps ?? [],
|
|
6672
6698
|
outputType: data.outputType ?? "message_content",
|
|
6673
6699
|
contentAssertion: data.contentAssertion ?? "",
|
|
6674
|
-
rubrics: data.rubrics
|
|
6700
|
+
rubrics: data.rubrics,
|
|
6701
|
+
interruptPolicy: data.interruptPolicy
|
|
6675
6702
|
});
|
|
6676
6703
|
return reply.status(201).send({
|
|
6677
6704
|
success: true,
|