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

Function executeUpsert

packages/server/src/utils/upsertVector.ts:42–231  ·  view source on GitHub ↗
({
    componentNodes,
    incomingInput,
    chatflow,
    chatId,
    appDataSource,
    telemetry,
    cachePool,
    isInternal,
    files,
    orgId,
    workspaceId,
    subscriptionId,
    usageCacheManager
}: IExecuteFlowParams)

Source from the content-addressed store, hash-verified

40import { validateFlowAPIKey } from './validateKey'
41
42export const executeUpsert = async ({
43 componentNodes,
44 incomingInput,
45 chatflow,
46 chatId,
47 appDataSource,
48 telemetry,
49 cachePool,
50 isInternal,
51 files,
52 orgId,
53 workspaceId,
54 subscriptionId,
55 usageCacheManager
56}: IExecuteFlowParams) => {
57 const question = incomingInput.question
58 let overrideConfig = incomingInput.overrideConfig ?? {}
59 let stopNodeId = incomingInput?.stopNodeId ?? ''
60 const chatHistory: IMessage[] = []
61 const isUpsert = true
62 const chatflowid = chatflow.id
63 const apiMessageId = uuidv4()
64
65 if (files?.length) {
66 overrideConfig = { ...incomingInput }
67 for (const file of files) {
68 await checkStorage(orgId, subscriptionId, usageCacheManager)
69
70 const fileNames: string[] = []
71 const fileBuffer = await getFileFromUpload(file.path ?? file.key)
72 // Address file name with special characters: https://github.com/expressjs/multer/issues/1104
73 file.originalname = Buffer.from(file.originalname, 'latin1').toString('utf8')
74
75 // Validate file extension, MIME type, and content to prevent security vulnerabilities
76 validateFileMimeTypeAndExtensionMatch(file.originalname, file.mimetype)
77
78 const { path: storagePath, totalSize } = await addArrayFilesToStorage(
79 file.mimetype,
80 fileBuffer,
81 file.originalname,
82 fileNames,
83 orgId,
84 chatflowid
85 )
86 await updateStorageUsage(orgId, workspaceId, totalSize, usageCacheManager)
87
88 const fileInputFieldFromMimeType = mapMimeTypeToInputField(file.mimetype)
89
90 const fileExtension = path.extname(file.originalname)
91
92 const fileInputFieldFromExt = mapExtToInputField(fileExtension)
93
94 let fileInputField = 'txtFile'
95
96 if (fileInputFieldFromExt !== 'txtFile') {
97 fileInputField = fileInputFieldFromExt
98 } else if (fileInputFieldFromMimeType !== 'txtFile') {
99 fileInputField = fileInputFieldFromExt

Callers 2

processJobMethod · 0.90
upsertVectorFunction · 0.85

Calls 15

checkStorageFunction · 0.90
updateStorageUsageFunction · 0.90
findMemoryNodeFunction · 0.90
getMemorySessionIdFunction · 0.90
constructGraphsFunction · 0.90
getAllConnectedNodesFunction · 0.90
getStartingNodesFunction · 0.90
getAPIOverrideConfigFunction · 0.90
buildFlowFunction · 0.90
getAppVersionFunction · 0.90

Tested by

no test coverage detected