Skip to content
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

fix: move fastembed import to the isnode condition check #709

Merged
merged 2 commits into from
Nov 30, 2024

Conversation

antpb
Copy link
Contributor

@antpb antpb commented Nov 30, 2024

In current state it looks like we had a bit of a regression importing fastembed at the top level again, which causes build failures in non-Node environments due to native dependencies (.node files) like Cloudflare Workers and other edge workers.

This PR:

  • Removes top-level import of EmbeddingModel from fastembed
  • Dynamically imports fastembed package only when local embeddings are needed
  • Ensures native modules are only loaded in Node.js environment

This allows the package to be built for both browser and Node.js environments while maintaining all existing functionality.

Testing:

  • Confirm local embeddings still work in Node.js
  • Verify builds succeed in browser/Cloudflare Worker environments (done!)
  • Maintained original behavior for remote embedding fallbacks

@augchan42
Copy link
Contributor

Sorry, that change was from me. Now I understand why it's needed.

@shakkernerd
Copy link
Member

Great!

@shakkernerd shakkernerd merged commit 9029c2b into elizaOS:main Nov 30, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants