vellum-ai 0.12.8__py3-none-any.whl → 0.12.9__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. vellum/client/core/client_wrapper.py +1 -1
  2. vellum/evaluations/resources.py +1 -1
  3. vellum/prompts/blocks/compilation.py +4 -4
  4. vellum/workflows/nodes/bases/__init__.py +0 -2
  5. vellum/workflows/nodes/bases/base.py +2 -6
  6. vellum/workflows/nodes/core/inline_subworkflow_node/node.py +13 -7
  7. vellum/workflows/nodes/core/inline_subworkflow_node/tests/__init__.py +0 -0
  8. vellum/workflows/nodes/core/inline_subworkflow_node/tests/test_node.py +41 -0
  9. vellum/workflows/nodes/core/map_node/node.py +1 -1
  10. vellum/workflows/nodes/core/templating_node/node.py +8 -1
  11. vellum/workflows/nodes/core/templating_node/tests/test_templating_node.py +66 -0
  12. vellum/workflows/nodes/core/try_node/node.py +1 -3
  13. vellum/workflows/nodes/core/try_node/tests/test_node.py +1 -1
  14. vellum/workflows/nodes/displayable/bases/api_node/node.py +2 -2
  15. vellum/workflows/nodes/displayable/bases/search_node.py +5 -2
  16. vellum/workflows/nodes/displayable/subworkflow_deployment_node/node.py +4 -2
  17. vellum/workflows/sandbox.py +4 -5
  18. vellum/workflows/state/context.py +5 -4
  19. vellum/workflows/tests/test_sandbox.py +2 -2
  20. vellum/workflows/utils/tests/test_vellum_variables.py +3 -0
  21. vellum/workflows/utils/vellum_variables.py +5 -4
  22. vellum/workflows/workflows/base.py +5 -2
  23. {vellum_ai-0.12.8.dist-info → vellum_ai-0.12.9.dist-info}/METADATA +1 -1
  24. {vellum_ai-0.12.8.dist-info → vellum_ai-0.12.9.dist-info}/RECORD +31 -30
  25. vellum_cli/tests/test_push.py +1 -1
  26. vellum_ee/workflows/display/nodes/vellum/inline_subworkflow_node.py +6 -1
  27. vellum_ee/workflows/display/tests/workflow_serialization/test_basic_templating_node_serialization.py +207 -0
  28. vellum/workflows/nodes/bases/base_subworkflow_node/__init__.py +0 -5
  29. vellum/workflows/nodes/bases/base_subworkflow_node/node.py +0 -10
  30. /vellum/{evaluations/utils → utils}/uuid.py +0 -0
  31. {vellum_ai-0.12.8.dist-info → vellum_ai-0.12.9.dist-info}/LICENSE +0 -0
  32. {vellum_ai-0.12.8.dist-info → vellum_ai-0.12.9.dist-info}/WHEEL +0 -0
  33. {vellum_ai-0.12.8.dist-info → vellum_ai-0.12.9.dist-info}/entry_points.txt +0 -0
@@ -18,7 +18,7 @@ class BaseClientWrapper:
18
18
  headers: typing.Dict[str, str] = {
19
19
  "X-Fern-Language": "Python",
20
20
  "X-Fern-SDK-Name": "vellum-ai",
21
- "X-Fern-SDK-Version": "0.12.8",
21
+ "X-Fern-SDK-Version": "0.12.9",
22
22
  }
23
23
  headers["X_API_KEY"] = self.api_key
24
24
  return headers
@@ -12,7 +12,6 @@ from vellum.evaluations.constants import DEFAULT_MAX_POLLING_DURATION_MS, DEFAUL
12
12
  from vellum.evaluations.exceptions import TestSuiteRunResultsException
13
13
  from vellum.evaluations.utils.env import get_api_key
14
14
  from vellum.evaluations.utils.paginator import PaginatedResults, get_all_results
15
- from vellum.evaluations.utils.uuid import is_valid_uuid
16
15
  from vellum.types import (
17
16
  ExternalTestCaseExecutionRequest,
18
17
  NamedTestCaseVariableValueRequest,
@@ -24,6 +23,7 @@ from vellum.types import (
24
23
  TestSuiteRunState,
25
24
  )
26
25
  from vellum.utils.typing import cast_not_optional
26
+ from vellum.utils.uuid import is_valid_uuid
27
27
 
28
28
  logger = logging.getLogger(__name__)
29
29
 
@@ -104,16 +104,16 @@ def compile_prompt_blocks(
104
104
  chat_message_blocks = _compile_chat_messages_as_prompt_blocks(compiled_input.value)
105
105
  compiled_blocks.extend(chat_message_blocks)
106
106
  else:
107
- raise ValueError(f"Invalid input type for variable block: {compiled_input.type}")
107
+ raise PromptCompilationError(f"Invalid input type for variable block: {compiled_input.type}")
108
108
 
109
109
  elif block.block_type == "RICH_TEXT":
110
110
  value_block = _compile_rich_text_block_as_value_block(block=block, inputs=sanitized_inputs)
111
111
  compiled_blocks.append(value_block)
112
112
 
113
113
  elif block.block_type == "FUNCTION_DEFINITION":
114
- raise ValueError("Function definitions shouldn't go through compilation process")
114
+ raise PromptCompilationError("Function definitions shouldn't go through compilation process")
115
115
  else:
116
- raise ValueError(f"Unknown block_type: {block.block_type}")
116
+ raise PromptCompilationError(f"Unknown block_type: {block.block_type}")
117
117
 
118
118
  return compiled_blocks
119
119
 
@@ -172,7 +172,7 @@ def _compile_rich_text_block_as_value_block(
172
172
  f"Input variable '{child_block.input_variable}' must be of type STRING or JSON"
173
173
  )
174
174
  else:
175
- raise ValueError(f"Invalid child block_type for RICH_TEXT: {child_block.block_type}")
175
+ raise PromptCompilationError(f"Invalid child block_type for RICH_TEXT: {child_block.block_type}")
176
176
 
177
177
  return CompiledValuePromptBlock(content=StringVellumValue(value=value), cache_config=block.cache_config)
178
178
 
@@ -1,7 +1,5 @@
1
1
  from .base import BaseNode
2
- from .base_subworkflow_node import BaseSubworkflowNode
3
2
 
4
3
  __all__ = [
5
4
  "BaseNode",
6
- "BaseSubworkflowNode",
7
5
  ]
@@ -344,8 +344,8 @@ class BaseNode(Generic[StateType], metaclass=BaseNodeMeta):
344
344
  all_inputs = {}
345
345
  for key, value in inputs.items():
346
346
  path_parts = key.split(".")
347
- node_attribute_discriptor = getattr(self.__class__, path_parts[0])
348
- inputs_key = reduce(lambda acc, part: acc[part], path_parts[1:], node_attribute_discriptor)
347
+ node_attribute_descriptor = getattr(self.__class__, path_parts[0])
348
+ inputs_key = reduce(lambda acc, part: acc[part], path_parts[1:], node_attribute_descriptor)
349
349
  all_inputs[inputs_key] = value
350
350
 
351
351
  self._inputs = MappingProxyType(all_inputs)
@@ -355,7 +355,3 @@ class BaseNode(Generic[StateType], metaclass=BaseNodeMeta):
355
355
 
356
356
  def __repr__(self) -> str:
357
357
  return str(self.__class__)
358
-
359
-
360
- class MyNode2(BaseNode):
361
- pass
@@ -1,12 +1,14 @@
1
- from typing import TYPE_CHECKING, Generic, Iterator, Optional, Set, Type, TypeVar
1
+ from typing import TYPE_CHECKING, ClassVar, Generic, Iterator, Optional, Set, Type, TypeVar, Union
2
2
 
3
3
  from vellum.workflows.context import execution_context, get_parent_context
4
4
  from vellum.workflows.errors.types import WorkflowErrorCode
5
5
  from vellum.workflows.exceptions import NodeException
6
- from vellum.workflows.nodes.bases.base_subworkflow_node import BaseSubworkflowNode
6
+ from vellum.workflows.inputs.base import BaseInputs
7
+ from vellum.workflows.nodes.bases.base import BaseNode
7
8
  from vellum.workflows.outputs.base import BaseOutput, BaseOutputs
8
9
  from vellum.workflows.state.base import BaseState
9
10
  from vellum.workflows.state.context import WorkflowContext
11
+ from vellum.workflows.types.core import EntityInputsInterface
10
12
  from vellum.workflows.types.generics import StateType, WorkflowInputsType
11
13
 
12
14
  if TYPE_CHECKING:
@@ -15,7 +17,7 @@ if TYPE_CHECKING:
15
17
  InnerStateType = TypeVar("InnerStateType", bound=BaseState)
16
18
 
17
19
 
18
- class InlineSubworkflowNode(BaseSubworkflowNode[StateType], Generic[StateType, WorkflowInputsType, InnerStateType]):
20
+ class InlineSubworkflowNode(BaseNode[StateType], Generic[StateType, WorkflowInputsType, InnerStateType]):
19
21
  """
20
22
  Used to execute a Subworkflow defined inline.
21
23
 
@@ -24,14 +26,13 @@ class InlineSubworkflowNode(BaseSubworkflowNode[StateType], Generic[StateType, W
24
26
  """
25
27
 
26
28
  subworkflow: Type["BaseWorkflow[WorkflowInputsType, InnerStateType]"]
29
+ subworkflow_inputs: ClassVar[Union[EntityInputsInterface, BaseInputs]] = {}
27
30
 
28
31
  def run(self) -> Iterator[BaseOutput]:
29
32
  with execution_context(parent_context=get_parent_context() or self._context.parent_context):
30
33
  subworkflow = self.subworkflow(
31
34
  parent_state=self.state,
32
- context=WorkflowContext(
33
- _vellum_client=self._context._vellum_client,
34
- ),
35
+ context=WorkflowContext(vellum_client=self._context.vellum_client),
35
36
  )
36
37
  subworkflow_stream = subworkflow.stream(
37
38
  inputs=self._compile_subworkflow_inputs(),
@@ -68,4 +69,9 @@ class InlineSubworkflowNode(BaseSubworkflowNode[StateType], Generic[StateType, W
68
69
 
69
70
  def _compile_subworkflow_inputs(self) -> WorkflowInputsType:
70
71
  inputs_class = self.subworkflow.get_inputs_class()
71
- return inputs_class(**self.subworkflow_inputs)
72
+ if isinstance(self.subworkflow_inputs, dict):
73
+ return inputs_class(**self.subworkflow_inputs)
74
+ elif isinstance(self.subworkflow_inputs, inputs_class):
75
+ return self.subworkflow_inputs
76
+ else:
77
+ raise ValueError(f"Invalid subworkflow inputs type: {type(self.subworkflow_inputs)}")
@@ -0,0 +1,41 @@
1
+ import pytest
2
+
3
+ from vellum.workflows.inputs.base import BaseInputs
4
+ from vellum.workflows.nodes.bases.base import BaseNode
5
+ from vellum.workflows.nodes.core.inline_subworkflow_node.node import InlineSubworkflowNode
6
+ from vellum.workflows.outputs.base import BaseOutput
7
+ from vellum.workflows.state.base import BaseState
8
+ from vellum.workflows.workflows.base import BaseWorkflow
9
+
10
+
11
+ class Inputs(BaseInputs):
12
+ foo: str
13
+
14
+
15
+ class MyInnerNode(BaseNode):
16
+ class Outputs(BaseNode.Outputs):
17
+ out = Inputs.foo
18
+
19
+
20
+ class MySubworkflow(BaseWorkflow[Inputs, BaseState]):
21
+ graph = MyInnerNode
22
+
23
+ class Outputs(BaseWorkflow.Outputs):
24
+ out = MyInnerNode.Outputs.out
25
+
26
+
27
+ @pytest.mark.parametrize("inputs", [{"foo": "bar"}, Inputs(foo="bar")])
28
+ def test_inline_subworkflow_node__inputs(inputs):
29
+ # GIVEN a node setup with subworkflow inputs
30
+ class MyNode(InlineSubworkflowNode):
31
+ subworkflow = MySubworkflow
32
+ subworkflow_inputs = inputs
33
+
34
+ # WHEN the node is run
35
+ node = MyNode()
36
+ events = list(node.run())
37
+
38
+ # THEN the output is as expected
39
+ assert events == [
40
+ BaseOutput(name="out", value="bar"),
41
+ ]
@@ -108,7 +108,7 @@ class MapNode(BaseNode, Generic[StateType, MapNodeItemType]):
108
108
  self._run_subworkflow(item=item, index=index)
109
109
 
110
110
  def _run_subworkflow(self, *, item: MapNodeItemType, index: int) -> None:
111
- context = WorkflowContext(_vellum_client=self._context._vellum_client)
111
+ context = WorkflowContext(vellum_client=self._context.vellum_client)
112
112
  subworkflow = self.subworkflow(parent_state=self.state, context=context)
113
113
  events = subworkflow.stream(
114
114
  inputs=self.SubworkflowInputs(index=index, item=item, all_items=self.items),
@@ -1,3 +1,4 @@
1
+ import json
1
2
  from typing import Any, Callable, ClassVar, Dict, Generic, Mapping, Tuple, Type, TypeVar, Union, get_args
2
3
 
3
4
  from vellum.utils.templating.constants import DEFAULT_JINJA_CUSTOM_FILTERS, DEFAULT_JINJA_GLOBALS
@@ -7,7 +8,7 @@ from vellum.workflows.errors import WorkflowErrorCode
7
8
  from vellum.workflows.exceptions import NodeException
8
9
  from vellum.workflows.nodes.bases import BaseNode
9
10
  from vellum.workflows.nodes.bases.base import BaseNodeMeta
10
- from vellum.workflows.types.core import EntityInputsInterface
11
+ from vellum.workflows.types.core import EntityInputsInterface, Json
11
12
  from vellum.workflows.types.generics import StateType
12
13
  from vellum.workflows.types.utils import get_original_base
13
14
 
@@ -87,6 +88,12 @@ class TemplatingNode(BaseNode[StateType], Generic[StateType, _OutputType], metac
87
88
  if output_type is bool:
88
89
  return bool(rendered_template)
89
90
 
91
+ if output_type is Json:
92
+ try:
93
+ return json.loads(rendered_template)
94
+ except json.JSONDecodeError:
95
+ raise ValueError("Invalid JSON format for rendered_template")
96
+
90
97
  raise ValueError(f"Unsupported output type: {output_type}")
91
98
 
92
99
  def run(self) -> Outputs:
@@ -2,6 +2,8 @@ import json
2
2
 
3
3
  from vellum.workflows.nodes.bases.base import BaseNode
4
4
  from vellum.workflows.nodes.core.templating_node.node import TemplatingNode
5
+ from vellum.workflows.state import BaseState
6
+ from vellum.workflows.types.core import Json
5
7
 
6
8
 
7
9
  def test_templating_node__dict_output():
@@ -22,6 +24,70 @@ def test_templating_node__dict_output():
22
24
  assert json.loads(outputs.result) == {"key": "value"}
23
25
 
24
26
 
27
+ def test_templating_node__int_output():
28
+ # GIVEN a templating node that outputs an integer
29
+ class IntTemplateNode(TemplatingNode[BaseState, int]):
30
+ template = "{{ data }}"
31
+ inputs = {
32
+ "data": 42,
33
+ }
34
+
35
+ # WHEN the node is run
36
+ node = IntTemplateNode()
37
+ outputs = node.run()
38
+
39
+ # THEN the output is the expected integer
40
+ assert outputs.result == 42
41
+
42
+
43
+ def test_templating_node__float_output():
44
+ # GIVEN a templating node that outputs a float
45
+ class FloatTemplateNode(TemplatingNode[BaseState, float]):
46
+ template = "{{ data }}"
47
+ inputs = {
48
+ "data": 42.5,
49
+ }
50
+
51
+ # WHEN the node is run
52
+ node = FloatTemplateNode()
53
+ outputs = node.run()
54
+
55
+ # THEN the output is the expected float
56
+ assert outputs.result == 42.5
57
+
58
+
59
+ def test_templating_node__bool_output():
60
+ # GIVEN a templating node that outputs a bool
61
+ class BoolTemplateNode(TemplatingNode[BaseState, bool]):
62
+ template = "{{ data }}"
63
+ inputs = {
64
+ "data": True,
65
+ }
66
+
67
+ # WHEN the node is run
68
+ node = BoolTemplateNode()
69
+ outputs = node.run()
70
+
71
+ # THEN the output is the expected bool
72
+ assert outputs.result is True
73
+
74
+
75
+ def test_templating_node__json_output():
76
+ # GIVEN a templating node that outputs JSON
77
+ class JSONTemplateNode(TemplatingNode[BaseState, Json]):
78
+ template = "{{ data }}"
79
+ inputs = {
80
+ "data": {"key": "value"},
81
+ }
82
+
83
+ # WHEN the node is run
84
+ node = JSONTemplateNode()
85
+ outputs = node.run()
86
+
87
+ # THEN the output is the expected JSON
88
+ assert outputs.result == {"key": "value"}
89
+
90
+
25
91
  def test_templating_node__execution_count_reference():
26
92
  # GIVEN a random node
27
93
  class OtherNode(BaseNode):
@@ -73,9 +73,7 @@ class TryNode(BaseNode[StateType], Generic[StateType], metaclass=_TryNodeMeta):
73
73
  def run(self) -> Iterator[BaseOutput]:
74
74
  subworkflow = self.subworkflow(
75
75
  parent_state=self.state,
76
- context=WorkflowContext(
77
- _vellum_client=self._context._vellum_client,
78
- ),
76
+ context=WorkflowContext(vellum_client=self._context.vellum_client),
79
77
  )
80
78
  subworkflow_stream = subworkflow.stream(
81
79
  event_filter=all_workflow_event_filter,
@@ -103,7 +103,7 @@ def test_try_node__use_parent_execution_context():
103
103
  # WHEN the node is run with a custom vellum client
104
104
  node = TestNode(
105
105
  context=WorkflowContext(
106
- _vellum_client=Vellum(api_key="test-key"),
106
+ vellum_client=Vellum(api_key="test-key"),
107
107
  )
108
108
  )
109
109
  outputs = list(node.run())
@@ -26,11 +26,11 @@ class BaseAPINode(BaseNode, Generic[StateType]):
26
26
  url: str
27
27
  method: APIRequestMethod
28
28
  data: Optional[str] = None
29
- json: Optional["Json"] = None
29
+ json: Optional[Json] = None
30
30
  headers: Optional[Dict[str, Union[str, VellumSecret]]] = None
31
31
 
32
32
  class Outputs(BaseOutputs):
33
- json: Optional["Json"]
33
+ json: Optional[Json]
34
34
  headers: Dict[str, str]
35
35
  status_code: int
36
36
  text: str
@@ -12,6 +12,7 @@ from vellum import (
12
12
  SearchWeightsRequest,
13
13
  )
14
14
  from vellum.core import ApiError, RequestOptions
15
+ from vellum.utils.uuid import is_valid_uuid
15
16
  from vellum.workflows.errors import WorkflowErrorCode
16
17
  from vellum.workflows.exceptions import NodeException
17
18
  from vellum.workflows.nodes.bases import BaseNode
@@ -73,11 +74,13 @@ class BaseSearchNode(BaseNode[StateType], Generic[StateType]):
73
74
  results: List[SearchResult]
74
75
 
75
76
  def _perform_search(self) -> SearchResponse:
77
+ index_is_uuid = True if isinstance(self.document_index, UUID) else is_valid_uuid(self.document_index)
78
+
76
79
  try:
77
80
  return self._context.vellum_client.search(
78
81
  query=self.query,
79
- index_id=str(self.document_index) if isinstance(self.document_index, UUID) else None,
80
- index_name=self.document_index if isinstance(self.document_index, str) else None,
82
+ index_id=str(self.document_index) if index_is_uuid else None,
83
+ index_name=str(self.document_index) if not index_is_uuid else None,
81
84
  options=self.options,
82
85
  )
83
86
  except NotFoundError:
@@ -17,12 +17,13 @@ from vellum.workflows.context import get_parent_context
17
17
  from vellum.workflows.errors import WorkflowErrorCode
18
18
  from vellum.workflows.errors.types import workflow_event_error_to_workflow_error
19
19
  from vellum.workflows.exceptions import NodeException
20
- from vellum.workflows.nodes.bases.base_subworkflow_node.node import BaseSubworkflowNode
20
+ from vellum.workflows.nodes.bases.base import BaseNode
21
21
  from vellum.workflows.outputs.base import BaseOutput
22
+ from vellum.workflows.types.core import EntityInputsInterface
22
23
  from vellum.workflows.types.generics import StateType
23
24
 
24
25
 
25
- class SubworkflowDeploymentNode(BaseSubworkflowNode[StateType], Generic[StateType]):
26
+ class SubworkflowDeploymentNode(BaseNode[StateType], Generic[StateType]):
26
27
  """
27
28
  Used to execute a Workflow Deployment.
28
29
 
@@ -38,6 +39,7 @@ class SubworkflowDeploymentNode(BaseSubworkflowNode[StateType], Generic[StateTyp
38
39
 
39
40
  # Either the Workflow Deployment's UUID or its name.
40
41
  deployment: ClassVar[Union[UUID, str]]
42
+ subworkflow_inputs: ClassVar[EntityInputsInterface] = {}
41
43
 
42
44
  release_tag: str = LATEST_RELEASE_TAG
43
45
  external_id: Optional[str] = OMIT
@@ -1,4 +1,4 @@
1
- from typing import Generic, Sequence, Type
1
+ from typing import Generic, Sequence
2
2
 
3
3
  import dotenv
4
4
 
@@ -9,8 +9,8 @@ from vellum.workflows.types.generics import WorkflowType
9
9
  from vellum.workflows.workflows.event_filters import root_workflow_event_filter
10
10
 
11
11
 
12
- class SandboxRunner(Generic[WorkflowType]):
13
- def __init__(self, workflow: Type[WorkflowType], inputs: Sequence[BaseInputs]):
12
+ class WorkflowSandboxRunner(Generic[WorkflowType]):
13
+ def __init__(self, workflow: WorkflowType, inputs: Sequence[BaseInputs]):
14
14
  if not inputs:
15
15
  raise ValueError("Inputs are required to have at least one defined inputs")
16
16
 
@@ -30,8 +30,7 @@ class SandboxRunner(Generic[WorkflowType]):
30
30
 
31
31
  selected_inputs = self._inputs[index]
32
32
 
33
- workflow = self._workflow()
34
- events = workflow.stream(
33
+ events = self._workflow.stream(
35
34
  inputs=selected_inputs,
36
35
  event_filter=root_workflow_event_filter,
37
36
  )
@@ -13,11 +13,12 @@ if TYPE_CHECKING:
13
13
  class WorkflowContext:
14
14
  def __init__(
15
15
  self,
16
- _vellum_client: Optional[Vellum] = None,
17
- _parent_context: Optional[ParentContext] = None,
16
+ *,
17
+ vellum_client: Optional[Vellum] = None,
18
+ parent_context: Optional[ParentContext] = None,
18
19
  ):
19
- self._vellum_client = _vellum_client
20
- self._parent_context = _parent_context
20
+ self._vellum_client = vellum_client
21
+ self._parent_context = parent_context
21
22
  self._event_queue: Optional[Queue["WorkflowEvent"]] = None
22
23
 
23
24
  @cached_property
@@ -3,7 +3,7 @@ from typing import List
3
3
 
4
4
  from vellum.workflows.inputs.base import BaseInputs
5
5
  from vellum.workflows.nodes.bases.base import BaseNode
6
- from vellum.workflows.sandbox import SandboxRunner
6
+ from vellum.workflows.sandbox import WorkflowSandboxRunner
7
7
  from vellum.workflows.state.base import BaseState
8
8
  from vellum.workflows.workflows.base import BaseWorkflow
9
9
 
@@ -49,7 +49,7 @@ def test_sandbox_runner__happy_path(mock_logger, run_kwargs, expected_last_log):
49
49
  ]
50
50
 
51
51
  # WHEN we run the sandbox
52
- runner = SandboxRunner(workflow=Workflow, inputs=inputs)
52
+ runner = WorkflowSandboxRunner(workflow=Workflow(), inputs=inputs)
53
53
  runner.run(**run_kwargs)
54
54
 
55
55
  # THEN we see the logs
@@ -2,6 +2,7 @@ import pytest
2
2
  from typing import List, Optional
3
3
 
4
4
  from vellum import ChatMessage, SearchResult
5
+ from vellum.workflows.types.core import Json
5
6
  from vellum.workflows.utils.vellum_variables import primitive_type_to_vellum_variable_type
6
7
 
7
8
 
@@ -18,6 +19,8 @@ from vellum.workflows.utils.vellum_variables import primitive_type_to_vellum_var
18
19
  (Optional[List[ChatMessage]], "CHAT_HISTORY"),
19
20
  (List[SearchResult], "SEARCH_RESULTS"),
20
21
  (Optional[List[SearchResult]], "SEARCH_RESULTS"),
22
+ (Json, "JSON"),
23
+ (Optional[Json], "JSON"),
21
24
  ],
22
25
  )
23
26
  def test_primitive_type_to_vellum_variable_type(type_, expected):
@@ -35,14 +35,15 @@ def primitive_type_to_vellum_variable_type(type_: Union[Type, BaseDescriptor]) -
35
35
  if len(types) != 1:
36
36
  # Check explicitly for our internal JSON type.
37
37
  # Matches the type found at vellum.workflows.utils.vellum_variables.Json
38
- if types == [
38
+ actual_types_with_explicit_ref = [
39
39
  bool,
40
40
  int,
41
41
  float,
42
42
  str,
43
- typing.List[typing.ForwardRef("Json")], # type: ignore [misc]
44
- typing.Dict[str, typing.ForwardRef("Json")], # type: ignore [misc]
45
- ]:
43
+ typing.List[Json],
44
+ typing.Dict[str, Json],
45
+ ]
46
+ if types == actual_types_with_explicit_ref:
46
47
  return "JSON"
47
48
  raise ValueError(f"Expected Descriptor to only have one type, got {types}")
48
49
 
@@ -121,10 +121,11 @@ class BaseWorkflow(Generic[WorkflowInputsType, StateType], metaclass=_BaseWorkfl
121
121
 
122
122
  def __init__(
123
123
  self,
124
+ *,
125
+ context: Optional[WorkflowContext] = None,
124
126
  parent_state: Optional[BaseState] = None,
125
127
  emitters: Optional[List[BaseWorkflowEmitter]] = None,
126
128
  resolvers: Optional[List[BaseWorkflowResolver]] = None,
127
- context: Optional[WorkflowContext] = None,
128
129
  ):
129
130
  self._parent_state = parent_state
130
131
  self.emitters = emitters or (self.emitters if hasattr(self, "emitters") else [])
@@ -188,6 +189,7 @@ class BaseWorkflow(Generic[WorkflowInputsType, StateType], metaclass=_BaseWorkfl
188
189
  def run(
189
190
  self,
190
191
  inputs: Optional[WorkflowInputsType] = None,
192
+ *,
191
193
  state: Optional[StateType] = None,
192
194
  entrypoint_nodes: Optional[RunFromNodeArg] = None,
193
195
  external_inputs: Optional[ExternalInputsArg] = None,
@@ -281,8 +283,9 @@ class BaseWorkflow(Generic[WorkflowInputsType, StateType], metaclass=_BaseWorkfl
281
283
 
282
284
  def stream(
283
285
  self,
284
- event_filter: Optional[Callable[[Type["BaseWorkflow"], WorkflowEvent], bool]] = None,
285
286
  inputs: Optional[WorkflowInputsType] = None,
287
+ *,
288
+ event_filter: Optional[Callable[[Type["BaseWorkflow"], WorkflowEvent], bool]] = None,
286
289
  state: Optional[StateType] = None,
287
290
  entrypoint_nodes: Optional[RunFromNodeArg] = None,
288
291
  external_inputs: Optional[ExternalInputsArg] = None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vellum-ai
3
- Version: 0.12.8
3
+ Version: 0.12.9
4
4
  Summary:
5
5
  License: MIT
6
6
  Requires-Python: >=3.9,<4.0
@@ -12,7 +12,7 @@ vellum_cli/tests/conftest.py,sha256=eFGwBxib3Nki830lIFintB0b6r4x8T_KMnmzhlTY5x0,
12
12
  vellum_cli/tests/test_config.py,sha256=uvKGDc8BoVyT9_H0Z-g8469zVxomn6Oi3Zj-vK7O_wU,2631
13
13
  vellum_cli/tests/test_main.py,sha256=qDZG-aQauPwBwM6A2DIu1494n47v3pL28XakTbLGZ-k,272
14
14
  vellum_cli/tests/test_pull.py,sha256=Bnf21VjfiRb_j495idz5N8afucagtiktNCtVMvU8tGs,18977
15
- vellum_cli/tests/test_push.py,sha256=V2iGcskh2X3OHj2uV5Vx_BhmtyfmUkyx0lrp8DDOExc,5824
15
+ vellum_cli/tests/test_push.py,sha256=NpwGXuZSzrR7B6hBO1UF9O8im13_LlpSqncVSdzYDiQ,5812
16
16
  vellum_ee/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  vellum_ee/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  vellum_ee/workflows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -34,7 +34,7 @@ vellum_ee/workflows/display/nodes/vellum/error_node.py,sha256=ygTjSjYDI4DtkxADWu
34
34
  vellum_ee/workflows/display/nodes/vellum/final_output_node.py,sha256=t5iJQVoRT5g-v2IiUb4kFYdvUVKch0zn27016pzDZoo,2761
35
35
  vellum_ee/workflows/display/nodes/vellum/guardrail_node.py,sha256=3TJvHX_Uuf_gr94VkYc_zmNH8I5p71ChIeoAbJZ3ddY,2158
36
36
  vellum_ee/workflows/display/nodes/vellum/inline_prompt_node.py,sha256=DYhxHgFT06CNCpovO4Z-wFPqCjFKxyl89ygFs8AucRQ,7189
37
- vellum_ee/workflows/display/nodes/vellum/inline_subworkflow_node.py,sha256=x5wiuWbRjxNcPGu8BoBEKHwPeqCpHE-vrGjAdM5TJOs,4721
37
+ vellum_ee/workflows/display/nodes/vellum/inline_subworkflow_node.py,sha256=IqPQdlxLdaMirgDbOSxq17d8bolqqjjRPy4t3YCBhmc,5028
38
38
  vellum_ee/workflows/display/nodes/vellum/map_node.py,sha256=AqUlItgSZij12qRKguKVmDbbaLuDy3Cdom5uOlJPqrc,3640
39
39
  vellum_ee/workflows/display/nodes/vellum/merge_node.py,sha256=jzO63B9KiEAncnBqmz2ZTcxjmEHozMEe7WnfpcpsQYg,3195
40
40
  vellum_ee/workflows/display/nodes/vellum/note_node.py,sha256=9VpC3h0RYOxJuRbjDwidBYlLKakkmlEnDMBh2C7lHcY,1107
@@ -60,6 +60,7 @@ vellum_ee/workflows/display/tests/workflow_serialization/test_basic_merge_node_s
60
60
  vellum_ee/workflows/display/tests/workflow_serialization/test_basic_prompt_deployment_serialization.py,sha256=NkpgaTbu6nLr3iwgsSNtiHyiNDCUaFakd1JaoW6CC6Y,9489
61
61
  vellum_ee/workflows/display/tests/workflow_serialization/test_basic_search_node_serialization.py,sha256=9R6ELHBn9tsp3cy15q1qp1OByyCxFOVdrM67EwCYY50,12984
62
62
  vellum_ee/workflows/display/tests/workflow_serialization/test_basic_subworkflow_deployment_serialization.py,sha256=8bz0vm_EyQKSjnwS5vqqgnjE9ygvm-CaPKcwCfeOrlo,12704
63
+ vellum_ee/workflows/display/tests/workflow_serialization/test_basic_templating_node_serialization.py,sha256=6LrGPS7e9CWpjFq2hpliSzP9kDpZ9KqvBNlNO3sq8cs,8063
63
64
  vellum_ee/workflows/display/tests/workflow_serialization/test_basic_terminal_node_serialization.py,sha256=xG8nKA1iKXxUe1fnD2X6qm7cUGW14iq2P-L16zhcKC8,4271
64
65
  vellum_ee/workflows/display/tests/workflow_serialization/test_basic_try_node_serialization.py,sha256=1_02RbghUwhKMr8VtRaPjHOXAX59hgWw1rJ2EDyKs-E,2880
65
66
  vellum_ee/workflows/display/tests/workflow_serialization/test_complex_terminal_node_serialization.py,sha256=BGCgJ3WWiYK5fWJp_Yz-aWQPli5sIKOhLTVYfG9Tpq8,9177
@@ -76,7 +77,7 @@ vellum/client/README.md,sha256=JkCJjmMZl4jrPj46pkmL9dpK4gSzQQmP5I7z4aME4LY,4749
76
77
  vellum/client/__init__.py,sha256=o4m7iRZWEV8rP3GkdaztHAjNmjxjWERlarviFoHzuKI,110927
77
78
  vellum/client/core/__init__.py,sha256=SQ85PF84B9MuKnBwHNHWemSGuy-g_515gFYNFhvEE0I,1438
78
79
  vellum/client/core/api_error.py,sha256=RE8LELok2QCjABadECTvtDp7qejA1VmINCh6TbqPwSE,426
79
- vellum/client/core/client_wrapper.py,sha256=oWk19_A_3mvqQM_W3wJgQnObX6YIE918NEp9olVAuEo,1868
80
+ vellum/client/core/client_wrapper.py,sha256=W6xaTM0O9LGmf_593EW5mnu33zCfMxGoWxp7zMTtbok,1868
80
81
  vellum/client/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
81
82
  vellum/client/core/file.py,sha256=X9IbmkZmB2bB_DpmZAO3crWdXagOakAyn6UCOCImCPg,2322
82
83
  vellum/client/core/http_client.py,sha256=R0pQpCppnEtxccGvXl4uJ76s7ro_65Fo_erlNNLp_AI,19228
@@ -649,19 +650,18 @@ vellum/errors/not_found_error.py,sha256=gC71YBdPyHR46l3RNTs0v9taVvAY0gWRFrcKpKzb
649
650
  vellum/evaluations/__init__.py,sha256=hNsLoHSykqXDJP-MwFvu2lExImxo9KEyEJjt_fdAzpE,77
650
651
  vellum/evaluations/constants.py,sha256=Vteml4_csZsMgo_q3-71E3JRCAoN6308TXLu5nfLhmU,116
651
652
  vellum/evaluations/exceptions.py,sha256=6Xacoyv43fJvVf6Dt6Io5a-f9vF12Tx51jzsQRNSqhY,56
652
- vellum/evaluations/resources.py,sha256=33IDRHOjrRsC20JHs0BtRlaSYCY9Gg-AkA6qkPjBrWo,12676
653
+ vellum/evaluations/resources.py,sha256=7xS4eYeRLLz44KLMDL0wwIY80wMy2carFREB85k_Avk,12664
653
654
  vellum/evaluations/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
654
655
  vellum/evaluations/utils/env.py,sha256=Xj_nxsoU5ox06EOTjRopR4lrigQI6Le6qbWGltYoEGU,276
655
656
  vellum/evaluations/utils/exceptions.py,sha256=dXMAkzqbHV_AP5FjjbegPlfUE0zQDlpA3qOsoOJUxfg,49
656
657
  vellum/evaluations/utils/paginator.py,sha256=rEED_BJAXAM6tM1yMwHePNzszjq_tTq4NbQvi1jWQ_Q,697
657
- vellum/evaluations/utils/uuid.py,sha256=Ch6wWRgwICxLxJCTl5iE3EdRlZj2zADR-zUMUtjcMWM,214
658
658
  vellum/plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
659
659
  vellum/plugins/pydantic.py,sha256=EbI0pJMhUS9rLPSkzmAELfnCHrWCJzOrU06T8ommwdw,2334
660
660
  vellum/plugins/utils.py,sha256=U9ZY9KdE3RRvbcG01hXxu9CvfJD6Fo7nJDgcHjQn0FI,606
661
661
  vellum/plugins/vellum_mypy.py,sha256=VC15EzjTsXOb9uF1bky4rcxePP-0epMVmCsLB2z4Dh8,24816
662
662
  vellum/prompts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
663
663
  vellum/prompts/blocks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
664
- vellum/prompts/blocks/compilation.py,sha256=hBN_ajq77tSkVyUIcDlO-Qu77PSeJ1OzVhp70NmQd2k,7458
664
+ vellum/prompts/blocks/compilation.py,sha256=GVxV0iaVp72RCNMlLtUasfg25jBjbeEu3u97QUSbrQo,7506
665
665
  vellum/prompts/blocks/exceptions.py,sha256=vmk5PV6Vyw9nKjZYQDUDW0LH8MfQNIgFvFb_mFWdIRI,50
666
666
  vellum/prompts/blocks/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
667
667
  vellum/prompts/blocks/tests/test_compilation.py,sha256=0DhMoc4huHR6YnNL-0aBLmWSyUfw2BpRq_gEdKsQmAc,3693
@@ -1210,6 +1210,7 @@ vellum/utils/templating/custom_filters.py,sha256=Q0DahYRHP4KfaUXDt9XxN-DFLBrAxlv
1210
1210
  vellum/utils/templating/exceptions.py,sha256=cDp140PP4OnInW4qAvg3KqiSiF70C71UyEAKRBR1Abo,46
1211
1211
  vellum/utils/templating/render.py,sha256=0vgkwhu2A6o64aT4fUdTSLFCEMbeRjAKAuvv2k2LYGY,1772
1212
1212
  vellum/utils/typing.py,sha256=wx_daFqD69cYkuJTVnvNrpjhqC3uuhbnyJ9_bIwC9OU,327
1213
+ vellum/utils/uuid.py,sha256=Ch6wWRgwICxLxJCTl5iE3EdRlZj2zADR-zUMUtjcMWM,214
1213
1214
  vellum/version.py,sha256=jq-1PlAYxN9AXuaZqbYk9ak27SgE2lw9Ia5gx1b1gVI,76
1214
1215
  vellum/workflows/README.md,sha256=MLNm-ihc0ao6I8gwwOhXQQBf0jOf-EsA9C519ALYI1o,3610
1215
1216
  vellum/workflows/__init__.py,sha256=CssPsbNvN6rDhoLuqpEv7MMKGa51vE6dvAh6U31Pcio,71
@@ -1271,19 +1272,19 @@ vellum/workflows/inputs/__init__.py,sha256=AbFEteIYEvCb14fM3EK7bhM-40-6s494rSlIh
1271
1272
  vellum/workflows/inputs/base.py,sha256=1kMgr0WqCYdWUqgFvgSoAMw2067FAlgwhGXLgbIOrLY,2391
1272
1273
  vellum/workflows/logging.py,sha256=_a217XogktV4Ncz6xKFz7WfYmZAzkfVRVuC0rWob8ls,437
1273
1274
  vellum/workflows/nodes/__init__.py,sha256=aVdQVv7Y3Ro3JlqXGpxwaU2zrI06plDHD2aumH5WUIs,1157
1274
- vellum/workflows/nodes/bases/__init__.py,sha256=Ll1Ti6t3e_HKtGLsQTHAJevDmfo0QtfgPZUZ9FCRduI,140
1275
- vellum/workflows/nodes/bases/base.py,sha256=oqNO8rEeSu86wBuXQ8pGIOCZP7Bc_PdDL1etz_ef2A0,14271
1276
- vellum/workflows/nodes/bases/base_subworkflow_node/__init__.py,sha256=0nkHQiFC4IpA1ZGx60XG0BLUWF6hwUpgqmS3ZrlFGhg,80
1277
- vellum/workflows/nodes/bases/base_subworkflow_node/node.py,sha256=vC0gUBQewAUNtP3i2G0-LUpE_kY-r_ijBD_tS1XkQ1E,383
1275
+ vellum/workflows/nodes/bases/__init__.py,sha256=cniHuz_RXdJ4TQgD8CBzoiKDiPxg62ErdVpCbWICX64,58
1276
+ vellum/workflows/nodes/bases/base.py,sha256=_Ms_Yov6sIsgWnKb0OWnOG7liqgjFSat0y1OIX36hFA,14235
1278
1277
  vellum/workflows/nodes/bases/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1279
1278
  vellum/workflows/nodes/bases/tests/test_base_node.py,sha256=ghpLm_ljNBxWs43GlvIId47hOVwKU50XpvZxmlg6_8g,3439
1280
1279
  vellum/workflows/nodes/core/__init__.py,sha256=5zDMCmyt1v0HTJzlUBwq3U9L825yZGZhT9JL18-mRR4,455
1281
1280
  vellum/workflows/nodes/core/error_node/__init__.py,sha256=g7RRnlHhqu4qByfLjBwCunmgGA8dI5gNsjS3h6TwlSI,60
1282
1281
  vellum/workflows/nodes/core/error_node/node.py,sha256=MFHU5vITYSK-L9CuMZ49In2ZeNLWnhZD0f8r5dWvb5Y,1270
1283
1282
  vellum/workflows/nodes/core/inline_subworkflow_node/__init__.py,sha256=nKNEH1QTl-1PcvmYoqSWEl0-t6gAur8GLTXHzklRQfM,84
1284
- vellum/workflows/nodes/core/inline_subworkflow_node/node.py,sha256=vSlDEKwJsd2YazkWPRXPiNKZtbyhTBhfO3dJxcNiSWE,3059
1283
+ vellum/workflows/nodes/core/inline_subworkflow_node/node.py,sha256=btscTP3T5VzvuNpbzaUlRZ1ahMkTox0Vyv17tI7YFUw,3467
1284
+ vellum/workflows/nodes/core/inline_subworkflow_node/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1285
+ vellum/workflows/nodes/core/inline_subworkflow_node/tests/test_node.py,sha256=99LLPgHMqohGL-G4KqOSjeVlDR_FH8Rv1gtRii85MC4,1143
1285
1286
  vellum/workflows/nodes/core/map_node/__init__.py,sha256=MXpZYmGfhsMJHqqlpd64WiJRtbAtAMQz-_3fCU_cLV0,56
1286
- vellum/workflows/nodes/core/map_node/node.py,sha256=vubEWObFh6rVUZ9GGHSi7H9b-Y-SHCwEgYkgdb3QTgM,7288
1287
+ vellum/workflows/nodes/core/map_node/node.py,sha256=5Bqi0co1T9Ex_sTlyTDMGahwsUWd9NCO0vTY6UqsZeQ,7286
1287
1288
  vellum/workflows/nodes/core/map_node/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1288
1289
  vellum/workflows/nodes/core/map_node/tests/test_node.py,sha256=RHSZs7t6mW3UWvRrXnHZqaXVdRT2ZquOK_YHJ-gzXsU,1871
1289
1290
  vellum/workflows/nodes/core/retry_node/__init__.py,sha256=lN2bIy5a3Uzhs_FYCrooADyYU6ZGShtvLKFWpelwPvo,60
@@ -1291,25 +1292,25 @@ vellum/workflows/nodes/core/retry_node/node.py,sha256=IjNcpzFmHyBUjOHEoULLbKf85B
1291
1292
  vellum/workflows/nodes/core/retry_node/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1292
1293
  vellum/workflows/nodes/core/retry_node/tests/test_node.py,sha256=QXTnHwmJHISxXjvZMeuuEo0iVugVMJyaJoggI8yKXfI,3132
1293
1294
  vellum/workflows/nodes/core/templating_node/__init__.py,sha256=GmyuYo81_A1_Bz6id69ozVFS6FKiuDsZTiA3I6MaL2U,70
1294
- vellum/workflows/nodes/core/templating_node/node.py,sha256=mWNzsa6TLosrD3higKIsiqEv54OIfNY7YzFDkuQgm6k,3964
1295
- vellum/workflows/nodes/core/templating_node/tests/test_templating_node.py,sha256=0BtXeSix7KGIuKzlPFTMLATpNnFPhut1UV_srGptkt0,1120
1295
+ vellum/workflows/nodes/core/templating_node/node.py,sha256=N-NOBd-UY91qO9orCcW4KEbhNvDQivZPA-PCxs-M0RM,4204
1296
+ vellum/workflows/nodes/core/templating_node/tests/test_templating_node.py,sha256=nW_kyJ9RAqz45_kJE_rlhOOvbV4OO3hecP-P-ydQpkw,2845
1296
1297
  vellum/workflows/nodes/core/try_node/__init__.py,sha256=JVD4DrldTIqFQQFrubs9KtWCCc0YCAc7Fzol5ZWIWeM,56
1297
- vellum/workflows/nodes/core/try_node/node.py,sha256=_xkpUNIfHXuwjivMBxdU5DegsNge2ITW5nBifWmBPTY,6670
1298
+ vellum/workflows/nodes/core/try_node/node.py,sha256=e4gavIJ9AHM0JCKOrBIeKC4aHxmJK3j17XTBaipqfpc,6637
1298
1299
  vellum/workflows/nodes/core/try_node/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1299
- vellum/workflows/nodes/core/try_node/tests/test_node.py,sha256=uqMU7ZPPHI6a-VoWnMSVwTHoRmqCk6w8wzaXogTV_J4,4093
1300
+ vellum/workflows/nodes/core/try_node/tests/test_node.py,sha256=Wc2kLl-MkffsBxl3IiFaqLd16e2Iosxhk7qBnojPvQg,4092
1300
1301
  vellum/workflows/nodes/displayable/__init__.py,sha256=6F_4DlSwvHuilWnIalp8iDjjDXl0Nmz4QzJV2PYe5RI,1023
1301
1302
  vellum/workflows/nodes/displayable/api_node/__init__.py,sha256=MoxdQSnidIj1Nf_d-hTxlOxcZXaZnsWFDbE-PkTK24o,56
1302
1303
  vellum/workflows/nodes/displayable/api_node/node.py,sha256=ehvJNkI-L_WLn8pszCaRkQuhRDgioCLaX6TT72KM_9E,2111
1303
1304
  vellum/workflows/nodes/displayable/bases/__init__.py,sha256=0mWIx3qUrzllV7jqt7wN03vWGMuI1WrrLZeMLT2Cl2c,304
1304
1305
  vellum/workflows/nodes/displayable/bases/api_node/__init__.py,sha256=1jwx4WC358CLA1jgzl_UD-rZmdMm2v9Mps39ndwCD7U,64
1305
- vellum/workflows/nodes/displayable/bases/api_node/node.py,sha256=x0RQVoG1yvokaPfGgf719qd0Lt5qxCvKFqyehYiGyqA,2481
1306
+ vellum/workflows/nodes/displayable/bases/api_node/node.py,sha256=ywPwCxDesgnE86Wjyf2ZyG2Dr2O7xW8D4tPHZB5Se_s,2477
1306
1307
  vellum/workflows/nodes/displayable/bases/base_prompt_node/__init__.py,sha256=Org3xTvgp1pA0uUXFfnJr29D3HzCey2lEdYF4zbIUgo,70
1307
1308
  vellum/workflows/nodes/displayable/bases/base_prompt_node/node.py,sha256=EvylK1rGKpd4iiooEW9O5A9Q8DMTtBwETe_GtQT8M-E,2139
1308
1309
  vellum/workflows/nodes/displayable/bases/inline_prompt_node/__init__.py,sha256=Hl35IAoepRpE-j4cALaXVJIYTYOF3qszyVbxTj4kS1s,82
1309
1310
  vellum/workflows/nodes/displayable/bases/inline_prompt_node/constants.py,sha256=fnjiRWLoRlC4Puo5oQcpZD5Hd-EesxsAo9l5tGAkpZQ,270
1310
1311
  vellum/workflows/nodes/displayable/bases/inline_prompt_node/node.py,sha256=fypgmZHgaDtGqSBC8rjYiyryJ0H58LPt_CafLfAprO0,6341
1311
1312
  vellum/workflows/nodes/displayable/bases/prompt_deployment_node.py,sha256=zdpNJoawB5PedsCCfgOGDDoWuif0jNtlV-K9sFL6cNQ,4968
1312
- vellum/workflows/nodes/displayable/bases/search_node.py,sha256=pqiui8G6l_9FLE1HH4rCdFC73Bl7_AIBAmQQMjqe190,3570
1313
+ vellum/workflows/nodes/displayable/bases/search_node.py,sha256=Gq6CqvTxg4TPm7OBbAA9wnuSwtiKoxFINjMHX-_oNdE,3687
1313
1314
  vellum/workflows/nodes/displayable/code_execution_node/__init__.py,sha256=0FLWMMktpzSnmBMizQglBpcPrP80fzVsoJwJgf822Cg,76
1314
1315
  vellum/workflows/nodes/displayable/code_execution_node/node.py,sha256=JgyTgZRSb-gSXL4ccHn4VkPcPZFOkVK5ohPazPqSWFw,8652
1315
1316
  vellum/workflows/nodes/displayable/code_execution_node/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -1336,7 +1337,7 @@ vellum/workflows/nodes/displayable/prompt_deployment_node/node.py,sha256=cpOrqQQ
1336
1337
  vellum/workflows/nodes/displayable/search_node/__init__.py,sha256=hpBpvbrDYf43DElRZFLzieSn8weXiwNiiNOJurERQbs,62
1337
1338
  vellum/workflows/nodes/displayable/search_node/node.py,sha256=yhFWulbNmSQoDAwtTSGD4AtKmBbcykezRGRG16xga_0,1311
1338
1339
  vellum/workflows/nodes/displayable/subworkflow_deployment_node/__init__.py,sha256=9yYM6001YZeqI1VOk1QuEM_yrffk_EdsO7qaPzINKds,92
1339
- vellum/workflows/nodes/displayable/subworkflow_deployment_node/node.py,sha256=pnbRCgdzWXrXhm5jDkDDASl5xu5w3DxskC34yJVmWUs,7147
1340
+ vellum/workflows/nodes/displayable/subworkflow_deployment_node/node.py,sha256=FgS1ZMnIBliqEMNKX2ChE80bw4IVHEQ6IGiTDvF0RZw,7226
1340
1341
  vellum/workflows/nodes/displayable/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1341
1342
  vellum/workflows/nodes/displayable/tests/test_inline_text_prompt_node.py,sha256=UI_RMmXn9qwB-StnFPvkDd9FctBQAg43wrfouqvPepk,4701
1342
1343
  vellum/workflows/nodes/displayable/tests/test_search_node_wth_text_output.py,sha256=4CMwDtXwTaEvFfDpA6j2iLqc7S6IICSkvVZOobEpeps,6954
@@ -1367,16 +1368,16 @@ vellum/workflows/resolvers/__init__.py,sha256=eH6hTvZO4IciDaf_cf7aM2vs-DkBDyJPyc
1367
1368
  vellum/workflows/resolvers/base.py,sha256=WHra9LRtlTuB1jmuNqkfVE2JUgB61Cyntn8f0b0WZg4,411
1368
1369
  vellum/workflows/runner/__init__.py,sha256=i1iG5sAhtpdsrlvwgH6B-m49JsINkiWyPWs8vyT-bqM,72
1369
1370
  vellum/workflows/runner/runner.py,sha256=RXnLEmSJFbp0u4vKF7rvD2fscuYfcRYkspIJINnvFAI,27607
1370
- vellum/workflows/sandbox.py,sha256=1aL5BoUgJX6dbIN3pqui20Wk3VyzXV16BUaZz-clmFs,2269
1371
+ vellum/workflows/sandbox.py,sha256=GVJzVjMuYzOBnSrboB0_6MMRZWBluAyQ2o7syeaeBd0,2235
1371
1372
  vellum/workflows/state/__init__.py,sha256=yUUdR-_Vl7UiixNDYQZ-GEM_kJI9dnOia75TtuNEsnE,60
1372
1373
  vellum/workflows/state/base.py,sha256=jpSzF1OQd3-fqi6dMGlNsQl-7JnJxCdzWIigmX8Wz-I,14425
1373
- vellum/workflows/state/context.py,sha256=oXiEdNsWJi1coRB85IreTgUeR6_CrWWBXndtLff9S7M,1272
1374
+ vellum/workflows/state/context.py,sha256=_NeGQpYo8yNuh0Tfh3OvcB_bG_-GC8b3ZLLl83Pf8-I,1279
1374
1375
  vellum/workflows/state/encoder.py,sha256=kRrqwD0vFCiSRZR3rg8Sjkh8sDEerQQhlvmdSYQAOl8,1741
1375
1376
  vellum/workflows/state/store.py,sha256=VYGBQgN1bpd1as5eGiouV_7scg8QsRs4_1aqZAGIsRQ,793
1376
1377
  vellum/workflows/state/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1377
1378
  vellum/workflows/state/tests/test_state.py,sha256=BQjcdREIK1MPuGhivRUgpynVJLftjEpH9RG3cRKxQEY,3310
1378
1379
  vellum/workflows/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1379
- vellum/workflows/tests/test_sandbox.py,sha256=OMN15LuFUV58-XnAhtBiLcEjNt-Pj6bZgetDr8miCiw,1808
1380
+ vellum/workflows/tests/test_sandbox.py,sha256=JKwaluI-lODQo7Ek9sjDstjL_WTdSqUlVik6ZVTfVOA,1826
1380
1381
  vellum/workflows/types/__init__.py,sha256=KxUTMBGzuRCfiMqzzsykOeVvrrkaZmTTo1a7SLu8gRM,68
1381
1382
  vellum/workflows/types/core.py,sha256=D2NcSBwGgWj_mtXZqe3KnEQcb5qd5HzqAwnxwmlCfCw,899
1382
1383
  vellum/workflows/types/generics.py,sha256=ZkfoRhWs042i5IjA99v2wIhmh1u-Wieo3LzosgGWJVk,600
@@ -1391,15 +1392,15 @@ vellum/workflows/utils/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
1391
1392
  vellum/workflows/utils/tests/test_functions.py,sha256=ytdruS55aO2egsb5sAv8_9jf68L1cJoZu2uKV2iamrg,8083
1392
1393
  vellum/workflows/utils/tests/test_names.py,sha256=aOqpyvMsOEK_9mg_-yaNxQDW7QQfwqsYs37PseyLhxw,402
1393
1394
  vellum/workflows/utils/tests/test_uuids.py,sha256=i77ABQ0M3S-aFLzDXHJq_yr5FPkJEWCMBn1HJ3DObrE,437
1394
- vellum/workflows/utils/tests/test_vellum_variables.py,sha256=0ISy1xjY7_rci0Mt_naK0xrmurE1REZLMCgPOCLFKRM,776
1395
+ vellum/workflows/utils/tests/test_vellum_variables.py,sha256=6H-BpmbIEmVRO75QQ3Rfy4bEUMMP2qwGzx2Gp1uXbfw,879
1395
1396
  vellum/workflows/utils/uuids.py,sha256=DFzPv9RCvsKhvdTEIQyfSek2A31D6S_QcmeLPbgrgTY,739
1396
- vellum/workflows/utils/vellum_variables.py,sha256=DsjVj_M_vTafpi5OUDs4KNrmbU2n4LR7fcLhuHb67Z4,3123
1397
+ vellum/workflows/utils/vellum_variables.py,sha256=g5xHYB8etfHE32ek19nP6Anf8NyjhmUtOwO2KmQ5xZU,3111
1397
1398
  vellum/workflows/vellum_client.py,sha256=ODrq_TSl-drX2aezXegf7pizpWDVJuTXH-j6528t75s,683
1398
1399
  vellum/workflows/workflows/__init__.py,sha256=KY45TqvavCCvXIkyCFMEc0dc6jTMOUci93U2DUrlZYc,66
1399
- vellum/workflows/workflows/base.py,sha256=zpspOEdO5Ye_0ZvN-Wkzv9iQSiF1sD201ba8lhbnPbs,17086
1400
+ vellum/workflows/workflows/base.py,sha256=FxK6ZNrQtuqcgZxWXy4_ole1LeeTiZI8VlxavRd3VbA,17119
1400
1401
  vellum/workflows/workflows/event_filters.py,sha256=GSxIgwrX26a1Smfd-6yss2abGCnadGsrSZGa7t7LpJA,2008
1401
- vellum_ai-0.12.8.dist-info/LICENSE,sha256=hOypcdt481qGNISA784bnAGWAE6tyIf9gc2E78mYC3E,1574
1402
- vellum_ai-0.12.8.dist-info/METADATA,sha256=FI7BG5Gx3Dd3exq5uqBWnHu8kuqFrVpE_9tcdUuYwdk,5160
1403
- vellum_ai-0.12.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
1404
- vellum_ai-0.12.8.dist-info/entry_points.txt,sha256=HCH4yc_V3J_nDv3qJzZ_nYS8llCHZViCDP1ejgCc5Ak,42
1405
- vellum_ai-0.12.8.dist-info/RECORD,,
1402
+ vellum_ai-0.12.9.dist-info/LICENSE,sha256=hOypcdt481qGNISA784bnAGWAE6tyIf9gc2E78mYC3E,1574
1403
+ vellum_ai-0.12.9.dist-info/METADATA,sha256=XnLz57ZnuFRq6HV_sXjLRLt2cBE7jKWY0HoCKn7G1Fs,5160
1404
+ vellum_ai-0.12.9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
1405
+ vellum_ai-0.12.9.dist-info/entry_points.txt,sha256=HCH4yc_V3J_nDv3qJzZ_nYS8llCHZViCDP1ejgCc5Ak,42
1406
+ vellum_ai-0.12.9.dist-info/RECORD,,
@@ -8,7 +8,7 @@ from uuid import uuid4
8
8
  from click.testing import CliRunner
9
9
 
10
10
  from vellum.client.types.workflow_push_response import WorkflowPushResponse
11
- from vellum.evaluations.utils.uuid import is_valid_uuid
11
+ from vellum.utils.uuid import is_valid_uuid
12
12
  from vellum_cli import main as cli_main
13
13
 
14
14
 
@@ -61,6 +61,11 @@ class BaseInlineSubworkflowNodeDisplay(
61
61
  display_context: WorkflowDisplayContext,
62
62
  ) -> Tuple[List[NodeInput], List[VellumVariable]]:
63
63
  subworkflow_inputs = raise_if_descriptor(node.subworkflow_inputs)
64
+ subworkflow_entries = (
65
+ [(variable_name, variable_value) for variable_name, variable_value in subworkflow_inputs.items()]
66
+ if isinstance(subworkflow_inputs, dict)
67
+ else [(variable_ref.name, variable_value) for variable_ref, variable_value in subworkflow_inputs]
68
+ )
64
69
  node_inputs = [
65
70
  create_node_input(
66
71
  node_id=node_id,
@@ -69,7 +74,7 @@ class BaseInlineSubworkflowNodeDisplay(
69
74
  display_context=display_context,
70
75
  input_id=self.workflow_input_ids_by_name.get(variable_name),
71
76
  )
72
- for variable_name, variable_value in subworkflow_inputs.items()
77
+ for variable_name, variable_value in subworkflow_entries
73
78
  ]
74
79
  node_inputs_by_key = {node_input.key: node_input for node_input in node_inputs}
75
80
  workflow_inputs = [
@@ -0,0 +1,207 @@
1
+ from deepdiff import DeepDiff
2
+
3
+ from vellum_ee.workflows.display.workflows import VellumWorkflowDisplay
4
+ from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
5
+
6
+ from tests.workflows.basic_templating_node.workflow_with_json_input import BasicTemplatingNodeWorkflowWithJson
7
+
8
+
9
+ def test_serialize_workflow():
10
+ # GIVEN a Workflow that uses a vellum templating node",
11
+
12
+ # WHEN we serialize it
13
+ workflow_display = get_workflow_display(
14
+ base_display_class=VellumWorkflowDisplay, workflow_class=BasicTemplatingNodeWorkflowWithJson
15
+ )
16
+
17
+ serialized_workflow: dict = workflow_display.serialize()
18
+
19
+ # THEN we should get a serialized representation of the Workflow
20
+ assert serialized_workflow.keys() == {
21
+ "workflow_raw_data",
22
+ "input_variables",
23
+ "output_variables",
24
+ }
25
+
26
+ # AND its input variables should be what we expect
27
+ input_variables = serialized_workflow["input_variables"]
28
+ assert len(input_variables) == 1
29
+ assert input_variables == [
30
+ {
31
+ "id": "f4435f88-703f-40e5-9197-d39b0e43ab72",
32
+ "key": "info",
33
+ "type": "JSON",
34
+ "default": None,
35
+ "required": True,
36
+ "extensions": {"color": None},
37
+ }
38
+ ]
39
+
40
+ # AND its output variables should be what we expect
41
+ output_variables = serialized_workflow["output_variables"]
42
+ assert len(output_variables) == 1
43
+ assert not DeepDiff(
44
+ [{"id": "62ec9b08-6437-4f8d-bc20-983d317bc348", "key": "result", "type": "JSON"}],
45
+ output_variables,
46
+ ignore_order=True,
47
+ )
48
+
49
+ # AND its raw data should be what we expect
50
+ workflow_raw_data = serialized_workflow["workflow_raw_data"]
51
+ assert workflow_raw_data.keys() == {"edges", "nodes", "display_data", "definition"}
52
+ assert len(workflow_raw_data["edges"]) == 2
53
+ assert len(workflow_raw_data["nodes"]) == 3
54
+
55
+ # AND each node should be serialized correctly
56
+ entrypoint_node = workflow_raw_data["nodes"][0]
57
+ assert entrypoint_node == {
58
+ "id": "09579c0a-acbf-4e04-8724-2230a8aa6534",
59
+ "type": "ENTRYPOINT",
60
+ "inputs": [],
61
+ "data": {"label": "Entrypoint Node", "source_handle_id": "34069190-0942-4e0c-8700-b33b9dea4ea0"},
62
+ "display_data": {"position": {"x": 0.0, "y": 0.0}},
63
+ "definition": {"name": "BaseNode", "module": ["vellum", "workflows", "nodes", "bases", "base"], "bases": []},
64
+ }
65
+
66
+ templating_node = workflow_raw_data["nodes"][1]
67
+ assert not DeepDiff(
68
+ {
69
+ "id": "51cbe21d-0232-4362-bc54-5bc283297aa6",
70
+ "type": "TEMPLATING",
71
+ "inputs": [
72
+ {
73
+ "id": "7c775379-d589-4d79-b876-dcd224d72966",
74
+ "key": "template",
75
+ "value": {
76
+ "rules": [
77
+ {
78
+ "type": "CONSTANT_VALUE",
79
+ "data": {"type": "STRING", "value": "The meaning of {{ info }} is not known"},
80
+ }
81
+ ],
82
+ "combinator": "OR",
83
+ },
84
+ },
85
+ {
86
+ "id": "bb712499-4265-4d71-bc14-0c3d8ca6a7de",
87
+ "key": "info",
88
+ "value": {
89
+ "rules": [
90
+ {
91
+ "type": "INPUT_VARIABLE",
92
+ "data": {"input_variable_id": "f4435f88-703f-40e5-9197-d39b0e43ab72"},
93
+ }
94
+ ],
95
+ "combinator": "OR",
96
+ },
97
+ },
98
+ ],
99
+ "data": {
100
+ "label": "Example Templating Node",
101
+ "output_id": "6834cae4-8173-4fa6-88f7-bc09d335bdd1",
102
+ "error_output_id": None,
103
+ "source_handle_id": "39317827-df43-4f5a-bfbc-20bffc839748",
104
+ "target_handle_id": "58427684-3848-498a-8299-c6b0fc70265d",
105
+ "template_node_input_id": "7c775379-d589-4d79-b876-dcd224d72966",
106
+ "output_type": "JSON",
107
+ },
108
+ "display_data": {"position": {"x": 0.0, "y": 0.0}},
109
+ "definition": {
110
+ "name": "ExampleTemplatingNode",
111
+ "module": ["tests", "workflows", "basic_templating_node", "workflow_with_json_input"],
112
+ "bases": [
113
+ {
114
+ "name": "TemplatingNode",
115
+ "module": ["vellum", "workflows", "nodes", "core", "templating_node", "node"],
116
+ }
117
+ ],
118
+ },
119
+ },
120
+ templating_node,
121
+ )
122
+
123
+ final_output_node = workflow_raw_data["nodes"][-1]
124
+ assert not DeepDiff(
125
+ {
126
+ "id": "9f75228b-1d5b-4c30-a581-6087e6a1b738",
127
+ "type": "TERMINAL",
128
+ "data": {
129
+ "label": "Final Output",
130
+ "name": "result",
131
+ "target_handle_id": "16ba108e-61a8-4338-8a5b-4f1278d7fd7b",
132
+ "output_id": "62ec9b08-6437-4f8d-bc20-983d317bc348",
133
+ "output_type": "JSON",
134
+ "node_input_id": "310072db-6d07-4d29-8e5c-9c6909300925",
135
+ },
136
+ "inputs": [
137
+ {
138
+ "id": "310072db-6d07-4d29-8e5c-9c6909300925",
139
+ "key": "node_input",
140
+ "value": {
141
+ "rules": [
142
+ {
143
+ "type": "NODE_OUTPUT",
144
+ "data": {
145
+ "node_id": "51cbe21d-0232-4362-bc54-5bc283297aa6",
146
+ "output_id": "6834cae4-8173-4fa6-88f7-bc09d335bdd1",
147
+ },
148
+ }
149
+ ],
150
+ "combinator": "OR",
151
+ },
152
+ }
153
+ ],
154
+ "display_data": {"position": {"x": 0.0, "y": 0.0}},
155
+ "definition": {
156
+ "name": "FinalOutputNode",
157
+ "module": ["vellum", "workflows", "nodes", "displayable", "final_output_node", "node"],
158
+ "bases": [
159
+ {"name": "BaseNode", "module": ["vellum", "workflows", "nodes", "bases", "base"], "bases": []}
160
+ ],
161
+ },
162
+ },
163
+ final_output_node,
164
+ ignore_order=True,
165
+ )
166
+
167
+ # AND each edge should be serialized correctly
168
+ serialized_edges = workflow_raw_data["edges"]
169
+ assert not DeepDiff(
170
+ [
171
+ {
172
+ "id": "9f753b40-68de-4186-838e-806a14853935",
173
+ "source_node_id": "09579c0a-acbf-4e04-8724-2230a8aa6534",
174
+ "source_handle_id": "34069190-0942-4e0c-8700-b33b9dea4ea0",
175
+ "target_node_id": "51cbe21d-0232-4362-bc54-5bc283297aa6",
176
+ "target_handle_id": "58427684-3848-498a-8299-c6b0fc70265d",
177
+ "type": "DEFAULT",
178
+ },
179
+ {
180
+ "id": "00cbff5c-5cce-4ef4-81b2-1a11d9b42597",
181
+ "source_node_id": "51cbe21d-0232-4362-bc54-5bc283297aa6",
182
+ "source_handle_id": "39317827-df43-4f5a-bfbc-20bffc839748",
183
+ "target_node_id": "9f75228b-1d5b-4c30-a581-6087e6a1b738",
184
+ "target_handle_id": "16ba108e-61a8-4338-8a5b-4f1278d7fd7b",
185
+ "type": "DEFAULT",
186
+ },
187
+ ],
188
+ serialized_edges,
189
+ ignore_order=True,
190
+ )
191
+
192
+ # AND the display data should be what we expect
193
+ display_data = workflow_raw_data["display_data"]
194
+ assert display_data == {
195
+ "viewport": {
196
+ "x": 0.0,
197
+ "y": 0.0,
198
+ "zoom": 1.0,
199
+ }
200
+ }
201
+
202
+ # AND the definition should be what we expect
203
+ definition = workflow_raw_data["definition"]
204
+ assert definition == {
205
+ "name": "BasicTemplatingNodeWorkflowWithJson",
206
+ "module": ["tests", "workflows", "basic_templating_node", "workflow_with_json_input"],
207
+ }
@@ -1,5 +0,0 @@
1
- from .node import BaseSubworkflowNode
2
-
3
- __all__ = [
4
- "BaseSubworkflowNode",
5
- ]
@@ -1,10 +0,0 @@
1
- from typing import ClassVar, Generic
2
-
3
- from vellum.workflows.nodes.bases import BaseNode
4
- from vellum.workflows.types.core import EntityInputsInterface
5
- from vellum.workflows.types.generics import StateType
6
-
7
-
8
- class BaseSubworkflowNode(BaseNode[StateType], Generic[StateType]):
9
- # Inputs that are passed to the Subworkflow
10
- subworkflow_inputs: ClassVar[EntityInputsInterface] = {}
File without changes