File size: 381 Bytes
f43196f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
'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[]
}