veryfront 0.1.947 → 0.1.949

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
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.947",
3
+ "version": "0.1.949",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "minimumDependencyAge": {
@@ -1 +1 @@
1
- {"version":3,"file":"judges.d.ts","sourceRoot":"","sources":["../../../src/src/eval/judges.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAgB,MAAM,sBAAsB,CAAC;AAGvE,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,YAAY,CAAC;AAEtE,KAAK,iBAAiB,GAAG,WAAW,CAAC,mCAAmC,CAAC,OAAO,CAAC,CAAC,CAAC;AAEnF,uDAAuD;AACvD,MAAM,WAAW,+BAA+B;IAC9C,8FAA8F;IAC9F,KAAK,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IAC9B,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6FAA6F;IAC7F,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sDAAsD;IACtD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gEAAgE;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC3C;AAkLD,iBAAS,0BAA0B,CACjC,OAAO,GAAE,+BAAoC,GAC5C,iBAAiB,CAoBnB;AAED,0DAA0D;AAC1D,eAAO,MAAM,MAAM;;QAEf,6DAA6D;;;CAGvD,CAAC"}
1
+ {"version":3,"file":"judges.d.ts","sourceRoot":"","sources":["../../../src/src/eval/judges.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAgB,MAAM,sBAAsB,CAAC;AAGvE,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,YAAY,CAAC;AAEtE,KAAK,iBAAiB,GAAG,WAAW,CAAC,mCAAmC,CAAC,OAAO,CAAC,CAAC,CAAC;AAEnF,uDAAuD;AACvD,MAAM,WAAW,+BAA+B;IAC9C,8FAA8F;IAC9F,KAAK,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IAC9B,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6FAA6F;IAC7F,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sDAAsD;IACtD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gEAAgE;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC3C;AAoND,iBAAS,0BAA0B,CACjC,OAAO,GAAE,+BAAoC,GAC5C,iBAAiB,CAoBnB;AAED,0DAA0D;AAC1D,eAAO,MAAM,MAAM;;QAEf,6DAA6D;;;CAGvD,CAAC"}
@@ -5,6 +5,8 @@ const DEFAULT_JUDGE_MODEL = "auto";
5
5
  const DEFAULT_THRESHOLD = 0.8;
6
6
  const DEFAULT_MAX_EVIDENCE_CHARS = 12_000;
7
7
  const DEFAULT_MAX_OUTPUT_TOKENS = 800;
8
+ const MAX_SOURCE_CHARS = 2_000;
9
+ const SOURCE_BUDGET_RATIO = 0.25;
8
10
  function asJson(value) {
9
11
  try {
10
12
  return JSON.stringify(value, null, 2);
@@ -24,17 +26,29 @@ function resolveJudgeModel(model) {
24
26
  return resolveModel(resolveRuntimeModel(model ?? DEFAULT_JUDGE_MODEL));
25
27
  }
26
28
  function truncate(value, maxChars) {
29
+ if (maxChars <= 0)
30
+ return "";
27
31
  if (value.length <= maxChars)
28
32
  return value;
29
- return `${value.slice(0, Math.max(0, maxChars - 24))}\n[truncated]`;
33
+ const marker = "\n[truncated]";
34
+ if (maxChars <= marker.length)
35
+ return value.slice(0, maxChars);
36
+ return `${value.slice(0, maxChars - marker.length)}${marker}`;
30
37
  }
31
38
  function buildEvidenceBlock(evidence, sources, maxChars) {
32
39
  const entries = evidence.length > 0 ? evidence : ["No retrieved evidence was provided."];
33
- const block = entries.map((entry, index) => {
34
- const source = sources[index] ?? `evidence-${index + 1}`;
35
- return `[${index + 1}] ${source}\n${entry}`;
36
- }).join("\n\n");
37
- return truncate(block, maxChars);
40
+ const evidenceBlock = entries.map((entry, index) => `[evidence ${index + 1}]\n${entry}`).join("\n\n");
41
+ const sourceBlock = sources.length > 0
42
+ ? sources.map((source, index) => `- [source ${index + 1}] ${source}`).join("\n")
43
+ : "- none";
44
+ const sourceBudget = Math.min(sourceBlock.length, MAX_SOURCE_CHARS, Math.floor(maxChars * SOURCE_BUDGET_RATIO));
45
+ const sectionOverhead = "Evidence snippets:\n\n\nRetrieved sources:\n".length;
46
+ const evidenceBudget = Math.max(0, maxChars - sectionOverhead - sourceBudget);
47
+ return `Evidence snippets:
48
+ ${truncate(evidenceBlock, evidenceBudget)}
49
+
50
+ Retrieved sources:
51
+ ${truncate(sourceBlock, sourceBudget)}`;
38
52
  }
39
53
  function buildGroundednessPrompt(input, options) {
40
54
  return `Evaluate whether an agent answer is grounded in retrieved evidence.
@@ -139,8 +153,22 @@ function parseJudgeResponse(text, threshold) {
139
153
  }
140
154
  try {
141
155
  const parsed = JSON.parse(json);
142
- const score = clampScore(typeof parsed.score === "number" ? parsed.score : 0);
143
- const modelPass = typeof parsed.pass === "boolean" ? parsed.pass : true;
156
+ if (typeof parsed.score !== "number" || !Number.isFinite(parsed.score)) {
157
+ return {
158
+ score: 0,
159
+ pass: false,
160
+ explanation: "LLM judge response did not include a finite numeric score.",
161
+ };
162
+ }
163
+ if (typeof parsed.pass !== "boolean") {
164
+ return {
165
+ score: 0,
166
+ pass: false,
167
+ explanation: "LLM judge response did not include a boolean pass field.",
168
+ };
169
+ }
170
+ const score = clampScore(parsed.score);
171
+ const modelPass = parsed.pass;
144
172
  const unsupportedClaims = stringList(parsed.unsupportedClaims);
145
173
  const missingEvidence = stringList(parsed.missingEvidence);
146
174
  const details = [
@@ -1,3 +1,3 @@
1
1
  /** Shared version value. */
2
- export declare const VERSION = "0.1.947";
2
+ export declare const VERSION = "0.1.949";
3
3
  //# sourceMappingURL=version-constant.d.ts.map
@@ -1,4 +1,4 @@
1
1
  // Keep in sync with deno.json version.
2
2
  // scripts/release.ts updates this constant during releases.
3
3
  /** Shared version value. */
4
- export const VERSION = "0.1.947";
4
+ export const VERSION = "0.1.949";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfront",
3
- "version": "0.1.947",
3
+ "version": "0.1.949",
4
4
  "description": "The simplest way to build AI-powered apps",
5
5
  "keywords": [
6
6
  "react",