"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.summarizeFormWithLLM = void 0;
const prompt_1 = require("./prompt");
/**
 * Uses LLM to summarize form data in a specified format and language.
 * The function follows these steps:
 * 1. Formats prompt with form data and preferences
 * 2. Runs LLM with appropriate system prompt
 * 3. Returns formatted summary with disclaimer
 *
 * @example
 * const result = await summarizeFormWithLLM({
 *   model,
 *   formData: "Name: John Doe\nAge: 30\n...",
 *   summaryFormat: "Bullet-points",
 *   language: "English",
 *   disclaimerMessage: "AI generated...",
 *   additionalInstructions: "Focus on medication details",
 *   metadata: { ... }
 * })
 */
const summarizeFormWithLLM = async ({ model, formData, summaryFormat, language, disclaimerMessage, additionalInstructions, metadata, callbacks, }) => {
    const systemPrompt = summaryFormat === 'Bullet-points' ? prompt_1.systemPromptBulletPoints :
        summaryFormat === 'Text paragraph' ? prompt_1.systemPromptTextParagraph :
            prompt_1.systemPromptBulletPoints; // Default to bullet points if unknown format
    const prompt = await systemPrompt.format({
        language,
        input: formData,
        disclaimerMessage,
        additionalInstructions: additionalInstructions !== null && additionalInstructions !== void 0 ? additionalInstructions : 'No additional instructions',
    });
    try {
        const result = await model.invoke(prompt, {
            metadata,
            runName: 'ShellySummarizeForm',
            callbacks
        });
        return result.content;
    }
    catch (error) {
        throw new Error('Failed to generate form summary');
    }
};
exports.summarizeFormWithLLM = summarizeFormWithLLM;
//# sourceMappingURL=summarizeFormWithLLM.js.map