import { pipeline } from '@huggingface/transformers'; // Create a text generation pipeline const generator = await pipeline( 'text-generation', 'onnx-community/Qwen2.5-0.5B-Instruct', { dtype: 'q4', device: 'webgpu' }, ); // Define the list of messages const messages = [ { role: 'system', content: 'You are a helpful assistant.' }, { role: 'user', content: 'Tell me a funny joke.' }, ]; // Generate a response const output = await generator(messages, { max_new_tokens: 128 }); console.log(output[0].generated_text.at(-1).content); // "Why did the tomato turn red?\n\nBecause it saw the salad dressing!"