"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, {
    getEmbeddedModel: function() {
        return getEmbeddedModel;
    },
    setEmbeddedModel: function() {
        return setEmbeddedModel;
    },
    withEmbeddedModel: function() {
        return withEmbeddedModel;
    }
});
const _env = require("@llamaindex/env");
const _OpenAIEmbedding = require("../../embeddings/OpenAIEmbedding.js");
const embeddedModelAsyncLocalStorage = new _env.AsyncLocalStorage();
let globalEmbeddedModel = null;
function getEmbeddedModel() {
    if (globalEmbeddedModel === null) {
        globalEmbeddedModel = new _OpenAIEmbedding.OpenAIEmbedding();
    }
    return embeddedModelAsyncLocalStorage.getStore() ?? globalEmbeddedModel;
}
function setEmbeddedModel(embeddedModel) {
    globalEmbeddedModel = embeddedModel;
}
function withEmbeddedModel(embeddedModel, fn) {
    return embeddedModelAsyncLocalStorage.run(embeddedModel, fn);
}
