mrlectus's picture
Upload 54 files
adf1923 verified
raw
history blame contribute delete
515 Bytes
import { NextRequest, NextResponse } from "next/server";
import { pipeline, env } from "@huggingface/transformers";
env.cacheDir = "./.cache";
export const POST = async (request: NextRequest) => {
try{
const {key, text} = await request.json();
const qa_pipeline = await pipeline('document-question-answering', 'Xenova/donut-base-finetuned-docvqa');
const output = await qa_pipeline(key, text);
return NextResponse.json(output);
}catch (e) {
console.error(e)
}
};