fix(MultiModalModel): Lazy-load SmartPdf and guard document processing across providers; ensure SmartPdf is initialized only when needed
This commit is contained in:
@@ -149,11 +149,14 @@ export class XAIProvider extends MultiModalModel {
|
||||
pdfDocuments: Uint8Array[];
|
||||
messageHistory: { role: string; content: string; }[];
|
||||
}): Promise<{ message: any }> {
|
||||
// Ensure SmartPdf is initialized before processing documents
|
||||
await this.ensureSmartpdfReady();
|
||||
|
||||
// First convert PDF documents to images
|
||||
let pdfDocumentImageBytesArray: Uint8Array[] = [];
|
||||
|
||||
|
||||
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