feat: implementation

This commit is contained in:
Riccardo
2024-05-07 21:52:38 +02:00
parent 734b590482
commit f752787605
26 changed files with 6365 additions and 1 deletions

7
utils/data.ts Normal file
View File

@@ -0,0 +1,7 @@
import { z } from 'zod';
export const responseSchema = z.object({
text: z.string()
});
export type Response = z.infer<typeof responseSchema>;

12
utils/parser.ts Normal file
View File

@@ -0,0 +1,12 @@
import PdfParse from 'pdf-parse';
export async function parser(file: File) {
const chunks = [];
for await (const chunk of file.stream() as any) {
chunks.push(chunk);
}
const parsedContent = await PdfParse(Buffer.concat(chunks));
return parsedContent.text;
}