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

Can this be used on Node? #22

Closed
gunta opened this issue Mar 17, 2023 · 8 comments
Closed

Can this be used on Node? #22

gunta opened this issue Mar 17, 2023 · 8 comments

Comments

@gunta
Copy link

gunta commented Mar 17, 2023

I've tested on Node 18 and latest Bun, both don't work.

@xenova
Copy link
Collaborator

xenova commented Mar 17, 2023

What errors are you getting? Others have had similar problems due to a bug in ONNX runtime web. Check out this thread for some fixes: #4

@epigramengineer
Copy link

I'm trying to run this on my sveltekit server code (instead of browser) with pretty much the documented setup:

import { pipeline } from "@xenova/transformers";


export const load: PageServerLoad = async ({ locals }) => {
  let pipe = await pipeline('summarization');
  let summary = await pipe("I am happy");

  return {
    summary
  };
};

And I'm getting the error:

TypeError: Cannot read properties of undefined (reading 'pipeline')
    at load (projects/web/src/routes/+page.server.ts:33:19)
    at Module.load_server_data (/node_modules/@sveltejs/kit/src/runtime/server/page/load_data.js:43:41)
    at /node_modules/@sveltejs/kit/src/runtime/server/page/index.js:141:18
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

If I move it into the page instead of the server i get the same error, though maybe that's because of ssr?

Anyway super cool project you've got here I'm very excited to use it, I just have no idea what I'm doing in general lol

@xenova
Copy link
Collaborator

xenova commented Mar 17, 2023

Hmm - for some reason it's not picking up the module. I assume you've installed it correctly (npm i @xenova/transformers)? I unfortunately haven't been able to test it in many different environments (such as sveltekit), so, I'm a little out-of-my-depth here. Perhaps someone else can provide some help?

I just have no idea what I'm doing in general lol

Same... 🤣

@chelouche9
Copy link
Contributor

Hi @epigramengineer,

I also ran into behaviors like that when using Next.js. I think that the library is trying to use some browser features.
For me, it helped move the code into the code running on the client (like onClick of the button) and do the import dynamically.

export const onClick = async () => {
  const { pipeline } = await import("@xenova/transformers")
  let pipe = await pipeline('summarization');
  let summary = await pipe("I am happy");

  return {
    summary
  };
};

@epigramengineer
Copy link

Follow up; somehow I didn't install it correctly 🤦

It's working for me now in the server code as well :) Had to use the env.onnx.wasm.numThreads = 1 fix mentioned in other another issue

@xenova
Copy link
Collaborator

xenova commented Mar 18, 2023

Great! Thanks for following up.

The numThreads fix is unfortunately necessary due to a bug in onnxruntime itself (microsoft/onnxruntime#14445). Hopefully they will fix it soon. Otherwise, I might have to add a check to see if the user is running node, then override this value.

Closing the issue for now. Feel free to reopen/open a new issue if something else arises.

@wokutesh
Copy link

wokutesh commented Mar 7, 2024

when I use the pipeline of @xenova/transformers in my project it return the error 'pipeline is undefined' my project is built in react using vite platform , I have already installed dependencies needed, so why it don't work

@xenova
Copy link
Collaborator

xenova commented Mar 7, 2024

@wokutesh Feel free to open a new issue with more information. I'd be happy to assist.

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

No branches or pull requests

5 participants