|
1 | 1 | import { z } from "zod"; |
2 | 2 | import type { EvalScorerArgs } from "braintrust"; |
| 3 | +import { GetResponseTool } from "./tool/getResponse.js"; |
| 4 | +import { GetConversationTool } from "./tool/getConversation.js"; |
| 5 | +import { GetReferenceAnswerTool } from "./tool/getReferenceAnswer.js"; |
3 | 6 |
|
4 | 7 | // ╭──────────────────────────────────────────────╮ |
5 | 8 | // │ ↘️ "Input" Types in Eval │ |
@@ -80,13 +83,38 @@ export const RunEvalInputSchema = z |
80 | 83 | /** Eval `expected`: the criteria the LLM judge grades the answer against. */ |
81 | 84 | export const RunEvalExpectedSchema = z |
82 | 85 | .object({ |
83 | | - llm_judge: z |
84 | | - .union([z.string(), z.array(z.string())]) |
| 86 | + llm_judge: z.union([z.string()]).optional() |
| 87 | + .describe(`Provide a prompt for the LLM judge to evaluate and make assertions about: |
| 88 | +- the state of the database after the assistant completes the prompt. The judge may use any available read-only MCP tools to check and validate these assertions. |
| 89 | +- if prompt references ${GetResponseTool.keyword}, the assistant’s response for this eval case will be made available for evaluation. |
| 90 | +- if prompt references ${GetConversationTool.keyword}, the full conversation history, including tool calls and tool results for this eval case, will be accessible for evaluation. |
| 91 | +- if prompt references ${GetReferenceAnswerTool.keyword}, the reference answer as specified in the "expected.reference_answer" field will be made available for evaluation. |
| 92 | +`), |
| 93 | + reference_answer: z |
| 94 | + .string() |
85 | 95 | .optional() |
86 | | - .describe("Grading criteria (one string or several) the LLM judge checks the output against."), |
| 96 | + .describe( |
| 97 | + `The reference answer for the eval case. This provides human reviewers with a clear example of the expected answer. |
| 98 | + If the LLM judge prompt references ${GetReferenceAnswerTool.keyword}, this value will be made available to the judge for automated evaluation.` |
| 99 | + ), |
87 | 100 | }) |
88 | 101 | .describe("Expected outcome for a case, expressed as LLM-judge criteria."); |
89 | 102 |
|
| 103 | +// ╭──────────────────────────────────────────────╮ |
| 104 | +// │ ↘️ "Metadata" Types in Eval │ |
| 105 | +// ╰──────────────────────────────────────────────╯ |
| 106 | + |
| 107 | +export const RunEvalMetadataSchema = z |
| 108 | + .object({ |
| 109 | + name: z.string().describe("A short, descriptive name for this eval case."), |
| 110 | + description: z.string().describe("A brief summary explaining what this eval case tests."), |
| 111 | + category: z.string().optional().describe("The primary (level 1) taxonomy category for this eval case."), |
| 112 | + subcategory: z.string().optional().describe("The secondary (level 2) taxonomy subcategory for this eval case."), |
| 113 | + group: z.string().optional().describe("Level 3 taxonomy group for this eval case."), |
| 114 | + subGroup: z.string().optional().describe("Level 4 taxonomy subgroup for this eval case."), |
| 115 | + }) |
| 116 | + .describe("Metadata for a single MongoDB agent eval case."); |
| 117 | + |
90 | 118 | // ╭──────────────────────────────────────────────╮ |
91 | 119 | // │ ↘️ "Output" Types in Eval │ |
92 | 120 | // ╰──────────────────────────────────────────────╯ |
|
0 commit comments