Spaces:
Running
Running
File size: 604 Bytes
d49dbe5 43fcfb0 9b62581 f5fd590 521f9a6 43fcfb0 521f9a6 d49dbe5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
// To demonstrate use of Javascript promise in Transformers.js pipeline API
// Import the library
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@xenova/[email protected]';
// Make it available globally
window.pipeline = pipeline;
async function makepipe() {
return await pipeline('sentiment-analysis');
}
async function main() {
let pipe = await makepipe();
let out = await pipe('I love transformers!');
console.log(out);
}
main(); // cannot manually call main() from a browser console. main() not defined error. Seems to be attributed to Huggingface's use of container |