feat: implementation
This commit is contained in:
7
utils/data.ts
Normal file
7
utils/data.ts
Normal 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
12
utils/parser.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user