({
componentNodes,
incomingInput,
chatflow,
chatId,
isEvaluation,
evaluationRunId,
appDataSource,
telemetry,
cachePool,
usageCacheManager,
sseStreamer,
baseURL,
isInternal,
files,
signal,
isTool,
chatType,
orgId,
workspaceId,
subscriptionId,
productId
}: IExecuteFlowParams)
| 299 | * Function to traverse the flow graph and execute the nodes |
| 300 | */ |
| 301 | export const executeFlow = async ({ |
| 302 | componentNodes, |
| 303 | incomingInput, |
| 304 | chatflow, |
| 305 | chatId, |
| 306 | isEvaluation, |
| 307 | evaluationRunId, |
| 308 | appDataSource, |
| 309 | telemetry, |
| 310 | cachePool, |
| 311 | usageCacheManager, |
| 312 | sseStreamer, |
| 313 | baseURL, |
| 314 | isInternal, |
| 315 | files, |
| 316 | signal, |
| 317 | isTool, |
| 318 | chatType, |
| 319 | orgId, |
| 320 | workspaceId, |
| 321 | subscriptionId, |
| 322 | productId |
| 323 | }: IExecuteFlowParams) => { |
| 324 | // Ensure incomingInput has all required properties with default values |
| 325 | incomingInput = { |
| 326 | history: [], |
| 327 | streaming: false, |
| 328 | ...incomingInput |
| 329 | } |
| 330 | |
| 331 | let question = incomingInput.question || '' // Ensure question is never undefined |
| 332 | let overrideConfig = incomingInput.overrideConfig ?? {} |
| 333 | const uploads = incomingInput.uploads |
| 334 | const prependMessages = incomingInput.history ?? [] |
| 335 | const streaming = incomingInput.streaming ?? false |
| 336 | const userMessageDateTime = new Date() |
| 337 | const chatflowid = chatflow.id |
| 338 | |
| 339 | /* Process file uploads from the chat |
| 340 | * - Images |
| 341 | * - Files |
| 342 | * - Audio |
| 343 | */ |
| 344 | let fileUploads: IFileUpload[] = [] |
| 345 | let uploadedFilesContent = '' |
| 346 | if (uploads) { |
| 347 | fileUploads = uploads |
| 348 | for (let i = 0; i < fileUploads.length; i += 1) { |
| 349 | await checkStorage(orgId, subscriptionId, usageCacheManager) |
| 350 | |
| 351 | const upload = fileUploads[i] |
| 352 | |
| 353 | // if upload in an image, a rag file, or audio |
| 354 | if ((upload.type === 'file' || upload.type === 'file:rag' || upload.type === 'audio') && upload.data) { |
| 355 | const filename = upload.name |
| 356 | const splitDataURI = upload.data.split(',') |
| 357 | const bf = Buffer.from(splitDataURI.pop() || '', 'base64') |
| 358 | const mime = splitDataURI[0].split(':')[1].split(';')[0] |
no test coverage detected