Hello guys im trying use @xenova/transformers as known transformers package by Hugging Face.
There is any way use esm module with nest?
javascript
import { Injectable, OnModuleInit } from '@nestjs/common';
import path from "path";
import { TextClassificationPipeline, pipeline } from '@xenova/transformers';
@Injectable()
export class ChatService implements OnModuleInit {
textPipeline: TextClassificationPipeline;
async onModuleInit() {
this.textPipeline = await pipeline("sentiment-analysis");
}
async givePrompt(): Promise<string> {
const generatedResponse = await this.textPipeline("I am happy");
console.log(generatedResponse);
return ""
}
}
Error:
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/halit/Desktop/gpt-backend/node_modules/@xenova/transformers/src/transformers.js from /Users/halit/Desktop/gpt-backend/dist/chat/chat.service.js not supported.
Instead change the require of transformers.js in /Users/halit/Desktop/gpt-backend/dist/chat/chat.service.js to a dynamic import() which is available in all CommonJS modules.
at /Users/halit/Desktop/gpt-backend/dist/chat/chat.service.js:13:59
at async ChatService.onModuleInit (/Users/halit/Desktop/gpt-backend/dist/chat/chat.service.js:13:24)
``` g