vellum-ai 0.10.9__py3-none-any.whl → 0.11.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. vellum/client/core/client_wrapper.py +1 -1
  2. vellum/evaluations/resources.py +7 -12
  3. vellum/evaluations/utils/env.py +1 -3
  4. vellum/evaluations/utils/paginator.py +0 -1
  5. vellum/evaluations/utils/typing.py +1 -1
  6. vellum/evaluations/utils/uuid.py +1 -1
  7. vellum/plugins/vellum_mypy.py +3 -1
  8. vellum/workflows/events/node.py +7 -6
  9. vellum/workflows/events/tests/test_event.py +0 -1
  10. vellum/workflows/events/types.py +0 -1
  11. vellum/workflows/events/workflow.py +19 -1
  12. vellum/workflows/nodes/bases/base.py +17 -56
  13. vellum/workflows/nodes/bases/tests/test_base_node.py +0 -1
  14. vellum/workflows/nodes/core/templating_node/node.py +1 -0
  15. vellum/workflows/nodes/core/try_node/node.py +2 -2
  16. vellum/workflows/nodes/core/try_node/tests/test_node.py +1 -3
  17. vellum/workflows/nodes/displayable/bases/api_node/node.py +1 -1
  18. vellum/workflows/nodes/displayable/bases/base_prompt_node/node.py +0 -1
  19. vellum/workflows/nodes/displayable/bases/inline_prompt_node/node.py +0 -1
  20. vellum/workflows/nodes/displayable/bases/prompt_deployment_node.py +2 -1
  21. vellum/workflows/nodes/displayable/bases/search_node.py +0 -1
  22. vellum/workflows/nodes/displayable/code_execution_node/tests/test_code_execution_node.py +0 -1
  23. vellum/workflows/nodes/displayable/code_execution_node/utils.py +3 -2
  24. vellum/workflows/nodes/displayable/conditional_node/node.py +1 -1
  25. vellum/workflows/nodes/displayable/guardrail_node/node.py +0 -1
  26. vellum/workflows/nodes/displayable/inline_prompt_node/node.py +1 -0
  27. vellum/workflows/nodes/displayable/prompt_deployment_node/node.py +3 -1
  28. vellum/workflows/nodes/displayable/search_node/node.py +1 -0
  29. vellum/workflows/nodes/displayable/subworkflow_deployment_node/node.py +3 -2
  30. vellum/workflows/nodes/displayable/tests/test_inline_text_prompt_node.py +10 -7
  31. vellum/workflows/nodes/displayable/tests/test_search_node_wth_text_output.py +0 -1
  32. vellum/workflows/outputs/base.py +2 -4
  33. vellum/workflows/ports/node_ports.py +1 -1
  34. vellum/workflows/runner/runner.py +152 -191
  35. vellum/workflows/state/base.py +0 -2
  36. vellum/workflows/types/core.py +1 -0
  37. vellum/workflows/types/tests/test_utils.py +1 -0
  38. vellum/workflows/types/utils.py +0 -1
  39. vellum/workflows/utils/functions.py +74 -0
  40. vellum/workflows/utils/tests/test_functions.py +171 -0
  41. vellum/workflows/utils/tests/test_vellum_variables.py +0 -1
  42. vellum/workflows/utils/vellum_variables.py +2 -2
  43. vellum/workflows/workflows/base.py +74 -34
  44. vellum/workflows/workflows/event_filters.py +4 -12
  45. {vellum_ai-0.10.9.dist-info → vellum_ai-0.11.0.dist-info}/METADATA +1 -1
  46. {vellum_ai-0.10.9.dist-info → vellum_ai-0.11.0.dist-info}/RECORD +96 -90
  47. vellum_cli/__init__.py +147 -13
  48. vellum_cli/config.py +0 -1
  49. vellum_cli/image_push.py +1 -1
  50. vellum_cli/pull.py +29 -19
  51. vellum_cli/push.py +9 -10
  52. vellum_cli/tests/__init__.py +0 -0
  53. vellum_cli/tests/conftest.py +40 -0
  54. vellum_cli/tests/test_main.py +11 -0
  55. vellum_cli/tests/test_pull.py +125 -71
  56. vellum_cli/tests/test_push.py +173 -0
  57. vellum_ee/workflows/display/nodes/base_node_display.py +3 -2
  58. vellum_ee/workflows/display/nodes/base_node_vellum_display.py +2 -2
  59. vellum_ee/workflows/display/nodes/get_node_display_class.py +1 -1
  60. vellum_ee/workflows/display/nodes/tests/test_base_node_display.py +1 -1
  61. vellum_ee/workflows/display/nodes/vellum/__init__.py +1 -1
  62. vellum_ee/workflows/display/nodes/vellum/api_node.py +4 -7
  63. vellum_ee/workflows/display/nodes/vellum/conditional_node.py +39 -22
  64. vellum_ee/workflows/display/nodes/vellum/error_node.py +3 -3
  65. vellum_ee/workflows/display/nodes/vellum/final_output_node.py +0 -2
  66. vellum_ee/workflows/display/nodes/vellum/guardrail_node.py +1 -1
  67. vellum_ee/workflows/display/nodes/vellum/inline_prompt_node.py +1 -1
  68. vellum_ee/workflows/display/nodes/vellum/inline_subworkflow_node.py +4 -2
  69. vellum_ee/workflows/display/nodes/vellum/map_node.py +11 -5
  70. vellum_ee/workflows/display/nodes/vellum/merge_node.py +2 -2
  71. vellum_ee/workflows/display/nodes/vellum/note_node.py +1 -3
  72. vellum_ee/workflows/display/nodes/vellum/prompt_deployment_node.py +1 -1
  73. vellum_ee/workflows/display/nodes/vellum/search_node.py +1 -1
  74. vellum_ee/workflows/display/nodes/vellum/subworkflow_deployment_node.py +1 -1
  75. vellum_ee/workflows/display/nodes/vellum/templating_node.py +1 -1
  76. vellum_ee/workflows/display/nodes/vellum/tests/test_utils.py +5 -5
  77. vellum_ee/workflows/display/nodes/vellum/utils.py +4 -4
  78. vellum_ee/workflows/display/tests/test_vellum_workflow_display.py +45 -0
  79. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_api_node_serialization.py +13 -24
  80. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_conditional_node_serialization.py +13 -39
  81. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_guardrail_node_serialization.py +2 -2
  82. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_inline_subworkflow_serialization.py +62 -58
  83. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_map_node_serialization.py +25 -4
  84. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_merge_node_serialization.py +2 -1
  85. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_prompt_deployment_serialization.py +2 -2
  86. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_subworkflow_deployment_serialization.py +2 -2
  87. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_terminal_node_serialization.py +1 -1
  88. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_try_node_serialization.py +2 -1
  89. vellum_ee/workflows/display/tests/workflow_serialization/test_complex_terminal_node_serialization.py +2 -2
  90. vellum_ee/workflows/display/types.py +4 -4
  91. vellum_ee/workflows/display/utils/vellum.py +2 -6
  92. vellum_ee/workflows/display/workflows/get_vellum_workflow_display_class.py +4 -1
  93. vellum_ee/workflows/display/workflows/vellum_workflow_display.py +6 -2
  94. vellum/workflows/runner/types.py +0 -16
  95. {vellum_ai-0.10.9.dist-info → vellum_ai-0.11.0.dist-info}/LICENSE +0 -0
  96. {vellum_ai-0.10.9.dist-info → vellum_ai-0.11.0.dist-info}/WHEEL +0 -0
  97. {vellum_ai-0.10.9.dist-info → vellum_ai-0.11.0.dist-info}/entry_points.txt +0 -0
@@ -1,7 +1,7 @@
1
1
  from typing import Optional, Type
2
2
 
3
- from vellum_ee.workflows.display.types import NodeDisplayType
4
3
  from vellum.workflows.types.generics import NodeType
4
+ from vellum_ee.workflows.display.types import NodeDisplayType
5
5
 
6
6
 
7
7
  def get_node_display_class(
@@ -1,8 +1,8 @@
1
1
  import pytest
2
2
  from uuid import UUID
3
3
 
4
- from vellum_ee.workflows.display.nodes.base_node_display import BaseNodeDisplay
5
4
  from vellum.workflows.nodes.bases import BaseNode
5
+ from vellum_ee.workflows.display.nodes.base_node_display import BaseNodeDisplay
6
6
 
7
7
 
8
8
  @pytest.fixture
@@ -32,5 +32,5 @@ __all__ = [
32
32
  "BaseSearchNodeDisplay",
33
33
  "BaseSubworkflowDeploymentNodeDisplay",
34
34
  "BaseTemplatingNodeDisplay",
35
- "BaseTryNodeDisplay"
35
+ "BaseTryNodeDisplay",
36
36
  ]
@@ -22,10 +22,6 @@ class BaseAPINodeDisplay(BaseNodeVellumDisplay[_APINodeType], Generic[_APINodeTy
22
22
  api_key_header_key_input_id: ClassVar[Optional[UUID]] = None
23
23
  api_key_header_value_input_id: ClassVar[Optional[UUID]] = None
24
24
 
25
- text_output_id: ClassVar[Optional[UUID]] = None
26
- json_output_id: ClassVar[Optional[UUID]] = None
27
- status_code_output_id: ClassVar[Optional[UUID]] = None
28
-
29
25
  # A mapping between node input keys and their ids for inputs representing additional header keys
30
26
  additional_header_key_input_ids: ClassVar[Optional[Dict[str, UUID]]] = None
31
27
 
@@ -68,6 +64,7 @@ class BaseAPINodeDisplay(BaseNodeVellumDisplay[_APINodeType], Generic[_APINodeTy
68
64
 
69
65
  headers = raise_if_descriptor(node.headers)
70
66
  api_key_header_key = raise_if_descriptor(node.api_key_header_key)
67
+ api_key_header_value = raise_if_descriptor(node.api_key_header_value)
71
68
  authorization_type = raise_if_descriptor(node.authorization_type)
72
69
  bearer_token_value = raise_if_descriptor(node.bearer_token_value)
73
70
 
@@ -112,7 +109,7 @@ class BaseAPINodeDisplay(BaseNodeVellumDisplay[_APINodeType], Generic[_APINodeTy
112
109
  display_context=display_context,
113
110
  input_id=self.api_key_header_value_input_id,
114
111
  )
115
- if headers and api_key_header_key
112
+ if headers and api_key_header_key and api_key_header_value
116
113
  else None
117
114
  )
118
115
 
@@ -123,7 +120,7 @@ class BaseAPINodeDisplay(BaseNodeVellumDisplay[_APINodeType], Generic[_APINodeTy
123
120
  {
124
121
  "header_key_input_id": create_node_input(
125
122
  node_id=node_id,
126
- input_name=f"additional_header_key_{key}",
123
+ input_name="additional_header_key",
127
124
  value=key,
128
125
  display_context=display_context,
129
126
  input_id=(
@@ -134,7 +131,7 @@ class BaseAPINodeDisplay(BaseNodeVellumDisplay[_APINodeType], Generic[_APINodeTy
134
131
  ).id,
135
132
  "header_value_input_id": create_node_input(
136
133
  node_id=node_id,
137
- input_name=f"additional_header_value_{key}",
134
+ input_name="additional_header_value",
138
135
  value=value,
139
136
  display_context=display_context,
140
137
  input_id=(
@@ -1,12 +1,7 @@
1
1
  from dataclasses import dataclass
2
2
  from uuid import UUID
3
- from typing import Any, ClassVar, Dict, Generic, List, Optional, TypeVar, Union, Tuple
3
+ from typing import Any, ClassVar, Dict, Generic, List, Optional, Tuple, TypeVar, Union
4
4
 
5
- from vellum_ee.workflows.display.nodes.base_node_vellum_display import BaseNodeVellumDisplay
6
- from vellum_ee.workflows.display.nodes.vellum.utils import create_node_input
7
- from vellum_ee.workflows.display.types import WorkflowDisplayContext
8
- from vellum_ee.workflows.display.utils.uuids import uuid4_from_hash
9
- from vellum_ee.workflows.display.vellum import NodeInput
10
5
  from vellum.workflows.descriptors.base import BaseDescriptor
11
6
  from vellum.workflows.expressions.and_ import AndExpression
12
7
  from vellum.workflows.expressions.begins_with import BeginsWithExpression
@@ -29,7 +24,12 @@ from vellum.workflows.expressions.not_between import NotBetweenExpression
29
24
  from vellum.workflows.expressions.not_in import NotInExpression
30
25
  from vellum.workflows.expressions.or_ import OrExpression
31
26
  from vellum.workflows.nodes.displayable import ConditionalNode
32
- from vellum.workflows.types.core import JsonObject, ConditionType
27
+ from vellum.workflows.types.core import ConditionType, JsonObject
28
+ from vellum_ee.workflows.display.nodes.base_node_vellum_display import BaseNodeVellumDisplay
29
+ from vellum_ee.workflows.display.nodes.vellum.utils import create_node_input
30
+ from vellum_ee.workflows.display.types import WorkflowDisplayContext
31
+ from vellum_ee.workflows.display.utils.uuids import uuid4_from_hash
32
+ from vellum_ee.workflows.display.vellum import NodeInput
33
33
 
34
34
  _ConditionalNodeType = TypeVar("_ConditionalNodeType", bound=ConditionalNode)
35
35
 
@@ -42,6 +42,7 @@ class RuleIdMap:
42
42
  field_node_input_id: Optional[UUID]
43
43
  value_node_input_id: Optional[UUID]
44
44
 
45
+
45
46
  @dataclass
46
47
  class ConditionId:
47
48
  id: UUID
@@ -65,7 +66,9 @@ class BaseConditionalNodeDisplay(BaseNodeVellumDisplay[_ConditionalNodeType], Ge
65
66
 
66
67
  if len(condition_ids) > ports_size:
67
68
  raise ValueError(
68
- f"Too many defined condition ids. Ports are size {ports_size} but the defined conditions have length {len(condition_ids)}")
69
+ f"""Too many defined condition ids. Ports are size {ports_size} \
70
+ but the defined conditions have length {len(condition_ids)}"""
71
+ )
69
72
 
70
73
  def serialize_rule(
71
74
  descriptor: BaseDescriptor, path: List[int], rule_id_map: Optional[RuleIdMap]
@@ -113,7 +116,11 @@ class BaseConditionalNodeDisplay(BaseNodeVellumDisplay[_ConditionalNodeType], Ge
113
116
  node_id, f"{current_id}.field", descriptor._value, display_context, field_node_input_id
114
117
  )
115
118
  value_node_input = create_node_input(
116
- node_id, f"{current_id}.value", f"{descriptor._start},{descriptor._end}", display_context, value_node_input_id
119
+ node_id,
120
+ f"{current_id}.value",
121
+ f"{descriptor._start},{descriptor._end}",
122
+ display_context,
123
+ value_node_input_id,
117
124
  )
118
125
  node_inputs.extend([field_node_input, value_node_input])
119
126
  operator = self._convert_descriptor_to_operator(descriptor)
@@ -124,11 +131,15 @@ class BaseConditionalNodeDisplay(BaseNodeVellumDisplay[_ConditionalNodeType], Ge
124
131
  lhs = descriptor._lhs # type: ignore[attr-defined]
125
132
  rhs = descriptor._rhs # type: ignore[attr-defined]
126
133
 
127
- lhs_node_input = create_node_input(node_id, f"{current_id}.field", lhs, display_context, field_node_input_id)
134
+ lhs_node_input = create_node_input(
135
+ node_id, f"{current_id}.field", lhs, display_context, field_node_input_id
136
+ )
128
137
  node_inputs.append(lhs_node_input)
129
138
 
130
139
  if descriptor._rhs is not None: # type: ignore[attr-defined]
131
- rhs_node_input = create_node_input(node_id, f"{current_id}.value", rhs, display_context, value_node_input_id)
140
+ rhs_node_input = create_node_input(
141
+ node_id, f"{current_id}.value", rhs, display_context, value_node_input_id
142
+ )
132
143
  node_inputs.append(rhs_node_input)
133
144
  value_node_input_id = UUID(rhs_node_input.id)
134
145
 
@@ -148,18 +159,24 @@ class BaseConditionalNodeDisplay(BaseNodeVellumDisplay[_ConditionalNodeType], Ge
148
159
  conditions = []
149
160
  for idx, port in enumerate(node.Ports):
150
161
 
151
- condition_id = str(condition_ids[idx].id if condition_ids else uuid4_from_hash(f"{node_id}|conditions|{idx}"))
152
- rule_group_id = str(condition_ids[idx].rule_group_id if condition_ids else uuid4_from_hash(f"{condition_id}|rule_group"))
162
+ condition_id = str(
163
+ condition_ids[idx].id if condition_ids else uuid4_from_hash(f"{node_id}|conditions|{idx}")
164
+ )
165
+ rule_group_id = str(
166
+ condition_ids[idx].rule_group_id if condition_ids else uuid4_from_hash(f"{condition_id}|rule_group")
167
+ )
153
168
  source_handle_id = str(source_handle_ids.get(idx) or uuid4_from_hash(f"{node_id}|handles|{idx}"))
154
169
 
155
170
  if port._condition is None:
156
171
  if port._condition_type == ConditionType.ELSE:
157
- conditions.append({
158
- "id": condition_id,
159
- "type": ConditionType.ELSE.value,
160
- "source_handle_id": source_handle_id,
161
- "data": None
162
- })
172
+ conditions.append(
173
+ {
174
+ "id": condition_id,
175
+ "type": ConditionType.ELSE.value,
176
+ "source_handle_id": source_handle_id,
177
+ "data": None,
178
+ }
179
+ )
163
180
  else:
164
181
  continue
165
182
 
@@ -241,7 +258,7 @@ class BaseConditionalNodeDisplay(BaseNodeVellumDisplay[_ConditionalNodeType], Ge
241
258
  raise ValueError(f"Unsupported descriptor type: {descriptor}")
242
259
 
243
260
  def get_nested_rule_details_by_path(
244
- self, rule_ids: List[RuleIdMap], path: List[int]
261
+ self, rule_ids: List[RuleIdMap], path: List[int]
245
262
  ) -> Union[Tuple[UUID, Optional[UUID], Optional[UUID]], None]:
246
263
  current_rule = rule_ids[path[0]]
247
264
 
@@ -267,7 +284,7 @@ class BaseConditionalNodeDisplay(BaseNodeVellumDisplay[_ConditionalNodeType], Ge
267
284
  return (
268
285
  uuid4_from_hash(f"{node_id}|{rule_id}|current"),
269
286
  uuid4_from_hash(f"{node_id}|{rule_id}||field"),
270
- uuid4_from_hash(f"{node_id}|{rule_id}||value")
287
+ uuid4_from_hash(f"{node_id}|{rule_id}||value"),
271
288
  )
272
289
 
273
290
  def _get_source_handle_ids(self) -> Dict[int, UUID]:
@@ -276,5 +293,5 @@ class BaseConditionalNodeDisplay(BaseNodeVellumDisplay[_ConditionalNodeType], Ge
276
293
  def _get_rule_ids(self) -> List[RuleIdMap]:
277
294
  return self._get_explicit_node_display_attr("rule_ids", List[RuleIdMap]) or []
278
295
 
279
- def _get_condition_ids(self)-> List[ConditionId]:
296
+ def _get_condition_ids(self) -> List[ConditionId]:
280
297
  return self._get_explicit_node_display_attr("condition_ids", List[ConditionId]) or []
@@ -2,22 +2,22 @@ from uuid import UUID
2
2
  from typing import Any, ClassVar, Dict, Generic, Optional, TypeVar
3
3
 
4
4
  from vellum.workflows.nodes import ErrorNode
5
- from vellum.workflows.types.core import EntityInputsInterface, Json, JsonObject
5
+ from vellum.workflows.types.core import JsonObject
6
6
  from vellum_ee.workflows.display.nodes.base_node_vellum_display import BaseNodeVellumDisplay
7
7
  from vellum_ee.workflows.display.nodes.vellum.utils import create_node_input
8
8
  from vellum_ee.workflows.display.types import WorkflowDisplayContext
9
9
 
10
10
  _ErrorNodeType = TypeVar("_ErrorNodeType", bound=ErrorNode)
11
11
 
12
+
12
13
  class BaseErrorNodeDisplay(BaseNodeVellumDisplay[_ErrorNodeType], Generic[_ErrorNodeType]):
13
14
  error_output_id: ClassVar[Optional[UUID]] = None
14
15
  error_inputs_by_name: ClassVar[Dict[str, Any]] = {}
15
16
  name: ClassVar[str] = "error-node"
16
17
 
17
18
  def serialize(
18
- self, display_context: WorkflowDisplayContext, error_output_id: Optional[UUID] = None, **kwargs
19
+ self, display_context: WorkflowDisplayContext, error_output_id: Optional[UUID] = None, **kwargs
19
20
  ) -> JsonObject:
20
- node = self._node
21
21
  node_id = self.node_id
22
22
  error_source_input_id = self.node_input_ids_by_name.get("error_source_input_id")
23
23
 
@@ -1,9 +1,7 @@
1
1
  from uuid import UUID
2
2
  from typing import Any, ClassVar, Generic, Optional, TypeVar
3
3
 
4
- from vellum.workflows.nodes.core.map_node.node import MapNode
5
4
  from vellum.workflows.nodes.displayable.final_output_node import FinalOutputNode
6
- from vellum.workflows.references.output import OutputReference
7
5
  from vellum.workflows.types.core import JsonObject
8
6
  from vellum_ee.workflows.display.nodes.base_node_vellum_display import BaseNodeVellumDisplay
9
7
  from vellum_ee.workflows.display.nodes.utils import to_kebab_case
@@ -1,5 +1,5 @@
1
1
  from uuid import UUID
2
- from typing import Any, ClassVar, Dict, Generic, Optional, TypeVar
2
+ from typing import ClassVar, Dict, Generic, Optional, TypeVar
3
3
 
4
4
  from vellum.workflows.nodes import GuardrailNode
5
5
  from vellum.workflows.types.core import JsonObject
@@ -1,5 +1,5 @@
1
1
  from uuid import UUID
2
- from typing import Any, ClassVar, Dict, Generic, List, Optional, Tuple, Type, TypeVar, Union, cast
2
+ from typing import ClassVar, Dict, Generic, List, Optional, Tuple, Type, TypeVar, Union, cast
3
3
 
4
4
  from vellum import PromptBlock, RichTextChildBlock, VellumVariable
5
5
  from vellum.workflows.nodes import InlinePromptNode
@@ -1,5 +1,5 @@
1
1
  from uuid import UUID
2
- from typing import Any, ClassVar, Dict, Generic, List, Optional, Tuple, Type, TypeVar, cast
2
+ from typing import ClassVar, Dict, Generic, List, Optional, Tuple, Type, TypeVar, cast
3
3
 
4
4
  from vellum import VellumVariable
5
5
  from vellum.workflows.nodes import InlineSubworkflowNode
@@ -90,7 +90,9 @@ class BaseInlineSubworkflowNodeDisplay(
90
90
  ) -> List[VellumVariable]:
91
91
  workflow_outputs: List[VellumVariable] = []
92
92
  for output_descriptor in raise_if_descriptor(node.subworkflow).Outputs: # type: ignore[union-attr]
93
- workflow_output_display = cast(WorkflowOutputVellumDisplay, display_context.workflow_output_displays[output_descriptor])
93
+ workflow_output_display = cast(
94
+ WorkflowOutputVellumDisplay, display_context.workflow_output_displays[output_descriptor]
95
+ )
94
96
  output_type = infer_vellum_variable_type(output_descriptor)
95
97
  workflow_outputs.append(
96
98
  VellumVariable(id=str(workflow_output_display.id), key=workflow_output_display.name, type=output_type)
@@ -1,5 +1,5 @@
1
1
  from uuid import UUID
2
- from typing import Collection, Dict, Generic, List, Optional, TypeVar, cast
2
+ from typing import Dict, Generic, List, Optional, TypeVar, cast
3
3
 
4
4
  from vellum.workflows.nodes import MapNode
5
5
  from vellum.workflows.types.core import JsonObject
@@ -39,15 +39,21 @@ class BaseMapNodeDisplay(BaseNodeVellumDisplay[_MapNodeType], Generic[_MapNodeTy
39
39
  renamed_input_variables = []
40
40
  for input_variable in cast(List[Dict[str, str]], serialized_subworkflow["input_variables"]):
41
41
  if input_variable["key"] == "all_items":
42
- renamed_item = { **input_variable, "key": "items" }
42
+ renamed_item = {**input_variable, "key": "items"}
43
43
  renamed_input_variables.append(renamed_item)
44
44
  else:
45
45
  renamed_input_variables.append(input_variable)
46
46
 
47
47
  # Note: This must match the items input ID for the map node's node input
48
- items_workflow_input_id = next(input_variable["id"] for input_variable in renamed_input_variables if input_variable["key"] == "items")
49
- item_workflow_input_id = next(input_variable["id"] for input_variable in renamed_input_variables if input_variable["key"] == "item")
50
- index_workflow_input_id = next(input_variable["id"] for input_variable in renamed_input_variables if input_variable["key"] == "index")
48
+ items_workflow_input_id = next(
49
+ input_variable["id"] for input_variable in renamed_input_variables if input_variable["key"] == "items"
50
+ )
51
+ item_workflow_input_id = next(
52
+ input_variable["id"] for input_variable in renamed_input_variables if input_variable["key"] == "item"
53
+ )
54
+ index_workflow_input_id = next(
55
+ input_variable["id"] for input_variable in renamed_input_variables if input_variable["key"] == "index"
56
+ )
51
57
 
52
58
  return {
53
59
  "id": str(node_id),
@@ -1,12 +1,12 @@
1
1
  from uuid import UUID
2
2
  from typing import Any, ClassVar, Generic, List, Optional, TypeVar
3
3
 
4
+ from vellum.workflows.nodes.displayable import MergeNode
5
+ from vellum.workflows.types.core import JsonObject
4
6
  from vellum_ee.workflows.display.nodes.base_node_vellum_display import BaseNodeVellumDisplay
5
7
  from vellum_ee.workflows.display.types import WorkflowDisplayContext
6
8
  from vellum_ee.workflows.display.utils.uuids import uuid4_from_hash
7
9
  from vellum_ee.workflows.display.vellum import EdgeVellumDisplay
8
- from vellum.workflows.nodes.displayable import MergeNode
9
- from vellum.workflows.types.core import JsonObject
10
10
 
11
11
  _MergeNodeType = TypeVar("_MergeNodeType", bound=MergeNode)
12
12
 
@@ -13,9 +13,7 @@ class BaseNoteNodeDisplay(BaseNodeVellumDisplay[_NoteNodeType], Generic[_NoteNod
13
13
  text: ClassVar[str] = ""
14
14
  style: ClassVar[Union[Dict[str, Any], None]] = None
15
15
 
16
- def serialize(
17
- self, display_context: WorkflowDisplayContext, **kwargs: Any
18
- ) -> JsonObject:
16
+ def serialize(self, display_context: WorkflowDisplayContext, **kwargs: Any) -> JsonObject:
19
17
  node_id = self.node_id
20
18
 
21
19
  return {
@@ -1,5 +1,5 @@
1
1
  from uuid import UUID
2
- from typing import Any, ClassVar, Dict, Generic, Optional, TypeVar, cast
2
+ from typing import ClassVar, Dict, Generic, Optional, TypeVar, cast
3
3
 
4
4
  from vellum.workflows.nodes.displayable.prompt_deployment_node import PromptDeploymentNode
5
5
  from vellum.workflows.references import OutputReference
@@ -1,6 +1,6 @@
1
1
  from dataclasses import dataclass
2
2
  from uuid import UUID
3
- from typing import Any, Dict, Generic, List, Optional, Tuple, Type, TypeVar, Union, cast
3
+ from typing import Dict, Generic, List, Optional, Tuple, Type, TypeVar, Union, cast
4
4
 
5
5
  from vellum import (
6
6
  MetadataFilterConfigRequest,
@@ -1,5 +1,5 @@
1
1
  from uuid import UUID
2
- from typing import Any, ClassVar, Dict, Generic, Optional, TypeVar
2
+ from typing import ClassVar, Dict, Generic, Optional, TypeVar
3
3
 
4
4
  from vellum.workflows.nodes import SubworkflowDeploymentNode
5
5
  from vellum.workflows.types.core import JsonObject
@@ -1,5 +1,5 @@
1
1
  from uuid import UUID
2
- from typing import Any, ClassVar, Dict, Generic, Optional, TypeVar
2
+ from typing import ClassVar, Dict, Generic, Optional, TypeVar
3
3
 
4
4
  from vellum.workflows.nodes.core.templating_node import TemplatingNode
5
5
  from vellum.workflows.types.core import JsonObject
@@ -2,6 +2,11 @@ import pytest
2
2
  from uuid import UUID, uuid4
3
3
  from typing import List, cast
4
4
 
5
+ from vellum.workflows.descriptors.base import BaseDescriptor
6
+ from vellum.workflows.inputs import BaseInputs
7
+ from vellum.workflows.nodes.bases import BaseNode
8
+ from vellum.workflows.outputs import BaseOutputs
9
+ from vellum.workflows.references import OutputReference, WorkflowInputReference
5
10
  from vellum_ee.workflows.display.nodes.base_node_vellum_display import BaseNodeVellumDisplay
6
11
  from vellum_ee.workflows.display.nodes.types import NodeOutputDisplay
7
12
  from vellum_ee.workflows.display.nodes.vellum.utils import create_node_input_value_pointer_rules
@@ -19,11 +24,6 @@ from vellum_ee.workflows.display.vellum import (
19
24
  WorkflowMetaVellumDisplay,
20
25
  )
21
26
  from vellum_ee.workflows.display.workflows.vellum_workflow_display import VellumWorkflowDisplay
22
- from vellum.workflows.descriptors.base import BaseDescriptor
23
- from vellum.workflows.inputs import BaseInputs
24
- from vellum.workflows.nodes.bases import BaseNode
25
- from vellum.workflows.outputs import BaseOutputs
26
- from vellum.workflows.references import OutputReference, WorkflowInputReference
27
27
 
28
28
 
29
29
  class Inputs(BaseInputs):
@@ -1,6 +1,10 @@
1
1
  from uuid import UUID
2
2
  from typing import Any, List, Optional, cast
3
3
 
4
+ from vellum.workflows.descriptors.base import BaseDescriptor
5
+ from vellum.workflows.expressions.coalesce_expression import CoalesceExpression
6
+ from vellum.workflows.nodes.utils import get_wrapped_node, has_wrapped_node
7
+ from vellum.workflows.references import NodeReference, OutputReference
4
8
  from vellum_ee.workflows.display.types import WorkflowDisplayContext
5
9
  from vellum_ee.workflows.display.utils.uuids import uuid4_from_hash
6
10
  from vellum_ee.workflows.display.utils.vellum import create_node_input_value_pointer_rule, primitive_to_vellum_value
@@ -10,10 +14,6 @@ from vellum_ee.workflows.display.vellum import (
10
14
  NodeInputValuePointer,
11
15
  NodeInputValuePointerRule,
12
16
  )
13
- from vellum.workflows.descriptors.base import BaseDescriptor
14
- from vellum.workflows.expressions.coalesce_expression import CoalesceExpression
15
- from vellum.workflows.nodes.utils import get_wrapped_node, has_wrapped_node
16
- from vellum.workflows.references import NodeReference, OutputReference
17
17
 
18
18
 
19
19
  def create_node_input(
@@ -0,0 +1,45 @@
1
+ from vellum.workflows.workflows.base import BaseWorkflow
2
+ from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
3
+ from vellum_ee.workflows.display.workflows.vellum_workflow_display import VellumWorkflowDisplay
4
+
5
+
6
+ def test_vellum_workflow_display__serialize_empty_workflow():
7
+ # GIVEN an empty workflow
8
+ class ExampleWorkflow(BaseWorkflow):
9
+ pass
10
+
11
+ display = get_workflow_display(
12
+ base_display_class=VellumWorkflowDisplay,
13
+ workflow_class=ExampleWorkflow,
14
+ )
15
+
16
+ # WHEN serializing the workflow
17
+ exec_config = display.serialize()
18
+
19
+ # THEN it should return the expected config
20
+ assert exec_config == {
21
+ "input_variables": [],
22
+ "output_variables": [],
23
+ "workflow_raw_data": {
24
+ "definition": {
25
+ "module": ["vellum_ee", "workflows", "display", "tests", "test_vellum_workflow_display"],
26
+ "name": "ExampleWorkflow",
27
+ },
28
+ "display_data": {"viewport": {"x": 0.0, "y": 0.0, "zoom": 1.0}},
29
+ "edges": [],
30
+ "nodes": [
31
+ {
32
+ "data": {"label": "Entrypoint Node", "source_handle_id": "508b8b82-3517-4672-a155-18c9c7b9c545"},
33
+ "definition": {
34
+ "bases": [],
35
+ "module": ["vellum", "workflows", "nodes", "bases", "base"],
36
+ "name": "BaseNode",
37
+ },
38
+ "display_data": {"position": {"x": 0.0, "y": 0.0}},
39
+ "id": "9eef0c18-f322-4d56-aa89-f088d3e53f6a",
40
+ "inputs": [],
41
+ "type": "ENTRYPOINT",
42
+ }
43
+ ],
44
+ },
45
+ }
@@ -4,17 +4,18 @@ from uuid import uuid4
4
4
  from deepdiff import DeepDiff
5
5
 
6
6
  from vellum import WorkspaceSecretRead
7
-
8
- from tests.workflows.basic_vellum_api_node.workflow import SimpleAPIWorkflow
9
7
  from vellum_ee.workflows.display.workflows import VellumWorkflowDisplay
10
8
  from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
11
9
 
10
+ from tests.workflows.basic_vellum_api_node.workflow import SimpleAPIWorkflow
11
+
12
12
 
13
13
  def test_serialize_workflow(vellum_client):
14
14
  # GIVEN a Workflow that uses a vellum API node
15
15
  # AND stubbed out API calls
16
+ workspace_secret_id = str(uuid4())
16
17
  workspace_secret = WorkspaceSecretRead(
17
- id=str(uuid4()),
18
+ id=workspace_secret_id,
18
19
  modified=datetime.now(),
19
20
  name="MY_SECRET",
20
21
  label="My Secret",
@@ -133,7 +134,10 @@ def test_serialize_workflow(vellum_client):
133
134
  "rules": [
134
135
  {
135
136
  "type": "WORKSPACE_SECRET",
136
- "data": {"type": "STRING", "workspace_secret_id": workspace_secret.id},
137
+ "data": {
138
+ "type": "STRING",
139
+ "workspace_secret_id": f"{workspace_secret_id}",
140
+ },
137
141
  }
138
142
  ],
139
143
  "combinator": "OR",
@@ -154,8 +158,8 @@ def test_serialize_workflow(vellum_client):
154
158
  "api_key_header_value_input_id": "d794bb51-a419-4fd8-be63-dfaf4166e831",
155
159
  "additional_headers": [
156
160
  {
157
- "header_key_input_id": "cff297b8-8ef9-46ab-9ef4-1f1eb43a2298",
158
- "header_value_input_id": "0d41f210-f428-4849-9c21-0cde2cf54657",
161
+ "header_key_input_id": "57c31247-998a-430d-bb62-bf50eca7df35",
162
+ "header_value_input_id": "47b32274-f19b-4c15-b788-55c069c311c5",
159
163
  }
160
164
  ],
161
165
  "text_output_id": "17342c21-12bb-49ab-88ce-f144e0376b32",
@@ -164,26 +168,11 @@ def test_serialize_workflow(vellum_client):
164
168
  },
165
169
  "display_data": {"position": {"x": 0.0, "y": 0.0}},
166
170
  "definition": {
171
+ "name": "SimpleAPINode",
172
+ "module": ["tests", "workflows", "basic_vellum_api_node", "workflow"],
167
173
  "bases": [
168
- {
169
- "module": [
170
- "vellum",
171
- "workflows",
172
- "nodes",
173
- "displayable",
174
- "api_node",
175
- "node",
176
- ],
177
- "name": "APINode",
178
- }
174
+ {"name": "APINode", "module": ["vellum", "workflows", "nodes", "displayable", "api_node", "node"]}
179
175
  ],
180
- "module": [
181
- "tests",
182
- "workflows",
183
- "basic_vellum_api_node",
184
- "workflow",
185
- ],
186
- "name": "SimpleAPINode",
187
176
  },
188
177
  },
189
178
  api_node,