vellum-ai 0.14.39__py3-none-any.whl → 0.14.40__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. vellum/client/core/client_wrapper.py +1 -1
  2. vellum/workflows/nodes/bases/tests/test_base_node.py +24 -0
  3. vellum/workflows/nodes/core/try_node/node.py +1 -2
  4. vellum/workflows/nodes/experimental/tool_calling_node/__init__.py +3 -0
  5. vellum/workflows/nodes/experimental/tool_calling_node/node.py +147 -0
  6. vellum/workflows/nodes/experimental/tool_calling_node/utils.py +132 -0
  7. vellum/workflows/nodes/utils.py +4 -2
  8. vellum/workflows/outputs/base.py +3 -2
  9. vellum/workflows/references/output.py +20 -0
  10. vellum/workflows/state/base.py +36 -14
  11. vellum/workflows/state/tests/test_state.py +5 -2
  12. vellum/workflows/types/stack.py +11 -0
  13. vellum/workflows/workflows/base.py +5 -0
  14. vellum/workflows/workflows/tests/test_base_workflow.py +96 -9
  15. {vellum_ai-0.14.39.dist-info → vellum_ai-0.14.40.dist-info}/METADATA +1 -1
  16. {vellum_ai-0.14.39.dist-info → vellum_ai-0.14.40.dist-info}/RECORD +67 -62
  17. vellum_cli/push.py +0 -2
  18. vellum_ee/workflows/display/base.py +14 -1
  19. vellum_ee/workflows/display/nodes/base_node_display.py +56 -14
  20. vellum_ee/workflows/display/nodes/get_node_display_class.py +9 -15
  21. vellum_ee/workflows/display/nodes/tests/test_base_node_display.py +36 -0
  22. vellum_ee/workflows/display/nodes/vellum/base_adornment_node.py +3 -2
  23. vellum_ee/workflows/display/nodes/vellum/retry_node.py +1 -2
  24. vellum_ee/workflows/display/nodes/vellum/tests/test_code_execution_node.py +1 -2
  25. vellum_ee/workflows/display/nodes/vellum/tests/test_error_node.py +1 -2
  26. vellum_ee/workflows/display/nodes/vellum/tests/test_note_node.py +1 -2
  27. vellum_ee/workflows/display/nodes/vellum/tests/test_prompt_node.py +55 -3
  28. vellum_ee/workflows/display/nodes/vellum/tests/test_retry_node.py +1 -2
  29. vellum_ee/workflows/display/nodes/vellum/tests/test_templating_node.py +1 -2
  30. vellum_ee/workflows/display/nodes/vellum/tests/test_try_node.py +1 -2
  31. vellum_ee/workflows/display/nodes/vellum/tests/test_utils.py +2 -2
  32. vellum_ee/workflows/display/nodes/vellum/try_node.py +1 -2
  33. vellum_ee/workflows/display/nodes/vellum/utils.py +7 -1
  34. vellum_ee/workflows/display/tests/{test_vellum_workflow_display.py → test_base_workflow_display.py} +10 -22
  35. vellum_ee/workflows/display/tests/workflow_serialization/generic_nodes/conftest.py +4 -6
  36. vellum_ee/workflows/display/tests/workflow_serialization/generic_nodes/test_adornments_serialization.py +7 -16
  37. vellum_ee/workflows/display/tests/workflow_serialization/generic_nodes/test_attributes_serialization.py +2 -6
  38. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_api_node_serialization.py +1 -2
  39. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_code_execution_node_serialization.py +3 -10
  40. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_conditional_node_serialization.py +4 -5
  41. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_default_state_serialization.py +1 -4
  42. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_error_node_serialization.py +1 -4
  43. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_generic_node_serialization.py +2 -5
  44. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_guardrail_node_serialization.py +7 -5
  45. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_inline_prompt_node_serialization.py +1 -4
  46. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_inline_subworkflow_serialization.py +1 -4
  47. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_map_node_serialization.py +1 -2
  48. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_merge_node_serialization.py +1 -4
  49. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_prompt_deployment_serialization.py +1 -4
  50. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_search_node_serialization.py +7 -5
  51. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_subworkflow_deployment_serialization.py +1 -4
  52. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_templating_node_serialization.py +1 -4
  53. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_terminal_node_serialization.py +1 -4
  54. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_try_node_serialization.py +2 -5
  55. vellum_ee/workflows/display/tests/workflow_serialization/test_complex_terminal_node_serialization.py +2 -7
  56. vellum_ee/workflows/display/types.py +5 -4
  57. vellum_ee/workflows/display/utils/exceptions.py +7 -0
  58. vellum_ee/workflows/display/utils/registry.py +37 -0
  59. vellum_ee/workflows/display/utils/vellum.py +2 -1
  60. vellum_ee/workflows/display/workflows/base_workflow_display.py +281 -43
  61. vellum_ee/workflows/display/workflows/get_vellum_workflow_display_class.py +34 -21
  62. vellum_ee/workflows/display/workflows/tests/test_workflow_display.py +58 -20
  63. vellum_ee/workflows/display/workflows/vellum_workflow_display.py +4 -257
  64. vellum_ee/workflows/tests/local_workflow/display/workflow.py +2 -2
  65. {vellum_ai-0.14.39.dist-info → vellum_ai-0.14.40.dist-info}/LICENSE +0 -0
  66. {vellum_ai-0.14.39.dist-info → vellum_ai-0.14.40.dist-info}/WHEEL +0 -0
  67. {vellum_ai-0.14.39.dist-info → vellum_ai-0.14.40.dist-info}/entry_points.txt +0 -0
@@ -1,7 +1,6 @@
1
1
  from deepdiff import DeepDiff
2
2
 
3
3
  from vellum.workflows.nodes.utils import ADORNMENT_MODULE_NAME
4
- from vellum_ee.workflows.display.workflows import VellumWorkflowDisplay
5
4
  from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
6
5
 
7
6
  from tests.workflows.basic_code_execution_node.try_workflow import TrySimpleCodeExecutionWorkflow
@@ -12,9 +11,7 @@ from tests.workflows.basic_code_execution_node.workflow_with_code import SimpleC
12
11
  def test_serialize_workflow_with_filepath():
13
12
  # GIVEN a Workflow with a code execution node
14
13
  # WHEN we serialize it
15
- workflow_display = get_workflow_display(
16
- base_display_class=VellumWorkflowDisplay, workflow_class=SimpleCodeExecutionWithFilepathWorkflow
17
- )
14
+ workflow_display = get_workflow_display(workflow_class=SimpleCodeExecutionWithFilepathWorkflow)
18
15
  serialized_workflow: dict = workflow_display.serialize()
19
16
 
20
17
  # THEN we should get a serialized representation of the Workflow
@@ -253,9 +250,7 @@ def test_serialize_workflow_with_filepath():
253
250
  def test_serialize_workflow_with_code():
254
251
  # GIVEN a Workflow with a code execution node
255
252
  # WHEN we serialize it
256
- workflow_display = get_workflow_display(
257
- base_display_class=VellumWorkflowDisplay, workflow_class=SimpleCodeExecutionWithCodeWorkflow
258
- )
253
+ workflow_display = get_workflow_display(workflow_class=SimpleCodeExecutionWithCodeWorkflow)
259
254
  serialized_workflow: dict = workflow_display.serialize()
260
255
 
261
256
  # THEN we should get a serialized representation of the Workflow
@@ -482,9 +477,7 @@ def test_serialize_workflow_with_code():
482
477
  def test_serialize_workflow__try_wrapped():
483
478
  # GIVEN a Workflow with a code execution node
484
479
  # WHEN we serialize it
485
- workflow_display = get_workflow_display(
486
- base_display_class=VellumWorkflowDisplay, workflow_class=TrySimpleCodeExecutionWorkflow
487
- )
480
+ workflow_display = get_workflow_display(workflow_class=TrySimpleCodeExecutionWorkflow)
488
481
  serialized_workflow: dict = workflow_display.serialize()
489
482
 
490
483
  # THEN we should get a serialized representation of the Workflow
@@ -20,7 +20,6 @@ from vellum.workflows.expressions.less_than import LessThanExpression
20
20
  from vellum.workflows.expressions.less_than_or_equal_to import LessThanOrEqualToExpression
21
21
  from vellum.workflows.expressions.not_between import NotBetweenExpression
22
22
  from vellum.workflows.expressions.not_in import NotInExpression
23
- from vellum_ee.workflows.display.workflows import VellumWorkflowDisplay
24
23
  from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
25
24
 
26
25
  from tests.workflows.basic_conditional_node.workflow import CategoryWorkflow
@@ -30,7 +29,7 @@ from tests.workflows.basic_conditional_node.workflow_with_only_one_conditional_n
30
29
  def test_serialize_workflow():
31
30
  # GIVEN a Workflow that uses a ConditionalNode
32
31
  # WHEN we serialize it
33
- workflow_display = get_workflow_display(base_display_class=VellumWorkflowDisplay, workflow_class=CategoryWorkflow)
32
+ workflow_display = get_workflow_display(workflow_class=CategoryWorkflow)
34
33
  serialized_workflow: dict = workflow_display.serialize()
35
34
 
36
35
  # THEN we should get a serialized representation of the Workflow
@@ -779,7 +778,7 @@ def test_conditional_node_serialize_all_operators_with_lhs_and_rhs(descriptor, o
779
778
  # GIVEN a simple workflow with one conditional node
780
779
  workflow_cls = create_simple_workflow(descriptor)
781
780
 
782
- workflow_display = get_workflow_display(base_display_class=VellumWorkflowDisplay, workflow_class=workflow_cls)
781
+ workflow_display = get_workflow_display(workflow_class=workflow_cls)
783
782
  serialized_workflow: dict = workflow_display.serialize()
784
783
 
785
784
  # THEN we should get a serialized representation of the Workflow
@@ -885,7 +884,7 @@ def test_conditional_node_serialize_all_operators_with_expression(descriptor, op
885
884
  # GIVEN a simple workflow with one conditional node
886
885
  workflow_cls = create_simple_workflow(descriptor)
887
886
 
888
- workflow_display = get_workflow_display(base_display_class=VellumWorkflowDisplay, workflow_class=workflow_cls)
887
+ workflow_display = get_workflow_display(workflow_class=workflow_cls)
889
888
  serialized_workflow: dict = workflow_display.serialize()
890
889
 
891
890
  # THEN we should get a serialized representation of the Workflow
@@ -978,7 +977,7 @@ def test_conditional_node_serialize_all_operators_with_value_and_start_and_end(d
978
977
  # GIVEN a simple workflow with one conditional node
979
978
  workflow_cls = create_simple_workflow(descriptor)
980
979
 
981
- workflow_display = get_workflow_display(base_display_class=VellumWorkflowDisplay, workflow_class=workflow_cls)
980
+ workflow_display = get_workflow_display(workflow_class=workflow_cls)
982
981
  serialized_workflow: dict = workflow_display.serialize()
983
982
 
984
983
  # THEN we should get a serialized representation of the Workflow
@@ -1,6 +1,5 @@
1
1
  from deepdiff import DeepDiff
2
2
 
3
- from vellum_ee.workflows.display.workflows import VellumWorkflowDisplay
4
3
  from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
5
4
 
6
5
  from tests.workflows.basic_default_state.workflow import BasicDefaultStateWorkflow
@@ -9,9 +8,7 @@ from tests.workflows.basic_default_state.workflow import BasicDefaultStateWorkfl
9
8
  def test_serialize_workflow():
10
9
  # GIVEN a Workflow that has a simple state definition
11
10
  # WHEN we serialize it
12
- workflow_display = get_workflow_display(
13
- base_display_class=VellumWorkflowDisplay, workflow_class=BasicDefaultStateWorkflow
14
- )
11
+ workflow_display = get_workflow_display(workflow_class=BasicDefaultStateWorkflow)
15
12
 
16
13
  serialized_workflow: dict = workflow_display.serialize()
17
14
  # THEN we should get a serialized representation of the Workflow
@@ -1,6 +1,5 @@
1
1
  from deepdiff import DeepDiff
2
2
 
3
- from vellum_ee.workflows.display.workflows import VellumWorkflowDisplay
4
3
  from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
5
4
 
6
5
  from tests.workflows.basic_error_node.workflow import BasicErrorNodeWorkflow
@@ -9,9 +8,7 @@ from tests.workflows.basic_error_node.workflow import BasicErrorNodeWorkflow
9
8
  def test_serialize_workflow():
10
9
  # GIVEN a Workflow with an error node
11
10
  # WHEN we serialize it
12
- workflow_display = get_workflow_display(
13
- base_display_class=VellumWorkflowDisplay, workflow_class=BasicErrorNodeWorkflow
14
- )
11
+ workflow_display = get_workflow_display(workflow_class=BasicErrorNodeWorkflow)
15
12
 
16
13
  serialized_workflow: dict = workflow_display.serialize()
17
14
 
@@ -1,17 +1,14 @@
1
1
  from deepdiff import DeepDiff
2
2
 
3
- from vellum_ee.workflows.display.workflows import VellumWorkflowDisplay
4
3
  from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
5
4
 
6
5
  from tests.workflows.basic_generic_node.workflow import BasicGenericNodeWorkflow
7
6
 
8
7
 
9
- def test_serialize_workflow(vellum_client):
8
+ def test_serialize_workflow():
10
9
  # GIVEN a Workflow that uses a generic node
11
10
  # WHEN we serialize it
12
- workflow_display = get_workflow_display(
13
- base_display_class=VellumWorkflowDisplay, workflow_class=BasicGenericNodeWorkflow
14
- )
11
+ workflow_display = get_workflow_display(workflow_class=BasicGenericNodeWorkflow)
15
12
 
16
13
  serialized_workflow: dict = workflow_display.serialize()
17
14
 
@@ -1,6 +1,5 @@
1
1
  from deepdiff import DeepDiff
2
2
 
3
- from vellum_ee.workflows.display.workflows import VellumWorkflowDisplay
4
3
  from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
5
4
 
6
5
  from tests.workflows.basic_guardrail_node.workflow import BasicGuardrailNodeWorkflow
@@ -9,14 +8,17 @@ from tests.workflows.basic_guardrail_node.workflow import BasicGuardrailNodeWork
9
8
  def test_serialize_workflow():
10
9
  # GIVEN a workflow that uses a guardrail node
11
10
  # WHEN we serialize it
12
- workflow_display = get_workflow_display(
13
- base_display_class=VellumWorkflowDisplay, workflow_class=BasicGuardrailNodeWorkflow
14
- )
11
+ workflow_display = get_workflow_display(workflow_class=BasicGuardrailNodeWorkflow)
15
12
 
16
13
  serialized_workflow: dict = workflow_display.serialize()
17
14
 
18
15
  # THEN we should get a serialized representation of the workflow
19
- assert serialized_workflow.keys() == {"workflow_raw_data", "input_variables", "state_variables", "output_variables"}
16
+ assert serialized_workflow.keys() == {
17
+ "workflow_raw_data",
18
+ "input_variables",
19
+ "state_variables",
20
+ "output_variables",
21
+ }
20
22
 
21
23
  # AND its input variables should be what we expect
22
24
  input_variables = serialized_workflow["input_variables"]
@@ -1,4 +1,3 @@
1
- from vellum_ee.workflows.display.workflows import VellumWorkflowDisplay
2
1
  from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
3
2
 
4
3
  from tests.workflows.basic_inline_prompt_node_with_functions.workflow import BasicInlinePromptWithFunctionsWorkflow
@@ -6,9 +5,7 @@ from tests.workflows.basic_inline_prompt_node_with_functions.workflow import Bas
6
5
 
7
6
  def test_serialize_workflow():
8
7
  # WHEN we serialize it
9
- workflow_display = get_workflow_display(
10
- base_display_class=VellumWorkflowDisplay, workflow_class=BasicInlinePromptWithFunctionsWorkflow
11
- )
8
+ workflow_display = get_workflow_display(workflow_class=BasicInlinePromptWithFunctionsWorkflow)
12
9
  serialized_workflow: dict = workflow_display.serialize()
13
10
  assert (
14
11
  serialized_workflow["workflow_raw_data"]["nodes"][-2]["data"]["exec_config"]["prompt_template_block_data"][
@@ -1,6 +1,5 @@
1
1
  from deepdiff import DeepDiff
2
2
 
3
- from vellum_ee.workflows.display.workflows import VellumWorkflowDisplay
4
3
  from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
5
4
 
6
5
  from tests.workflows.basic_inline_subworkflow.workflow import BasicInlineSubworkflowWorkflow
@@ -9,9 +8,7 @@ from tests.workflows.basic_inline_subworkflow.workflow import BasicInlineSubwork
9
8
  def test_serialize_workflow():
10
9
  # GIVEN a Workflow
11
10
  # WHEN we serialize it
12
- workflow_display = get_workflow_display(
13
- base_display_class=VellumWorkflowDisplay, workflow_class=BasicInlineSubworkflowWorkflow
14
- )
11
+ workflow_display = get_workflow_display(workflow_class=BasicInlineSubworkflowWorkflow)
15
12
  serialized_workflow: dict = workflow_display.serialize()
16
13
 
17
14
  # THEN we should get a serialized representation of the Workflow
@@ -1,6 +1,5 @@
1
1
  from deepdiff import DeepDiff
2
2
 
3
- from vellum_ee.workflows.display.workflows import VellumWorkflowDisplay
4
3
  from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
5
4
 
6
5
  from tests.workflows.basic_map_node.workflow import SimpleMapExample
@@ -9,7 +8,7 @@ from tests.workflows.basic_map_node.workflow import SimpleMapExample
9
8
  def test_serialize_workflow():
10
9
  # GIVEN a Workflow that uses a MapNode
11
10
  # WHEN we serialize it
12
- workflow_display = get_workflow_display(base_display_class=VellumWorkflowDisplay, workflow_class=SimpleMapExample)
11
+ workflow_display = get_workflow_display(workflow_class=SimpleMapExample)
13
12
  serialized_workflow: dict = workflow_display.serialize()
14
13
 
15
14
  # THEN we should get a serialized representation of the Workflow
@@ -1,6 +1,5 @@
1
1
  from deepdiff import DeepDiff
2
2
 
3
- from vellum_ee.workflows.display.workflows import VellumWorkflowDisplay
4
3
  from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
5
4
 
6
5
  from tests.workflows.basic_merge_node.await_all_workflow import AwaitAllPassingWorkflow
@@ -9,9 +8,7 @@ from tests.workflows.basic_merge_node.await_all_workflow import AwaitAllPassingW
9
8
  def test_serialize_workflow__await_all():
10
9
  # GIVEN a Workflow that uses an await all merge node
11
10
  # WHEN we serialize it
12
- workflow_display = get_workflow_display(
13
- base_display_class=VellumWorkflowDisplay, workflow_class=AwaitAllPassingWorkflow
14
- )
11
+ workflow_display = get_workflow_display(workflow_class=AwaitAllPassingWorkflow)
15
12
  serialized_workflow: dict = workflow_display.serialize()
16
13
 
17
14
  # THEN we should get a serialized representation of the Workflow
@@ -4,7 +4,6 @@ from uuid import uuid4
4
4
  from deepdiff import DeepDiff
5
5
 
6
6
  from vellum import DeploymentRead
7
- from vellum_ee.workflows.display.workflows import VellumWorkflowDisplay
8
7
  from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
9
8
 
10
9
  from tests.workflows.basic_text_prompt_deployment.workflow import BasicTextPromptDeployment
@@ -25,9 +24,7 @@ def test_serialize_workflow(vellum_client):
25
24
  vellum_client.deployments.retrieve.return_value = deployment
26
25
 
27
26
  # WHEN we serialize it
28
- workflow_display = get_workflow_display(
29
- base_display_class=VellumWorkflowDisplay, workflow_class=BasicTextPromptDeployment
30
- )
27
+ workflow_display = get_workflow_display(workflow_class=BasicTextPromptDeployment)
31
28
  serialized_workflow: dict = workflow_display.serialize()
32
29
 
33
30
  # THEN we should get a serialized representation of the Workflow
@@ -1,4 +1,3 @@
1
- from vellum_ee.workflows.display.workflows import VellumWorkflowDisplay
2
1
  from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
3
2
 
4
3
  from tests.workflows.basic_search_node.workflow import BasicSearchWorkflow
@@ -8,14 +7,17 @@ def test_serialize_workflow():
8
7
  # GIVEN a Workflow with a search node
9
8
  # WHEN we serialize it
10
9
 
11
- workflow_display = get_workflow_display(
12
- base_display_class=VellumWorkflowDisplay, workflow_class=BasicSearchWorkflow
13
- )
10
+ workflow_display = get_workflow_display(workflow_class=BasicSearchWorkflow)
14
11
 
15
12
  serialized_workflow: dict = workflow_display.serialize()
16
13
 
17
14
  # THEN we should get a serialized representation of the workflow
18
- assert serialized_workflow.keys() == {"workflow_raw_data", "input_variables", "state_variables", "output_variables"}
15
+ assert serialized_workflow.keys() == {
16
+ "workflow_raw_data",
17
+ "input_variables",
18
+ "state_variables",
19
+ "output_variables",
20
+ }
19
21
 
20
22
  # AND its input variables should be what we expect
21
23
  input_variables = serialized_workflow["input_variables"]
@@ -4,7 +4,6 @@ from uuid import uuid4
4
4
  from deepdiff import DeepDiff
5
5
 
6
6
  from vellum import WorkflowDeploymentRead
7
- from vellum_ee.workflows.display.workflows import VellumWorkflowDisplay
8
7
  from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
9
8
 
10
9
  from tests.workflows.basic_subworkflow_deployment.workflow import BasicSubworkflowDeploymentWorkflow
@@ -25,9 +24,7 @@ def test_serialize_workflow(vellum_client):
25
24
  vellum_client.workflow_deployments.retrieve.return_value = deployment
26
25
 
27
26
  # WHEN we serialize it
28
- workflow_display = get_workflow_display(
29
- base_display_class=VellumWorkflowDisplay, workflow_class=BasicSubworkflowDeploymentWorkflow
30
- )
27
+ workflow_display = get_workflow_display(workflow_class=BasicSubworkflowDeploymentWorkflow)
31
28
  serialized_workflow: dict = workflow_display.serialize()
32
29
 
33
30
  # THEN we should get a serialized representation of the Workflow
@@ -1,6 +1,5 @@
1
1
  from deepdiff import DeepDiff
2
2
 
3
- from vellum_ee.workflows.display.workflows import VellumWorkflowDisplay
4
3
  from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
5
4
 
6
5
  from tests.workflows.basic_templating_node.workflow_with_json_input import BasicTemplatingNodeWorkflowWithJson
@@ -10,9 +9,7 @@ def test_serialize_workflow():
10
9
  # GIVEN a Workflow that uses a vellum templating node",
11
10
 
12
11
  # WHEN we serialize it
13
- workflow_display = get_workflow_display(
14
- base_display_class=VellumWorkflowDisplay, workflow_class=BasicTemplatingNodeWorkflowWithJson
15
- )
12
+ workflow_display = get_workflow_display(workflow_class=BasicTemplatingNodeWorkflowWithJson)
16
13
 
17
14
  serialized_workflow: dict = workflow_display.serialize()
18
15
 
@@ -1,4 +1,3 @@
1
- from vellum_ee.workflows.display.workflows import VellumWorkflowDisplay
2
1
  from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
3
2
 
4
3
  from tests.workflows.basic_final_output_node.workflow import BasicFinalOutputNodeWorkflow
@@ -7,9 +6,7 @@ from tests.workflows.basic_final_output_node.workflow import BasicFinalOutputNod
7
6
  def test_serialize_workflow():
8
7
  # GIVEN a Workflow that uses a Final Output Node
9
8
  # WHEN we serialize it
10
- workflow_display = get_workflow_display(
11
- base_display_class=VellumWorkflowDisplay, workflow_class=BasicFinalOutputNodeWorkflow
12
- )
9
+ workflow_display = get_workflow_display(workflow_class=BasicFinalOutputNodeWorkflow)
13
10
  serialized_workflow: dict = workflow_display.serialize()
14
11
 
15
12
  # THEN we should get a serialized representation of the Workflow
@@ -2,7 +2,6 @@ import pytest
2
2
 
3
3
  from deepdiff import DeepDiff
4
4
 
5
- from vellum_ee.workflows.display.workflows import VellumWorkflowDisplay
6
5
  from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
7
6
 
8
7
  from tests.workflows.basic_try_node.workflow import SimpleTryExample, StandaloneTryExample
@@ -11,7 +10,7 @@ from tests.workflows.basic_try_node.workflow import SimpleTryExample, Standalone
11
10
  def test_serialize_workflow():
12
11
  # GIVEN a Workflow with a TryNode
13
12
  # WHEN we serialize it
14
- workflow_display = get_workflow_display(base_display_class=VellumWorkflowDisplay, workflow_class=SimpleTryExample)
13
+ workflow_display = get_workflow_display(workflow_class=SimpleTryExample)
15
14
  serialized_workflow: dict = workflow_display.serialize()
16
15
 
17
16
  # THEN we should get a serialized representation of the Workflow
@@ -77,9 +76,7 @@ def test_serialize_workflow__standalone():
77
76
  # GIVEN a Workflow with a standalone TryNode
78
77
  # WHEN we serialize it
79
78
  with pytest.raises(NotImplementedError) as exc:
80
- workflow_display = get_workflow_display(
81
- base_display_class=VellumWorkflowDisplay, workflow_class=StandaloneTryExample
82
- )
79
+ workflow_display = get_workflow_display(workflow_class=StandaloneTryExample)
83
80
  workflow_display.serialize()
84
81
 
85
82
  # THEN we should get an error
@@ -2,7 +2,6 @@ import pytest
2
2
 
3
3
  from deepdiff import DeepDiff
4
4
 
5
- from vellum_ee.workflows.display.workflows import VellumWorkflowDisplay
6
5
  from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
7
6
 
8
7
  from tests.workflows.complex_final_output_node.missing_final_output_node import MissingFinalOutputNodeWorkflow
@@ -11,9 +10,7 @@ from tests.workflows.complex_final_output_node.missing_workflow_output import Mi
11
10
 
12
11
  def test_serialize_workflow__missing_final_output_node():
13
12
  # GIVEN a Workflow that is missing a Terminal Node
14
- workflow_display = get_workflow_display(
15
- base_display_class=VellumWorkflowDisplay, workflow_class=MissingFinalOutputNodeWorkflow
16
- )
13
+ workflow_display = get_workflow_display(workflow_class=MissingFinalOutputNodeWorkflow)
17
14
 
18
15
  # WHEN we serialize it
19
16
  serialized_workflow: dict = workflow_display.serialize()
@@ -179,9 +176,7 @@ def test_serialize_workflow__missing_final_output_node():
179
176
 
180
177
  def test_serialize_workflow__missing_workflow_output():
181
178
  # GIVEN a Workflow that contains a terminal node that is unreferenced by the Workflow's Outputs
182
- workflow_display = get_workflow_display(
183
- base_display_class=VellumWorkflowDisplay, workflow_class=MissingWorkflowOutputWorkflow
184
- )
179
+ workflow_display = get_workflow_display(workflow_class=MissingWorkflowOutputWorkflow)
185
180
 
186
181
  # WHEN we serialize it, it should throw an error
187
182
  with pytest.raises(ValueError) as exc_info:
@@ -1,11 +1,12 @@
1
1
  from dataclasses import dataclass, field
2
- from typing import TYPE_CHECKING, Dict, Tuple, Type, TypeVar
2
+ from typing import TYPE_CHECKING, Dict, Tuple, Type
3
3
 
4
4
  from vellum.workflows.descriptors.base import BaseDescriptor
5
5
  from vellum.workflows.events.workflow import WorkflowEventDisplayContext # noqa: F401
6
6
  from vellum.workflows.nodes import BaseNode
7
7
  from vellum.workflows.ports import Port
8
8
  from vellum.workflows.references import OutputReference, StateValueReference, WorkflowInputReference
9
+ from vellum.workflows.workflows.base import BaseWorkflow
9
10
  from vellum_ee.workflows.display.base import (
10
11
  EdgeDisplay,
11
12
  EntrypointDisplay,
@@ -16,11 +17,11 @@ from vellum_ee.workflows.display.base import (
16
17
  )
17
18
  from vellum_ee.workflows.display.nodes.base_node_display import BaseNodeDisplay
18
19
  from vellum_ee.workflows.display.nodes.types import NodeOutputDisplay, PortDisplay
20
+ from vellum_ee.workflows.display.utils.registry import get_default_workflow_display_class
19
21
 
20
22
  if TYPE_CHECKING:
21
23
  from vellum_ee.workflows.display.workflows import BaseWorkflowDisplay
22
24
 
23
- WorkflowDisplayType = TypeVar("WorkflowDisplayType", bound="BaseWorkflowDisplay")
24
25
 
25
26
  WorkflowInputsDisplays = Dict[WorkflowInputReference, WorkflowInputsDisplay]
26
27
  StateValueDisplays = Dict[StateValueReference, StateValueDisplay]
@@ -34,8 +35,8 @@ PortDisplays = Dict[Port, PortDisplay]
34
35
 
35
36
  @dataclass
36
37
  class WorkflowDisplayContext:
37
- workflow_display_class: Type["BaseWorkflowDisplay"]
38
- workflow_display: WorkflowMetaDisplay
38
+ workflow_display_class: Type["BaseWorkflowDisplay"] = field(default_factory=get_default_workflow_display_class)
39
+ workflow_display: WorkflowMetaDisplay = field(default_factory=lambda: WorkflowMetaDisplay.get_default(BaseWorkflow))
39
40
  workflow_input_displays: WorkflowInputsDisplays = field(default_factory=dict)
40
41
  global_workflow_input_displays: WorkflowInputsDisplays = field(default_factory=dict)
41
42
  state_value_displays: StateValueDisplays = field(default_factory=dict)
@@ -0,0 +1,7 @@
1
+ class UserFacingException(Exception):
2
+ def to_message(self) -> str:
3
+ return str(self)
4
+
5
+
6
+ class UnsupportedSerializationException(UserFacingException):
7
+ pass
@@ -0,0 +1,37 @@
1
+ from typing import TYPE_CHECKING, Dict, Optional, Type
2
+
3
+ from vellum.workflows.nodes import BaseNode
4
+ from vellum.workflows.workflows.base import BaseWorkflow
5
+
6
+ if TYPE_CHECKING:
7
+ from vellum_ee.workflows.display.nodes.base_node_display import BaseNodeDisplay
8
+ from vellum_ee.workflows.display.workflows.base_workflow_display import BaseWorkflowDisplay
9
+
10
+
11
+ # Used to store the mapping between workflows and their display classes
12
+ _workflow_display_registry: Dict[Type[BaseWorkflow], Type["BaseWorkflowDisplay"]] = {}
13
+
14
+ # Used to store the mapping between node types and their display classes
15
+ _node_display_registry: Dict[Type[BaseNode], Type["BaseNodeDisplay"]] = {}
16
+
17
+
18
+ def get_from_workflow_display_registry(workflow_class: Type[BaseWorkflow]) -> Optional[Type["BaseWorkflowDisplay"]]:
19
+ return _workflow_display_registry.get(workflow_class)
20
+
21
+
22
+ def register_workflow_display_class(
23
+ workflow_class: Type[BaseWorkflow], workflow_display_class: Type["BaseWorkflowDisplay"]
24
+ ) -> None:
25
+ _workflow_display_registry[workflow_class] = workflow_display_class
26
+
27
+
28
+ def get_default_workflow_display_class() -> Type["BaseWorkflowDisplay"]:
29
+ return _workflow_display_registry[BaseWorkflow]
30
+
31
+
32
+ def get_from_node_display_registry(node_class: Type[BaseNode]) -> Optional[Type["BaseNodeDisplay"]]:
33
+ return _node_display_registry.get(node_class)
34
+
35
+
36
+ def register_node_display_class(node_class: Type[BaseNode], node_display_class: Type["BaseNodeDisplay"]) -> None:
37
+ _node_display_registry[node_class] = node_display_class
@@ -41,6 +41,7 @@ from vellum.workflows.references.node import NodeReference
41
41
  from vellum.workflows.references.vellum_secret import VellumSecretReference
42
42
  from vellum.workflows.utils.vellum_variables import primitive_type_to_vellum_variable_type
43
43
  from vellum.workflows.vellum_client import create_vellum_client
44
+ from vellum_ee.workflows.display.utils.exceptions import UnsupportedSerializationException
44
45
  from vellum_ee.workflows.display.utils.expressions import get_child_descriptor
45
46
 
46
47
  if TYPE_CHECKING:
@@ -164,7 +165,7 @@ def create_node_input_value_pointer_rule(
164
165
  vellum_value = primitive_to_vellum_value(value)
165
166
  return ConstantValuePointer(type="CONSTANT_VALUE", data=vellum_value)
166
167
 
167
- raise ValueError(f"Unsupported descriptor type: {value.__class__.__name__}")
168
+ raise UnsupportedSerializationException(f"Unsupported descriptor type: {value.__class__.__name__}")
168
169
 
169
170
 
170
171
  def convert_descriptor_to_operator(descriptor: BaseDescriptor) -> LogicalOperator: