Skip to content

Commit

Permalink
add fix for override files in upsert vector
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryHengZJ committed Jan 9, 2025
1 parent 8d84632 commit b2ce4fa
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 9 deletions.
25 changes: 19 additions & 6 deletions packages/server/src/utils/upsertVector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,29 @@ 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.
// 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) {
const fileInputFieldFromExt = mapExtToInputField(enabledFileParam.type)
nodeOverrides[nodeLabel].push({
...enabledFileParam,
name: fileInputFieldFromExt
})
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
})
}
}
}

Expand Down
39 changes: 37 additions & 2 deletions packages/ui/src/views/chatflows/APICodeDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import cURLSVG from '@/assets/images/cURL.svg'
import EmbedSVG from '@/assets/images/embed.svg'
import ShareChatbotSVG from '@/assets/images/sharing.png'
import settingsSVG from '@/assets/images/settings.svg'
import { IconBulb, IconBox, IconVariable } from '@tabler/icons-react'
import { IconBulb, IconBox, IconVariable, IconExclamationCircle } from '@tabler/icons-react'

// API
import apiKeyApi from '@/api/apikey'
Expand Down Expand Up @@ -726,9 +726,44 @@ formData.append("openAIApiKey[openAIEmbeddings_0]", "sk-my-openai-2nd-key")`
<CheckboxInput label='Show Override Config' value={checkboxVal} onChange={onCheckBoxChanged} />
{checkboxVal && getConfigApi.data && getConfigApi.data.length > 0 && (
<>
<Typography sx={{ mt: 2, mb: 3 }}>
<Typography sx={{ mt: 2 }}>
You can override existing input configuration of the chatflow with overrideConfig property.
</Typography>
<div
style={{
display: 'flex',
flexDirection: 'column',
borderRadius: 10,
background: 'rgb(254,252,191)',
padding: 10,
marginTop: 10,
marginBottom: 10
}}
>
<div
style={{
display: 'flex',
flexDirection: 'row',
alignItems: 'center'
}}
>
<IconExclamationCircle size={30} color='rgb(116,66,16)' />
<span style={{ color: 'rgb(116,66,16)', marginLeft: 10, fontWeight: 500 }}>
{
'For security reason, override config is disabled by default. You can change this by going into Chatflow Configuration -> Security tab, and enable the property you want to override.'
}
&nbsp;Refer{' '}
<a
rel='noreferrer'
target='_blank'
href='https://docs.flowiseai.com/using-flowise/api#override-config'
>
here
</a>{' '}
for more details
</span>
</div>
</div>
<Stack direction='column' spacing={2} sx={{ width: '100%', my: 2 }}>
<Card sx={{ borderColor: theme.palette.primary[200] + 75, p: 2 }} variant='outlined'>
<Stack sx={{ mt: 1, mb: 2, ml: 1, alignItems: 'center' }} direction='row' spacing={2}>
Expand Down
43 changes: 42 additions & 1 deletion packages/ui/src/views/vectorstore/VectorStoreDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { CheckboxInput } from '@/ui-component/checkbox/Checkbox'
import { BackdropLoader } from '@/ui-component/loading/BackdropLoader'
import { TableViewOnly } from '@/ui-component/table/Table'

import { IconX, IconBulb } from '@tabler/icons-react'
import { IconX, IconBulb, IconExclamationCircle } from '@tabler/icons-react'
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
import pythonSVG from '@/assets/images/python.svg'
import javascriptSVG from '@/assets/images/javascript.svg'
Expand Down Expand Up @@ -545,6 +545,47 @@ formData.append("openAIApiKey[openAIEmbeddings_0]", "sk-my-openai-2nd-key")`
showLineNumbers={false}
wrapLines
/>
<div
style={{
display: 'flex',
flexDirection: 'column',
borderRadius: 10,
background: 'rgb(254,252,191)',
padding: 10,
marginTop: 20,
marginBottom: 20
}}
>
<div
style={{
display: 'flex',
flexDirection: 'row',
alignItems: 'center'
}}
>
<IconExclamationCircle size={30} color='rgb(116,66,16)' />
<span
style={{
color: 'rgb(116,66,16)',
marginLeft: 10,
fontWeight: 500
}}
>
{
'For security reason, override config is disabled by default. You can change this by going into Chatflow Configuration -> Security tab, and enable the property you want to override.'
}
&nbsp;Refer{' '}
<a
rel='noreferrer'
target='_blank'
href='https://docs.flowiseai.com/using-flowise/api#override-config'
>
here
</a>{' '}
for more details
</span>
</div>
</div>
<div
style={{
display: 'flex',
Expand Down

0 comments on commit b2ce4fa

Please sign in to comment.