mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 15:00:57 +03:00
update ui changes
This commit is contained in:
@@ -85,26 +85,29 @@ class CustomTool_Tools implements INode {
|
||||
|
||||
// override variables defined in overrideConfig
|
||||
// nodeData.inputs.variables is an Object, check each property and override the variable
|
||||
if (nodeData?.inputs?.envVars) {
|
||||
for (const propertyName of Object.getOwnPropertyNames(nodeData.inputs.envVars)) {
|
||||
if (nodeData?.inputs?.vars) {
|
||||
for (const propertyName of Object.getOwnPropertyNames(nodeData.inputs.vars)) {
|
||||
const foundVar = variables.find((v) => v.name === propertyName)
|
||||
if (foundVar) {
|
||||
// even if the variable was defined as runtime, we override it with static value
|
||||
foundVar.type = 'static'
|
||||
foundVar.value = nodeData.inputs.envVars[propertyName]
|
||||
foundVar.value = nodeData.inputs.vars[propertyName]
|
||||
} else {
|
||||
// add it the variables, if not found locally in the db
|
||||
variables.push({ name: propertyName, type: 'static', value: nodeData.inputs.envVars[propertyName] })
|
||||
variables.push({ name: propertyName, type: 'static', value: nodeData.inputs.vars[propertyName] })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const flow = {
|
||||
chatId: options.chatId, // id is uppercase (I)
|
||||
chatflowId: options.chatflowid // id is lowercase (i)
|
||||
}
|
||||
|
||||
let dynamicStructuredTool = new DynamicStructuredTool(obj)
|
||||
dynamicStructuredTool.setVariables(variables)
|
||||
dynamicStructuredTool.setFlowObject(flow)
|
||||
|
||||
return dynamicStructuredTool
|
||||
} catch (e) {
|
||||
throw new Error(e)
|
||||
|
||||
@@ -102,15 +102,19 @@ export class DynamicStructuredTool<
|
||||
sandbox[`$${item}`] = arg[item]
|
||||
}
|
||||
}
|
||||
//inject variables
|
||||
let env = {}
|
||||
|
||||
// inject variables
|
||||
let vars = {}
|
||||
if (this.variables) {
|
||||
for (const item of this.variables) {
|
||||
let value = item.value
|
||||
|
||||
// read from .env file
|
||||
if (item.type === 'runtime') {
|
||||
value = process.env[item.name]
|
||||
}
|
||||
Object.defineProperty(env, item.name, {
|
||||
|
||||
Object.defineProperty(vars, item.name, {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
@@ -118,10 +122,13 @@ export class DynamicStructuredTool<
|
||||
})
|
||||
}
|
||||
}
|
||||
sandbox['$env'] = env
|
||||
sandbox['$vars'] = vars
|
||||
|
||||
// inject flow properties
|
||||
if (this.flowObj) {
|
||||
sandbox['$flow'] = { ...this.flowObj, sessionId: overrideSessionId }
|
||||
}
|
||||
|
||||
const defaultAllowBuiltInDep = [
|
||||
'assert',
|
||||
'buffer',
|
||||
|
||||
Reference in New Issue
Block a user