Download app/api/classify/route.ts from Archana25/Sentify-Sentiment-Analyser: direct link, hf CLI and curl.
- Browser
- Download file 506 Bytes
-
https://huggingface.co/spaces/Archana25/Sentify-Sentiment-Analyser/resolve/main/app/api/classify/route.ts
- Command line
-
hf download hf://spaces/Archana25/Sentify-Sentiment-Analyser/app/api/classify/route.ts
-
curl -L -o route.ts https://huggingface.co/spaces/Archana25/Sentify-Sentiment-Analyser/resolve/main/app/api/classify/route.ts
506 Bytes
| 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); | |
| } | |