@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.js
CHANGED
|
@@ -8269,6 +8269,7 @@ var EvalRunner = class {
|
|
|
8269
8269
|
input: { message: c.inputMessage, files: c.inputFiles },
|
|
8270
8270
|
steps: c.steps,
|
|
8271
8271
|
output: { type: "message_content" },
|
|
8272
|
+
interruptPolicy: c.interruptPolicy,
|
|
8272
8273
|
eval: {
|
|
8273
8274
|
content_assertion: c.contentAssertion,
|
|
8274
8275
|
eval_rubrics: c.rubrics?.map((r) => ({
|
|
@@ -8325,13 +8326,14 @@ var EvalRunner = class {
|
|
|
8325
8326
|
concurrency
|
|
8326
8327
|
};
|
|
8327
8328
|
const abortController = new AbortController();
|
|
8328
|
-
const stats = { passed: 0, failed: 0, totalScore: 0 };
|
|
8329
|
+
const stats = { passed: 0, failed: 0, interrupted: 0, totalScore: 0 };
|
|
8329
8330
|
const onCaseComplete = async (result, suiteName) => {
|
|
8330
8331
|
const passed = result.result?.pass ?? false;
|
|
8331
8332
|
const score = result.result?.final_score ?? 0;
|
|
8332
8333
|
if (passed) stats.passed++;
|
|
8333
8334
|
else stats.failed++;
|
|
8334
8335
|
stats.totalScore += score;
|
|
8336
|
+
if (result.interrupted) stats.interrupted++;
|
|
8335
8337
|
const completedCount = stats.passed + stats.failed;
|
|
8336
8338
|
await store2.createRunResult(tenantId, runId, (0, import_uuid4.v4)(), {
|
|
8337
8339
|
suiteName,
|
|
@@ -8347,18 +8349,20 @@ var EvalRunner = class {
|
|
|
8347
8349
|
durationMs: result.duration_ms,
|
|
8348
8350
|
messages: result.messages,
|
|
8349
8351
|
logs: mapLogs(result.logs),
|
|
8350
|
-
error: result.error
|
|
8352
|
+
error: result.error,
|
|
8353
|
+
interrupted: result.interrupted
|
|
8351
8354
|
});
|
|
8352
8355
|
const avgScore = completedCount > 0 ? stats.totalScore / completedCount : 0;
|
|
8353
8356
|
await store2.updateRunStatus(tenantId, runId, {
|
|
8354
8357
|
passedCases: stats.passed,
|
|
8355
8358
|
failedCases: stats.failed,
|
|
8359
|
+
interruptedCases: stats.interrupted,
|
|
8356
8360
|
avgScore
|
|
8357
8361
|
});
|
|
8358
8362
|
this.eventEmitter.emit(`run:${runId}`, {
|
|
8359
8363
|
type: "progress",
|
|
8360
8364
|
runId,
|
|
8361
|
-
data: { suiteName, caseId: result.caseId, pass: passed, score, completed: completedCount, total: totalCases }
|
|
8365
|
+
data: { suiteName, caseId: result.caseId, pass: passed, score, interrupted: result.interrupted ?? false, completed: completedCount, total: totalCases }
|
|
8362
8366
|
});
|
|
8363
8367
|
};
|
|
8364
8368
|
const runPromise = (async () => {
|
|
@@ -8384,6 +8388,7 @@ var EvalRunner = class {
|
|
|
8384
8388
|
completedAt: /* @__PURE__ */ new Date(),
|
|
8385
8389
|
passedCases: stats.passed,
|
|
8386
8390
|
failedCases: stats.failed,
|
|
8391
|
+
interruptedCases: stats.interrupted,
|
|
8387
8392
|
avgScore: completedCount > 0 ? stats.totalScore / completedCount : 0
|
|
8388
8393
|
});
|
|
8389
8394
|
this.eventEmitter.emit(`run:${runId}`, {
|
|
@@ -8425,6 +8430,12 @@ var EvalRunner = class {
|
|
|
8425
8430
|
await store2.updateRunStatus(ctx.tenantId, runId, { status: "aborted", completedAt: /* @__PURE__ */ new Date() });
|
|
8426
8431
|
return true;
|
|
8427
8432
|
}
|
|
8433
|
+
async waitForRun(runId) {
|
|
8434
|
+
const ctx = this.runs.get(runId);
|
|
8435
|
+
if (!ctx) throw new Error("Run not found or no longer in memory");
|
|
8436
|
+
const { report } = await ctx.promise;
|
|
8437
|
+
return report;
|
|
8438
|
+
}
|
|
8428
8439
|
isRunning(runId) {
|
|
8429
8440
|
return this.runs.has(runId);
|
|
8430
8441
|
}
|
|
@@ -8451,6 +8462,13 @@ async function createProject(request, reply) {
|
|
|
8451
8462
|
const store2 = getEvalStore();
|
|
8452
8463
|
const id = (0, import_uuid5.v4)();
|
|
8453
8464
|
const data = request.body;
|
|
8465
|
+
const existing = await store2.getProjectsByTenant(tenantId);
|
|
8466
|
+
if (existing.some((p) => p.name === data.name)) {
|
|
8467
|
+
return reply.status(409).send({
|
|
8468
|
+
success: false,
|
|
8469
|
+
message: `Eval project with name "${data.name}" already exists`
|
|
8470
|
+
});
|
|
8471
|
+
}
|
|
8454
8472
|
const serverCfg = data.targetServerConfig || {};
|
|
8455
8473
|
const judgeCfg = data.judgeModelConfig || {};
|
|
8456
8474
|
const modelKey = judgeCfg.modelKey || "";
|
|
@@ -8482,6 +8500,14 @@ async function createProject(request, reply) {
|
|
|
8482
8500
|
});
|
|
8483
8501
|
} catch (err) {
|
|
8484
8502
|
const message = err instanceof Error ? err.message : "Failed to create project";
|
|
8503
|
+
const code = err.code;
|
|
8504
|
+
const isUniqueViolation = code === "23505" || typeof message === "string" && message.includes("UNIQUE constraint failed");
|
|
8505
|
+
if (isUniqueViolation) {
|
|
8506
|
+
return reply.status(409).send({
|
|
8507
|
+
success: false,
|
|
8508
|
+
message: `Eval project with name "${request.body.name}" already exists`
|
|
8509
|
+
});
|
|
8510
|
+
}
|
|
8485
8511
|
return reply.status(500).send({ success: false, message });
|
|
8486
8512
|
}
|
|
8487
8513
|
}
|
|
@@ -8679,7 +8705,8 @@ async function createCase(request, reply) {
|
|
|
8679
8705
|
steps: data.steps ?? [],
|
|
8680
8706
|
outputType: data.outputType ?? "message_content",
|
|
8681
8707
|
contentAssertion: data.contentAssertion ?? "",
|
|
8682
|
-
rubrics: data.rubrics
|
|
8708
|
+
rubrics: data.rubrics,
|
|
8709
|
+
interruptPolicy: data.interruptPolicy
|
|
8683
8710
|
});
|
|
8684
8711
|
return reply.status(201).send({
|
|
8685
8712
|
success: true,
|