Closed adityadafe closed 8 months ago
🤖
Hey @KaKashi1210! I'm Dosu, a friendly bot here to lend a hand with bugs, answer questions, and guide you to be an awesome contributor. While we're waiting for a human maintainer, I'm here to help. Let's dive into this together. 😊
The error you're encountering might be due to the way hnswlib-node
is being imported in the HNSWLib
class. The error message suggests that the hnswlib-node
library is not found, which could be due to a number of reasons:
The hnswlib-node
library is not installed. You can install it using npm install hnswlib-node
.
The hnswlib-node
library is installed, but it's not in the correct location where the code is looking for it. Make sure that the hnswlib-node
library is in the node_modules
directory of your project.
There might be an issue with the way the hnswlib-node
library is being imported. The hnswlib-node
library is being imported using a dynamic import statement, which might not be supported in your environment. You can try changing the dynamic import statement to a static import statement at the top of your file.
Here is the part of the code that might be causing the issue:
static async imports(): Promise<{
HierarchicalNSW: typeof HierarchicalNSWT;
}> {
try {
const {
default: { HierarchicalNSW },
} = await import("hnswlib-node");
return { HierarchicalNSW };
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
throw new Error(
`Could not import hnswlib-node. Please install hnswlib-node as a dependency with, e.g. \`npm install -S hnswlib-node\`.\n\nError: ${err?.message}`
);
}
}
You can try changing the dynamic import statement to a static import statement like this:
import { HierarchicalNSW } from "hnswlib-node";
And then use HierarchicalNSW
directly in your code without the need to import it dynamically.
You can find this code in the libs/langchain-community/src/vectorstores/hnswlib.ts file.
If you're still encountering issues, could you please provide more details about the error message you're seeing and the steps you're taking when the error occurs? This will help me better understand the issue and provide a more accurate solution.
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
same here
It looks like you're using bun
- can you try with just base node
?
It might be worth opening an issue/PR on the HNSW package for bun
support.
@jacoblee93 thanks for the idea much appreciated <3
use bun 1.1.0+
same here, but I am using Node 18.18.0 - any recommendations please?
After Installing hnswlib-node the issue persists-