vellum-ai 1.4.0__py3-none-any.whl → 1.4.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vellum/client/core/client_wrapper.py +2 -2
- vellum/workflows/constants.py +4 -0
- vellum/workflows/emitters/base.py +8 -0
- vellum/workflows/emitters/vellum_emitter.py +10 -0
- vellum/workflows/events/exception_handling.py +58 -0
- vellum/workflows/events/tests/test_event.py +27 -0
- vellum/workflows/exceptions.py +11 -6
- vellum/workflows/inputs/base.py +1 -0
- vellum/workflows/inputs/dataset_row.py +2 -2
- vellum/workflows/nodes/bases/base.py +12 -1
- vellum/workflows/nodes/displayable/bases/base_prompt_node/node.py +6 -0
- vellum/workflows/nodes/displayable/bases/inline_prompt_node/node.py +16 -2
- vellum/workflows/nodes/displayable/final_output_node/node.py +59 -0
- vellum/workflows/nodes/displayable/final_output_node/tests/test_node.py +40 -1
- vellum/workflows/nodes/displayable/tool_calling_node/node.py +3 -0
- vellum/workflows/nodes/displayable/tool_calling_node/tests/test_utils.py +64 -0
- vellum/workflows/nodes/displayable/tool_calling_node/utils.py +30 -41
- vellum/workflows/nodes/mocks.py +15 -4
- vellum/workflows/tests/test_dataset_row.py +29 -0
- vellum/workflows/types/core.py +13 -2
- vellum/workflows/types/definition.py +13 -1
- vellum/workflows/utils/functions.py +63 -26
- vellum/workflows/utils/tests/test_functions.py +10 -6
- vellum/workflows/vellum_client.py +7 -1
- vellum/workflows/workflows/base.py +8 -0
- {vellum_ai-1.4.0.dist-info → vellum_ai-1.4.2.dist-info}/METADATA +1 -1
- {vellum_ai-1.4.0.dist-info → vellum_ai-1.4.2.dist-info}/RECORD +38 -36
- vellum_cli/tests/test_pull.py +1 -0
- vellum_cli/tests/test_push.py +2 -0
- vellum_ee/workflows/display/nodes/vellum/inline_prompt_node.py +1 -3
- vellum_ee/workflows/display/nodes/vellum/tests/test_final_output_node.py +78 -0
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_inline_workflow_serialization.py +5 -0
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_serialization.py +5 -0
- vellum_ee/workflows/display/types.py +3 -0
- vellum_ee/workflows/display/workflows/base_workflow_display.py +6 -0
- {vellum_ai-1.4.0.dist-info → vellum_ai-1.4.2.dist-info}/LICENSE +0 -0
- {vellum_ai-1.4.0.dist-info → vellum_ai-1.4.2.dist-info}/WHEEL +0 -0
- {vellum_ai-1.4.0.dist-info → vellum_ai-1.4.2.dist-info}/entry_points.txt +0 -0
vellum_cli/tests/test_push.py
CHANGED
@@ -721,6 +721,7 @@ MY_OTHER_VELLUM_API_KEY=aaabbbcccddd
|
|
721
721
|
vellum_client_class.assert_called_once_with(
|
722
722
|
api_key="aaabbbcccddd",
|
723
723
|
environment=mock.ANY,
|
724
|
+
api_version=None,
|
724
725
|
)
|
725
726
|
|
726
727
|
# AND the vellum lock file should have been updated with the correct workspace
|
@@ -882,6 +883,7 @@ MY_OTHER_VELLUM_API_KEY=aaabbbcccddd
|
|
882
883
|
vellum_client_class.assert_called_once_with(
|
883
884
|
api_key="aaabbbcccddd",
|
884
885
|
environment=mock.ANY,
|
886
|
+
api_version=None,
|
885
887
|
)
|
886
888
|
|
887
889
|
# AND the vellum lock file should have the same two workflows
|
@@ -163,9 +163,7 @@ class BaseInlinePromptNodeDisplay(BaseNodeDisplay[_InlinePromptNodeType], Generi
|
|
163
163
|
elif callable(function):
|
164
164
|
normalized_functions = compile_function_definition(function)
|
165
165
|
elif isinstance(function, DeploymentDefinition):
|
166
|
-
normalized_functions = compile_workflow_deployment_function_definition(
|
167
|
-
function.model_dump(), display_context.client
|
168
|
-
)
|
166
|
+
normalized_functions = compile_workflow_deployment_function_definition(function, display_context.client)
|
169
167
|
else:
|
170
168
|
raise ValueError(f"Unsupported function type: {type(function)}")
|
171
169
|
return {
|
@@ -0,0 +1,78 @@
|
|
1
|
+
from vellum.workflows import BaseWorkflow
|
2
|
+
from vellum.workflows.nodes import BaseNode
|
3
|
+
from vellum.workflows.nodes.displayable.final_output_node import FinalOutputNode
|
4
|
+
from vellum.workflows.state.base import BaseState
|
5
|
+
from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
|
6
|
+
|
7
|
+
|
8
|
+
def test_final_output_node_display__serialize_with_valid_types():
|
9
|
+
# GIVEN a node that outputs a str
|
10
|
+
class StringNode(BaseNode):
|
11
|
+
class Outputs:
|
12
|
+
result: str
|
13
|
+
|
14
|
+
# AND a FinalOutputNode with matching type to that node
|
15
|
+
class CorrectOutput(FinalOutputNode[BaseState, str]):
|
16
|
+
class Outputs(FinalOutputNode.Outputs):
|
17
|
+
value = StringNode.Outputs.result
|
18
|
+
|
19
|
+
# AND a workflow referencing the node
|
20
|
+
class MyWorkflow(BaseWorkflow):
|
21
|
+
graph = StringNode >> CorrectOutput
|
22
|
+
|
23
|
+
class Outputs(BaseWorkflow.Outputs):
|
24
|
+
final_result = CorrectOutput.Outputs.value
|
25
|
+
|
26
|
+
# WHEN we serialize the workflow
|
27
|
+
workflow_display = get_workflow_display(workflow_class=MyWorkflow)
|
28
|
+
|
29
|
+
# THEN serialization should succeed without raising validation errors
|
30
|
+
serialized_workflow: dict = workflow_display.serialize()
|
31
|
+
|
32
|
+
# AND the node should be properly serialized
|
33
|
+
assert "workflow_raw_data" in serialized_workflow
|
34
|
+
assert "nodes" in serialized_workflow["workflow_raw_data"]
|
35
|
+
|
36
|
+
# Find the terminal node in the serialized output
|
37
|
+
terminal_node = next(
|
38
|
+
node for node in serialized_workflow["workflow_raw_data"]["nodes"] if node["type"] == "TERMINAL"
|
39
|
+
)
|
40
|
+
assert terminal_node is not None
|
41
|
+
assert terminal_node["id"] == str(CorrectOutput.__id__)
|
42
|
+
|
43
|
+
|
44
|
+
def test_final_output_node_display__serialize_with_invalid_types_should_raise_error():
|
45
|
+
# GIVEN a node that outputs a str
|
46
|
+
class StringNode(BaseNode):
|
47
|
+
class Outputs:
|
48
|
+
result: str
|
49
|
+
|
50
|
+
# AND a FinalOutputNode with mismatched types (expects list but gets str)
|
51
|
+
class BadOutput(FinalOutputNode[BaseState, list]):
|
52
|
+
"""Output with type mismatch."""
|
53
|
+
|
54
|
+
class Outputs(FinalOutputNode.Outputs):
|
55
|
+
value = StringNode.Outputs.result # str type, conflicts with list
|
56
|
+
|
57
|
+
# AND a workflow referencing the node
|
58
|
+
class MyWorkflow(BaseWorkflow):
|
59
|
+
graph = StringNode >> BadOutput
|
60
|
+
|
61
|
+
class Outputs(BaseWorkflow.Outputs):
|
62
|
+
final_result = BadOutput.Outputs.value
|
63
|
+
|
64
|
+
# WHEN we attempt to serialize the workflow
|
65
|
+
workflow_display = get_workflow_display(workflow_class=MyWorkflow)
|
66
|
+
|
67
|
+
# THEN serialization should complete without raising an exception
|
68
|
+
serialized_workflow = workflow_display.serialize()
|
69
|
+
|
70
|
+
# AND the error should be captured in workflow_display.errors
|
71
|
+
errors = list(workflow_display.display_context.errors)
|
72
|
+
assert len(errors) == 1
|
73
|
+
assert "Output type mismatch" in str(errors[0])
|
74
|
+
assert "list" in str(errors[0])
|
75
|
+
assert "str" in str(errors[0])
|
76
|
+
|
77
|
+
# AND the serialized workflow should still be created
|
78
|
+
assert "workflow_raw_data" in serialized_workflow
|
@@ -437,6 +437,11 @@ def test_serialize_workflow():
|
|
437
437
|
"name": "max_prompt_iterations",
|
438
438
|
"value": {"type": "CONSTANT_VALUE", "value": {"type": "NUMBER", "value": 5.0}},
|
439
439
|
},
|
440
|
+
{
|
441
|
+
"id": "f92dc3ec-a19a-4491-a98a-2b2df322e2e3",
|
442
|
+
"name": "settings",
|
443
|
+
"value": {"type": "CONSTANT_VALUE", "value": {"type": "JSON", "value": None}},
|
444
|
+
},
|
440
445
|
],
|
441
446
|
"outputs": [
|
442
447
|
{"id": "e62bc785-a914-4066-b79e-8c89a5d0ec6c", "name": "text", "type": "STRING", "value": None},
|
@@ -206,6 +206,11 @@ def test_serialize_workflow():
|
|
206
206
|
"name": "max_prompt_iterations",
|
207
207
|
"value": {"type": "CONSTANT_VALUE", "value": {"type": "NUMBER", "value": 5.0}},
|
208
208
|
},
|
209
|
+
{
|
210
|
+
"id": "f92dc3ec-a19a-4491-a98a-2b2df322e2e3",
|
211
|
+
"name": "settings",
|
212
|
+
"value": {"type": "CONSTANT_VALUE", "value": {"type": "JSON", "value": None}},
|
213
|
+
},
|
209
214
|
],
|
210
215
|
"outputs": [
|
211
216
|
{"id": "e62bc785-a914-4066-b79e-8c89a5d0ec6c", "name": "text", "type": "STRING", "value": None},
|
@@ -62,6 +62,9 @@ class WorkflowDisplayContext:
|
|
62
62
|
|
63
63
|
raise error
|
64
64
|
|
65
|
+
def add_validation_error(self, error: Exception) -> None:
|
66
|
+
self._errors.append(error)
|
67
|
+
|
65
68
|
def add_invalid_node(self, node: Type[BaseNode]) -> None:
|
66
69
|
"""Track a node that failed to serialize."""
|
67
70
|
if node not in self._invalid_nodes:
|
@@ -196,6 +196,12 @@ class BaseWorkflowDisplay(Generic[WorkflowType]):
|
|
196
196
|
node_display = self.display_context.node_displays[node]
|
197
197
|
|
198
198
|
try:
|
199
|
+
try:
|
200
|
+
node.__validate__()
|
201
|
+
except ValueError as validation_error:
|
202
|
+
# Only collect node validation errors directly to errors list, don't raise them
|
203
|
+
self.display_context.add_validation_error(validation_error)
|
204
|
+
|
199
205
|
serialized_node = node_display.serialize(self.display_context)
|
200
206
|
except (NotImplementedError, NodeValidationError) as e:
|
201
207
|
self.display_context.add_error(e)
|
File without changes
|
File without changes
|
File without changes
|