parent
a2c36b4447
commit
7d9e1514b1
|
|
@ -288,5 +288,21 @@ export interface ICustomTemplate {
|
||||||
usecases?: string
|
usecases?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface INodeOverrides {
|
||||||
|
[key: string]: {
|
||||||
|
label: string
|
||||||
|
name: string
|
||||||
|
type: string
|
||||||
|
enabled: boolean
|
||||||
|
}[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IVariableOverride {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
type: 'static' | 'runtime'
|
||||||
|
enabled: boolean
|
||||||
|
}
|
||||||
|
|
||||||
// DocumentStore related
|
// DocumentStore related
|
||||||
export * from './Interface.DocumentStore'
|
export * from './Interface.DocumentStore'
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,13 @@ import {
|
||||||
INodeData,
|
INodeData,
|
||||||
INodeDependencies,
|
INodeDependencies,
|
||||||
INodeDirectedGraph,
|
INodeDirectedGraph,
|
||||||
|
INodeOverrides,
|
||||||
INodeQueue,
|
INodeQueue,
|
||||||
IOverrideConfig,
|
IOverrideConfig,
|
||||||
IReactFlowEdge,
|
IReactFlowEdge,
|
||||||
IReactFlowNode,
|
IReactFlowNode,
|
||||||
IVariableDict,
|
IVariableDict,
|
||||||
|
IVariableOverride,
|
||||||
IncomingInput
|
IncomingInput
|
||||||
} from '../Interface'
|
} from '../Interface'
|
||||||
import { cloneDeep, get, isEqual } from 'lodash'
|
import { cloneDeep, get, isEqual } from 'lodash'
|
||||||
|
|
@ -436,8 +438,8 @@ type BuildFlowParams = {
|
||||||
appDataSource: DataSource
|
appDataSource: DataSource
|
||||||
overrideConfig?: ICommonObject
|
overrideConfig?: ICommonObject
|
||||||
apiOverrideStatus?: boolean
|
apiOverrideStatus?: boolean
|
||||||
nodeOverrides?: ICommonObject
|
nodeOverrides?: INodeOverrides
|
||||||
variableOverrides?: ICommonObject[]
|
variableOverrides?: IVariableOverride[]
|
||||||
cachePool?: CachePool
|
cachePool?: CachePool
|
||||||
isUpsert?: boolean
|
isUpsert?: boolean
|
||||||
stopNodeId?: string
|
stopNodeId?: string
|
||||||
|
|
@ -1000,15 +1002,15 @@ export const resolveVariables = async (
|
||||||
* Loop through each inputs and replace their value with override config values
|
* Loop through each inputs and replace their value with override config values
|
||||||
* @param {INodeData} flowNodeData
|
* @param {INodeData} flowNodeData
|
||||||
* @param {ICommonObject} overrideConfig
|
* @param {ICommonObject} overrideConfig
|
||||||
* @param {ICommonObject} nodeOverrides
|
* @param {INodeOverrides} nodeOverrides
|
||||||
* @param {ICommonObject[]} variableOverrides
|
* @param {IVariableOverride[]} variableOverrides
|
||||||
* @returns {INodeData}
|
* @returns {INodeData}
|
||||||
*/
|
*/
|
||||||
export const replaceInputsWithConfig = (
|
export const replaceInputsWithConfig = (
|
||||||
flowNodeData: INodeData,
|
flowNodeData: INodeData,
|
||||||
overrideConfig: ICommonObject,
|
overrideConfig: ICommonObject,
|
||||||
nodeOverrides: ICommonObject,
|
nodeOverrides: INodeOverrides,
|
||||||
variableOverrides: ICommonObject[]
|
variableOverrides: IVariableOverride[]
|
||||||
) => {
|
) => {
|
||||||
const types = 'inputs'
|
const types = 'inputs'
|
||||||
|
|
||||||
|
|
@ -1676,9 +1678,12 @@ export const aMonthAgo = () => {
|
||||||
export const getAPIOverrideConfig = (chatflow: IChatFlow) => {
|
export const getAPIOverrideConfig = (chatflow: IChatFlow) => {
|
||||||
try {
|
try {
|
||||||
const apiConfig = chatflow.apiConfig ? JSON.parse(chatflow.apiConfig) : {}
|
const apiConfig = chatflow.apiConfig ? JSON.parse(chatflow.apiConfig) : {}
|
||||||
const nodeOverrides = apiConfig.overrideConfig && apiConfig.overrideConfig.nodes ? apiConfig.overrideConfig.nodes : {}
|
const nodeOverrides: INodeOverrides =
|
||||||
const variableOverrides = apiConfig.overrideConfig && apiConfig.overrideConfig.variables ? apiConfig.overrideConfig.variables : []
|
apiConfig.overrideConfig && apiConfig.overrideConfig.nodes ? apiConfig.overrideConfig.nodes : {}
|
||||||
const apiOverrideStatus = apiConfig.overrideConfig && apiConfig.overrideConfig.status ? apiConfig.overrideConfig.status : false
|
const variableOverrides: IVariableOverride[] =
|
||||||
|
apiConfig.overrideConfig && apiConfig.overrideConfig.variables ? apiConfig.overrideConfig.variables : []
|
||||||
|
const apiOverrideStatus: boolean =
|
||||||
|
apiConfig.overrideConfig && apiConfig.overrideConfig.status ? apiConfig.overrideConfig.status : false
|
||||||
|
|
||||||
return { nodeOverrides, variableOverrides, apiOverrideStatus }
|
return { nodeOverrides, variableOverrides, apiOverrideStatus }
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,19 @@ export const upsertVector = async (req: Request, isInternal: boolean = false) =>
|
||||||
/*** Get API Config ***/
|
/*** Get API Config ***/
|
||||||
const { nodeOverrides, variableOverrides, apiOverrideStatus } = getAPIOverrideConfig(chatflow)
|
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 (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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const upsertedResult = await buildFlow({
|
const upsertedResult = await buildFlow({
|
||||||
startingNodeIds,
|
startingNodeIds,
|
||||||
reactFlowNodes: nodes,
|
reactFlowNodes: nodes,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue