Download util/classify.ts from Archana25/Sentify-Sentiment-Analyser: direct link, hf CLI and curl.
- Browser
- Download file 381 Bytes
-
https://huggingface.co/spaces/Archana25/Sentify-Sentiment-Analyser/resolve/main/util/classify.ts
- Command line
-
hf download hf://spaces/Archana25/Sentify-Sentiment-Analyser/util/classify.ts
-
curl -L -o classify.ts https://huggingface.co/spaces/Archana25/Sentify-Sentiment-Analyser/resolve/main/util/classify.ts
381 Bytes
| 'use server' | |
| import PipelineSingleton from '@/pipeline'; | |
| export interface ClassifyOutputElement { | |
| label: string; | |
| score: number; | |
| } | |
| export async function classify(text: string) { | |
| const classifier = await PipelineSingleton.getInstance(); | |
| //@ts-expect-error That's the library | |
| const out = await classifier(text, { top_k: null }); | |
| return out as ClassifyOutputElement[] | |
| } | |