@atlanai/sdk 0.3.1 → 0.3.2
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 -1
- package/dist/evals.js +26 -6
- package/dist/tracing/version.d.ts +1 -1
- package/dist/tracing/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -68,7 +68,9 @@ Set `ATLAN_API_KEY` and `ATLAN_WORKSPACE_ID`. Replace inline `data` with
|
|
|
68
68
|
to proceed when tracing is disabled because trace-less eval rows break the
|
|
69
69
|
evidence chain. After flushing, it reads every case trace back through the
|
|
70
70
|
experiment filter before it uploads results; a missing trace marks the
|
|
71
|
-
experiment failed.
|
|
71
|
+
experiment failed. A Registry dataset case passes the value at the dataset's
|
|
72
|
+
`inputKey` (default `question`) to the task and unwraps a single-key
|
|
73
|
+
`{ value: ... }` expected value.
|
|
72
74
|
|
|
73
75
|
## Control an eval lifecycle directly
|
|
74
76
|
|
package/dist/evals.js
CHANGED
|
@@ -725,7 +725,7 @@ async function casesDigest(cases) {
|
|
|
725
725
|
const hash = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(canonicalJson(normalized)));
|
|
726
726
|
return "sha256:" + [...new Uint8Array(hash)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
727
727
|
}
|
|
728
|
-
async function datasetCases(resources, datasetId) {
|
|
728
|
+
async function datasetCases(resources, datasetId, inputKey) {
|
|
729
729
|
const records = [];
|
|
730
730
|
let offset = 0;
|
|
731
731
|
while (true) {
|
|
@@ -749,8 +749,8 @@ async function datasetCases(resources, datasetId) {
|
|
|
749
749
|
}
|
|
750
750
|
records.push({
|
|
751
751
|
id: recordId,
|
|
752
|
-
input:
|
|
753
|
-
expected:
|
|
752
|
+
input: recordInput(item, inputKey),
|
|
753
|
+
expected: recordExpected(item),
|
|
754
754
|
metadata: (rawMetadata ?? {}),
|
|
755
755
|
tags: (rawTags ?? []),
|
|
756
756
|
});
|
|
@@ -765,11 +765,31 @@ async function datasetCases(resources, datasetId) {
|
|
|
765
765
|
}
|
|
766
766
|
return records;
|
|
767
767
|
}
|
|
768
|
+
function datasetInputKey(dataset) {
|
|
769
|
+
const key = field(dataset, "inputKey");
|
|
770
|
+
return typeof key === "string" && key.trim() ? key : "question";
|
|
771
|
+
}
|
|
772
|
+
function recordInput(record, inputKey) {
|
|
773
|
+
const stored = field(record, "input");
|
|
774
|
+
if (!isRecord(stored) || !Object.hasOwn(stored, inputKey)) {
|
|
775
|
+
const found = isRecord(stored) ? Object.keys(stored).sort().join(", ") || "no keys" : "no input object";
|
|
776
|
+
throw new Error(`dataset record ${JSON.stringify(field(record, "id"))} has nothing at ${JSON.stringify(inputKey)}, ` +
|
|
777
|
+
`the dataset's declared inputKey (found: ${found}); fix the record or its inputKey`);
|
|
778
|
+
}
|
|
779
|
+
return stored[inputKey];
|
|
780
|
+
}
|
|
781
|
+
function recordExpected(record) {
|
|
782
|
+
const expected = field(record, "expected");
|
|
783
|
+
return isRecord(expected) && Object.keys(expected).length === 1 && Object.hasOwn(expected, "value")
|
|
784
|
+
? expected.value
|
|
785
|
+
: expected;
|
|
786
|
+
}
|
|
768
787
|
function snapshotCases(experiment) {
|
|
769
788
|
const snapshot = field(experiment, "datasetSnapshot");
|
|
770
789
|
const raw = field(snapshot, "records");
|
|
771
790
|
if (!Array.isArray(raw))
|
|
772
791
|
return undefined;
|
|
792
|
+
const inputKey = datasetInputKey(snapshot);
|
|
773
793
|
return raw.map((record) => {
|
|
774
794
|
const id = field(record, "id");
|
|
775
795
|
if (typeof id !== "string" || id.length === 0) {
|
|
@@ -779,8 +799,8 @@ function snapshotCases(experiment) {
|
|
|
779
799
|
const categories = field(record, "categories");
|
|
780
800
|
return {
|
|
781
801
|
id,
|
|
782
|
-
input:
|
|
783
|
-
expected:
|
|
802
|
+
input: recordInput(record, inputKey),
|
|
803
|
+
expected: recordExpected(record),
|
|
784
804
|
metadata: (isRecord(extra) ? extra : {}),
|
|
785
805
|
tags: (Array.isArray(categories) ? categories : []),
|
|
786
806
|
};
|
|
@@ -1405,7 +1425,7 @@ async function Eval(name, evaluator, options = {}) {
|
|
|
1405
1425
|
}
|
|
1406
1426
|
cases =
|
|
1407
1427
|
snapshot ??
|
|
1408
|
-
(await datasetCases(resources, String(field(run.dataset, "id"))));
|
|
1428
|
+
(await datasetCases(resources, String(field(run.dataset, "id")), datasetInputKey(run.dataset)));
|
|
1409
1429
|
}
|
|
1410
1430
|
if (evaluator.dataset !== undefined && cases.length === 0) {
|
|
1411
1431
|
// A named dataset that yields nothing is a mistake upstream, not an eval
|
package/dist/tracing/version.js
CHANGED
|
@@ -4,4 +4,4 @@ exports.SDK_VERSION = exports.SDK_LANGUAGE = void 0;
|
|
|
4
4
|
/** SDK identity (SPEC §2.2, §5.1). Kept in sync with package.json — the
|
|
5
5
|
* version test fails the build on drift. */
|
|
6
6
|
exports.SDK_LANGUAGE = "typescript";
|
|
7
|
-
exports.SDK_VERSION = "0.3.
|
|
7
|
+
exports.SDK_VERSION = "0.3.2";
|