Feat/environment variables in workflow (#6515)

Co-authored-by: JzoNg <jzongcode@gmail.com>
This commit is contained in:
-LAN-
2024-07-22 15:29:39 +08:00
committed by GitHub
parent 87d583f454
commit 5e6fc58db3
146 changed files with 2486 additions and 746 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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')

View File

@@ -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)

View File

@@ -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)

View File

@@ -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',