You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm very interested in the world of WebML and for me Transformer.js is one of the most promising libraries in this field, so I'd like to thank all the contributors to this library.
But right now I'm working on a personal project make in next.js and I've run into a lot of issues trying to get transformer.js to work in client-side components.
First when I set the configuration of next.js as the documentation states i.e.
/** @type {import('next').NextConfig} */constnextConfig={// (Optional) Export as a static site// See https://nextjs.org/docs/pages/building-your-application/deploying/static-exports#configurationoutput: 'export',// Feel free to modify/remove this option// Override the default webpack configurationwebpack: (config)=>{// See https://webpack.js.org/configuration/resolve/#resolvealiasconfig.resolve.alias={
...config.resolve.alias,"sharp$": false,"onnxruntime-node$": false,}returnconfig;},}module.exports=nextConfig
I get this error
Module not found: Can't resolve './'
I get this error even if i make this configuration
But after that I still have problems when I want to use the pipeline function to do text-generation with onnx-community/Llama-3.2-1B-Instruct as the documentation states https://huggingface.co/blog/llama32#transformersjs
my code :
"use client"exportasyncfunctionhandleFreeMode(){const{ pipeline }=awaitimport("@huggingface/transformers")constgenerator=awaitpipeline("text-generation","onnx-community/Llama-3.2-1B-Instruct");// Define the list of messagesconstmessages=[{role: "system",content: "You are a helpful assistant."},{role: "user",content: "Tell me a joke."},];// Generate a responseconstoutput=awaitgenerator(messages,{max_new_tokens: 128});console.log(output[0].generated_text.at(-1).content);returnoutput[0].generated_text.at(-1).content;}
the error :
transformers.cjs:3971 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'create')
at createInferenceSession (transformers.cjs:3971:45)
at eval (transformers.cjs:7090:108)
at async Promise.all (:3000/fr/148/index 0)
at async constructSessions (transformers.cjs:7087:31)
at async Promise.all (:3000/fr/148/index 0)
at async LlamaForCausalLM.from_pretrained (transformers.cjs:7643:20)
at async AutoModelForCausalLM.from_pretrained (transformers.cjs:12826:20)
at async Promise.all (:3000/fr/148/index 1)
at async loadItems (transformers.cjs:17386:5)
at async pipeline (transformers.cjs:17316:21)
at async handleFreeMode (ClientSide.ts:5:23)
at async handleSubmit (Chatbot.tsx:60:20)
Thank you in advance if anyone in the community can help me solve this problem.
Reproduction
Use next.js v14.2
Use transformer.js v3
The text was updated successfully, but these errors were encountered:
System Info
Transfomer.js version: "@huggingface/transformers": "^3.0.2"
Next.js version: "next": "14.2.5"
React version: "react": "^18",
OS that run next.js : windows11
Environment/Platform
Description
I'm very interested in the world of WebML and for me Transformer.js is one of the most promising libraries in this field, so I'd like to thank all the contributors to this library.
But right now I'm working on a personal project make in next.js and I've run into a lot of issues trying to get transformer.js to work in client-side components.
First when I set the configuration of next.js as the documentation states i.e.
I get this error
I get this error even if i make this configuration
If i make this configuration i have the same error of previously
The only configuration that work for me is
But after that I still have problems when I want to use the pipeline function to do text-generation with onnx-community/Llama-3.2-1B-Instruct as the documentation states https://huggingface.co/blog/llama32#transformersjs
my code :
the error :
Reproduction
Use next.js v14.2
Use transformer.js v3
The text was updated successfully, but these errors were encountered: