File size: 506 Bytes
f5d25f5
 
 
 
 
 
 
 
 
 
 
 
f43196f
f5d25f5
 
f43196f
f5d25f5
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import PipelineSingleton from '@/pipeline';
import { NextRequest, NextResponse } from 'next/server'

export async function POST(request: NextRequest) {
  const { text } = await request.json();
  if (!text) {
    return NextResponse.json({
      error: 'Missing text parameter',
    }, { status: 400 });
  }
  const classifier = await PipelineSingleton.getInstance();

  //@ts-expect-error That's the library
  const result = await classifier(text, { top_k: null });


  return NextResponse.json(result);
}