-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nextjs invalid exports #824
Comments
Answer generated by a 🤖 AnswerFrom your description, it appears that you're encountering an issue with Next.js where it's unable to find the module To address this, you could modify the {
"name": "@visheratin/web-ai",
"version": "1.0.0",
"main": "index.js",
"exports": {
".": "./index.js"
}
} In this example, the However, if you don't have the ability to modify the Here's an example of how you could adjust the export class WebAIEmbeddingFunction implements IEmbeddingFunction {
// ...
constructor(
modality: "text" | "image",
node: boolean,
proxy?: boolean,
wasmPath?: string,
modelID?: string
) {
if (node) {
this.proxy = proxy ? proxy : false;
import("@visheratin/web-ai-node")
.then((module) => {
webAI = module;
})
.catch((e) => {
console.log(e);
throw new Error(
"Please install the @visheratin/web-ai-node package to use the WebAIEmbeddingFunction, `npm install -S @visheratin/web-ai-node`"
);
});
} else {
this.proxy = proxy ? proxy : true;
import("@visheratin/web-ai")
.then((module) => {
webAI = module;
})
.catch((e) => {
console.log(e);
throw new Error(
"Please install the @visheratin/web-ai package to use the WebAIEmbeddingFunction, `npm install -S @visheratin/web-ai`"
);
});
}
// ...
}
// ...
} In this revised version of the Please note that this is just one potential solution to your problem. If you find this solution to be correct and believe it could benefit other users, I encourage you to make a pull request. If this solution doesn't align with your experience, I recommend updating to the latest version of the software. SourcesThis response is meant to be useful, save you time, and share context. 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. |
I got this error with using Next JS using the newer I rolled back to |
Chiming in here - confirmed that rolling back to |
@cishiv thanks!! if anyone can help me with a small reproducible example - id love to fix this |
Hi @jeffchuber Here is a repo: This is currently using If I upgrade to If I go through the process of adding each dependency I hope this helps |
thank you @e-roy ! asking Vercel for help on this |
From a quick look I think the problem is that the CJS build of
And then, a require("@visheratin/web-ai") So it tries to load the CJS build of "exports": {
".": {
"types": "./index.d.ts",
"import": "./index.js"
}, Which doesn't have a CJS build provided for that path at all. To fix, you have to either use |
## Description of changes After the recent changes in the Web AI structure, the embedder function became invalid because of different imports and because the browser version of the library is only ESM, as mentioned [here](#824 (comment)). To fix the issue, I updated the import paths and changed the `require` statements to `import` for the browser version of the function. **Important note:** When using the embedded in the browser, you should import `chromadb/dist/module` because the [browser version](https://www.npmjs.com/package/@visheratin/web-ai) of Web AI is ESM-only. For Node.js, you can use regular `chromadb` import because [Node.js version](https://www.npmjs.com/package/@visheratin/web-ai-node) of the library is CJS. Additionally, because Web AI since recently supports multimodal embeddings, I added building multimodal embeddings using CLIP-base. ## Test plan I tested the changes locally for both browser and Node.js. The built `chromadb` package if someone wants to test it in their projects, is available [here](https://drive.google.com/file/d/1cNLsHGd1VmiFiamvsEaMVGA7ng56QQKG/view?usp=sharing). ## Documentation Changes There likely will be needed changes regarding the multimodal functionality.
You will still have this error when you use the ESM build.
The problem here is, that the package @shuding can you confirm that? |
I just checked and can confirm that this issue exists. When working on a fix, I didn't consider this use case. To fix the issue in version 1.5.6 of the package for Next.js, you can add the following to the Webpack config in
This way, the app will get compiled. If somebody knows how to fix this issue in the |
I already fixed the |
I was having this same issue on a Vue app I'm working on. I found the following script roughly fixes the import problem so my app will build properly. Not a great solution, but works.
|
we are close to fixing this up thanks to some excellent work by @perzeuss ! stand by :) |
well unfortunately neither the PR was merged nor does the custom webpack config work for me. Would be great not to have to build a workaround or rolling back to prev. versions to fix the issue. |
This should be fixed in the release |
@jeffchuber
|
@jonsoku2 Are you trying to use the webai embedding function or only the chroma client? |
This seems to be working fine now with Next JS, using: Here is a working example: https://github.com/e-roy/langchain-chatbot-demo/tree/main For this error:
You can adjust your
|
interesting! Will try out. Thx for notifying! |
This is fixed with |
From discord: https://discord.com/channels/1073293645303795742/1130258136905814066/1130258136905814066
The text was updated successfully, but these errors were encountered: