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

Demo #15

Open
DawChihLiou opened this issue Mar 27, 2023 · 15 comments
Open

Demo #15

DawChihLiou opened this issue Mar 27, 2023 · 15 comments
Assignees

Comments

@DawChihLiou
Copy link
Contributor

No description provided.

@DawChihLiou DawChihLiou self-assigned this Mar 27, 2023
@josephrocca
Copy link

josephrocca commented Apr 4, 2023

I've just tested the code in the readme on node.js and I'm getting a bunch of different import errors. I've also tried to get it working in the browser but am getting this:

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/wasm". Strict MIME type checking is enforced for module scripts per HTML spec.

I'm really only interested in getting it working in the browser - just tested in node.js after getting this wasm module loading error. Seems like wasm module loading via ESM syntax is only phase 2? https://github.com/WebAssembly/esm-integration/tree/main/proposals/esm-integration

@DawChihLiou
Copy link
Contributor Author

Hey @josephrocca thanks for your question! Please check out #6 (comment) for more info.

@josephrocca
Copy link

Do you not intend to make it import-able with a simple import statement in the browser? Or is this just a temporary workaround?

@DawChihLiou
Copy link
Contributor Author

Currently WASM modules requires dynamic import in browsers and node.js. I'll look into it to make it easier to import in browsers. Do you mind sharing your use case with me so I understand more about your needs? Thanks!

@josephrocca
Copy link

Use case: https://github.com/josephrocca/OpenCharacters - to handle character memory storage/recall

Currently I'm doing a brute force cosine similarity search - it'll be fine for short chats but might become slow if the character/agent accumulates thousands of memories.

@GarciaLnk
Copy link

GarciaLnk commented Apr 12, 2023

The simplest solution to support browser imports would be building and bundling a version targeting browsers (as I suggested in #6) inside the current npm package and doing import * as voy from "voy-search/web" when needed, additionally you'd need to call await voy.default("voy_search_bg.wasm") before using voy.

The same would apply to a node version building against the nodejs target.

It's not a perfect solution, but it's better than the current options (my current solution is having a git submodule linked and running git -C voy pull && wasm-pack build -t web voy on pnpm preinstall).

@MentalGear
Copy link

@GarciaLnk sounds neat, would you be able to add a PR for this ?

@DawChihLiou
Copy link
Contributor Author

@GarciaLnk have you tried #6 (comment)? If it doesn't work, I'll work on the build for web.

<script src="https://www.unpkg.com/[email protected]/voy_search.js" type="module"></script>

@kwkr
Copy link

kwkr commented Sep 6, 2023

Hi @DawChihLiou !
I'm currently working on integrating Voy into LangChain.js and I got a few questions while playing with the library. The environment that I was working with was mainly Node.js 18. First I tried to follow the example usage in the README but I quickly got into trouble with utilizing the dynamic import. Are the instructions contained there intended only for browsers? I'm not sure whether it might be useful to include it somewhere in the README, but from my perspective, this information could have potentially saved me some debugging time.

After some time I was able to run the code in the Node environment, although it needed some adjustments:

  • I needed to include --experimental-wasm-modules in order to correctly include .wasm files.
  • I needed to add "type":"module","main":"voy_search.js" in the package.json in order to correctly import the module.
    When I did this I could run some example code using Node environment.

Do the changes that I've made make sense in my case or am I missing some easier way to run this?
Would it be useful to you to have this information somewhere within the README? If so, if you would be willing to assist me with some hints and review it, I would be glad to create a PR for it.

@DawChihLiou
Copy link
Contributor Author

Hey @kwkr thanks for the comment! The configuration besides the "main" property in your package.json should work. I'm more than happy to review if you'd like to creat a PR! Thanks so much!

@kwkr
Copy link

kwkr commented Sep 8, 2023

I wasn't precise with specifying which package.json I modified. I needed to modify the package.json of the voy-search inside node_modules. Should this work with Node without those modifications?

@DawChihLiou
Copy link
Contributor Author

Yes that's correct. If it doesn't work, please let me know. I'm currently on vacation but I'll take a look at it as soon as I get back. Thanks!

@DawChihLiou
Copy link
Contributor Author

Hey @kwkr just came across your integration in LangChain.js. Amazing work! Is your issue resolved?

@kwkr
Copy link

kwkr commented Sep 19, 2023

Yes, I managed to integrate it. The question is whether the information I needed in order to do that should be included in the README of your package as well because as I mentioned, I needed a few workarounds.

@DawChihLiou
Copy link
Contributor Author

@kwkr I'll work in a build for Node. Thanks for your suggestion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

5 participants