"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPrompt = getPrompt;
const envars_1 = require("../envars");
const langfuseParams = {
    publicKey: (0, envars_1.getEnvString)('LANGFUSE_PUBLIC_KEY'),
    secretKey: (0, envars_1.getEnvString)('LANGFUSE_SECRET_KEY'),
    baseUrl: (0, envars_1.getEnvString)('LANGFUSE_HOST'),
};
let langfuse;
async function getPrompt(id, vars, type, version) {
    let prompt;
    if (!langfuse) {
        const { Langfuse } = await import('langfuse');
        langfuse = new Langfuse(langfuseParams);
    }
    if (type === 'text' || type === undefined) {
        prompt = await langfuse.getPrompt(id, version, { type: 'text' });
    }
    else {
        prompt = await langfuse.getPrompt(id, version, { type: 'chat' });
    }
    const compiledPrompt = prompt.compile(vars);
    if (typeof compiledPrompt !== 'string') {
        return JSON.stringify(compiledPrompt);
    }
    return compiledPrompt;
}
//# sourceMappingURL=langfuse.js.map