"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    serviceContextFromDefaults: function() {
        return serviceContextFromDefaults;
    },
    serviceContextFromServiceContext: function() {
        return serviceContextFromServiceContext;
    }
});
const _PromptHelper = require("./PromptHelper.js");
const _OpenAIEmbedding = require("./embeddings/OpenAIEmbedding.js");
const _openai = require("./llm/openai.js");
const _SimpleNodeParser = require("./nodeParsers/SimpleNodeParser.js");
function serviceContextFromDefaults(options) {
    const serviceContext = {
        llm: options?.llm ?? new _openai.OpenAI(),
        embedModel: options?.embedModel ?? new _OpenAIEmbedding.OpenAIEmbedding(),
        nodeParser: options?.nodeParser ?? new _SimpleNodeParser.SimpleNodeParser({
            chunkSize: options?.chunkSize,
            chunkOverlap: options?.chunkOverlap
        }),
        promptHelper: options?.promptHelper ?? new _PromptHelper.PromptHelper()
    };
    return serviceContext;
}
function serviceContextFromServiceContext(serviceContext, options) {
    const newServiceContext = {
        ...serviceContext
    };
    if (options.llm) {
        newServiceContext.llm = options.llm;
    }
    if (options.promptHelper) {
        newServiceContext.promptHelper = options.promptHelper;
    }
    if (options.embedModel) {
        newServiceContext.embedModel = options.embedModel;
    }
    if (options.nodeParser) {
        newServiceContext.nodeParser = options.nodeParser;
    }
    return newServiceContext;
}
