mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-10 19:36:53 +08:00
Feat/environment variables in workflow (#6515)
Co-authored-by: JzoNg <jzongcode@gmail.com>
This commit is contained in:
@@ -55,9 +55,9 @@ def test_execute_code(setup_code_executor_mock):
|
||||
)
|
||||
|
||||
# construct variable pool
|
||||
pool = VariablePool(system_variables={}, user_inputs={})
|
||||
pool.append_variable(node_id='1', variable_key_list=['123', 'args1'], value=1)
|
||||
pool.append_variable(node_id='1', variable_key_list=['123', 'args2'], value=2)
|
||||
pool = VariablePool(system_variables={}, user_inputs={}, environment_variables=[])
|
||||
pool.add(['1', '123', 'args1'], 1)
|
||||
pool.add(['1', '123', 'args2'], 2)
|
||||
|
||||
# execute node
|
||||
result = node.run(pool)
|
||||
@@ -109,9 +109,9 @@ def test_execute_code_output_validator(setup_code_executor_mock):
|
||||
)
|
||||
|
||||
# construct variable pool
|
||||
pool = VariablePool(system_variables={}, user_inputs={})
|
||||
pool.append_variable(node_id='1', variable_key_list=['123', 'args1'], value=1)
|
||||
pool.append_variable(node_id='1', variable_key_list=['123', 'args2'], value=2)
|
||||
pool = VariablePool(system_variables={}, user_inputs={}, environment_variables=[])
|
||||
pool.add(['1', '123', 'args1'], 1)
|
||||
pool.add(['1', '123', 'args2'], 2)
|
||||
|
||||
# execute node
|
||||
result = node.run(pool)
|
||||
|
||||
@@ -18,9 +18,9 @@ BASIC_NODE_DATA = {
|
||||
}
|
||||
|
||||
# construct variable pool
|
||||
pool = VariablePool(system_variables={}, user_inputs={})
|
||||
pool.append_variable(node_id='a', variable_key_list=['b123', 'args1'], value=1)
|
||||
pool.append_variable(node_id='a', variable_key_list=['b123', 'args2'], value=2)
|
||||
pool = VariablePool(system_variables={}, user_inputs={}, environment_variables=[])
|
||||
pool.add(['a', 'b123', 'args1'], 1)
|
||||
pool.add(['a', 'b123', 'args2'], 2)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('setup_http_mock', [['none']], indirect=True)
|
||||
|
||||
@@ -70,8 +70,8 @@ def test_execute_llm(setup_openai_mock):
|
||||
SystemVariable.FILES: [],
|
||||
SystemVariable.CONVERSATION_ID: 'abababa',
|
||||
SystemVariable.USER_ID: 'aaa'
|
||||
}, user_inputs={})
|
||||
pool.append_variable(node_id='abc', variable_key_list=['output'], value='sunny')
|
||||
}, user_inputs={}, environment_variables=[])
|
||||
pool.add(['abc', 'output'], 'sunny')
|
||||
|
||||
credentials = {
|
||||
'openai_api_key': os.environ.get('OPENAI_API_KEY')
|
||||
@@ -185,8 +185,8 @@ def test_execute_llm_with_jinja2(setup_code_executor_mock, setup_openai_mock):
|
||||
SystemVariable.FILES: [],
|
||||
SystemVariable.CONVERSATION_ID: 'abababa',
|
||||
SystemVariable.USER_ID: 'aaa'
|
||||
}, user_inputs={})
|
||||
pool.append_variable(node_id='abc', variable_key_list=['output'], value='sunny')
|
||||
}, user_inputs={}, environment_variables=[])
|
||||
pool.add(['abc', 'output'], 'sunny')
|
||||
|
||||
credentials = {
|
||||
'openai_api_key': os.environ.get('OPENAI_API_KEY')
|
||||
|
||||
@@ -123,7 +123,7 @@ def test_function_calling_parameter_extractor(setup_openai_mock):
|
||||
SystemVariable.FILES: [],
|
||||
SystemVariable.CONVERSATION_ID: 'abababa',
|
||||
SystemVariable.USER_ID: 'aaa'
|
||||
}, user_inputs={})
|
||||
}, user_inputs={}, environment_variables=[])
|
||||
|
||||
result = node.run(pool)
|
||||
|
||||
@@ -181,7 +181,7 @@ def test_instructions(setup_openai_mock):
|
||||
SystemVariable.FILES: [],
|
||||
SystemVariable.CONVERSATION_ID: 'abababa',
|
||||
SystemVariable.USER_ID: 'aaa'
|
||||
}, user_inputs={})
|
||||
}, user_inputs={}, environment_variables=[])
|
||||
|
||||
result = node.run(pool)
|
||||
|
||||
@@ -247,7 +247,7 @@ def test_chat_parameter_extractor(setup_anthropic_mock):
|
||||
SystemVariable.FILES: [],
|
||||
SystemVariable.CONVERSATION_ID: 'abababa',
|
||||
SystemVariable.USER_ID: 'aaa'
|
||||
}, user_inputs={})
|
||||
}, user_inputs={}, environment_variables=[])
|
||||
|
||||
result = node.run(pool)
|
||||
|
||||
@@ -311,7 +311,7 @@ def test_completion_parameter_extractor(setup_openai_mock):
|
||||
SystemVariable.FILES: [],
|
||||
SystemVariable.CONVERSATION_ID: 'abababa',
|
||||
SystemVariable.USER_ID: 'aaa'
|
||||
}, user_inputs={})
|
||||
}, user_inputs={}, environment_variables=[])
|
||||
|
||||
result = node.run(pool)
|
||||
|
||||
@@ -424,7 +424,7 @@ def test_chat_parameter_extractor_with_memory(setup_anthropic_mock):
|
||||
SystemVariable.FILES: [],
|
||||
SystemVariable.CONVERSATION_ID: 'abababa',
|
||||
SystemVariable.USER_ID: 'aaa'
|
||||
}, user_inputs={})
|
||||
}, user_inputs={}, environment_variables=[])
|
||||
|
||||
result = node.run(pool)
|
||||
|
||||
|
||||
@@ -38,9 +38,9 @@ def test_execute_code(setup_code_executor_mock):
|
||||
)
|
||||
|
||||
# construct variable pool
|
||||
pool = VariablePool(system_variables={}, user_inputs={})
|
||||
pool.append_variable(node_id='1', variable_key_list=['123', 'args1'], value=1)
|
||||
pool.append_variable(node_id='1', variable_key_list=['123', 'args2'], value=3)
|
||||
pool = VariablePool(system_variables={}, user_inputs={}, environment_variables=[])
|
||||
pool.add(['1', '123', 'args1'], 1)
|
||||
pool.add(['1', '123', 'args2'], 3)
|
||||
|
||||
# execute node
|
||||
result = node.run(pool)
|
||||
|
||||
@@ -6,8 +6,8 @@ from models.workflow import WorkflowNodeExecutionStatus
|
||||
|
||||
|
||||
def test_tool_variable_invoke():
|
||||
pool = VariablePool(system_variables={}, user_inputs={})
|
||||
pool.append_variable(node_id='1', variable_key_list=['123', 'args1'], value='1+1')
|
||||
pool = VariablePool(system_variables={}, user_inputs={}, environment_variables=[])
|
||||
pool.add(['1', '123', 'args1'], '1+1')
|
||||
|
||||
node = ToolNode(
|
||||
tenant_id='1',
|
||||
@@ -45,8 +45,8 @@ def test_tool_variable_invoke():
|
||||
assert result.outputs['files'] == []
|
||||
|
||||
def test_tool_mixed_invoke():
|
||||
pool = VariablePool(system_variables={}, user_inputs={})
|
||||
pool.append_variable(node_id='1', variable_key_list=['args1'], value='1+1')
|
||||
pool = VariablePool(system_variables={}, user_inputs={}, environment_variables=[])
|
||||
pool.add(['1', 'args1'], '1+1')
|
||||
|
||||
node = ToolNode(
|
||||
tenant_id='1',
|
||||
|
||||
Reference in New Issue
Block a user