exportasyncfunctionGET(request:NextRequest) { const text = request.nextUrl.searchParams.get('text'); if (!text) { returnNextResponse.json({ error: 'Missing text parameter', }, { status: 400 }); } // Get the classification pipeline. When called for the first time, // this will load the pipeline and cache it for future use. const classifier = awaitPipelineSingleton.getInstance();
// Actually perform the classification const result = awaitclassifier(text);
consthandleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => { // Update the input value state whenever the input changes setValue(event.target.value); };
constclassify = async (text: string) => { if (!text) return; if (ready === null) setReady(false); const result = awaitfetch(`/test?text=${encodeURIComponent(text)}`); if (!ready) setReady(true); const json = await result.json(); setResult(json); };