(
appDataSource: DataSource,
componentNodes: IComponentNodes,
data: IDocumentStoreLoaderForPreview,
workspaceId?: string
)
| 567 | } |
| 568 | |
| 569 | const _splitIntoChunks = async ( |
| 570 | appDataSource: DataSource, |
| 571 | componentNodes: IComponentNodes, |
| 572 | data: IDocumentStoreLoaderForPreview, |
| 573 | workspaceId?: string |
| 574 | ) => { |
| 575 | try { |
| 576 | let splitterInstance = null |
| 577 | if (data.splitterId && data.splitterConfig && Object.keys(data.splitterConfig).length > 0) { |
| 578 | const nodeInstanceFilePath = componentNodes[data.splitterId].filePath as string |
| 579 | const nodeModule = await import(nodeInstanceFilePath) |
| 580 | const newNodeInstance = new nodeModule.nodeClass() |
| 581 | let nodeData = { |
| 582 | inputs: { ...data.splitterConfig }, |
| 583 | id: 'splitter_0' |
| 584 | } |
| 585 | splitterInstance = await newNodeInstance.init(nodeData) |
| 586 | } |
| 587 | if (!data.loaderId) return [] |
| 588 | const nodeInstanceFilePath = componentNodes[data.loaderId].filePath as string |
| 589 | const nodeModule = await import(nodeInstanceFilePath) |
| 590 | // doc loader configs |
| 591 | const nodeData = { |
| 592 | credential: data.credential || data.loaderConfig['FLOWISE_CREDENTIAL_ID'] || undefined, |
| 593 | inputs: { ...data.loaderConfig, textSplitter: splitterInstance }, |
| 594 | outputs: { output: 'document' } |
| 595 | } |
| 596 | const options: ICommonObject = { |
| 597 | chatflowid: uuidv4(), |
| 598 | appDataSource, |
| 599 | databaseEntities, |
| 600 | logger, |
| 601 | processRaw: true, |
| 602 | workspaceId |
| 603 | } |
| 604 | const docNodeInstance = new nodeModule.nodeClass() |
| 605 | let docs: IDocument[] = await docNodeInstance.init(nodeData, '', options) |
| 606 | return docs |
| 607 | } catch (error) { |
| 608 | throw new InternalFlowiseError( |
| 609 | StatusCodes.INTERNAL_SERVER_ERROR, |
| 610 | `Error: documentStoreServices.splitIntoChunks - ${getErrorMessage(error)}` |
| 611 | ) |
| 612 | } |
| 613 | } |
| 614 | |
| 615 | const _normalizeFilePaths = async ( |
| 616 | appDataSource: DataSource, |
no test coverage detected