@fabricorg/databricks-testkit 0.6.2 → 0.7.1
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/README.md +3 -0
- package/dist/index.cjs +47 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +47 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -10
package/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# @fabricorg/databricks-testkit
|
|
2
2
|
|
|
3
|
+
This package is ESM-only. Use `import` from TypeScript or JavaScript on Node 22
|
|
4
|
+
or newer; CommonJS `require()` is not an exported runtime surface.
|
|
5
|
+
|
|
3
6
|
Testing toolkit for Databricks artifacts (ADR-0006). One `ExecutionContext`,
|
|
4
7
|
two profiles:
|
|
5
8
|
|
package/dist/index.cjs
CHANGED
|
@@ -2444,6 +2444,12 @@ function parseJson(value, name) {
|
|
|
2444
2444
|
throw new Error(`${name} must contain valid JSON`);
|
|
2445
2445
|
}
|
|
2446
2446
|
}
|
|
2447
|
+
function isObject(value) {
|
|
2448
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
2449
|
+
}
|
|
2450
|
+
function isNonNegativeInteger(value) {
|
|
2451
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
2452
|
+
}
|
|
2447
2453
|
function assertNotFailed(label, state) {
|
|
2448
2454
|
if (typeof state === "string" && /FAIL|ERROR|DELET/i.test(state)) {
|
|
2449
2455
|
throw new Error(`${label} is ${state}`);
|
|
@@ -2678,6 +2684,46 @@ function modelServingCheck() {
|
|
|
2678
2684
|
}
|
|
2679
2685
|
};
|
|
2680
2686
|
}
|
|
2687
|
+
function evalJudgeModelServingCheck() {
|
|
2688
|
+
const names = ["DBX_TEST_EVAL_SERVING_ENDPOINT"];
|
|
2689
|
+
return {
|
|
2690
|
+
id: "model-eval-judge",
|
|
2691
|
+
description: "Databricks Model Serving satisfies the deterministic evaluator chat contract",
|
|
2692
|
+
configured: (env) => required2(env, names).length === 0,
|
|
2693
|
+
async run({ env, client }) {
|
|
2694
|
+
requireEnv(env, names);
|
|
2695
|
+
const api = adapter(client);
|
|
2696
|
+
const name = env.DBX_TEST_EVAL_SERVING_ENDPOINT;
|
|
2697
|
+
const endpoint = await api.servingEndpoint(name);
|
|
2698
|
+
assertReady("Evaluator serving endpoint", endpoint.state?.ready, ["READY"]);
|
|
2699
|
+
const response = await api.invokeServingEndpoint(name, {
|
|
2700
|
+
messages: [
|
|
2701
|
+
{
|
|
2702
|
+
role: "system",
|
|
2703
|
+
content: 'Answer on the first line with exactly "LABEL: relevant".'
|
|
2704
|
+
},
|
|
2705
|
+
{ role: "user", content: "Is this response relevant to this question?" }
|
|
2706
|
+
],
|
|
2707
|
+
temperature: 0,
|
|
2708
|
+
max_tokens: 32
|
|
2709
|
+
});
|
|
2710
|
+
const choices = Array.isArray(response.choices) ? response.choices : [];
|
|
2711
|
+
const first = choices[0];
|
|
2712
|
+
const message = isObject(first) && isObject(first.message) ? first.message : void 0;
|
|
2713
|
+
const content = typeof message?.content === "string" ? message.content : "";
|
|
2714
|
+
const usage = isObject(response.usage) ? response.usage : void 0;
|
|
2715
|
+
const inputTokens = usage?.prompt_tokens;
|
|
2716
|
+
const outputTokens = usage?.completion_tokens;
|
|
2717
|
+
if (!/^\s*LABEL:\s*relevant\s*$/im.test(content)) {
|
|
2718
|
+
throw new Error("Evaluator serving endpoint did not return the requested label contract");
|
|
2719
|
+
}
|
|
2720
|
+
if (!isNonNegativeInteger(inputTokens) || !isNonNegativeInteger(outputTokens)) {
|
|
2721
|
+
throw new Error("Evaluator serving endpoint did not return integer token usage");
|
|
2722
|
+
}
|
|
2723
|
+
return { endpoint: endpoint.name ?? name, inputTokens, outputTokens };
|
|
2724
|
+
}
|
|
2725
|
+
};
|
|
2726
|
+
}
|
|
2681
2727
|
function vectorSearchCheck() {
|
|
2682
2728
|
const names = ["DBX_TEST_VECTOR_ENDPOINT", "DBX_TEST_VECTOR_INDEX"];
|
|
2683
2729
|
return {
|
|
@@ -3224,6 +3270,7 @@ exports.deleteVolumeFile = deleteVolumeFile;
|
|
|
3224
3270
|
exports.deltaContractCheck = deltaContractCheck;
|
|
3225
3271
|
exports.doctorTargetPack = doctorTargetPack;
|
|
3226
3272
|
exports.ensureVolumeDirectory = ensureVolumeDirectory;
|
|
3273
|
+
exports.evalJudgeModelServingCheck = evalJudgeModelServingCheck;
|
|
3227
3274
|
exports.expectQueryToMatchGolden = expectQueryToMatchGolden;
|
|
3228
3275
|
exports.expectTable = expectTable;
|
|
3229
3276
|
exports.failureRecoveryCheck = failureRecoveryCheck;
|