"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "LLMQuestionGenerator", {
    enumerable: true,
    get: function() {
        return LLMQuestionGenerator;
    }
});
const _OutputParser = require("./OutputParser.js");
const _Prompt = require("./Prompt.js");
const _openai = require("./llm/openai.js");
const _index = require("./prompts/index.js");
class LLMQuestionGenerator extends _index.PromptMixin {
    llm;
    prompt;
    outputParser;
    constructor(init){
        super();
        this.llm = init?.llm ?? new _openai.OpenAI();
        this.prompt = init?.prompt ?? _Prompt.defaultSubQuestionPrompt;
        this.outputParser = init?.outputParser ?? new _OutputParser.SubQuestionOutputParser();
    }
    _getPrompts() {
        return {
            subQuestion: this.prompt
        };
    }
    _updatePrompts(promptsDict) {
        if ("subQuestion" in promptsDict) {
            this.prompt = promptsDict.subQuestion;
        }
    }
    async generate(tools, query) {
        const toolsStr = (0, _Prompt.buildToolsText)(tools);
        const queryStr = query;
        const prediction = (await this.llm.complete({
            prompt: this.prompt({
                toolsStr,
                queryStr
            })
        })).text;
        const structuredOutput = this.outputParser.parse(prediction);
        return structuredOutput.parsedOutput;
    }
}
