@mastra/fastembed 1.3.5-alpha.0 → 1.3.5-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +5 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -18416,7 +18416,7 @@ function loadTokenizerFromDir(modelDir, maxLength) {
|
|
|
18416
18416
|
const tokenizerFilePath = path.join(modelDir.toString(), "tokenizer_config.json");
|
|
18417
18417
|
if (!fs.existsSync(tokenizerFilePath)) throw new Error(`Tokenizer config file not found at ${tokenizerFilePath}`);
|
|
18418
18418
|
const tokenizerConfig = JSON.parse(fs.readFileSync(tokenizerFilePath, "utf-8"));
|
|
18419
|
-
maxLength = Math.min(maxLength, tokenizerConfig["model_max_length"]);
|
|
18419
|
+
maxLength = Math.min(maxLength, tokenizerConfig["model_max_length"] ?? maxLength);
|
|
18420
18420
|
const tokensMapPath = path.join(modelDir.toString(), "special_tokens_map.json");
|
|
18421
18421
|
if (!fs.existsSync(tokensMapPath)) throw new Error(`Tokens map file not found at ${tokensMapPath}`);
|
|
18422
18422
|
const tokensMap = JSON.parse(fs.readFileSync(tokensMapPath, "utf-8"));
|
|
@@ -18626,7 +18626,10 @@ var SparseTextEmbedding = class SparseTextEmbedding extends SparseEmbedding {
|
|
|
18626
18626
|
return { tokenizer: loadTokenizerFromDir(modelDir, maxLength) };
|
|
18627
18627
|
}
|
|
18628
18628
|
static async retrieveModel(model, cacheDir, _showDownloadProgress = true) {
|
|
18629
|
-
if (!fs.existsSync(cacheDir)) fs.mkdirSync(cacheDir, {
|
|
18629
|
+
if (!fs.existsSync(cacheDir)) fs.mkdirSync(cacheDir, {
|
|
18630
|
+
recursive: true,
|
|
18631
|
+
mode: 493
|
|
18632
|
+
});
|
|
18630
18633
|
const modelDir = path.join(cacheDir.toString(), model.replace("/", "_"));
|
|
18631
18634
|
if (fs.existsSync(modelDir)) return modelDir;
|
|
18632
18635
|
const filesToDownload = [
|