veryfront 0.1.1118 → 0.1.1119
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/esm/deno.js
CHANGED
|
@@ -27,7 +27,7 @@ export declare const metrics: {
|
|
|
27
27
|
pattern: string;
|
|
28
28
|
flags?: string;
|
|
29
29
|
}) => EvalMetric;
|
|
30
|
-
readonly jsonMatch: (options
|
|
30
|
+
readonly jsonMatch: (options?: {
|
|
31
31
|
expected?: unknown;
|
|
32
32
|
}) => EvalMetric;
|
|
33
33
|
readonly groundedness: (options?: EvalAnswerGroundednessMetricOptions) => EvalMetric;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../../src/src/eval/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mCAAmC,EACnC,kCAAkC,EAElC,6BAA6B,EAC7B,mCAAmC,EACnC,UAAU,EAMV,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AA8BpB,KAAK,gBAAgB,GAAG;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE;QACd,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,OAAO,CAAC;QACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChC,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnC,KAAK,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACxE,CAAC;AA2DF,iBAAS,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAQ9C;
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["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AAU;;;sCAgBvD,mCAAmC,KAAG,UAAU;yCAoC7C,mCAAmC,KAAG,UAAU;gCAuCzD,6BAA6B,KAAG,UAAU;+CA0C5B,kCAAkC,KAAQ,UAAU;4CA0CvD,kCAAkC,KAAQ,UAAU;;;oCAuD3D;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,KAAG,UAAU;mCAc/B;YAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;YAAC,SAAS,CAAC,EAAE,MAAM,CAAA;SAAE,KAAG,UAAU;iCAoB3E;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,KAAG,UAAU;;;mCAsB7B,gBAAgB,KAAG,UAAU;;CAmCvC,CAAC;AAEX,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC"}
|
package/esm/src/eval/metrics.js
CHANGED
|
@@ -66,11 +66,25 @@ function getOutputText(output) {
|
|
|
66
66
|
}
|
|
67
67
|
return stableStringify(output);
|
|
68
68
|
}
|
|
69
|
+
const INVALID_JSON_TEXT = Symbol("invalid-json-text");
|
|
69
70
|
function getOutputJson(output) {
|
|
70
|
-
if (output && typeof output === "object"
|
|
71
|
-
|
|
71
|
+
if (output && typeof output === "object") {
|
|
72
|
+
const record = output;
|
|
73
|
+
if (Object.hasOwn(record, "json"))
|
|
74
|
+
return { fromText: false, value: record.json };
|
|
75
|
+
if (Object.hasOwn(record, "text") && typeof record.text === "string") {
|
|
76
|
+
return { fromText: true, value: parseJsonText(record.text) };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return { fromText: false, value: output };
|
|
80
|
+
}
|
|
81
|
+
function parseJsonText(text) {
|
|
82
|
+
try {
|
|
83
|
+
return JSON.parse(text);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return INVALID_JSON_TEXT;
|
|
72
87
|
}
|
|
73
|
-
return output;
|
|
74
88
|
}
|
|
75
89
|
function stableStringify(value) {
|
|
76
90
|
return JSON.stringify(sortJsonValue(value));
|
|
@@ -80,7 +94,7 @@ function sortJsonValue(value) {
|
|
|
80
94
|
return value.map(sortJsonValue);
|
|
81
95
|
if (!value || typeof value !== "object")
|
|
82
96
|
return value;
|
|
83
|
-
const sorted =
|
|
97
|
+
const sorted = Object.create(null);
|
|
84
98
|
for (const key of Object.keys(value).sort()) {
|
|
85
99
|
sorted[key] = sortJsonValue(value[key]);
|
|
86
100
|
}
|
|
@@ -544,11 +558,19 @@ export const metrics = {
|
|
|
544
558
|
return scoreResult("answer.regex", "answer", "gate", pattern.test(getOutputText(record.output)));
|
|
545
559
|
}, options);
|
|
546
560
|
},
|
|
547
|
-
jsonMatch(options) {
|
|
561
|
+
jsonMatch(options = {}) {
|
|
548
562
|
return createMetric("answer.jsonMatch", "answer", (record) => {
|
|
549
|
-
const
|
|
563
|
+
const hasExpectedOption = Object.hasOwn(options, "expected");
|
|
564
|
+
const expectedInput = hasExpectedOption ? options.expected : record.reference;
|
|
550
565
|
const actual = getOutputJson(record.output);
|
|
551
|
-
|
|
566
|
+
let expected = expectedInput;
|
|
567
|
+
if (actual.fromText && !hasExpectedOption && typeof expectedInput === "string") {
|
|
568
|
+
const parsedReference = parseJsonText(expectedInput);
|
|
569
|
+
if (parsedReference !== INVALID_JSON_TEXT)
|
|
570
|
+
expected = parsedReference;
|
|
571
|
+
}
|
|
572
|
+
const pass = actual.value !== INVALID_JSON_TEXT && expected !== INVALID_JSON_TEXT &&
|
|
573
|
+
stableStringify(actual.value) === stableStringify(expected);
|
|
552
574
|
return scoreResult("answer.jsonMatch", "answer", "gate", pass);
|
|
553
575
|
}, options);
|
|
554
576
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "veryfront",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1119",
|
|
4
4
|
"description": "The simplest way to build AI-powered apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -332,10 +332,10 @@
|
|
|
332
332
|
"@types/react": "19.2.14",
|
|
333
333
|
"@types/react-dom": "19.2.3",
|
|
334
334
|
"ws": "8.21.0",
|
|
335
|
-
"@veryfront/ext-bundler-esbuild": "0.1.
|
|
336
|
-
"@veryfront/ext-content-mdx": "0.1.
|
|
337
|
-
"@veryfront/ext-css-tailwind": "0.1.
|
|
338
|
-
"@veryfront/ext-parser-babel": "0.1.
|
|
335
|
+
"@veryfront/ext-bundler-esbuild": "0.1.1119",
|
|
336
|
+
"@veryfront/ext-content-mdx": "0.1.1119",
|
|
337
|
+
"@veryfront/ext-css-tailwind": "0.1.1119",
|
|
338
|
+
"@veryfront/ext-parser-babel": "0.1.1119"
|
|
339
339
|
},
|
|
340
340
|
"devDependencies": {
|
|
341
341
|
"@types/node": "20.9.0"
|