UNPKG

mongodb-rag-core

Version:

Common elements used by MongoDB Chatbot Framework components.

39 lines (38 loc) 1.51 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getConversationsEvalCasesFromYaml = exports.ConversationEvalCaseSchema = void 0; const yaml_1 = __importDefault(require("yaml")); const zod_1 = require("zod"); exports.ConversationEvalCaseSchema = zod_1.z.object({ name: zod_1.z.string(), expectation: zod_1.z .string() .optional() .describe("Description of what the test case assesses. Used to evaluate against."), messages: zod_1.z .array(zod_1.z.object({ role: zod_1.z.enum(["assistant", "user", "system"]), content: zod_1.z.string(), })) .min(1), tags: zod_1.z.array(zod_1.z.string()).optional(), skip: zod_1.z.boolean().optional(), expectedLinks: zod_1.z .array(zod_1.z.string()) .optional() .describe("Sections of links to relevant sources"), }); /** Get conversation eval cases from YAML file. Throws if the YAML is not correctly formatted. */ function getConversationsEvalCasesFromYaml(yamlData) { const yamlEvalCases = yaml_1.default.parse(yamlData); const evalCases = yamlEvalCases.map((tc) => exports.ConversationEvalCaseSchema.parse(tc)); return evalCases; } exports.getConversationsEvalCasesFromYaml = getConversationsEvalCasesFromYaml; //# sourceMappingURL=getConversationEvalCasesFromYaml.js.map