vellum-ai 0.11.9__py3-none-any.whl → 0.12.0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- vellum/client/core/client_wrapper.py +1 -1
- vellum/workflows/descriptors/base.py +2 -2
- vellum/workflows/descriptors/tests/test_utils.py +4 -4
- vellum/workflows/errors/__init__.py +3 -3
- vellum/workflows/errors/types.py +46 -3
- vellum/workflows/events/node.py +3 -3
- vellum/workflows/events/tests/test_event.py +3 -3
- vellum/workflows/events/workflow.py +3 -3
- vellum/workflows/exceptions.py +8 -4
- vellum/workflows/nodes/bases/base.py +9 -2
- vellum/workflows/nodes/bases/tests/test_base_node.py +13 -0
- vellum/workflows/nodes/core/error_node/node.py +9 -5
- vellum/workflows/nodes/core/inline_subworkflow_node/node.py +3 -13
- vellum/workflows/nodes/core/map_node/node.py +2 -2
- vellum/workflows/nodes/core/retry_node/node.py +5 -5
- vellum/workflows/nodes/core/retry_node/tests/test_node.py +6 -6
- vellum/workflows/nodes/core/templating_node/node.py +2 -2
- vellum/workflows/nodes/core/try_node/node.py +7 -7
- vellum/workflows/nodes/core/try_node/tests/test_node.py +9 -7
- vellum/workflows/nodes/displayable/bases/api_node/node.py +3 -3
- vellum/workflows/nodes/displayable/bases/base_prompt_node/node.py +4 -12
- vellum/workflows/nodes/displayable/bases/inline_prompt_node/node.py +2 -2
- vellum/workflows/nodes/displayable/bases/prompt_deployment_node.py +2 -2
- vellum/workflows/nodes/displayable/bases/search_node.py +3 -3
- vellum/workflows/nodes/displayable/code_execution_node/node.py +21 -5
- vellum/workflows/nodes/displayable/code_execution_node/tests/test_code_execution_node.py +141 -0
- vellum/workflows/nodes/displayable/guardrail_node/node.py +3 -3
- vellum/workflows/nodes/displayable/inline_prompt_node/node.py +3 -3
- vellum/workflows/nodes/displayable/prompt_deployment_node/node.py +3 -3
- vellum/workflows/nodes/displayable/subworkflow_deployment_node/node.py +7 -14
- vellum/workflows/nodes/displayable/tests/test_inline_text_prompt_node.py +4 -4
- vellum/workflows/nodes/utils.py +5 -9
- vellum/workflows/references/external_input.py +2 -2
- vellum/workflows/references/node.py +2 -2
- vellum/workflows/references/state_value.py +2 -2
- vellum/workflows/references/workflow_input.py +2 -2
- vellum/workflows/runner/runner.py +15 -15
- {vellum_ee/workflows/display → vellum/workflows}/utils/tests/test_uuids.py +1 -1
- vellum/workflows/workflows/base.py +7 -7
- {vellum_ai-0.11.9.dist-info → vellum_ai-0.12.0.dist-info}/METADATA +1 -1
- {vellum_ai-0.11.9.dist-info → vellum_ai-0.12.0.dist-info}/RECORD +61 -62
- {vellum_ai-0.11.9.dist-info → vellum_ai-0.12.0.dist-info}/WHEEL +1 -1
- vellum_ee/workflows/display/nodes/base_node_display.py +50 -21
- vellum_ee/workflows/display/nodes/base_node_vellum_display.py +10 -1
- vellum_ee/workflows/display/nodes/get_node_display_class.py +10 -1
- vellum_ee/workflows/display/nodes/tests/test_base_node_display.py +5 -4
- vellum_ee/workflows/display/nodes/vellum/code_execution_node.py +13 -3
- vellum_ee/workflows/display/nodes/vellum/conditional_node.py +1 -1
- vellum_ee/workflows/display/nodes/vellum/final_output_node.py +1 -1
- vellum_ee/workflows/display/nodes/vellum/inline_prompt_node.py +1 -1
- vellum_ee/workflows/display/nodes/vellum/merge_node.py +4 -4
- vellum_ee/workflows/display/nodes/vellum/search_node.py +1 -1
- vellum_ee/workflows/display/nodes/vellum/tests/test_utils.py +5 -1
- vellum_ee/workflows/display/nodes/vellum/try_node.py +12 -6
- vellum_ee/workflows/display/nodes/vellum/utils.py +1 -1
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_code_execution_node_serialization.py +269 -85
- vellum_ee/workflows/display/workflows/base_workflow_display.py +2 -2
- vellum_ee/workflows/display/workflows/vellum_workflow_display.py +2 -6
- vellum_ee/workflows/display/utils/tests/__init__.py +0 -0
- {vellum_ee/workflows/display → vellum/workflows}/utils/uuids.py +0 -0
- {vellum_ai-0.11.9.dist-info → vellum_ai-0.12.0.dist-info}/LICENSE +0 -0
- {vellum_ai-0.11.9.dist-info → vellum_ai-0.12.0.dist-info}/entry_points.txt +0 -0
@@ -15,7 +15,7 @@ def node_with_implicit_properties():
|
|
15
15
|
|
16
16
|
expected_id = UUID("ace7f746-4fe6-45c7-8207-fc8a4d0c7f6f")
|
17
17
|
|
18
|
-
return
|
18
|
+
return MyNodeDisplay, expected_id
|
19
19
|
|
20
20
|
|
21
21
|
@pytest.fixture
|
@@ -28,7 +28,7 @@ def node_with_explicit_properties():
|
|
28
28
|
class MyNodeDisplay(BaseNodeDisplay[MyNode]):
|
29
29
|
node_id = explicit_id
|
30
30
|
|
31
|
-
return
|
31
|
+
return MyNodeDisplay, explicit_id
|
32
32
|
|
33
33
|
|
34
34
|
@pytest.fixture(
|
@@ -42,6 +42,7 @@ def node_info(request):
|
|
42
42
|
|
43
43
|
|
44
44
|
def test_get_id(node_info):
|
45
|
-
|
45
|
+
node_display, expected_id = node_info
|
46
46
|
|
47
|
-
assert node_display(
|
47
|
+
assert node_display().node_id == expected_id
|
48
|
+
assert node_display.infer_node_class().__id__ == expected_id
|
@@ -28,9 +28,19 @@ class BaseCodeExecutionNodeDisplay(BaseNodeVellumDisplay[_CodeExecutionNodeType]
|
|
28
28
|
) -> JsonObject:
|
29
29
|
node = self._node
|
30
30
|
node_id = self.node_id
|
31
|
+
raw_code = raise_if_descriptor(node.code)
|
32
|
+
code_value = None
|
33
|
+
|
34
|
+
if raw_code:
|
35
|
+
code_value = raw_code
|
36
|
+
else:
|
37
|
+
node_file_path = inspect.getfile(node)
|
38
|
+
file_code = read_file_from_path(
|
39
|
+
node_filepath=node_file_path,
|
40
|
+
script_filepath=(raise_if_descriptor(node.filepath)), # type: ignore
|
41
|
+
)
|
42
|
+
code_value = file_code
|
31
43
|
|
32
|
-
node_file_path = inspect.getfile(node)
|
33
|
-
code = read_file_from_path(node_filepath=node_file_path, script_filepath=(raise_if_descriptor(node.filepath)))
|
34
44
|
code_inputs = raise_if_descriptor(node.code_inputs)
|
35
45
|
|
36
46
|
inputs = [
|
@@ -47,7 +57,7 @@ class BaseCodeExecutionNodeDisplay(BaseNodeVellumDisplay[_CodeExecutionNodeType]
|
|
47
57
|
code_node_input = create_node_input(
|
48
58
|
node_id=node_id,
|
49
59
|
input_name="code",
|
50
|
-
value=
|
60
|
+
value=code_value,
|
51
61
|
display_context=display_context,
|
52
62
|
input_id=self.code_input_id,
|
53
63
|
)
|
@@ -25,10 +25,10 @@ from vellum.workflows.expressions.not_in import NotInExpression
|
|
25
25
|
from vellum.workflows.expressions.or_ import OrExpression
|
26
26
|
from vellum.workflows.nodes.displayable import ConditionalNode
|
27
27
|
from vellum.workflows.types.core import ConditionType, JsonObject
|
28
|
+
from vellum.workflows.utils.uuids import uuid4_from_hash
|
28
29
|
from vellum_ee.workflows.display.nodes.base_node_vellum_display import BaseNodeVellumDisplay
|
29
30
|
from vellum_ee.workflows.display.nodes.vellum.utils import create_node_input
|
30
31
|
from vellum_ee.workflows.display.types import WorkflowDisplayContext
|
31
|
-
from vellum_ee.workflows.display.utils.uuids import uuid4_from_hash
|
32
32
|
from vellum_ee.workflows.display.vellum import NodeInput
|
33
33
|
|
34
34
|
_ConditionalNodeType = TypeVar("_ConditionalNodeType", bound=ConditionalNode)
|
@@ -3,11 +3,11 @@ from typing import Any, ClassVar, Generic, Optional, TypeVar
|
|
3
3
|
|
4
4
|
from vellum.workflows.nodes.displayable.final_output_node import FinalOutputNode
|
5
5
|
from vellum.workflows.types.core import JsonObject
|
6
|
+
from vellum.workflows.utils.uuids import uuid4_from_hash
|
6
7
|
from vellum_ee.workflows.display.nodes.base_node_vellum_display import BaseNodeVellumDisplay
|
7
8
|
from vellum_ee.workflows.display.nodes.utils import to_kebab_case
|
8
9
|
from vellum_ee.workflows.display.nodes.vellum.utils import create_node_input
|
9
10
|
from vellum_ee.workflows.display.types import WorkflowDisplayContext
|
10
|
-
from vellum_ee.workflows.display.utils.uuids import uuid4_from_hash
|
11
11
|
from vellum_ee.workflows.display.utils.vellum import infer_vellum_variable_type
|
12
12
|
|
13
13
|
_FinalOutputNodeType = TypeVar("_FinalOutputNodeType", bound=FinalOutputNode)
|
@@ -5,11 +5,11 @@ from vellum import PromptBlock, RichTextChildBlock, VellumVariable
|
|
5
5
|
from vellum.workflows.nodes import InlinePromptNode
|
6
6
|
from vellum.workflows.references import OutputReference
|
7
7
|
from vellum.workflows.types.core import JsonObject
|
8
|
+
from vellum.workflows.utils.uuids import uuid4_from_hash
|
8
9
|
from vellum_ee.workflows.display.nodes.base_node_vellum_display import BaseNodeVellumDisplay
|
9
10
|
from vellum_ee.workflows.display.nodes.utils import raise_if_descriptor
|
10
11
|
from vellum_ee.workflows.display.nodes.vellum.utils import create_node_input
|
11
12
|
from vellum_ee.workflows.display.types import WorkflowDisplayContext
|
12
|
-
from vellum_ee.workflows.display.utils.uuids import uuid4_from_hash
|
13
13
|
from vellum_ee.workflows.display.utils.vellum import infer_vellum_variable_type
|
14
14
|
from vellum_ee.workflows.display.vellum import NodeInput
|
15
15
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
from uuid import UUID
|
2
|
-
from typing import Any, ClassVar, Generic, List, Optional,
|
2
|
+
from typing import Any, ClassVar, Generic, List, Optional, TypeVar
|
3
3
|
|
4
4
|
from vellum.workflows.nodes.displayable import MergeNode
|
5
5
|
from vellum.workflows.types.core import JsonObject
|
6
|
+
from vellum.workflows.utils.uuids import uuid4_from_hash
|
6
7
|
from vellum_ee.workflows.display.nodes.base_node_vellum_display import BaseNodeVellumDisplay
|
7
8
|
from vellum_ee.workflows.display.types import WorkflowDisplayContext
|
8
|
-
from vellum_ee.workflows.display.utils.uuids import uuid4_from_hash
|
9
9
|
from vellum_ee.workflows.display.vellum import EdgeVellumDisplay
|
10
10
|
|
11
11
|
_MergeNodeType = TypeVar("_MergeNodeType", bound=MergeNode)
|
@@ -14,8 +14,8 @@ _MergeNodeType = TypeVar("_MergeNodeType", bound=MergeNode)
|
|
14
14
|
class BaseMergeNodeDisplay(BaseNodeVellumDisplay[_MergeNodeType], Generic[_MergeNodeType]):
|
15
15
|
target_handle_ids: ClassVar[List[UUID]]
|
16
16
|
|
17
|
-
def __init__(self
|
18
|
-
super().__init__(
|
17
|
+
def __init__(self):
|
18
|
+
super().__init__()
|
19
19
|
self._target_handle_iterator = 0
|
20
20
|
|
21
21
|
def serialize(self, display_context: WorkflowDisplayContext, **kwargs: Any) -> JsonObject:
|
@@ -10,11 +10,11 @@ from vellum import (
|
|
10
10
|
from vellum.workflows.nodes.displayable.search_node import SearchNode
|
11
11
|
from vellum.workflows.references import OutputReference
|
12
12
|
from vellum.workflows.types.core import JsonArray, JsonObject
|
13
|
+
from vellum.workflows.utils.uuids import uuid4_from_hash
|
13
14
|
from vellum_ee.workflows.display.nodes.base_node_vellum_display import BaseNodeVellumDisplay
|
14
15
|
from vellum_ee.workflows.display.nodes.utils import raise_if_descriptor
|
15
16
|
from vellum_ee.workflows.display.nodes.vellum.utils import create_node_input
|
16
17
|
from vellum_ee.workflows.display.types import WorkflowDisplayContext
|
17
|
-
from vellum_ee.workflows.display.utils.uuids import uuid4_from_hash
|
18
18
|
from vellum_ee.workflows.display.vellum import InputVariablePointer, NodeInput
|
19
19
|
|
20
20
|
_SearchNodeType = TypeVar("_SearchNodeType", bound=SearchNode)
|
@@ -37,6 +37,10 @@ class MyNodeA(BaseNode):
|
|
37
37
|
output: str
|
38
38
|
|
39
39
|
|
40
|
+
class MyNodeADisplay(BaseNodeVellumDisplay[MyNodeA]):
|
41
|
+
pass
|
42
|
+
|
43
|
+
|
40
44
|
class MyNodeB(BaseNode):
|
41
45
|
example = MyNodeA.Outputs.output
|
42
46
|
fallback_example = MyNodeA.Outputs.output.coalesce(Inputs.example_workflow_input).coalesce("fallback")
|
@@ -99,7 +103,7 @@ def test_create_node_input_value_pointer_rules(
|
|
99
103
|
),
|
100
104
|
},
|
101
105
|
node_displays={
|
102
|
-
MyNodeA:
|
106
|
+
MyNodeA: MyNodeADisplay(),
|
103
107
|
},
|
104
108
|
),
|
105
109
|
)
|
@@ -1,13 +1,15 @@
|
|
1
1
|
from uuid import UUID
|
2
2
|
from typing import Any, ClassVar, Generic, Optional, TypeVar
|
3
3
|
|
4
|
+
from vellum.workflows.nodes.bases.base import BaseNode
|
4
5
|
from vellum.workflows.nodes.core.try_node.node import TryNode
|
5
6
|
from vellum.workflows.nodes.utils import ADORNMENT_MODULE_NAME, get_wrapped_node
|
6
7
|
from vellum.workflows.types.core import JsonObject
|
8
|
+
from vellum.workflows.utils.uuids import uuid4_from_hash
|
7
9
|
from vellum_ee.workflows.display.nodes.base_node_vellum_display import BaseNodeVellumDisplay
|
8
10
|
from vellum_ee.workflows.display.nodes.get_node_display_class import get_node_display_class
|
11
|
+
from vellum_ee.workflows.display.nodes.utils import raise_if_descriptor
|
9
12
|
from vellum_ee.workflows.display.types import WorkflowDisplayContext
|
10
|
-
from vellum_ee.workflows.display.utils.uuids import uuid4_from_hash
|
11
13
|
|
12
14
|
_TryNodeType = TypeVar("_TryNodeType", bound=TryNode)
|
13
15
|
|
@@ -20,15 +22,19 @@ class BaseTryNodeDisplay(BaseNodeVellumDisplay[_TryNodeType], Generic[_TryNodeTy
|
|
20
22
|
|
21
23
|
try:
|
22
24
|
inner_node = get_wrapped_node(node)
|
23
|
-
except
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
except AttributeError:
|
26
|
+
subworkflow = raise_if_descriptor(node.subworkflow)
|
27
|
+
if not isinstance(subworkflow.graph, type) or not issubclass(subworkflow.graph, BaseNode):
|
28
|
+
raise NotImplementedError(
|
29
|
+
"Unable to serialize Try Nodes that wrap subworkflows containing more than one Node."
|
30
|
+
)
|
31
|
+
|
32
|
+
inner_node = subworkflow.graph
|
27
33
|
|
28
34
|
# We need the node display class of the underlying node because
|
29
35
|
# it contains the logic for serializing the node and potential display overrides
|
30
36
|
node_display_class = get_node_display_class(BaseNodeVellumDisplay, inner_node)
|
31
|
-
node_display = node_display_class(
|
37
|
+
node_display = node_display_class()
|
32
38
|
|
33
39
|
serialized_node = node_display.serialize(
|
34
40
|
display_context,
|
@@ -5,8 +5,8 @@ from vellum.workflows.descriptors.base import BaseDescriptor
|
|
5
5
|
from vellum.workflows.expressions.coalesce_expression import CoalesceExpression
|
6
6
|
from vellum.workflows.nodes.utils import get_wrapped_node, has_wrapped_node
|
7
7
|
from vellum.workflows.references import NodeReference, OutputReference
|
8
|
+
from vellum.workflows.utils.uuids import uuid4_from_hash
|
8
9
|
from vellum_ee.workflows.display.types import WorkflowDisplayContext
|
9
|
-
from vellum_ee.workflows.display.utils.uuids import uuid4_from_hash
|
10
10
|
from vellum_ee.workflows.display.utils.vellum import create_node_input_value_pointer_rule, primitive_to_vellum_value
|
11
11
|
from vellum_ee.workflows.display.vellum import (
|
12
12
|
ConstantValuePointer,
|