fix(MultiModalModel): Lazy-load SmartPdf and guard document processing across providers; ensure SmartPdf is initialized only when needed
This commit is contained in:
@@ -173,11 +173,14 @@ export class OpenAiProvider extends MultiModalModel {
|
||||
content: any;
|
||||
}[];
|
||||
}) {
|
||||
// Ensure SmartPdf is initialized before processing documents
|
||||
await this.ensureSmartpdfReady();
|
||||
|
||||
let pdfDocumentImageBytesArray: Uint8Array[] = [];
|
||||
|
||||
// Convert each PDF into one or more image byte arrays.
|
||||
for (const pdfDocument of optionsArg.pdfDocuments) {
|
||||
const documentImageArray = await this.smartpdfInstance.convertPDFToPngBytes(pdfDocument);
|
||||
const documentImageArray = await this.smartpdfInstance!.convertPDFToPngBytes(pdfDocument);
|
||||
pdfDocumentImageBytesArray = pdfDocumentImageBytesArray.concat(documentImageArray);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user