MCPcopy
hub / github.com/FlowiseAI/Flowise / previewChunks

Function previewChunks

packages/server/src/services/documentstore/index.ts:725–758  ·  view source on GitHub ↗
({ appDataSource, componentNodes, data, orgId, workspaceId }: IExecutePreviewLoader)

Source from the content-addressed store, hash-verified

723}
724
725export const previewChunks = async ({ appDataSource, componentNodes, data, orgId, workspaceId }: IExecutePreviewLoader) => {
726 try {
727 if (data.preview) {
728 if (
729 data.loaderId === 'cheerioWebScraper' ||
730 data.loaderId === 'puppeteerWebScraper' ||
731 data.loaderId === 'playwrightWebScraper'
732 ) {
733 data.loaderConfig['limit'] = 3
734 }
735 }
736 if (!data.rehydrated) {
737 await _normalizeFilePaths(appDataSource, data, null, orgId, workspaceId)
738 }
739 let docs = await _splitIntoChunks(appDataSource, componentNodes, data, workspaceId)
740 const totalChunks = docs.length
741 // if -1, return all chunks
742 if (data.previewChunkCount === -1) data.previewChunkCount = totalChunks
743 // return all docs if the user ask for more than we have
744 if (totalChunks <= (data.previewChunkCount || 0)) data.previewChunkCount = totalChunks
745 // return only the first n chunks
746 if (totalChunks > (data.previewChunkCount || 0)) docs = docs.slice(0, data.previewChunkCount)
747
748 return { chunks: docs, totalChunks: totalChunks, previewChunkCount: data.previewChunkCount }
749 } catch (error) {
750 if (error instanceof InternalFlowiseError) {
751 throw error
752 }
753 throw new InternalFlowiseError(
754 StatusCodes.INTERNAL_SERVER_ERROR,
755 `Error: documentStoreServices.previewChunks - ${getErrorMessage(error)}`
756 )
757 }
758}
759
760const saveProcessingLoader = async (
761 appDataSource: DataSource,

Callers 3

processJobMethod · 0.90
previewChunksMiddlewareFunction · 0.70
_saveChunksToStorageFunction · 0.70

Calls 3

getErrorMessageFunction · 0.90
_normalizeFilePathsFunction · 0.85
_splitIntoChunksFunction · 0.85

Tested by

no test coverage detected