@naktibalda/jorel
Version:
The easiest way to use LLMs, including streams, images, documents, tools and various agent scenarios.
31 lines (30 loc) • 939 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.jsonResponseToMistral = void 0;
const zod_1 = require("zod");
const shared_1 = require("../../shared");
const jsonResponseToMistral = (format, schemaDescription) => {
if (!format) {
return {
type: "text",
};
}
else if (typeof format === "boolean") {
return {
type: "json_object",
};
}
else if (typeof format === "object") {
return {
type: "json_schema",
jsonSchema: {
name: "json_schema",
description: schemaDescription,
schemaDefinition: format instanceof zod_1.ZodObject ? (0, shared_1.zodSchemaToJsonSchema)(format, "openAi") : format,
strict: true,
},
};
}
throw new Error("Invalid format");
};
exports.jsonResponseToMistral = jsonResponseToMistral;