agsamantha/node_modules/langchain/dist/util/load.cjs
2024-10-02 15:15:21 -05:00

14 lines
465 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadFromFile = void 0;
const loadFromFile = async (uri, loader, values = {}) => {
try {
const fs = await import("node:fs/promises");
return loader(await fs.readFile(uri, { encoding: "utf-8" }), uri, values);
}
catch (e) {
console.error(e);
throw new Error(`Could not load file at ${uri}`);
}
};
exports.loadFromFile = loadFromFile;