import { jsonrepair } from "jsonrepair";
import { z } from "zod";
import { makeParseableResponseFormat } from "openai/lib/parser";
export function zodResponseFormat(zodObject, name, props) {
    return makeParseableResponseFormat({
        type: "json_schema",
        json_schema: {
            ...props,
            name,
            strict: true,
            schema: z.toJSONSchema(zodObject, { target: "draft-7" }),
        },
    }, (content) => zodObject.parse(JSON.parse(jsonrepair(content))));
}
