@mastra/evals 0.13.8-alpha.1 → 0.13.8-alpha.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/scorers/code/completeness/index.d.ts +1 -2
  3. package/dist/scorers/code/completeness/index.d.ts.map +1 -1
  4. package/dist/scorers/code/content-similarity/index.d.ts +1 -2
  5. package/dist/scorers/code/content-similarity/index.d.ts.map +1 -1
  6. package/dist/scorers/code/index.cjs +18 -12
  7. package/dist/scorers/code/index.cjs.map +1 -1
  8. package/dist/scorers/code/index.js +18 -12
  9. package/dist/scorers/code/index.js.map +1 -1
  10. package/dist/scorers/code/keyword-coverage/index.d.ts +1 -2
  11. package/dist/scorers/code/keyword-coverage/index.d.ts.map +1 -1
  12. package/dist/scorers/code/textual-difference/index.d.ts +1 -2
  13. package/dist/scorers/code/textual-difference/index.d.ts.map +1 -1
  14. package/dist/scorers/code/tone/index.d.ts +1 -2
  15. package/dist/scorers/code/tone/index.d.ts.map +1 -1
  16. package/dist/scorers/code/tool-call-accuracy/index.d.ts +1 -2
  17. package/dist/scorers/code/tool-call-accuracy/index.d.ts.map +1 -1
  18. package/dist/scorers/llm/answer-relevancy/index.d.ts +1 -2
  19. package/dist/scorers/llm/answer-relevancy/index.d.ts.map +1 -1
  20. package/dist/scorers/llm/answer-similarity/index.d.ts +1 -2
  21. package/dist/scorers/llm/answer-similarity/index.d.ts.map +1 -1
  22. package/dist/scorers/llm/bias/index.d.ts.map +1 -1
  23. package/dist/scorers/llm/context-precision/index.d.ts +1 -1
  24. package/dist/scorers/llm/context-precision/index.d.ts.map +1 -1
  25. package/dist/scorers/llm/context-relevance/index.d.ts +1 -1
  26. package/dist/scorers/llm/context-relevance/index.d.ts.map +1 -1
  27. package/dist/scorers/llm/faithfulness/index.d.ts +1 -2
  28. package/dist/scorers/llm/faithfulness/index.d.ts.map +1 -1
  29. package/dist/scorers/llm/hallucination/index.d.ts +1 -2
  30. package/dist/scorers/llm/hallucination/index.d.ts.map +1 -1
  31. package/dist/scorers/llm/index.cjs +20 -10
  32. package/dist/scorers/llm/index.cjs.map +1 -1
  33. package/dist/scorers/llm/index.js +20 -10
  34. package/dist/scorers/llm/index.js.map +1 -1
  35. package/dist/scorers/llm/noise-sensitivity/index.d.ts +1 -2
  36. package/dist/scorers/llm/noise-sensitivity/index.d.ts.map +1 -1
  37. package/dist/scorers/llm/tool-call-accuracy/index.d.ts +1 -2
  38. package/dist/scorers/llm/tool-call-accuracy/index.d.ts.map +1 -1
  39. package/dist/scorers/llm/toxicity/index.d.ts +1 -2
  40. package/dist/scorers/llm/toxicity/index.d.ts.map +1 -1
  41. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @mastra/evals
2
2
 
3
+ ## 0.13.8-alpha.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Add explicit type 'agent' for built in scorers ([#8132](https://github.com/mastra-ai/mastra/pull/8132))
8
+
3
9
  ## 0.13.8-alpha.1
4
10
 
5
11
  ### Patch Changes
@@ -1,5 +1,4 @@
1
- import type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/scores';
2
- export declare function createCompletenessScorer(): import("@mastra/core/scores").MastraScorer<string, ScorerRunInputForAgent, ScorerRunOutputForAgent, Record<"preprocessStepResult", {
1
+ export declare function createCompletenessScorer(): import("@mastra/core/scores").MastraScorer<"Completeness Scorer", import("@mastra/core/scores").ScorerRunInputForAgent, import("@mastra/core/scores").ScorerRunOutputForAgent, Record<"preprocessStepResult", {
3
2
  inputElements: string[];
4
3
  outputElements: string[];
5
4
  missingElements: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/code/completeness/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AA0E3F,wBAAgB,wBAAwB;;;;;;;;gDAkDvC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/code/completeness/index.ts"],"names":[],"mappings":"AA0EA,wBAAgB,wBAAwB;;;;;;;;gDAmDvC"}
@@ -1,9 +1,8 @@
1
- import type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/scores';
2
1
  interface ContentSimilarityOptions {
3
2
  ignoreCase?: boolean;
4
3
  ignoreWhitespace?: boolean;
5
4
  }
6
- export declare function createContentSimilarityScorer({ ignoreCase, ignoreWhitespace }?: ContentSimilarityOptions): import("@mastra/core/scores").MastraScorer<string, ScorerRunInputForAgent, ScorerRunOutputForAgent, Record<"preprocessStepResult", {
5
+ export declare function createContentSimilarityScorer({ ignoreCase, ignoreWhitespace }?: ContentSimilarityOptions): import("@mastra/core/scores").MastraScorer<"Content Similarity Scorer", import("@mastra/core/scores").ScorerRunInputForAgent, import("@mastra/core/scores").ScorerRunOutputForAgent, Record<"preprocessStepResult", {
7
6
  processedInput: string;
8
7
  processedOutput: string;
9
8
  }> & Record<"generateScoreStepResult", number>>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/code/content-similarity/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAG3F,UAAU,wBAAwB;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,wBAAgB,6BAA6B,CAC3C,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAE,wBAAuE;;;gDAkC1G"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/code/content-similarity/index.ts"],"names":[],"mappings":"AAGA,UAAU,wBAAwB;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,wBAAgB,6BAA6B,CAC3C,EAAE,UAAU,EAAE,gBAAgB,EAAE,GAAE,wBAAuE;;;gDAkC1G"}
@@ -58,8 +58,9 @@ function calculateCoverage({ original, simplified }) {
58
58
  }
59
59
  function createCompletenessScorer() {
60
60
  return scores.createScorer({
61
- name: "Completeness",
62
- description: 'Leverage the nlp method from "compromise" to extract elements from the input and output and calculate the coverage.'
61
+ name: "Completeness Scorer",
62
+ description: 'Leverage the nlp method from "compromise" to extract elements from the input and output and calculate the coverage.',
63
+ type: "agent"
63
64
  }).preprocess(async ({ run }) => {
64
65
  const isInputInvalid = !run.input || run.input.inputMessages.some((i) => i.content === null || i.content === void 0);
65
66
  const isOutputInvalid = !run.output || run.output.some((i) => i.content === null || i.content === void 0);
@@ -94,8 +95,9 @@ function createCompletenessScorer() {
94
95
  }
95
96
  function createTextualDifferenceScorer() {
96
97
  return scores.createScorer({
97
- name: "Completeness",
98
- description: 'Leverage the nlp method from "compromise" to extract elements from the input and output and calculate the coverage.'
98
+ name: "Textual Difference Scorer",
99
+ description: "Calculate textual difference between input and output using sequence matching algorithms.",
100
+ type: "agent"
99
101
  }).preprocess(async ({ run }) => {
100
102
  const input = run.input?.inputMessages?.map((i) => i.content).join(", ") || "";
101
103
  const output = run.output?.map((i) => i.content).join(", ") || "";
@@ -118,8 +120,9 @@ function createTextualDifferenceScorer() {
118
120
  }
119
121
  function createKeywordCoverageScorer() {
120
122
  return scores.createScorer({
121
- name: "Completeness",
122
- description: 'Leverage the nlp method from "compromise" to extract elements from the input and output and calculate the coverage.'
123
+ name: "Keyword Coverage Scorer",
124
+ description: 'Leverage the nlp method from "compromise" to extract elements from the input and output and calculate the coverage.',
125
+ type: "agent"
123
126
  }).preprocess(async ({ run }) => {
124
127
  const input = run.input?.inputMessages?.map((i) => i.content).join(", ") || "";
125
128
  const output = run.output?.map((i) => i.content).join(", ") || "";
@@ -170,8 +173,9 @@ function createKeywordCoverageScorer() {
170
173
  }
171
174
  function createContentSimilarityScorer({ ignoreCase, ignoreWhitespace } = { ignoreCase: true, ignoreWhitespace: true }) {
172
175
  return scores.createScorer({
173
- name: "Completeness",
174
- description: 'Leverage the nlp method from "compromise" to extract elements from the input and output and calculate the coverage.'
176
+ name: "Content Similarity Scorer",
177
+ description: "Calculates content similarity between input and output messages using string comparison algorithms.",
178
+ type: "agent"
175
179
  }).preprocess(async ({ run }) => {
176
180
  let processedInput = run.input?.inputMessages.map((i) => i.content).join(", ") || "";
177
181
  let processedOutput = run.output.map((i) => i.content).join(", ") || "";
@@ -198,8 +202,9 @@ function createContentSimilarityScorer({ ignoreCase, ignoreWhitespace } = { igno
198
202
  function createToneScorer(config = {}) {
199
203
  const { referenceTone } = config;
200
204
  return scores.createScorer({
201
- name: "Completeness",
202
- description: 'Leverage the nlp method from "compromise" to extract elements from the input and output and calculate the coverage.'
205
+ name: "Tone Scorer",
206
+ description: "Analyzes the tone and sentiment of agent responses using sentiment analysis. Can compare against a reference tone or evaluate sentiment stability.",
207
+ type: "agent"
203
208
  }).preprocess(async ({ run }) => {
204
209
  const sentiment = new Sentiment__default.default();
205
210
  const agentMessage = run.output?.map((i) => i.content).join(", ") || "";
@@ -279,8 +284,9 @@ function createToolCallAccuracyScorerCode(options) {
279
284
  return expectedToolOrder ? `Evaluates whether the LLM called tools in the correct order: [${expectedToolOrder.join(", ")}]` : `Evaluates whether the LLM selected the correct tool (${expectedTool}) from the available tools`;
280
285
  };
281
286
  return scores.createScorer({
282
- name: "Tool Call Accuracy",
283
- description: getDescription()
287
+ name: "Tool Call Accuracy Scorer",
288
+ description: getDescription(),
289
+ type: "agent"
284
290
  }).preprocess(async ({ run }) => {
285
291
  const isInputInvalid = !run.input || !run.input.inputMessages || run.input.inputMessages.length === 0;
286
292
  const isOutputInvalid = !run.output || run.output.length === 0;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/scorers/code/completeness/index.ts","../../../src/scorers/code/textual-difference/index.ts","../../../src/scorers/code/keyword-coverage/index.ts","../../../src/scorers/code/content-similarity/index.ts","../../../src/scorers/code/tone/index.ts","../../../src/scorers/code/tool-call-accuracy/index.ts"],"names":["createScorer","nlp","SequenceMatcher","keyword_extractor","stringSimilarity","Sentiment","extractToolCalls"],"mappings":";;;;;;;;;;;;;;;;;AAIA,SAAS,gBAAgB,GAAA,EAAqB;AAE5C,EAAA,OAAO,GAAA,CACJ,UAAU,KAAK,CAAA,CACf,QAAQ,kBAAA,EAAoB,EAAE,EAC9B,WAAA,EAAY;AACjB;AAEA,SAAS,gBAAgB,GAAA,EAAoB;AAE3C,EAAA,MAAM,QAAQ,GAAA,CAAI,KAAA,GAAQ,GAAA,CAAI,OAAO,KAAK,EAAC;AAC3C,EAAA,MAAM,KAAA,GAAQ,IAAI,KAAA,EAAM,CAAE,cAAa,CAAE,GAAA,CAAI,OAAO,CAAA,IAAK,EAAC;AAC1D,EAAA,MAAM,SAAS,GAAA,CAAI,MAAA,GAAS,GAAA,CAAI,OAAO,KAAK,EAAC;AAC7C,EAAA,MAAM,QAAQ,GAAA,CAAI,KAAA,GAAQ,GAAA,CAAI,OAAO,KAAK,EAAC;AAG3C,EAAA,MAAM,iBAAA,GAAoB,CAAC,IAAA,KAA2B;AAEpD,IAAA,MAAM,UAAA,GAAa,gBAAgB,IAAI,CAAA;AAGvC,IAAA,OAAO,WACJ,OAAA,CAAQ,iBAAA,EAAmB,OAAO,CAAA,CAClC,OAAA,CAAQ,eAAe,GAAG,CAAA,CAC1B,IAAA,EAAK,CACL,MAAM,KAAK,CAAA,CACX,OAAO,CAAA,IAAA,KAAQ,IAAA,CAAK,SAAS,CAAC,CAAA;AAAA,EACnC,CAAA;AAGA,EAAA,MAAM,cAAA,GAAiB;AAAA,IACrB,GAAG,KAAA,CAAM,OAAA,CAAQ,iBAAiB,CAAA;AAAA,IAClC,GAAG,KAAA,CAAM,OAAA,CAAQ,iBAAiB,CAAA;AAAA,IAClC,GAAG,MAAA,CAAO,OAAA,CAAQ,iBAAiB,CAAA;AAAA,IACn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A;AAAA,MACA,iBAAA;AAAA,MACA,YAAA,EAAc,YAAY,MAAA,GAAS,CAAA;AAAA,MACnC,iBAAA;AAAA,MACA,aAAA;AAAA,MACA,oBAAoB,iBAAA,GAAoB,cAAA,CAAe,WAAA,EAAa,iBAAA,EAAmB,UAAU,CAAA,GAAI;AAAA,KACvG;AAAA,EACF,CAAC,CAAA,CACA,aAAA,CAAc,CAAC,EAAE,SAAQ,KAAM;AAC9B,IAAA,MAAM,mBAAmB,OAAA,CAAQ,oBAAA;AACjC,IAAA,IAAI,CAAC,gBAAA,EAAkB;AACrB,MAAA,OAAO,CAAA;AAAA,IACT;AAEA,IAAA,OAAO,iBAAA,CAAkB;AAAA,MACvB,cAAc,gBAAA,CAAiB,YAAA;AAAA,MAC/B,aAAa,gBAAA,CAAiB,WAAA;AAAA,MAC9B,YAAY,gBAAA,CAAiB,UAAA;AAAA,MAC7B,mBAAmB,gBAAA,CAAiB;AAAA,KACrC,CAAA;AAAA,EACH,CAAC,CAAA;AACL","file":"index.cjs","sourcesContent":["import { createScorer } from '@mastra/core/scores';\nimport type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/scores';\nimport nlp from 'compromise';\n\nfunction normalizeString(str: string): string {\n // Remove diacritics and convert to lowercase\n return str\n .normalize('NFD')\n .replace(/[\\u0300-\\u036f]/g, '')\n .toLowerCase();\n}\n\nfunction extractElements(doc: any): string[] {\n // Get more specific elements and ensure they're arrays\n const nouns = doc.nouns().out('array') || [];\n const verbs = doc.verbs().toInfinitive().out('array') || [];\n const topics = doc.topics().out('array') || [];\n const terms = doc.terms().out('array') || [];\n\n // Helper function to clean and split terms\n const cleanAndSplitTerm = (term: string): string[] => {\n // First normalize the string\n const normalized = normalizeString(term);\n\n // Split on word boundaries and filter out empty strings\n return normalized\n .replace(/([a-z])([A-Z])/g, '$1 $2') // Split camelCase\n .replace(/[^a-z0-9]+/g, ' ') // Replace non-alphanumeric with spaces\n .trim()\n .split(/\\s+/)\n .filter(word => word.length > 0);\n };\n\n // Process all elements\n const processedTerms = [\n ...nouns.flatMap(cleanAndSplitTerm),\n ...verbs.flatMap(cleanAndSplitTerm),\n ...topics.flatMap(cleanAndSplitTerm),\n ...terms.flatMap(cleanAndSplitTerm),\n ];\n\n // Remove duplicates\n return [...new Set(processedTerms)];\n}\n\nfunction calculateCoverage({ original, simplified }: { original: string[]; simplified: string[] }): number {\n if (original.length === 0) {\n return simplified.length === 0 ? 1 : 0;\n }\n\n // Exact matching for short words (3 chars or less), substring matching for longer words\n const covered = original.filter(element =>\n simplified.some(s => {\n const elem = normalizeString(element);\n const simp = normalizeString(s);\n\n // For short words (3 chars or less), require exact match\n if (elem.length <= 3) {\n return elem === simp;\n }\n\n // For longer words, require substantial overlap (more than 60% of the longer word)\n const longer = elem.length > simp.length ? elem : simp;\n const shorter = elem.length > simp.length ? simp : elem;\n\n if (longer.includes(shorter)) {\n return shorter.length / longer.length > 0.6;\n }\n\n return false;\n }),\n );\n return covered.length / original.length;\n}\n\nexport function createCompletenessScorer() {\n return createScorer<ScorerRunInputForAgent, ScorerRunOutputForAgent>({\n name: 'Completeness',\n description:\n 'Leverage the nlp method from \"compromise\" to extract elements from the input and output and calculate the coverage.',\n })\n .preprocess(async ({ run }) => {\n const isInputInvalid =\n !run.input ||\n run.input.inputMessages.some((i: { content: string }) => i.content === null || i.content === undefined);\n\n const isOutputInvalid =\n !run.output || run.output.some((i: { content: string }) => i.content === null || i.content === undefined);\n\n if (isInputInvalid || isOutputInvalid) {\n throw new Error('Inputs cannot be null or undefined');\n }\n\n const input = run.input?.inputMessages.map((i: { content: string }) => i.content).join(', ') || '';\n const output = run.output?.map(({ content }: { content: string }) => content).join(', ') || '';\n\n const inputToProcess = input;\n const outputToProcess = output;\n\n const inputDoc = nlp(inputToProcess.trim());\n const outputDoc = nlp(outputToProcess.trim());\n\n // Extract and log elements\n const inputElements = extractElements(inputDoc);\n const outputElements = extractElements(outputDoc);\n\n return {\n inputElements,\n outputElements,\n missingElements: inputElements.filter(e => !outputElements.includes(e)),\n elementCounts: {\n input: inputElements.length,\n output: outputElements.length,\n },\n };\n })\n .generateScore(({ results }) => {\n const inputElements = results.preprocessStepResult?.inputElements;\n const outputElements = results.preprocessStepResult?.outputElements;\n\n return calculateCoverage({\n original: inputElements,\n simplified: outputElements,\n });\n });\n}\n","import { createScorer } from '@mastra/core/scores';\nimport type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/scores';\nimport { SequenceMatcher } from 'difflib';\n\nexport function createTextualDifferenceScorer() {\n return createScorer<ScorerRunInputForAgent, ScorerRunOutputForAgent>({\n name: 'Completeness',\n description:\n 'Leverage the nlp method from \"compromise\" to extract elements from the input and output and calculate the coverage.',\n })\n .preprocess(async ({ run }) => {\n const input = run.input?.inputMessages?.map((i: { content: string }) => i.content).join(', ') || '';\n const output = run.output?.map((i: { content: string }) => i.content).join(', ') || '';\n const matcher = new SequenceMatcher(null, input, output);\n const ratio = matcher.ratio();\n\n // Get detailed operations\n const ops = matcher.getOpcodes();\n const changes = ops.filter(([op]) => op !== 'equal').length;\n\n // Calculate confidence based on text length difference\n const maxLength = Math.max(input.length, output.length);\n const lengthDiff = maxLength > 0 ? Math.abs(input.length - output.length) / maxLength : 0;\n const confidence = 1 - lengthDiff;\n\n return {\n ratio,\n confidence,\n changes,\n lengthDiff,\n };\n })\n .generateScore(({ results }) => {\n return results.preprocessStepResult?.ratio;\n });\n}\n","import { createScorer } from '@mastra/core/scores';\nimport type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/scores';\nimport keyword_extractor from 'keyword-extractor';\n\nexport function createKeywordCoverageScorer() {\n return createScorer<ScorerRunInputForAgent, ScorerRunOutputForAgent>({\n name: 'Completeness',\n description:\n 'Leverage the nlp method from \"compromise\" to extract elements from the input and output and calculate the coverage.',\n })\n .preprocess(async ({ run }) => {\n const input = run.input?.inputMessages?.map((i: { content: string }) => i.content).join(', ') || '';\n const output = run.output?.map((i: { content: string }) => i.content).join(', ') || '';\n\n if (!input && !output) {\n return {\n result: {\n referenceKeywords: new Set<string>(),\n responseKeywords: new Set<string>(),\n },\n };\n }\n\n const extractKeywords = (text: string) => {\n return keyword_extractor.extract(text, {\n language: 'english',\n remove_digits: true,\n return_changed_case: true,\n remove_duplicates: true,\n });\n };\n\n const referenceKeywords = new Set(extractKeywords(input));\n const responseKeywords = new Set(extractKeywords(output));\n return {\n referenceKeywords,\n responseKeywords,\n };\n })\n .analyze(async ({ results }) => {\n if (\n !results.preprocessStepResult?.referenceKeywords?.size &&\n !results.preprocessStepResult?.responseKeywords?.size\n ) {\n return {\n totalKeywordsLength: 0,\n matchedKeywordsLength: 0,\n };\n }\n\n const matchedKeywords = [...results.preprocessStepResult?.referenceKeywords].filter(k =>\n results.preprocessStepResult?.responseKeywords?.has(k),\n );\n\n return {\n totalKeywordsLength: Array.from(results.preprocessStepResult?.referenceKeywords).length ?? 0,\n matchedKeywordsLength: matchedKeywords.length ?? 0,\n };\n })\n .generateScore(({ results }) => {\n if (!results.analyzeStepResult?.totalKeywordsLength) {\n return 1;\n }\n\n const totalKeywords = results.analyzeStepResult?.totalKeywordsLength!;\n const matchedKeywords = results.analyzeStepResult?.matchedKeywordsLength!;\n return totalKeywords > 0 ? matchedKeywords / totalKeywords : 0;\n });\n}\n","import { createScorer } from '@mastra/core/scores';\nimport type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/scores';\nimport stringSimilarity from 'string-similarity';\n\ninterface ContentSimilarityOptions {\n ignoreCase?: boolean;\n ignoreWhitespace?: boolean;\n}\n\nexport function createContentSimilarityScorer(\n { ignoreCase, ignoreWhitespace }: ContentSimilarityOptions = { ignoreCase: true, ignoreWhitespace: true },\n) {\n return createScorer<ScorerRunInputForAgent, ScorerRunOutputForAgent>({\n name: 'Completeness',\n description:\n 'Leverage the nlp method from \"compromise\" to extract elements from the input and output and calculate the coverage.',\n })\n .preprocess(async ({ run }) => {\n let processedInput = run.input?.inputMessages.map((i: { content: string }) => i.content).join(', ') || '';\n let processedOutput = run.output.map((i: { content: string }) => i.content).join(', ') || '';\n\n if (ignoreCase) {\n processedInput = processedInput.toLowerCase();\n processedOutput = processedOutput.toLowerCase();\n }\n\n if (ignoreWhitespace) {\n processedInput = processedInput.replace(/\\s+/g, ' ').trim();\n processedOutput = processedOutput.replace(/\\s+/g, ' ').trim();\n }\n\n return {\n processedInput,\n processedOutput,\n };\n })\n .generateScore(({ results }) => {\n const similarity = stringSimilarity.compareTwoStrings(\n results.preprocessStepResult?.processedInput,\n results.preprocessStepResult?.processedOutput,\n );\n\n return similarity;\n });\n}\n","import { createScorer } from '@mastra/core/scores';\nimport type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/scores';\nimport Sentiment from 'sentiment';\n\ninterface ToneScorerConfig {\n referenceTone?: string;\n}\n\nexport function createToneScorer(config: ToneScorerConfig = {}) {\n const { referenceTone } = config;\n\n return createScorer<ScorerRunInputForAgent, ScorerRunOutputForAgent>({\n name: 'Completeness',\n description:\n 'Leverage the nlp method from \"compromise\" to extract elements from the input and output and calculate the coverage.',\n })\n .preprocess(async ({ run }) => {\n const sentiment = new Sentiment();\n const agentMessage: string = run.output?.map((i: { content: string }) => i.content).join(', ') || '';\n const responseSentiment = sentiment.analyze(agentMessage);\n\n if (referenceTone) {\n // Compare sentiment with reference\n const referenceSentiment = sentiment.analyze(referenceTone);\n const sentimentDiff = Math.abs(responseSentiment.comparative - referenceSentiment.comparative);\n const normalizedScore = Math.max(0, 1 - sentimentDiff);\n\n return {\n score: normalizedScore,\n responseSentiment: responseSentiment.comparative,\n referenceSentiment: referenceSentiment.comparative,\n difference: sentimentDiff,\n };\n }\n\n // Evaluate sentiment stability across response\n const sentences = agentMessage.match(/[^.!?]+[.!?]+/g) || [agentMessage];\n const sentiments = sentences.map(s => sentiment.analyze(s).comparative);\n const avgSentiment = sentiments.reduce((a, b) => a + b, 0) / sentiments.length;\n const variance = sentiments.reduce((sum, s) => sum + Math.pow(s - avgSentiment, 2), 0) / sentiments.length;\n const stability = Math.max(0, 1 - variance);\n\n return {\n score: stability,\n avgSentiment,\n sentimentVariance: variance,\n };\n })\n .generateScore(({ results }) => {\n return results.preprocessStepResult?.score;\n });\n}\n","import type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/scores';\nimport { createScorer } from '@mastra/core/scores';\nimport { extractToolCalls } from '../../utils';\n\ninterface ToolCallAccuracyOptions {\n expectedTool?: string;\n strictMode?: boolean;\n expectedToolOrder?: string[];\n}\n\nfunction checkToolOrder(actualTools: string[], expectedOrder: string[], strictMode: boolean = false): boolean {\n if (strictMode) {\n return JSON.stringify(actualTools) === JSON.stringify(expectedOrder);\n }\n\n const expectedIndices: number[] = [];\n for (const expectedTool of expectedOrder) {\n const index = actualTools.indexOf(expectedTool);\n if (index === -1) {\n return false;\n }\n expectedIndices.push(index);\n }\n\n for (let i = 1; i < expectedIndices.length; i++) {\n const currentIndex = expectedIndices[i];\n const prevIndex = expectedIndices[i - 1];\n if (currentIndex !== undefined && prevIndex !== undefined && currentIndex <= prevIndex) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction calculateAccuracy({\n expectedTool,\n actualTools,\n strictMode = false,\n expectedToolOrder,\n}: {\n expectedTool?: string;\n actualTools: string[];\n strictMode?: boolean;\n expectedToolOrder?: string[];\n}): number {\n if (actualTools.length === 0) {\n return 0;\n }\n\n if (expectedToolOrder && expectedToolOrder.length > 0) {\n return checkToolOrder(actualTools, expectedToolOrder, strictMode) ? 1 : 0;\n }\n\n if (!expectedTool) {\n return 0;\n }\n\n if (strictMode) {\n return actualTools.length === 1 && actualTools[0] === expectedTool ? 1 : 0;\n }\n\n return actualTools.includes(expectedTool) ? 1 : 0;\n}\n\nexport function createToolCallAccuracyScorerCode(options: ToolCallAccuracyOptions) {\n const { expectedTool, strictMode = false, expectedToolOrder } = options;\n\n if (!expectedTool && !expectedToolOrder) {\n throw new Error('Either expectedTool or expectedToolOrder must be provided');\n }\n\n const getDescription = () => {\n return expectedToolOrder\n ? `Evaluates whether the LLM called tools in the correct order: [${expectedToolOrder.join(', ')}]`\n : `Evaluates whether the LLM selected the correct tool (${expectedTool}) from the available tools`;\n };\n\n return createScorer<ScorerRunInputForAgent, ScorerRunOutputForAgent>({\n name: 'Tool Call Accuracy',\n description: getDescription(),\n })\n .preprocess(async ({ run }) => {\n const isInputInvalid = !run.input || !run.input.inputMessages || run.input.inputMessages.length === 0;\n const isOutputInvalid = !run.output || run.output.length === 0;\n\n if (isInputInvalid || isOutputInvalid) {\n throw new Error('Input and output messages cannot be null or empty');\n }\n\n const { tools: actualTools, toolCallInfos } = extractToolCalls(run.output);\n\n const correctToolCalled = expectedTool\n ? strictMode\n ? actualTools.length === 1 && actualTools[0] === expectedTool\n : actualTools.includes(expectedTool)\n : false;\n\n return {\n expectedTool,\n actualTools,\n strictMode,\n expectedToolOrder,\n hasToolCalls: actualTools.length > 0,\n correctToolCalled,\n toolCallInfos,\n correctOrderCalled: expectedToolOrder ? checkToolOrder(actualTools, expectedToolOrder, strictMode) : null,\n };\n })\n .generateScore(({ results }) => {\n const preprocessResult = results.preprocessStepResult;\n if (!preprocessResult) {\n return 0;\n }\n\n return calculateAccuracy({\n expectedTool: preprocessResult.expectedTool,\n actualTools: preprocessResult.actualTools,\n strictMode: preprocessResult.strictMode,\n expectedToolOrder: preprocessResult.expectedToolOrder,\n });\n });\n}\n"]}
1
+ {"version":3,"sources":["../../../src/scorers/code/completeness/index.ts","../../../src/scorers/code/textual-difference/index.ts","../../../src/scorers/code/keyword-coverage/index.ts","../../../src/scorers/code/content-similarity/index.ts","../../../src/scorers/code/tone/index.ts","../../../src/scorers/code/tool-call-accuracy/index.ts"],"names":["createScorer","nlp","SequenceMatcher","keyword_extractor","stringSimilarity","Sentiment","extractToolCalls"],"mappings":";;;;;;;;;;;;;;;;;AAGA,SAAS,gBAAgB,GAAA,EAAqB;AAE5C,EAAA,OAAO,GAAA,CACJ,UAAU,KAAK,CAAA,CACf,QAAQ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AA;AAAA,MACA,aAAA;AAAA,MACA,oBAAoB,iBAAA,GAAoB,cAAA,CAAe,WAAA,EAAa,iBAAA,EAAmB,UAAU,CAAA,GAAI;AAAA,KACvG;AAAA,EACF,CAAC,CAAA,CACA,aAAA,CAAc,CAAC,EAAE,SAAQ,KAAM;AAC9B,IAAA,MAAM,mBAAmB,OAAA,CAAQ,oBAAA;AACjC,IAAA,IAAI,CAAC,gBAAA,EAAkB;AACrB,MAAA,OAAO,CAAA;AAAA,IACT;AAEA,IAAA,OAAO,iBAAA,CAAkB;AAAA,MACvB,cAAc,gBAAA,CAAiB,YAAA;AAAA,MAC/B,aAAa,gBAAA,CAAiB,WAAA;AAAA,MAC9B,YAAY,gBAAA,CAAiB,UAAA;AAAA,MAC7B,mBAAmB,gBAAA,CAAiB;AAAA,KACrC,CAAA;AAAA,EACH,CAAC,CAAA;AACL","file":"index.cjs","sourcesContent":["import { createScorer } from '@mastra/core/scores';\nimport nlp from 'compromise';\n\nfunction normalizeString(str: string): string {\n // Remove diacritics and convert to lowercase\n return str\n .normalize('NFD')\n .replace(/[\\u0300-\\u036f]/g, '')\n .toLowerCase();\n}\n\nfunction extractElements(doc: any): string[] {\n // Get more specific elements and ensure they're arrays\n const nouns = doc.nouns().out('array') || [];\n const verbs = doc.verbs().toInfinitive().out('array') || [];\n const topics = doc.topics().out('array') || [];\n const terms = doc.terms().out('array') || [];\n\n // Helper function to clean and split terms\n const cleanAndSplitTerm = (term: string): string[] => {\n // First normalize the string\n const normalized = normalizeString(term);\n\n // Split on word boundaries and filter out empty strings\n return normalized\n .replace(/([a-z])([A-Z])/g, '$1 $2') // Split camelCase\n .replace(/[^a-z0-9]+/g, ' ') // Replace non-alphanumeric with spaces\n .trim()\n .split(/\\s+/)\n .filter(word => word.length > 0);\n };\n\n // Process all elements\n const processedTerms = [\n ...nouns.flatMap(cleanAndSplitTerm),\n ...verbs.flatMap(cleanAndSplitTerm),\n ...topics.flatMap(cleanAndSplitTerm),\n ...terms.flatMap(cleanAndSplitTerm),\n ];\n\n // Remove duplicates\n return [...new Set(processedTerms)];\n}\n\nfunction calculateCoverage({ original, simplified }: { original: string[]; simplified: string[] }): number {\n if (original.length === 0) {\n return simplified.length === 0 ? 1 : 0;\n }\n\n // Exact matching for short words (3 chars or less), substring matching for longer words\n const covered = original.filter(element =>\n simplified.some(s => {\n const elem = normalizeString(element);\n const simp = normalizeString(s);\n\n // For short words (3 chars or less), require exact match\n if (elem.length <= 3) {\n return elem === simp;\n }\n\n // For longer words, require substantial overlap (more than 60% of the longer word)\n const longer = elem.length > simp.length ? elem : simp;\n const shorter = elem.length > simp.length ? simp : elem;\n\n if (longer.includes(shorter)) {\n return shorter.length / longer.length > 0.6;\n }\n\n return false;\n }),\n );\n return covered.length / original.length;\n}\n\nexport function createCompletenessScorer() {\n return createScorer({\n name: 'Completeness Scorer',\n description:\n 'Leverage the nlp method from \"compromise\" to extract elements from the input and output and calculate the coverage.',\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n const isInputInvalid =\n !run.input ||\n run.input.inputMessages.some((i: { content: string }) => i.content === null || i.content === undefined);\n\n const isOutputInvalid =\n !run.output || run.output.some((i: { content: string }) => i.content === null || i.content === undefined);\n\n if (isInputInvalid || isOutputInvalid) {\n throw new Error('Inputs cannot be null or undefined');\n }\n\n const input = run.input?.inputMessages.map((i: { content: string }) => i.content).join(', ') || '';\n const output = run.output?.map(({ content }: { content: string }) => content).join(', ') || '';\n\n const inputToProcess = input;\n const outputToProcess = output;\n\n const inputDoc = nlp(inputToProcess.trim());\n const outputDoc = nlp(outputToProcess.trim());\n\n // Extract and log elements\n const inputElements = extractElements(inputDoc);\n const outputElements = extractElements(outputDoc);\n\n return {\n inputElements,\n outputElements,\n missingElements: inputElements.filter(e => !outputElements.includes(e)),\n elementCounts: {\n input: inputElements.length,\n output: outputElements.length,\n },\n };\n })\n .generateScore(({ results }) => {\n const inputElements = results.preprocessStepResult?.inputElements;\n const outputElements = results.preprocessStepResult?.outputElements;\n\n return calculateCoverage({\n original: inputElements,\n simplified: outputElements,\n });\n });\n}\n","import { createScorer } from '@mastra/core/scores';\nimport { SequenceMatcher } from 'difflib';\n\nexport function createTextualDifferenceScorer() {\n return createScorer({\n name: 'Textual Difference Scorer',\n description: 'Calculate textual difference between input and output using sequence matching algorithms.',\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n const input = run.input?.inputMessages?.map((i: { content: string }) => i.content).join(', ') || '';\n const output = run.output?.map((i: { content: string }) => i.content).join(', ') || '';\n const matcher = new SequenceMatcher(null, input, output);\n const ratio = matcher.ratio();\n\n // Get detailed operations\n const ops = matcher.getOpcodes();\n const changes = ops.filter(([op]) => op !== 'equal').length;\n\n // Calculate confidence based on text length difference\n const maxLength = Math.max(input.length, output.length);\n const lengthDiff = maxLength > 0 ? Math.abs(input.length - output.length) / maxLength : 0;\n const confidence = 1 - lengthDiff;\n\n return {\n ratio,\n confidence,\n changes,\n lengthDiff,\n };\n })\n .generateScore(({ results }) => {\n return results.preprocessStepResult?.ratio;\n });\n}\n","import { createScorer } from '@mastra/core/scores';\nimport keyword_extractor from 'keyword-extractor';\n\nexport function createKeywordCoverageScorer() {\n return createScorer({\n name: 'Keyword Coverage Scorer',\n description:\n 'Leverage the nlp method from \"compromise\" to extract elements from the input and output and calculate the coverage.',\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n const input = run.input?.inputMessages?.map((i: { content: string }) => i.content).join(', ') || '';\n const output = run.output?.map((i: { content: string }) => i.content).join(', ') || '';\n\n if (!input && !output) {\n return {\n result: {\n referenceKeywords: new Set<string>(),\n responseKeywords: new Set<string>(),\n },\n };\n }\n\n const extractKeywords = (text: string) => {\n return keyword_extractor.extract(text, {\n language: 'english',\n remove_digits: true,\n return_changed_case: true,\n remove_duplicates: true,\n });\n };\n\n const referenceKeywords = new Set(extractKeywords(input));\n const responseKeywords = new Set(extractKeywords(output));\n return {\n referenceKeywords,\n responseKeywords,\n };\n })\n .analyze(async ({ results }) => {\n if (\n !results.preprocessStepResult?.referenceKeywords?.size &&\n !results.preprocessStepResult?.responseKeywords?.size\n ) {\n return {\n totalKeywordsLength: 0,\n matchedKeywordsLength: 0,\n };\n }\n\n const matchedKeywords = [...results.preprocessStepResult?.referenceKeywords].filter(k =>\n results.preprocessStepResult?.responseKeywords?.has(k),\n );\n\n return {\n totalKeywordsLength: Array.from(results.preprocessStepResult?.referenceKeywords).length ?? 0,\n matchedKeywordsLength: matchedKeywords.length ?? 0,\n };\n })\n .generateScore(({ results }) => {\n if (!results.analyzeStepResult?.totalKeywordsLength) {\n return 1;\n }\n\n const totalKeywords = results.analyzeStepResult?.totalKeywordsLength!;\n const matchedKeywords = results.analyzeStepResult?.matchedKeywordsLength!;\n return totalKeywords > 0 ? matchedKeywords / totalKeywords : 0;\n });\n}\n","import { createScorer } from '@mastra/core/scores';\nimport stringSimilarity from 'string-similarity';\n\ninterface ContentSimilarityOptions {\n ignoreCase?: boolean;\n ignoreWhitespace?: boolean;\n}\n\nexport function createContentSimilarityScorer(\n { ignoreCase, ignoreWhitespace }: ContentSimilarityOptions = { ignoreCase: true, ignoreWhitespace: true },\n) {\n return createScorer({\n name: 'Content Similarity Scorer',\n description: 'Calculates content similarity between input and output messages using string comparison algorithms.',\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n let processedInput = run.input?.inputMessages.map((i: { content: string }) => i.content).join(', ') || '';\n let processedOutput = run.output.map((i: { content: string }) => i.content).join(', ') || '';\n\n if (ignoreCase) {\n processedInput = processedInput.toLowerCase();\n processedOutput = processedOutput.toLowerCase();\n }\n\n if (ignoreWhitespace) {\n processedInput = processedInput.replace(/\\s+/g, ' ').trim();\n processedOutput = processedOutput.replace(/\\s+/g, ' ').trim();\n }\n\n return {\n processedInput,\n processedOutput,\n };\n })\n .generateScore(({ results }) => {\n const similarity = stringSimilarity.compareTwoStrings(\n results.preprocessStepResult?.processedInput,\n results.preprocessStepResult?.processedOutput,\n );\n\n return similarity;\n });\n}\n","import { createScorer } from '@mastra/core/scores';\nimport Sentiment from 'sentiment';\n\ninterface ToneScorerConfig {\n referenceTone?: string;\n}\n\nexport function createToneScorer(config: ToneScorerConfig = {}) {\n const { referenceTone } = config;\n\n return createScorer({\n name: 'Tone Scorer',\n description:\n 'Analyzes the tone and sentiment of agent responses using sentiment analysis. Can compare against a reference tone or evaluate sentiment stability.',\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n const sentiment = new Sentiment();\n const agentMessage: string = run.output?.map((i: { content: string }) => i.content).join(', ') || '';\n const responseSentiment = sentiment.analyze(agentMessage);\n\n if (referenceTone) {\n // Compare sentiment with reference\n const referenceSentiment = sentiment.analyze(referenceTone);\n const sentimentDiff = Math.abs(responseSentiment.comparative - referenceSentiment.comparative);\n const normalizedScore = Math.max(0, 1 - sentimentDiff);\n\n return {\n score: normalizedScore,\n responseSentiment: responseSentiment.comparative,\n referenceSentiment: referenceSentiment.comparative,\n difference: sentimentDiff,\n };\n }\n\n // Evaluate sentiment stability across response\n const sentences = agentMessage.match(/[^.!?]+[.!?]+/g) || [agentMessage];\n const sentiments = sentences.map(s => sentiment.analyze(s).comparative);\n const avgSentiment = sentiments.reduce((a, b) => a + b, 0) / sentiments.length;\n const variance = sentiments.reduce((sum, s) => sum + Math.pow(s - avgSentiment, 2), 0) / sentiments.length;\n const stability = Math.max(0, 1 - variance);\n\n return {\n score: stability,\n avgSentiment,\n sentimentVariance: variance,\n };\n })\n .generateScore(({ results }) => {\n return results.preprocessStepResult?.score;\n });\n}\n","import { createScorer } from '@mastra/core/scores';\nimport { extractToolCalls } from '../../utils';\ninterface ToolCallAccuracyOptions {\n expectedTool?: string;\n strictMode?: boolean;\n expectedToolOrder?: string[];\n}\n\nfunction checkToolOrder(actualTools: string[], expectedOrder: string[], strictMode: boolean = false): boolean {\n if (strictMode) {\n return JSON.stringify(actualTools) === JSON.stringify(expectedOrder);\n }\n\n const expectedIndices: number[] = [];\n for (const expectedTool of expectedOrder) {\n const index = actualTools.indexOf(expectedTool);\n if (index === -1) {\n return false;\n }\n expectedIndices.push(index);\n }\n\n for (let i = 1; i < expectedIndices.length; i++) {\n const currentIndex = expectedIndices[i];\n const prevIndex = expectedIndices[i - 1];\n if (currentIndex !== undefined && prevIndex !== undefined && currentIndex <= prevIndex) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction calculateAccuracy({\n expectedTool,\n actualTools,\n strictMode = false,\n expectedToolOrder,\n}: {\n expectedTool?: string;\n actualTools: string[];\n strictMode?: boolean;\n expectedToolOrder?: string[];\n}): number {\n if (actualTools.length === 0) {\n return 0;\n }\n\n if (expectedToolOrder && expectedToolOrder.length > 0) {\n return checkToolOrder(actualTools, expectedToolOrder, strictMode) ? 1 : 0;\n }\n\n if (!expectedTool) {\n return 0;\n }\n\n if (strictMode) {\n return actualTools.length === 1 && actualTools[0] === expectedTool ? 1 : 0;\n }\n\n return actualTools.includes(expectedTool) ? 1 : 0;\n}\n\nexport function createToolCallAccuracyScorerCode(options: ToolCallAccuracyOptions) {\n const { expectedTool, strictMode = false, expectedToolOrder } = options;\n\n if (!expectedTool && !expectedToolOrder) {\n throw new Error('Either expectedTool or expectedToolOrder must be provided');\n }\n\n const getDescription = () => {\n return expectedToolOrder\n ? `Evaluates whether the LLM called tools in the correct order: [${expectedToolOrder.join(', ')}]`\n : `Evaluates whether the LLM selected the correct tool (${expectedTool}) from the available tools`;\n };\n\n return createScorer({\n name: 'Tool Call Accuracy Scorer',\n description: getDescription(),\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n const isInputInvalid = !run.input || !run.input.inputMessages || run.input.inputMessages.length === 0;\n const isOutputInvalid = !run.output || run.output.length === 0;\n\n if (isInputInvalid || isOutputInvalid) {\n throw new Error('Input and output messages cannot be null or empty');\n }\n\n const { tools: actualTools, toolCallInfos } = extractToolCalls(run.output);\n\n const correctToolCalled = expectedTool\n ? strictMode\n ? actualTools.length === 1 && actualTools[0] === expectedTool\n : actualTools.includes(expectedTool)\n : false;\n\n return {\n expectedTool,\n actualTools,\n strictMode,\n expectedToolOrder,\n hasToolCalls: actualTools.length > 0,\n correctToolCalled,\n toolCallInfos,\n correctOrderCalled: expectedToolOrder ? checkToolOrder(actualTools, expectedToolOrder, strictMode) : null,\n };\n })\n .generateScore(({ results }) => {\n const preprocessResult = results.preprocessStepResult;\n if (!preprocessResult) {\n return 0;\n }\n\n return calculateAccuracy({\n expectedTool: preprocessResult.expectedTool,\n actualTools: preprocessResult.actualTools,\n strictMode: preprocessResult.strictMode,\n expectedToolOrder: preprocessResult.expectedToolOrder,\n });\n });\n}\n"]}
@@ -49,8 +49,9 @@ function calculateCoverage({ original, simplified }) {
49
49
  }
50
50
  function createCompletenessScorer() {
51
51
  return createScorer({
52
- name: "Completeness",
53
- description: 'Leverage the nlp method from "compromise" to extract elements from the input and output and calculate the coverage.'
52
+ name: "Completeness Scorer",
53
+ description: 'Leverage the nlp method from "compromise" to extract elements from the input and output and calculate the coverage.',
54
+ type: "agent"
54
55
  }).preprocess(async ({ run }) => {
55
56
  const isInputInvalid = !run.input || run.input.inputMessages.some((i) => i.content === null || i.content === void 0);
56
57
  const isOutputInvalid = !run.output || run.output.some((i) => i.content === null || i.content === void 0);
@@ -85,8 +86,9 @@ function createCompletenessScorer() {
85
86
  }
86
87
  function createTextualDifferenceScorer() {
87
88
  return createScorer({
88
- name: "Completeness",
89
- description: 'Leverage the nlp method from "compromise" to extract elements from the input and output and calculate the coverage.'
89
+ name: "Textual Difference Scorer",
90
+ description: "Calculate textual difference between input and output using sequence matching algorithms.",
91
+ type: "agent"
90
92
  }).preprocess(async ({ run }) => {
91
93
  const input = run.input?.inputMessages?.map((i) => i.content).join(", ") || "";
92
94
  const output = run.output?.map((i) => i.content).join(", ") || "";
@@ -109,8 +111,9 @@ function createTextualDifferenceScorer() {
109
111
  }
110
112
  function createKeywordCoverageScorer() {
111
113
  return createScorer({
112
- name: "Completeness",
113
- description: 'Leverage the nlp method from "compromise" to extract elements from the input and output and calculate the coverage.'
114
+ name: "Keyword Coverage Scorer",
115
+ description: 'Leverage the nlp method from "compromise" to extract elements from the input and output and calculate the coverage.',
116
+ type: "agent"
114
117
  }).preprocess(async ({ run }) => {
115
118
  const input = run.input?.inputMessages?.map((i) => i.content).join(", ") || "";
116
119
  const output = run.output?.map((i) => i.content).join(", ") || "";
@@ -161,8 +164,9 @@ function createKeywordCoverageScorer() {
161
164
  }
162
165
  function createContentSimilarityScorer({ ignoreCase, ignoreWhitespace } = { ignoreCase: true, ignoreWhitespace: true }) {
163
166
  return createScorer({
164
- name: "Completeness",
165
- description: 'Leverage the nlp method from "compromise" to extract elements from the input and output and calculate the coverage.'
167
+ name: "Content Similarity Scorer",
168
+ description: "Calculates content similarity between input and output messages using string comparison algorithms.",
169
+ type: "agent"
166
170
  }).preprocess(async ({ run }) => {
167
171
  let processedInput = run.input?.inputMessages.map((i) => i.content).join(", ") || "";
168
172
  let processedOutput = run.output.map((i) => i.content).join(", ") || "";
@@ -189,8 +193,9 @@ function createContentSimilarityScorer({ ignoreCase, ignoreWhitespace } = { igno
189
193
  function createToneScorer(config = {}) {
190
194
  const { referenceTone } = config;
191
195
  return createScorer({
192
- name: "Completeness",
193
- description: 'Leverage the nlp method from "compromise" to extract elements from the input and output and calculate the coverage.'
196
+ name: "Tone Scorer",
197
+ description: "Analyzes the tone and sentiment of agent responses using sentiment analysis. Can compare against a reference tone or evaluate sentiment stability.",
198
+ type: "agent"
194
199
  }).preprocess(async ({ run }) => {
195
200
  const sentiment = new Sentiment();
196
201
  const agentMessage = run.output?.map((i) => i.content).join(", ") || "";
@@ -270,8 +275,9 @@ function createToolCallAccuracyScorerCode(options) {
270
275
  return expectedToolOrder ? `Evaluates whether the LLM called tools in the correct order: [${expectedToolOrder.join(", ")}]` : `Evaluates whether the LLM selected the correct tool (${expectedTool}) from the available tools`;
271
276
  };
272
277
  return createScorer({
273
- name: "Tool Call Accuracy",
274
- description: getDescription()
278
+ name: "Tool Call Accuracy Scorer",
279
+ description: getDescription(),
280
+ type: "agent"
275
281
  }).preprocess(async ({ run }) => {
276
282
  const isInputInvalid = !run.input || !run.input.inputMessages || run.input.inputMessages.length === 0;
277
283
  const isOutputInvalid = !run.output || run.output.length === 0;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/scorers/code/completeness/index.ts","../../../src/scorers/code/textual-difference/index.ts","../../../src/scorers/code/keyword-coverage/index.ts","../../../src/scorers/code/content-similarity/index.ts","../../../src/scorers/code/tone/index.ts","../../../src/scorers/code/tool-call-accuracy/index.ts"],"names":["createScorer"],"mappings":";;;;;;;;AAIA,SAAS,gBAAgB,GAAA,EAAqB;AAE5C,EAAA,OAAO,GAAA,CACJ,UAAU,KAAK,CAAA,CACf,QAAQ,kBAAA,EAAoB,EAAE,EAC9B,WAAA,EAAY;AACjB;AAEA,SAAS,gBAAgB,GAAA,EAAoB;AAE3C,EAAA,MAAM,QAAQ,GAAA,CAAI,KAAA,GAAQ,GAAA,CAAI,OAAO,KAAK,EAAC;AAC3C,EAAA,MAAM,KAAA,GAAQ,IAAI,KAAA,EAAM,CAAE,cAAa,CAAE,GAAA,CAAI,OAAO,CAAA,IAAK,EAAC;AAC1D,EAAA,MAAM,SAAS,GAAA,CAAI,MAAA,GAAS,GAAA,CAAI,OAAO,KAAK,EAAC;AAC7C,EAAA,MAAM,QAAQ,GAAA,CAAI,KAAA,GAAQ,GAAA,CAAI,OAAO,KAAK,EAAC;AAG3C,EAAA,MAAM,iBAAA,GAAoB,CAAC,IAAA,KAA2B;AAEpD,IAAA,MAAM,UAAA,GAAa,gBAAgB,IAAI,CAAA;AAGvC,IAAA,OAAO,WACJ,OAAA,CAAQ,iBAAA,EAAmB,OAAO,CAAA,CAClC,OAAA,CAAQ,eAAe,GAAG,CAAA,CAC1B,IAAA,EAAK,CACL,MAAM,KAAK,CAAA,CACX,OAAO,CAAA,IAAA,KAAQ,IAAA,CAAK,SAAS,CAAC,CAAA;AAAA,EACnC,CAAA;AAGA,EAAA,MAAM,cAAA,GAAiB;AAAA,IACrB,GAAG,KAAA,CAA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AM,YAAA,GAC/C,WAAA,CAAY,QAAA,CAAS,YAAY,CAAA,GACnC,KAAA;AAEJ,IAAA,OAAO;AAAA,MACL,YAAA;AAAA,MACA,WAAA;AAAA,MACA,UAAA;AAAA,MACA,iBAAA;AAAA,MACA,YAAA,EAAc,YAAY,MAAA,GAAS,CAAA;AAAA,MACnC,iBAAA;AAAA,MACA,aAAA;AAAA,MACA,oBAAoB,iBAAA,GAAoB,cAAA,CAAe,WAAA,EAAa,iBAAA,EAAmB,UAAU,CAAA,GAAI;AAAA,KACvG;AAAA,EACF,CAAC,CAAA,CACA,aAAA,CAAc,CAAC,EAAE,SAAQ,KAAM;AAC9B,IAAA,MAAM,mBAAmB,OAAA,CAAQ,oBAAA;AACjC,IAAA,IAAI,CAAC,gBAAA,EAAkB;AACrB,MAAA,OAAO,CAAA;AAAA,IACT;AAEA,IAAA,OAAO,iBAAA,CAAkB;AAAA,MACvB,cAAc,gBAAA,CAAiB,YAAA;AAAA,MAC/B,aAAa,gBAAA,CAAiB,WAAA;AAAA,MAC9B,YAAY,gBAAA,CAAiB,UAAA;AAAA,MAC7B,mBAAmB,gBAAA,CAAiB;AAAA,KACrC,CAAA;AAAA,EACH,CAAC,CAAA;AACL","file":"index.js","sourcesContent":["import { createScorer } from '@mastra/core/scores';\nimport type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/scores';\nimport nlp from 'compromise';\n\nfunction normalizeString(str: string): string {\n // Remove diacritics and convert to lowercase\n return str\n .normalize('NFD')\n .replace(/[\\u0300-\\u036f]/g, '')\n .toLowerCase();\n}\n\nfunction extractElements(doc: any): string[] {\n // Get more specific elements and ensure they're arrays\n const nouns = doc.nouns().out('array') || [];\n const verbs = doc.verbs().toInfinitive().out('array') || [];\n const topics = doc.topics().out('array') || [];\n const terms = doc.terms().out('array') || [];\n\n // Helper function to clean and split terms\n const cleanAndSplitTerm = (term: string): string[] => {\n // First normalize the string\n const normalized = normalizeString(term);\n\n // Split on word boundaries and filter out empty strings\n return normalized\n .replace(/([a-z])([A-Z])/g, '$1 $2') // Split camelCase\n .replace(/[^a-z0-9]+/g, ' ') // Replace non-alphanumeric with spaces\n .trim()\n .split(/\\s+/)\n .filter(word => word.length > 0);\n };\n\n // Process all elements\n const processedTerms = [\n ...nouns.flatMap(cleanAndSplitTerm),\n ...verbs.flatMap(cleanAndSplitTerm),\n ...topics.flatMap(cleanAndSplitTerm),\n ...terms.flatMap(cleanAndSplitTerm),\n ];\n\n // Remove duplicates\n return [...new Set(processedTerms)];\n}\n\nfunction calculateCoverage({ original, simplified }: { original: string[]; simplified: string[] }): number {\n if (original.length === 0) {\n return simplified.length === 0 ? 1 : 0;\n }\n\n // Exact matching for short words (3 chars or less), substring matching for longer words\n const covered = original.filter(element =>\n simplified.some(s => {\n const elem = normalizeString(element);\n const simp = normalizeString(s);\n\n // For short words (3 chars or less), require exact match\n if (elem.length <= 3) {\n return elem === simp;\n }\n\n // For longer words, require substantial overlap (more than 60% of the longer word)\n const longer = elem.length > simp.length ? elem : simp;\n const shorter = elem.length > simp.length ? simp : elem;\n\n if (longer.includes(shorter)) {\n return shorter.length / longer.length > 0.6;\n }\n\n return false;\n }),\n );\n return covered.length / original.length;\n}\n\nexport function createCompletenessScorer() {\n return createScorer<ScorerRunInputForAgent, ScorerRunOutputForAgent>({\n name: 'Completeness',\n description:\n 'Leverage the nlp method from \"compromise\" to extract elements from the input and output and calculate the coverage.',\n })\n .preprocess(async ({ run }) => {\n const isInputInvalid =\n !run.input ||\n run.input.inputMessages.some((i: { content: string }) => i.content === null || i.content === undefined);\n\n const isOutputInvalid =\n !run.output || run.output.some((i: { content: string }) => i.content === null || i.content === undefined);\n\n if (isInputInvalid || isOutputInvalid) {\n throw new Error('Inputs cannot be null or undefined');\n }\n\n const input = run.input?.inputMessages.map((i: { content: string }) => i.content).join(', ') || '';\n const output = run.output?.map(({ content }: { content: string }) => content).join(', ') || '';\n\n const inputToProcess = input;\n const outputToProcess = output;\n\n const inputDoc = nlp(inputToProcess.trim());\n const outputDoc = nlp(outputToProcess.trim());\n\n // Extract and log elements\n const inputElements = extractElements(inputDoc);\n const outputElements = extractElements(outputDoc);\n\n return {\n inputElements,\n outputElements,\n missingElements: inputElements.filter(e => !outputElements.includes(e)),\n elementCounts: {\n input: inputElements.length,\n output: outputElements.length,\n },\n };\n })\n .generateScore(({ results }) => {\n const inputElements = results.preprocessStepResult?.inputElements;\n const outputElements = results.preprocessStepResult?.outputElements;\n\n return calculateCoverage({\n original: inputElements,\n simplified: outputElements,\n });\n });\n}\n","import { createScorer } from '@mastra/core/scores';\nimport type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/scores';\nimport { SequenceMatcher } from 'difflib';\n\nexport function createTextualDifferenceScorer() {\n return createScorer<ScorerRunInputForAgent, ScorerRunOutputForAgent>({\n name: 'Completeness',\n description:\n 'Leverage the nlp method from \"compromise\" to extract elements from the input and output and calculate the coverage.',\n })\n .preprocess(async ({ run }) => {\n const input = run.input?.inputMessages?.map((i: { content: string }) => i.content).join(', ') || '';\n const output = run.output?.map((i: { content: string }) => i.content).join(', ') || '';\n const matcher = new SequenceMatcher(null, input, output);\n const ratio = matcher.ratio();\n\n // Get detailed operations\n const ops = matcher.getOpcodes();\n const changes = ops.filter(([op]) => op !== 'equal').length;\n\n // Calculate confidence based on text length difference\n const maxLength = Math.max(input.length, output.length);\n const lengthDiff = maxLength > 0 ? Math.abs(input.length - output.length) / maxLength : 0;\n const confidence = 1 - lengthDiff;\n\n return {\n ratio,\n confidence,\n changes,\n lengthDiff,\n };\n })\n .generateScore(({ results }) => {\n return results.preprocessStepResult?.ratio;\n });\n}\n","import { createScorer } from '@mastra/core/scores';\nimport type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/scores';\nimport keyword_extractor from 'keyword-extractor';\n\nexport function createKeywordCoverageScorer() {\n return createScorer<ScorerRunInputForAgent, ScorerRunOutputForAgent>({\n name: 'Completeness',\n description:\n 'Leverage the nlp method from \"compromise\" to extract elements from the input and output and calculate the coverage.',\n })\n .preprocess(async ({ run }) => {\n const input = run.input?.inputMessages?.map((i: { content: string }) => i.content).join(', ') || '';\n const output = run.output?.map((i: { content: string }) => i.content).join(', ') || '';\n\n if (!input && !output) {\n return {\n result: {\n referenceKeywords: new Set<string>(),\n responseKeywords: new Set<string>(),\n },\n };\n }\n\n const extractKeywords = (text: string) => {\n return keyword_extractor.extract(text, {\n language: 'english',\n remove_digits: true,\n return_changed_case: true,\n remove_duplicates: true,\n });\n };\n\n const referenceKeywords = new Set(extractKeywords(input));\n const responseKeywords = new Set(extractKeywords(output));\n return {\n referenceKeywords,\n responseKeywords,\n };\n })\n .analyze(async ({ results }) => {\n if (\n !results.preprocessStepResult?.referenceKeywords?.size &&\n !results.preprocessStepResult?.responseKeywords?.size\n ) {\n return {\n totalKeywordsLength: 0,\n matchedKeywordsLength: 0,\n };\n }\n\n const matchedKeywords = [...results.preprocessStepResult?.referenceKeywords].filter(k =>\n results.preprocessStepResult?.responseKeywords?.has(k),\n );\n\n return {\n totalKeywordsLength: Array.from(results.preprocessStepResult?.referenceKeywords).length ?? 0,\n matchedKeywordsLength: matchedKeywords.length ?? 0,\n };\n })\n .generateScore(({ results }) => {\n if (!results.analyzeStepResult?.totalKeywordsLength) {\n return 1;\n }\n\n const totalKeywords = results.analyzeStepResult?.totalKeywordsLength!;\n const matchedKeywords = results.analyzeStepResult?.matchedKeywordsLength!;\n return totalKeywords > 0 ? matchedKeywords / totalKeywords : 0;\n });\n}\n","import { createScorer } from '@mastra/core/scores';\nimport type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/scores';\nimport stringSimilarity from 'string-similarity';\n\ninterface ContentSimilarityOptions {\n ignoreCase?: boolean;\n ignoreWhitespace?: boolean;\n}\n\nexport function createContentSimilarityScorer(\n { ignoreCase, ignoreWhitespace }: ContentSimilarityOptions = { ignoreCase: true, ignoreWhitespace: true },\n) {\n return createScorer<ScorerRunInputForAgent, ScorerRunOutputForAgent>({\n name: 'Completeness',\n description:\n 'Leverage the nlp method from \"compromise\" to extract elements from the input and output and calculate the coverage.',\n })\n .preprocess(async ({ run }) => {\n let processedInput = run.input?.inputMessages.map((i: { content: string }) => i.content).join(', ') || '';\n let processedOutput = run.output.map((i: { content: string }) => i.content).join(', ') || '';\n\n if (ignoreCase) {\n processedInput = processedInput.toLowerCase();\n processedOutput = processedOutput.toLowerCase();\n }\n\n if (ignoreWhitespace) {\n processedInput = processedInput.replace(/\\s+/g, ' ').trim();\n processedOutput = processedOutput.replace(/\\s+/g, ' ').trim();\n }\n\n return {\n processedInput,\n processedOutput,\n };\n })\n .generateScore(({ results }) => {\n const similarity = stringSimilarity.compareTwoStrings(\n results.preprocessStepResult?.processedInput,\n results.preprocessStepResult?.processedOutput,\n );\n\n return similarity;\n });\n}\n","import { createScorer } from '@mastra/core/scores';\nimport type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/scores';\nimport Sentiment from 'sentiment';\n\ninterface ToneScorerConfig {\n referenceTone?: string;\n}\n\nexport function createToneScorer(config: ToneScorerConfig = {}) {\n const { referenceTone } = config;\n\n return createScorer<ScorerRunInputForAgent, ScorerRunOutputForAgent>({\n name: 'Completeness',\n description:\n 'Leverage the nlp method from \"compromise\" to extract elements from the input and output and calculate the coverage.',\n })\n .preprocess(async ({ run }) => {\n const sentiment = new Sentiment();\n const agentMessage: string = run.output?.map((i: { content: string }) => i.content).join(', ') || '';\n const responseSentiment = sentiment.analyze(agentMessage);\n\n if (referenceTone) {\n // Compare sentiment with reference\n const referenceSentiment = sentiment.analyze(referenceTone);\n const sentimentDiff = Math.abs(responseSentiment.comparative - referenceSentiment.comparative);\n const normalizedScore = Math.max(0, 1 - sentimentDiff);\n\n return {\n score: normalizedScore,\n responseSentiment: responseSentiment.comparative,\n referenceSentiment: referenceSentiment.comparative,\n difference: sentimentDiff,\n };\n }\n\n // Evaluate sentiment stability across response\n const sentences = agentMessage.match(/[^.!?]+[.!?]+/g) || [agentMessage];\n const sentiments = sentences.map(s => sentiment.analyze(s).comparative);\n const avgSentiment = sentiments.reduce((a, b) => a + b, 0) / sentiments.length;\n const variance = sentiments.reduce((sum, s) => sum + Math.pow(s - avgSentiment, 2), 0) / sentiments.length;\n const stability = Math.max(0, 1 - variance);\n\n return {\n score: stability,\n avgSentiment,\n sentimentVariance: variance,\n };\n })\n .generateScore(({ results }) => {\n return results.preprocessStepResult?.score;\n });\n}\n","import type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/scores';\nimport { createScorer } from '@mastra/core/scores';\nimport { extractToolCalls } from '../../utils';\n\ninterface ToolCallAccuracyOptions {\n expectedTool?: string;\n strictMode?: boolean;\n expectedToolOrder?: string[];\n}\n\nfunction checkToolOrder(actualTools: string[], expectedOrder: string[], strictMode: boolean = false): boolean {\n if (strictMode) {\n return JSON.stringify(actualTools) === JSON.stringify(expectedOrder);\n }\n\n const expectedIndices: number[] = [];\n for (const expectedTool of expectedOrder) {\n const index = actualTools.indexOf(expectedTool);\n if (index === -1) {\n return false;\n }\n expectedIndices.push(index);\n }\n\n for (let i = 1; i < expectedIndices.length; i++) {\n const currentIndex = expectedIndices[i];\n const prevIndex = expectedIndices[i - 1];\n if (currentIndex !== undefined && prevIndex !== undefined && currentIndex <= prevIndex) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction calculateAccuracy({\n expectedTool,\n actualTools,\n strictMode = false,\n expectedToolOrder,\n}: {\n expectedTool?: string;\n actualTools: string[];\n strictMode?: boolean;\n expectedToolOrder?: string[];\n}): number {\n if (actualTools.length === 0) {\n return 0;\n }\n\n if (expectedToolOrder && expectedToolOrder.length > 0) {\n return checkToolOrder(actualTools, expectedToolOrder, strictMode) ? 1 : 0;\n }\n\n if (!expectedTool) {\n return 0;\n }\n\n if (strictMode) {\n return actualTools.length === 1 && actualTools[0] === expectedTool ? 1 : 0;\n }\n\n return actualTools.includes(expectedTool) ? 1 : 0;\n}\n\nexport function createToolCallAccuracyScorerCode(options: ToolCallAccuracyOptions) {\n const { expectedTool, strictMode = false, expectedToolOrder } = options;\n\n if (!expectedTool && !expectedToolOrder) {\n throw new Error('Either expectedTool or expectedToolOrder must be provided');\n }\n\n const getDescription = () => {\n return expectedToolOrder\n ? `Evaluates whether the LLM called tools in the correct order: [${expectedToolOrder.join(', ')}]`\n : `Evaluates whether the LLM selected the correct tool (${expectedTool}) from the available tools`;\n };\n\n return createScorer<ScorerRunInputForAgent, ScorerRunOutputForAgent>({\n name: 'Tool Call Accuracy',\n description: getDescription(),\n })\n .preprocess(async ({ run }) => {\n const isInputInvalid = !run.input || !run.input.inputMessages || run.input.inputMessages.length === 0;\n const isOutputInvalid = !run.output || run.output.length === 0;\n\n if (isInputInvalid || isOutputInvalid) {\n throw new Error('Input and output messages cannot be null or empty');\n }\n\n const { tools: actualTools, toolCallInfos } = extractToolCalls(run.output);\n\n const correctToolCalled = expectedTool\n ? strictMode\n ? actualTools.length === 1 && actualTools[0] === expectedTool\n : actualTools.includes(expectedTool)\n : false;\n\n return {\n expectedTool,\n actualTools,\n strictMode,\n expectedToolOrder,\n hasToolCalls: actualTools.length > 0,\n correctToolCalled,\n toolCallInfos,\n correctOrderCalled: expectedToolOrder ? checkToolOrder(actualTools, expectedToolOrder, strictMode) : null,\n };\n })\n .generateScore(({ results }) => {\n const preprocessResult = results.preprocessStepResult;\n if (!preprocessResult) {\n return 0;\n }\n\n return calculateAccuracy({\n expectedTool: preprocessResult.expectedTool,\n actualTools: preprocessResult.actualTools,\n strictMode: preprocessResult.strictMode,\n expectedToolOrder: preprocessResult.expectedToolOrder,\n });\n });\n}\n"]}
1
+ {"version":3,"sources":["../../../src/scorers/code/completeness/index.ts","../../../src/scorers/code/textual-difference/index.ts","../../../src/scorers/code/keyword-coverage/index.ts","../../../src/scorers/code/content-similarity/index.ts","../../../src/scorers/code/tone/index.ts","../../../src/scorers/code/tool-call-accuracy/index.ts"],"names":["createScorer"],"mappings":";;;;;;;;AAGA,SAAS,gBAAgB,GAAA,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AAc,YAAY,MAAA,GAAS,CAAA;AAAA,MACnC,iBAAA;AAAA,MACA,aAAA;AAAA,MACA,oBAAoB,iBAAA,GAAoB,cAAA,CAAe,WAAA,EAAa,iBAAA,EAAmB,UAAU,CAAA,GAAI;AAAA,KACvG;AAAA,EACF,CAAC,CAAA,CACA,aAAA,CAAc,CAAC,EAAE,SAAQ,KAAM;AAC9B,IAAA,MAAM,mBAAmB,OAAA,CAAQ,oBAAA;AACjC,IAAA,IAAI,CAAC,gBAAA,EAAkB;AACrB,MAAA,OAAO,CAAA;AAAA,IACT;AAEA,IAAA,OAAO,iBAAA,CAAkB;AAAA,MACvB,cAAc,gBAAA,CAAiB,YAAA;AAAA,MAC/B,aAAa,gBAAA,CAAiB,WAAA;AAAA,MAC9B,YAAY,gBAAA,CAAiB,UAAA;AAAA,MAC7B,mBAAmB,gBAAA,CAAiB;AAAA,KACrC,CAAA;AAAA,EACH,CAAC,CAAA;AACL","file":"index.js","sourcesContent":["import { createScorer } from '@mastra/core/scores';\nimport nlp from 'compromise';\n\nfunction normalizeString(str: string): string {\n // Remove diacritics and convert to lowercase\n return str\n .normalize('NFD')\n .replace(/[\\u0300-\\u036f]/g, '')\n .toLowerCase();\n}\n\nfunction extractElements(doc: any): string[] {\n // Get more specific elements and ensure they're arrays\n const nouns = doc.nouns().out('array') || [];\n const verbs = doc.verbs().toInfinitive().out('array') || [];\n const topics = doc.topics().out('array') || [];\n const terms = doc.terms().out('array') || [];\n\n // Helper function to clean and split terms\n const cleanAndSplitTerm = (term: string): string[] => {\n // First normalize the string\n const normalized = normalizeString(term);\n\n // Split on word boundaries and filter out empty strings\n return normalized\n .replace(/([a-z])([A-Z])/g, '$1 $2') // Split camelCase\n .replace(/[^a-z0-9]+/g, ' ') // Replace non-alphanumeric with spaces\n .trim()\n .split(/\\s+/)\n .filter(word => word.length > 0);\n };\n\n // Process all elements\n const processedTerms = [\n ...nouns.flatMap(cleanAndSplitTerm),\n ...verbs.flatMap(cleanAndSplitTerm),\n ...topics.flatMap(cleanAndSplitTerm),\n ...terms.flatMap(cleanAndSplitTerm),\n ];\n\n // Remove duplicates\n return [...new Set(processedTerms)];\n}\n\nfunction calculateCoverage({ original, simplified }: { original: string[]; simplified: string[] }): number {\n if (original.length === 0) {\n return simplified.length === 0 ? 1 : 0;\n }\n\n // Exact matching for short words (3 chars or less), substring matching for longer words\n const covered = original.filter(element =>\n simplified.some(s => {\n const elem = normalizeString(element);\n const simp = normalizeString(s);\n\n // For short words (3 chars or less), require exact match\n if (elem.length <= 3) {\n return elem === simp;\n }\n\n // For longer words, require substantial overlap (more than 60% of the longer word)\n const longer = elem.length > simp.length ? elem : simp;\n const shorter = elem.length > simp.length ? simp : elem;\n\n if (longer.includes(shorter)) {\n return shorter.length / longer.length > 0.6;\n }\n\n return false;\n }),\n );\n return covered.length / original.length;\n}\n\nexport function createCompletenessScorer() {\n return createScorer({\n name: 'Completeness Scorer',\n description:\n 'Leverage the nlp method from \"compromise\" to extract elements from the input and output and calculate the coverage.',\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n const isInputInvalid =\n !run.input ||\n run.input.inputMessages.some((i: { content: string }) => i.content === null || i.content === undefined);\n\n const isOutputInvalid =\n !run.output || run.output.some((i: { content: string }) => i.content === null || i.content === undefined);\n\n if (isInputInvalid || isOutputInvalid) {\n throw new Error('Inputs cannot be null or undefined');\n }\n\n const input = run.input?.inputMessages.map((i: { content: string }) => i.content).join(', ') || '';\n const output = run.output?.map(({ content }: { content: string }) => content).join(', ') || '';\n\n const inputToProcess = input;\n const outputToProcess = output;\n\n const inputDoc = nlp(inputToProcess.trim());\n const outputDoc = nlp(outputToProcess.trim());\n\n // Extract and log elements\n const inputElements = extractElements(inputDoc);\n const outputElements = extractElements(outputDoc);\n\n return {\n inputElements,\n outputElements,\n missingElements: inputElements.filter(e => !outputElements.includes(e)),\n elementCounts: {\n input: inputElements.length,\n output: outputElements.length,\n },\n };\n })\n .generateScore(({ results }) => {\n const inputElements = results.preprocessStepResult?.inputElements;\n const outputElements = results.preprocessStepResult?.outputElements;\n\n return calculateCoverage({\n original: inputElements,\n simplified: outputElements,\n });\n });\n}\n","import { createScorer } from '@mastra/core/scores';\nimport { SequenceMatcher } from 'difflib';\n\nexport function createTextualDifferenceScorer() {\n return createScorer({\n name: 'Textual Difference Scorer',\n description: 'Calculate textual difference between input and output using sequence matching algorithms.',\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n const input = run.input?.inputMessages?.map((i: { content: string }) => i.content).join(', ') || '';\n const output = run.output?.map((i: { content: string }) => i.content).join(', ') || '';\n const matcher = new SequenceMatcher(null, input, output);\n const ratio = matcher.ratio();\n\n // Get detailed operations\n const ops = matcher.getOpcodes();\n const changes = ops.filter(([op]) => op !== 'equal').length;\n\n // Calculate confidence based on text length difference\n const maxLength = Math.max(input.length, output.length);\n const lengthDiff = maxLength > 0 ? Math.abs(input.length - output.length) / maxLength : 0;\n const confidence = 1 - lengthDiff;\n\n return {\n ratio,\n confidence,\n changes,\n lengthDiff,\n };\n })\n .generateScore(({ results }) => {\n return results.preprocessStepResult?.ratio;\n });\n}\n","import { createScorer } from '@mastra/core/scores';\nimport keyword_extractor from 'keyword-extractor';\n\nexport function createKeywordCoverageScorer() {\n return createScorer({\n name: 'Keyword Coverage Scorer',\n description:\n 'Leverage the nlp method from \"compromise\" to extract elements from the input and output and calculate the coverage.',\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n const input = run.input?.inputMessages?.map((i: { content: string }) => i.content).join(', ') || '';\n const output = run.output?.map((i: { content: string }) => i.content).join(', ') || '';\n\n if (!input && !output) {\n return {\n result: {\n referenceKeywords: new Set<string>(),\n responseKeywords: new Set<string>(),\n },\n };\n }\n\n const extractKeywords = (text: string) => {\n return keyword_extractor.extract(text, {\n language: 'english',\n remove_digits: true,\n return_changed_case: true,\n remove_duplicates: true,\n });\n };\n\n const referenceKeywords = new Set(extractKeywords(input));\n const responseKeywords = new Set(extractKeywords(output));\n return {\n referenceKeywords,\n responseKeywords,\n };\n })\n .analyze(async ({ results }) => {\n if (\n !results.preprocessStepResult?.referenceKeywords?.size &&\n !results.preprocessStepResult?.responseKeywords?.size\n ) {\n return {\n totalKeywordsLength: 0,\n matchedKeywordsLength: 0,\n };\n }\n\n const matchedKeywords = [...results.preprocessStepResult?.referenceKeywords].filter(k =>\n results.preprocessStepResult?.responseKeywords?.has(k),\n );\n\n return {\n totalKeywordsLength: Array.from(results.preprocessStepResult?.referenceKeywords).length ?? 0,\n matchedKeywordsLength: matchedKeywords.length ?? 0,\n };\n })\n .generateScore(({ results }) => {\n if (!results.analyzeStepResult?.totalKeywordsLength) {\n return 1;\n }\n\n const totalKeywords = results.analyzeStepResult?.totalKeywordsLength!;\n const matchedKeywords = results.analyzeStepResult?.matchedKeywordsLength!;\n return totalKeywords > 0 ? matchedKeywords / totalKeywords : 0;\n });\n}\n","import { createScorer } from '@mastra/core/scores';\nimport stringSimilarity from 'string-similarity';\n\ninterface ContentSimilarityOptions {\n ignoreCase?: boolean;\n ignoreWhitespace?: boolean;\n}\n\nexport function createContentSimilarityScorer(\n { ignoreCase, ignoreWhitespace }: ContentSimilarityOptions = { ignoreCase: true, ignoreWhitespace: true },\n) {\n return createScorer({\n name: 'Content Similarity Scorer',\n description: 'Calculates content similarity between input and output messages using string comparison algorithms.',\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n let processedInput = run.input?.inputMessages.map((i: { content: string }) => i.content).join(', ') || '';\n let processedOutput = run.output.map((i: { content: string }) => i.content).join(', ') || '';\n\n if (ignoreCase) {\n processedInput = processedInput.toLowerCase();\n processedOutput = processedOutput.toLowerCase();\n }\n\n if (ignoreWhitespace) {\n processedInput = processedInput.replace(/\\s+/g, ' ').trim();\n processedOutput = processedOutput.replace(/\\s+/g, ' ').trim();\n }\n\n return {\n processedInput,\n processedOutput,\n };\n })\n .generateScore(({ results }) => {\n const similarity = stringSimilarity.compareTwoStrings(\n results.preprocessStepResult?.processedInput,\n results.preprocessStepResult?.processedOutput,\n );\n\n return similarity;\n });\n}\n","import { createScorer } from '@mastra/core/scores';\nimport Sentiment from 'sentiment';\n\ninterface ToneScorerConfig {\n referenceTone?: string;\n}\n\nexport function createToneScorer(config: ToneScorerConfig = {}) {\n const { referenceTone } = config;\n\n return createScorer({\n name: 'Tone Scorer',\n description:\n 'Analyzes the tone and sentiment of agent responses using sentiment analysis. Can compare against a reference tone or evaluate sentiment stability.',\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n const sentiment = new Sentiment();\n const agentMessage: string = run.output?.map((i: { content: string }) => i.content).join(', ') || '';\n const responseSentiment = sentiment.analyze(agentMessage);\n\n if (referenceTone) {\n // Compare sentiment with reference\n const referenceSentiment = sentiment.analyze(referenceTone);\n const sentimentDiff = Math.abs(responseSentiment.comparative - referenceSentiment.comparative);\n const normalizedScore = Math.max(0, 1 - sentimentDiff);\n\n return {\n score: normalizedScore,\n responseSentiment: responseSentiment.comparative,\n referenceSentiment: referenceSentiment.comparative,\n difference: sentimentDiff,\n };\n }\n\n // Evaluate sentiment stability across response\n const sentences = agentMessage.match(/[^.!?]+[.!?]+/g) || [agentMessage];\n const sentiments = sentences.map(s => sentiment.analyze(s).comparative);\n const avgSentiment = sentiments.reduce((a, b) => a + b, 0) / sentiments.length;\n const variance = sentiments.reduce((sum, s) => sum + Math.pow(s - avgSentiment, 2), 0) / sentiments.length;\n const stability = Math.max(0, 1 - variance);\n\n return {\n score: stability,\n avgSentiment,\n sentimentVariance: variance,\n };\n })\n .generateScore(({ results }) => {\n return results.preprocessStepResult?.score;\n });\n}\n","import { createScorer } from '@mastra/core/scores';\nimport { extractToolCalls } from '../../utils';\ninterface ToolCallAccuracyOptions {\n expectedTool?: string;\n strictMode?: boolean;\n expectedToolOrder?: string[];\n}\n\nfunction checkToolOrder(actualTools: string[], expectedOrder: string[], strictMode: boolean = false): boolean {\n if (strictMode) {\n return JSON.stringify(actualTools) === JSON.stringify(expectedOrder);\n }\n\n const expectedIndices: number[] = [];\n for (const expectedTool of expectedOrder) {\n const index = actualTools.indexOf(expectedTool);\n if (index === -1) {\n return false;\n }\n expectedIndices.push(index);\n }\n\n for (let i = 1; i < expectedIndices.length; i++) {\n const currentIndex = expectedIndices[i];\n const prevIndex = expectedIndices[i - 1];\n if (currentIndex !== undefined && prevIndex !== undefined && currentIndex <= prevIndex) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction calculateAccuracy({\n expectedTool,\n actualTools,\n strictMode = false,\n expectedToolOrder,\n}: {\n expectedTool?: string;\n actualTools: string[];\n strictMode?: boolean;\n expectedToolOrder?: string[];\n}): number {\n if (actualTools.length === 0) {\n return 0;\n }\n\n if (expectedToolOrder && expectedToolOrder.length > 0) {\n return checkToolOrder(actualTools, expectedToolOrder, strictMode) ? 1 : 0;\n }\n\n if (!expectedTool) {\n return 0;\n }\n\n if (strictMode) {\n return actualTools.length === 1 && actualTools[0] === expectedTool ? 1 : 0;\n }\n\n return actualTools.includes(expectedTool) ? 1 : 0;\n}\n\nexport function createToolCallAccuracyScorerCode(options: ToolCallAccuracyOptions) {\n const { expectedTool, strictMode = false, expectedToolOrder } = options;\n\n if (!expectedTool && !expectedToolOrder) {\n throw new Error('Either expectedTool or expectedToolOrder must be provided');\n }\n\n const getDescription = () => {\n return expectedToolOrder\n ? `Evaluates whether the LLM called tools in the correct order: [${expectedToolOrder.join(', ')}]`\n : `Evaluates whether the LLM selected the correct tool (${expectedTool}) from the available tools`;\n };\n\n return createScorer({\n name: 'Tool Call Accuracy Scorer',\n description: getDescription(),\n type: 'agent',\n })\n .preprocess(async ({ run }) => {\n const isInputInvalid = !run.input || !run.input.inputMessages || run.input.inputMessages.length === 0;\n const isOutputInvalid = !run.output || run.output.length === 0;\n\n if (isInputInvalid || isOutputInvalid) {\n throw new Error('Input and output messages cannot be null or empty');\n }\n\n const { tools: actualTools, toolCallInfos } = extractToolCalls(run.output);\n\n const correctToolCalled = expectedTool\n ? strictMode\n ? actualTools.length === 1 && actualTools[0] === expectedTool\n : actualTools.includes(expectedTool)\n : false;\n\n return {\n expectedTool,\n actualTools,\n strictMode,\n expectedToolOrder,\n hasToolCalls: actualTools.length > 0,\n correctToolCalled,\n toolCallInfos,\n correctOrderCalled: expectedToolOrder ? checkToolOrder(actualTools, expectedToolOrder, strictMode) : null,\n };\n })\n .generateScore(({ results }) => {\n const preprocessResult = results.preprocessStepResult;\n if (!preprocessResult) {\n return 0;\n }\n\n return calculateAccuracy({\n expectedTool: preprocessResult.expectedTool,\n actualTools: preprocessResult.actualTools,\n strictMode: preprocessResult.strictMode,\n expectedToolOrder: preprocessResult.expectedToolOrder,\n });\n });\n}\n"]}
@@ -1,5 +1,4 @@
1
- import type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/scores';
2
- export declare function createKeywordCoverageScorer(): import("@mastra/core/scores").MastraScorer<string, ScorerRunInputForAgent, ScorerRunOutputForAgent, Record<"preprocessStepResult", {
1
+ export declare function createKeywordCoverageScorer(): import("@mastra/core/scores").MastraScorer<"Keyword Coverage Scorer", import("@mastra/core/scores").ScorerRunInputForAgent, import("@mastra/core/scores").ScorerRunOutputForAgent, Record<"preprocessStepResult", {
3
2
  result: {
4
3
  referenceKeywords: Set<string>;
5
4
  responseKeywords: Set<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/code/keyword-coverage/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAG3F,wBAAgB,2BAA2B;;;;;;;;;;;;;;gDAgE1C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/code/keyword-coverage/index.ts"],"names":[],"mappings":"AAGA,wBAAgB,2BAA2B;;;;;;;;;;;;;;gDAiE1C"}
@@ -1,5 +1,4 @@
1
- import type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/scores';
2
- export declare function createTextualDifferenceScorer(): import("@mastra/core/scores").MastraScorer<string, ScorerRunInputForAgent, ScorerRunOutputForAgent, Record<"preprocessStepResult", {
1
+ export declare function createTextualDifferenceScorer(): import("@mastra/core/scores").MastraScorer<"Textual Difference Scorer", import("@mastra/core/scores").ScorerRunInputForAgent, import("@mastra/core/scores").ScorerRunOutputForAgent, Record<"preprocessStepResult", {
3
2
  ratio: number;
4
3
  confidence: number;
5
4
  changes: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/code/textual-difference/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAG3F,wBAAgB,6BAA6B;;;;;gDA+B5C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/code/textual-difference/index.ts"],"names":[],"mappings":"AAGA,wBAAgB,6BAA6B;;;;;gDA+B5C"}
@@ -1,8 +1,7 @@
1
- import type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/scores';
2
1
  interface ToneScorerConfig {
3
2
  referenceTone?: string;
4
3
  }
5
- export declare function createToneScorer(config?: ToneScorerConfig): import("@mastra/core/scores").MastraScorer<string, ScorerRunInputForAgent, ScorerRunOutputForAgent, Record<"preprocessStepResult", {
4
+ export declare function createToneScorer(config?: ToneScorerConfig): import("@mastra/core/scores").MastraScorer<"Tone Scorer", import("@mastra/core/scores").ScorerRunInputForAgent, import("@mastra/core/scores").ScorerRunOutputForAgent, Record<"preprocessStepResult", {
6
5
  score: number;
7
6
  responseSentiment: number;
8
7
  referenceSentiment: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/code/tone/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAG3F,UAAU,gBAAgB;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,GAAE,gBAAqB;;;;;;;;;;;;;;gDA2C7D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/code/tone/index.ts"],"names":[],"mappings":"AAGA,UAAU,gBAAgB;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,GAAE,gBAAqB;;;;;;;;;;;;;;gDA4C7D"}
@@ -1,10 +1,9 @@
1
- import type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/scores';
2
1
  interface ToolCallAccuracyOptions {
3
2
  expectedTool?: string;
4
3
  strictMode?: boolean;
5
4
  expectedToolOrder?: string[];
6
5
  }
7
- export declare function createToolCallAccuracyScorerCode(options: ToolCallAccuracyOptions): import("@mastra/core/scores").MastraScorer<string, ScorerRunInputForAgent, ScorerRunOutputForAgent, Record<"preprocessStepResult", {
6
+ export declare function createToolCallAccuracyScorerCode(options: ToolCallAccuracyOptions): import("@mastra/core/scores").MastraScorer<"Tool Call Accuracy Scorer", import("@mastra/core/scores").ScorerRunInputForAgent, import("@mastra/core/scores").ScorerRunOutputForAgent, Record<"preprocessStepResult", {
8
7
  expectedTool: string | undefined;
9
8
  actualTools: string[];
10
9
  strictMode: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/code/tool-call-accuracy/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAI3F,UAAU,uBAAuB;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B;AAyDD,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,uBAAuB;;;;;;;;;gDAyDhF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/code/tool-call-accuracy/index.ts"],"names":[],"mappings":"AAEA,UAAU,uBAAuB;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B;AAyDD,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,uBAAuB;;;;;;;;;gDA0DhF"}
@@ -1,11 +1,10 @@
1
1
  import type { MastraLanguageModel } from '@mastra/core/agent';
2
- import type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/scores';
3
2
  export declare const DEFAULT_OPTIONS: Record<'uncertaintyWeight' | 'scale', number>;
4
3
  export declare const ANSWER_RELEVANCY_AGENT_INSTRUCTIONS = "\n You are a balanced and nuanced answer relevancy evaluator. Your job is to determine if LLM outputs are relevant to the input, including handling partially relevant or uncertain cases.\n\n Key Principles:\n 1. Evaluate whether the output addresses what the input is asking for\n 2. Consider both direct answers and related context\n 3. Prioritize relevance to the input over correctness\n 4. Recognize that responses can be partially relevant\n 5. Empty inputs or error messages should always be marked as \"no\"\n 6. Responses that discuss the type of information being asked show partial relevance\n";
5
4
  export declare function createAnswerRelevancyScorer({ model, options, }: {
6
5
  model: MastraLanguageModel;
7
6
  options?: Record<'uncertaintyWeight' | 'scale', number>;
8
- }): import("@mastra/core/scores").MastraScorer<string, ScorerRunInputForAgent, ScorerRunOutputForAgent, Record<"preprocessStepResult", {
7
+ }): import("@mastra/core/scores").MastraScorer<"Answer Relevancy Scorer", import("@mastra/core/scores").ScorerRunInputForAgent, import("@mastra/core/scores").ScorerRunOutputForAgent, Record<"preprocessStepResult", {
9
8
  statements: string[];
10
9
  }> & Record<"analyzeStepResult", {
11
10
  results: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/llm/answer-relevancy/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAM3F,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,mBAAmB,GAAG,OAAO,EAAE,MAAM,CAGzE,CAAC;AAEF,eAAO,MAAM,mCAAmC,wnBAU/C,CAAC;AAMF,wBAAgB,2BAA2B,CAAC,EAC1C,KAAK,EACL,OAAyB,GAC1B,EAAE;IACD,KAAK,EAAE,mBAAmB,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC,mBAAmB,GAAG,OAAO,EAAE,MAAM,CAAC,CAAC;CACzD;;;;;;;6FAyDA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/llm/answer-relevancy/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAO9D,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,mBAAmB,GAAG,OAAO,EAAE,MAAM,CAGzE,CAAC;AAEF,eAAO,MAAM,mCAAmC,wnBAU/C,CAAC;AAMF,wBAAgB,2BAA2B,CAAC,EAC1C,KAAK,EACL,OAAyB,GAC1B,EAAE;IACD,KAAK,EAAE,mBAAmB,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC,mBAAmB,GAAG,OAAO,EAAE,MAAM,CAAC,CAAC;CACzD;;;;;;;6FA0DA"}
@@ -1,5 +1,4 @@
1
1
  import type { MastraLanguageModel } from '@mastra/core/agent';
2
- import type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '@mastra/core/scores';
3
2
  export interface AnswerSimilarityOptions {
4
3
  requireGroundTruth?: boolean;
5
4
  semanticThreshold?: number;
@@ -14,7 +13,7 @@ export declare const ANSWER_SIMILARITY_INSTRUCTIONS = "\nYou are a precise answe
14
13
  export declare function createAnswerSimilarityScorer({ model, options, }: {
15
14
  model: MastraLanguageModel;
16
15
  options?: AnswerSimilarityOptions;
17
- }): import("@mastra/core/scores").MastraScorer<string, ScorerRunInputForAgent, ScorerRunOutputForAgent, Record<"preprocessStepResult", {
16
+ }): import("@mastra/core/scores").MastraScorer<"Answer Similarity Scorer", import("@mastra/core/scores").ScorerRunInputForAgent, import("@mastra/core/scores").ScorerRunOutputForAgent, Record<"preprocessStepResult", {
18
17
  outputUnits: string[];
19
18
  groundTruthUnits: string[];
20
19
  }> & Record<"analyzeStepResult", {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/llm/answer-similarity/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAM3F,MAAM,WAAW,uBAAuB;IACtC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,uBAAuB,CAQ/E,CAAC;AAEF,eAAO,MAAM,8BAA8B,+kBAU1C,CAAC;AA0BF,wBAAgB,4BAA4B,CAAC,EAC3C,KAAK,EACL,OAA2C,GAC5C,EAAE;IACD,KAAK,EAAE,mBAAmB,CAAC;IAC3B,OAAO,CAAC,EAAE,uBAAuB,CAAC;CACnC;;;;;;;;;;;;;;;;6FA4HA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/llm/answer-similarity/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAO9D,MAAM,WAAW,uBAAuB;IACtC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,uBAAuB,CAQ/E,CAAC;AAEF,eAAO,MAAM,8BAA8B,+kBAU1C,CAAC;AA0BF,wBAAgB,4BAA4B,CAAC,EAC3C,KAAK,EACL,OAA2C,GAC5C,EAAE;IACD,KAAK,EAAE,mBAAmB,CAAC;IAC3B,OAAO,CAAC,EAAE,uBAAuB,CAAC;CACnC;;;;;;;;;;;;;;;;6FA6HA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/llm/bias/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAW3F,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;IAAE,KAAK,EAAE,aAAa,CAAC;IAAC,OAAO,CAAC,EAAE,iBAAiB,CAAA;CAAE;;;;;;;6FA+CzG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/scorers/llm/bias/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAW3F,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;IAAE,KAAK,EAAE,aAAa,CAAC;IAAC,OAAO,CAAC,EAAE,iBAAiB,CAAA;CAAE;;;;;;;6FAgDzG"}
@@ -8,7 +8,7 @@ export interface ContextPrecisionMetricOptions {
8
8
  export declare function createContextPrecisionScorer({ model, options, }: {
9
9
  model: MastraLanguageModel;
10
10
  options: ContextPrecisionMetricOptions;
11
- }): import("@mastra/core/scores").MastraScorer<string, ScorerRunInputForAgent, ScorerRunOutputForAgent, Record<"analyzeStepResult", {
11
+ }): import("@mastra/core/scores").MastraScorer<"Context Precision Scorer", ScorerRunInputForAgent, ScorerRunOutputForAgent, Record<"analyzeStepResult", {
12
12
  verdicts: {
13
13
  verdict: string;
14
14
  reason: string;