"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.detectLanguageWithLLM = void 0;
const prompt_1 = require("./prompt");
/**
 * Uses LLM to detect the language of a given text.
 * The function follows these steps:
 * 1. Formats prompt with the input text
 * 2. Runs LLM to identify the language
 * 3. Returns the full language name (e.g., "English", "Croatian")
 */
const detectLanguageWithLLM = async ({ model, text, metadata, callbacks, }) => {
    const prompt = await prompt_1.systemPrompt.format({
        input: text,
    });
    try {
        const result = await model.invoke(prompt, {
            metadata,
            runName: 'ShellyDetectLanguage',
            callbacks
        });
        return result.content;
    }
    catch (error) {
        throw new Error('Failed to detect language');
    }
};
exports.detectLanguageWithLLM = detectLanguageWithLLM;
//# sourceMappingURL=detectLanguageWithLLM.js.map