Skip to content

Commit

Permalink
Bugfix/Allow files uploads without enabling overrideconfig (#3915)
Browse files Browse the repository at this point in the history
allow files uploads without enabling overrideconfig
  • Loading branch information
HenryHengZJ authored Jan 22, 2025
1 parent ca559c5 commit 1baa4f8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 30 deletions.
7 changes: 5 additions & 2 deletions packages/server/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1110,8 +1110,11 @@ export const replaceInputsWithConfig = (
continue
}
} else {
// Only proceed if the parameter is enabled
if (!isParameterEnabled(flowNodeData.label, config)) {
// Skip if it is an override "files" input, such as pdfFile, txtFile, etc
if (typeof overrideConfig[config] === 'string' && overrideConfig[config].includes('FILE-STORAGE::')) {
// pass
} else if (!isParameterEnabled(flowNodeData.label, config)) {
// Only proceed if the parameter is enabled
continue
}
}
Expand Down
26 changes: 0 additions & 26 deletions packages/server/src/utils/upsertVector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,32 +168,6 @@ export const upsertVector = async (req: Request, isInternal: boolean = false) =>
const availableVariables = await appServer.AppDataSource.getRepository(Variable).find()
const { nodeOverrides, variableOverrides, apiOverrideStatus } = getAPIOverrideConfig(chatflow)

// For "files" input, add a new node override with the actual input name such as pdfFile, txtFile, etc, to allow overriding the input
for (const nodeLabel in nodeOverrides) {
const params = nodeOverrides[nodeLabel]
const enabledFileParam = params.find((param) => param.enabled && param.name === 'files')
if (enabledFileParam) {
if (enabledFileParam.type.includes(',')) {
const fileInputFieldsFromExt = enabledFileParam.type.split(',').map((fileType) => mapExtToInputField(fileType.trim()))
for (const fileInputFieldFromExt of fileInputFieldsFromExt) {
if (nodeOverrides[nodeLabel].some((param) => param.name === fileInputFieldFromExt)) {
continue
}
nodeOverrides[nodeLabel].push({
...enabledFileParam,
name: fileInputFieldFromExt
})
}
} else {
const fileInputFieldFromExt = mapExtToInputField(enabledFileParam.type)
nodeOverrides[nodeLabel].push({
...enabledFileParam,
name: fileInputFieldFromExt
})
}
}
}

const upsertedResult = await buildFlow({
startingNodeIds,
reactFlowNodes: nodes,
Expand Down
10 changes: 8 additions & 2 deletions packages/ui/src/ui-component/extended/OverrideConfig.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,16 @@ const OverrideConfig = ({ dialogProps }) => {
}

if (overrideConfigStatus) {
// loop through each key in nodeOverrides and filter out the enabled ones
const filteredNodeOverrides = {}
for (const key in nodeOverrides) {
filteredNodeOverrides[key] = nodeOverrides[key].filter((node) => node.enabled)
}

obj.overrideConfig = {
...obj.overrideConfig,
nodes: nodeOverrides,
variables: variableOverrides
nodes: filteredNodeOverrides,
variables: variableOverrides.filter((node) => node.enabled)
}
}

Expand Down

0 comments on commit 1baa4f8

Please sign in to comment.