"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractDatesFromInstructions = void 0;
const parser_1 = require("./parser");
const prompt_1 = require("./prompt");
const extractDatesFromInstructions = async ({ model, prompt, metadata, callbacks, }) => {
    const chain = model.pipe(parser_1.parser);
    try {
        const result = (await chain.invoke(await prompt_1.systemPrompt.format({
            currentDateTime: new Date().toISOString(),
            prompt,
        }), {
            metadata,
            runName: 'ElationExtractDatesFromInstructions',
            callbacks,
        }));
        return {
            from: result.from,
            to: result.to,
            instructions: result.instructions,
        };
    }
    catch (error) {
        throw new Error(`Failed to extract dates from instructions. LLM reported error: ${error instanceof Error ? error.message : 'Unknown error'}`);
    }
};
exports.extractDatesFromInstructions = extractDatesFromInstructions;
//# sourceMappingURL=extractDatesFromInstructions.js.map