llamaindex
Version:
<p align="center"> <img height="100" width="100" alt="LlamaIndex logo" src="https://ts.llamaindex.ai/square.svg" /> </p> <h1 align="center">LlamaIndex.TS</h1> <h3 align="center"> Data framework for your LLM application. </h3>
51 lines (47 loc) • 2.5 kB
JavaScript
Object.defineProperty(exports, '__esModule', { value: true });
var node_module = require('node:module');
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
const nodeRequire = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
const nextJsVersion = nodeRequire("next/package.json").version;
const is14OrLower = nextJsVersion.startsWith("14.") || nextJsVersion.startsWith("13.");
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function withLlamaIndex(config) {
// needed for transformers, see https://huggingface.co/docs/transformers.js/en/tutorials/next#step-2-install-and-configure-transformersjs
if (is14OrLower) {
config.experimental.serverComponentsExternalPackages = config.experimental.serverComponentsExternalPackages ?? [];
config.experimental.serverComponentsExternalPackages.push("@huggingface/transformers");
} else {
config.serverExternalPackages = config.serverExternalPackages ?? [];
config.serverExternalPackages.push("@huggingface/transformers");
}
const userWebpack = config.webpack;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
config.webpack = function(webpackConfig, options) {
if (userWebpack) {
webpackConfig = userWebpack(webpackConfig, options);
}
webpackConfig.resolve.alias = {
...webpackConfig.resolve.alias,
"@google-cloud/vertexai": false
};
// Disable modules that are not supported in vercel edge runtime
if (options?.nextRuntime === "edge") {
webpackConfig.resolve.alias["replicate"] = false;
}
// Following lines will fix issues with onnxruntime-node when using pnpm
// See: https://github.com/vercel/next.js/issues/43433
const externals = {
"onnxruntime-node": "commonjs onnxruntime-node",
sharp: "commonjs sharp",
chromadb: "chromadb",
unpdf: "unpdf"
};
if (options?.nextRuntime === "nodejs") {
externals.replicate = "commonjs replicate";
}
webpackConfig.externals.push(externals);
return webpackConfig;
};
return config;
}
exports.default = withLlamaIndex;