vellum-ai 0.14.72__py3-none-any.whl → 0.14.74__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/__init__.py +8 -0
- vellum/client/core/client_wrapper.py +1 -1
- vellum/client/types/__init__.py +8 -0
- vellum/client/types/build_status_enum.py +5 -0
- vellum/client/types/container_image_build_config.py +20 -0
- vellum/client/types/container_image_read.py +4 -0
- vellum/client/types/execute_api_response.py +2 -2
- vellum/client/types/folder_entity.py +2 -0
- vellum/client/types/folder_entity_dataset.py +26 -0
- vellum/client/types/folder_entity_dataset_data.py +25 -0
- vellum/client/types/secret_type_enum.py +3 -1
- vellum/types/build_status_enum.py +3 -0
- vellum/types/container_image_build_config.py +3 -0
- vellum/types/folder_entity_dataset.py +3 -0
- vellum/types/folder_entity_dataset_data.py +3 -0
- vellum/workflows/nodes/core/retry_node/tests/test_node.py +1 -1
- vellum/workflows/nodes/displayable/api_node/node.py +2 -0
- vellum/workflows/nodes/displayable/api_node/tests/test_api_node.py +43 -0
- vellum/workflows/nodes/displayable/bases/api_node/node.py +6 -0
- vellum/workflows/nodes/displayable/bases/inline_prompt_node/node.py +30 -4
- vellum/workflows/nodes/displayable/bases/inline_prompt_node/tests/test_inline_prompt_node.py +43 -3
- vellum/workflows/nodes/displayable/bases/utils.py +2 -0
- vellum/workflows/nodes/displayable/subworkflow_deployment_node/node.py +68 -58
- vellum/workflows/nodes/experimental/tool_calling_node/node.py +15 -11
- vellum/workflows/nodes/experimental/tool_calling_node/tests/__init__.py +0 -0
- vellum/workflows/nodes/experimental/tool_calling_node/tests/test_node.py +13 -0
- vellum/workflows/nodes/experimental/tool_calling_node/tests/test_utils.py +49 -0
- vellum/workflows/nodes/experimental/tool_calling_node/utils.py +78 -7
- vellum/workflows/ports/utils.py +26 -6
- vellum/workflows/runner/runner.py +35 -3
- vellum/workflows/state/encoder.py +2 -0
- vellum/workflows/types/core.py +12 -0
- vellum/workflows/types/definition.py +6 -0
- vellum/workflows/utils/functions.py +12 -12
- vellum/workflows/utils/pydantic_schema.py +38 -0
- vellum/workflows/utils/tests/test_functions.py +18 -18
- {vellum_ai-0.14.72.dist-info → vellum_ai-0.14.74.dist-info}/METADATA +1 -1
- {vellum_ai-0.14.72.dist-info → vellum_ai-0.14.74.dist-info}/RECORD +74 -61
- vellum_cli/push.py +6 -8
- vellum_ee/workflows/display/nodes/vellum/inline_prompt_node.py +36 -7
- vellum_ee/workflows/display/nodes/vellum/subworkflow_deployment_node.py +8 -1
- vellum_ee/workflows/display/nodes/vellum/tests/test_prompt_node.py +102 -0
- vellum_ee/workflows/display/tests/test_base_workflow_display.py +1 -1
- vellum_ee/workflows/display/tests/workflow_serialization/generic_nodes/test_adornments_serialization.py +1 -1
- vellum_ee/workflows/display/tests/workflow_serialization/generic_nodes/test_attributes_serialization.py +91 -1
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_api_node_serialization.py +5 -5
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_code_execution_node_serialization.py +12 -12
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_conditional_node_serialization.py +10 -10
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_default_state_serialization.py +3 -3
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_error_node_serialization.py +3 -3
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_generic_node_serialization.py +20 -9
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_guardrail_node_serialization.py +3 -3
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_inline_prompt_node_serialization.py +120 -3
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_inline_subworkflow_serialization.py +8 -8
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_map_node_serialization.py +6 -6
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_merge_node_serialization.py +3 -3
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_prompt_deployment_serialization.py +8 -8
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_search_node_serialization.py +3 -3
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_subworkflow_deployment_serialization.py +4 -4
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_templating_node_serialization.py +3 -3
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_terminal_node_serialization.py +2 -2
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_inline_workflow_serialization.py +12 -5
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_serialization.py +8 -1
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_workflow_deployment_serialization.py +62 -0
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_try_node_serialization.py +1 -1
- vellum_ee/workflows/display/tests/workflow_serialization/test_complex_terminal_node_serialization.py +2 -2
- vellum_ee/workflows/display/utils/auto_layout.py +1 -1
- vellum_ee/workflows/display/utils/expressions.py +33 -2
- vellum_ee/workflows/display/workflows/base_workflow_display.py +199 -10
- vellum_ee/workflows/tests/test_display_meta.py +41 -0
- vellum_ee/workflows/tests/test_serialize_module.py +47 -0
- {vellum_ai-0.14.72.dist-info → vellum_ai-0.14.74.dist-info}/LICENSE +0 -0
- {vellum_ai-0.14.72.dist-info → vellum_ai-0.14.74.dist-info}/WHEEL +0 -0
- {vellum_ai-0.14.72.dist-info → vellum_ai-0.14.74.dist-info}/entry_points.txt +0 -0
@@ -26,27 +26,27 @@ type_map = {
|
|
26
26
|
}
|
27
27
|
|
28
28
|
|
29
|
-
def
|
29
|
+
def compile_annotation(annotation: Optional[Any], defs: dict[str, Any]) -> dict:
|
30
30
|
if annotation is None:
|
31
31
|
return {"type": "null"}
|
32
32
|
|
33
33
|
if get_origin(annotation) is Union:
|
34
|
-
return {"anyOf": [
|
34
|
+
return {"anyOf": [compile_annotation(a, defs) for a in get_args(annotation)]}
|
35
35
|
|
36
36
|
if get_origin(annotation) is dict:
|
37
37
|
_, value_type = get_args(annotation)
|
38
|
-
return {"type": "object", "additionalProperties":
|
38
|
+
return {"type": "object", "additionalProperties": compile_annotation(value_type, defs)}
|
39
39
|
|
40
40
|
if get_origin(annotation) is list:
|
41
41
|
item_type = get_args(annotation)[0]
|
42
|
-
return {"type": "array", "items":
|
42
|
+
return {"type": "array", "items": compile_annotation(item_type, defs)}
|
43
43
|
|
44
44
|
if dataclasses.is_dataclass(annotation):
|
45
45
|
if annotation.__name__ not in defs:
|
46
46
|
properties = {}
|
47
47
|
required = []
|
48
48
|
for field in dataclasses.fields(annotation):
|
49
|
-
properties[field.name] =
|
49
|
+
properties[field.name] = compile_annotation(field.type, defs)
|
50
50
|
if field.default is dataclasses.MISSING:
|
51
51
|
required.append(field.name)
|
52
52
|
else:
|
@@ -61,7 +61,7 @@ def _compile_annotation(annotation: Optional[Any], defs: dict[str, Any]) -> dict
|
|
61
61
|
for field_name, field in annotation.model_fields.items():
|
62
62
|
# Mypy is incorrect here, the `annotation` attribute is defined on `FieldInfo`
|
63
63
|
field_annotation = field.annotation # type: ignore[attr-defined]
|
64
|
-
properties[field_name] =
|
64
|
+
properties[field_name] = compile_annotation(field_annotation, defs)
|
65
65
|
if field.default is PydanticUndefined:
|
66
66
|
required.append(field_name)
|
67
67
|
else:
|
@@ -88,7 +88,7 @@ def _compile_default_value(default: Any) -> Any:
|
|
88
88
|
return default
|
89
89
|
|
90
90
|
|
91
|
-
def
|
91
|
+
def _compile_workflow_deployment_input(input_var: Any) -> dict[str, Any]:
|
92
92
|
"""
|
93
93
|
Converts a deployment workflow input variable to a JSON schema type definition.
|
94
94
|
"""
|
@@ -115,7 +115,7 @@ def compile_function_definition(function: Callable) -> FunctionDefinition:
|
|
115
115
|
required = []
|
116
116
|
defs: dict[str, Any] = {}
|
117
117
|
for param in signature.parameters.values():
|
118
|
-
properties[param.name] =
|
118
|
+
properties[param.name] = compile_annotation(param.annotation, defs)
|
119
119
|
if param.default is inspect.Parameter.empty:
|
120
120
|
required.append(param.name)
|
121
121
|
else:
|
@@ -132,7 +132,7 @@ def compile_function_definition(function: Callable) -> FunctionDefinition:
|
|
132
132
|
)
|
133
133
|
|
134
134
|
|
135
|
-
def
|
135
|
+
def compile_inline_workflow_function_definition(workflow_class: Type["BaseWorkflow"]) -> FunctionDefinition:
|
136
136
|
"""
|
137
137
|
Converts a base workflow class into our Vellum-native FunctionDefinition type.
|
138
138
|
"""
|
@@ -148,7 +148,7 @@ def compile_workflow_function_definition(workflow_class: Type["BaseWorkflow"]) -
|
|
148
148
|
if name.startswith("__"):
|
149
149
|
continue
|
150
150
|
|
151
|
-
properties[name] =
|
151
|
+
properties[name] = compile_annotation(field_type, defs)
|
152
152
|
|
153
153
|
# Check if the field has a default value
|
154
154
|
if name not in vars_inputs_class:
|
@@ -168,7 +168,7 @@ def compile_workflow_function_definition(workflow_class: Type["BaseWorkflow"]) -
|
|
168
168
|
)
|
169
169
|
|
170
170
|
|
171
|
-
def
|
171
|
+
def compile_workflow_deployment_function_definition(
|
172
172
|
deployment_config: Dict[str, str],
|
173
173
|
vellum_client: Vellum,
|
174
174
|
) -> FunctionDefinition:
|
@@ -193,7 +193,7 @@ def compile_deployment_workflow_function_definition(
|
|
193
193
|
required = []
|
194
194
|
|
195
195
|
for input_var in input_variables:
|
196
|
-
properties[input_var.key] =
|
196
|
+
properties[input_var.key] = _compile_workflow_deployment_input(input_var)
|
197
197
|
|
198
198
|
if input_var.required and input_var.default is None:
|
199
199
|
required.append(input_var.key)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import inspect
|
2
|
+
from typing import Any, Dict
|
3
|
+
|
4
|
+
from pydantic import BaseModel
|
5
|
+
|
6
|
+
from vellum.workflows.utils.functions import compile_annotation
|
7
|
+
|
8
|
+
|
9
|
+
def normalize_json(schema_input: Any) -> Any:
|
10
|
+
"""
|
11
|
+
Recursively normalize JSON data by converting Pydantic models to JSON schema.
|
12
|
+
|
13
|
+
This function processes dictionaries recursively to find and convert any
|
14
|
+
Pydantic model classes or instances to their JSON schema representation.
|
15
|
+
|
16
|
+
Args:
|
17
|
+
schema_input: Can be a Pydantic model class, instance, dict, or any other value
|
18
|
+
|
19
|
+
Returns:
|
20
|
+
Normalized JSON data with Pydantic models converted to JSON schema
|
21
|
+
"""
|
22
|
+
if isinstance(schema_input, dict):
|
23
|
+
return {key: normalize_json(value) for key, value in schema_input.items()}
|
24
|
+
|
25
|
+
if inspect.isclass(schema_input) and issubclass(schema_input, BaseModel):
|
26
|
+
defs: Dict[str, Any] = {}
|
27
|
+
result = compile_annotation(schema_input, defs)
|
28
|
+
|
29
|
+
if "$ref" in result and defs:
|
30
|
+
ref_name = result["$ref"].split("/")[-1]
|
31
|
+
if ref_name in defs:
|
32
|
+
return defs[ref_name]
|
33
|
+
|
34
|
+
return result
|
35
|
+
elif isinstance(schema_input, BaseModel):
|
36
|
+
return {key: normalize_json(getattr(schema_input, key)) for key in schema_input.__class__.model_fields.keys()}
|
37
|
+
else:
|
38
|
+
return schema_input
|
@@ -12,9 +12,9 @@ from vellum.workflows.inputs.base import BaseInputs
|
|
12
12
|
from vellum.workflows.nodes.bases.base import BaseNode
|
13
13
|
from vellum.workflows.state.base import BaseState
|
14
14
|
from vellum.workflows.utils.functions import (
|
15
|
-
compile_deployment_workflow_function_definition,
|
16
15
|
compile_function_definition,
|
17
|
-
|
16
|
+
compile_inline_workflow_function_definition,
|
17
|
+
compile_workflow_deployment_function_definition,
|
18
18
|
)
|
19
19
|
|
20
20
|
|
@@ -306,7 +306,7 @@ def test_compile_function_definition__lambda():
|
|
306
306
|
)
|
307
307
|
|
308
308
|
|
309
|
-
def
|
309
|
+
def test_compile_inline_workflow_function_definition():
|
310
310
|
class MyNode(BaseNode):
|
311
311
|
pass
|
312
312
|
|
@@ -314,7 +314,7 @@ def test_compile_workflow_function_definition():
|
|
314
314
|
graph = MyNode
|
315
315
|
|
316
316
|
# WHEN compiling the function
|
317
|
-
compiled_function =
|
317
|
+
compiled_function = compile_inline_workflow_function_definition(MyWorkflow)
|
318
318
|
|
319
319
|
# THEN it should return the compiled function definition
|
320
320
|
assert compiled_function == FunctionDefinition(
|
@@ -323,7 +323,7 @@ def test_compile_workflow_function_definition():
|
|
323
323
|
)
|
324
324
|
|
325
325
|
|
326
|
-
def
|
326
|
+
def test_compile_inline_workflow_function_definition__docstring():
|
327
327
|
class MyNode(BaseNode):
|
328
328
|
pass
|
329
329
|
|
@@ -335,7 +335,7 @@ def test_compile_workflow_function_definition__docstring():
|
|
335
335
|
graph = MyNode
|
336
336
|
|
337
337
|
# WHEN compiling the function
|
338
|
-
compiled_function =
|
338
|
+
compiled_function = compile_inline_workflow_function_definition(MyWorkflow)
|
339
339
|
|
340
340
|
# THEN it should return the compiled function definition
|
341
341
|
assert compiled_function == FunctionDefinition(
|
@@ -345,7 +345,7 @@ def test_compile_workflow_function_definition__docstring():
|
|
345
345
|
)
|
346
346
|
|
347
347
|
|
348
|
-
def
|
348
|
+
def test_compile_inline_workflow_function_definition__all_args():
|
349
349
|
class MyInputs(BaseInputs):
|
350
350
|
a: str
|
351
351
|
b: int
|
@@ -361,7 +361,7 @@ def test_compile_workflow_function_definition__all_args():
|
|
361
361
|
graph = MyNode
|
362
362
|
|
363
363
|
# WHEN compiling the workflow
|
364
|
-
compiled_function =
|
364
|
+
compiled_function = compile_inline_workflow_function_definition(MyWorkflow)
|
365
365
|
|
366
366
|
# THEN it should return the compiled function definition
|
367
367
|
assert compiled_function == FunctionDefinition(
|
@@ -381,7 +381,7 @@ def test_compile_workflow_function_definition__all_args():
|
|
381
381
|
)
|
382
382
|
|
383
383
|
|
384
|
-
def
|
384
|
+
def test_compile_inline_workflow_function_definition__unions():
|
385
385
|
# GIVEN a workflow with a union
|
386
386
|
class MyInputs(BaseInputs):
|
387
387
|
a: Union[str, int]
|
@@ -393,7 +393,7 @@ def test_compile_workflow_function_definition__unions():
|
|
393
393
|
graph = MyNode
|
394
394
|
|
395
395
|
# WHEN compiling the workflow
|
396
|
-
compiled_function =
|
396
|
+
compiled_function = compile_inline_workflow_function_definition(MyWorkflow)
|
397
397
|
|
398
398
|
# THEN it should return the compiled function definition
|
399
399
|
assert compiled_function == FunctionDefinition(
|
@@ -406,7 +406,7 @@ def test_compile_workflow_function_definition__unions():
|
|
406
406
|
)
|
407
407
|
|
408
408
|
|
409
|
-
def
|
409
|
+
def test_compile_inline_workflow_function_definition__optionals():
|
410
410
|
class MyInputs(BaseInputs):
|
411
411
|
a: str
|
412
412
|
b: Optional[str]
|
@@ -421,7 +421,7 @@ def test_compile_workflow_function_definition__optionals():
|
|
421
421
|
graph = MyNode
|
422
422
|
|
423
423
|
# WHEN compiling the workflow
|
424
|
-
compiled_function =
|
424
|
+
compiled_function = compile_inline_workflow_function_definition(MyWorkflow)
|
425
425
|
|
426
426
|
# THEN it should return the compiled function definition
|
427
427
|
assert compiled_function == FunctionDefinition(
|
@@ -440,7 +440,7 @@ def test_compile_workflow_function_definition__optionals():
|
|
440
440
|
)
|
441
441
|
|
442
442
|
|
443
|
-
def
|
443
|
+
def test_compile_workflow_deployment_function_definition__just_name():
|
444
444
|
# GIVEN a mock Vellum client and deployment
|
445
445
|
mock_client = Mock()
|
446
446
|
mock_release = Mock()
|
@@ -451,7 +451,7 @@ def test_compile_deployment_workflow_function_definition__just_name():
|
|
451
451
|
deployment_config = {"deployment": "my_deployment", "release_tag": "latest"}
|
452
452
|
|
453
453
|
# WHEN compiling the deployment workflow function
|
454
|
-
compiled_function =
|
454
|
+
compiled_function = compile_workflow_deployment_function_definition(deployment_config, mock_client)
|
455
455
|
|
456
456
|
# THEN it should return the compiled function definition (same structure as function test)
|
457
457
|
assert compiled_function == FunctionDefinition(
|
@@ -461,7 +461,7 @@ def test_compile_deployment_workflow_function_definition__just_name():
|
|
461
461
|
)
|
462
462
|
|
463
463
|
|
464
|
-
def
|
464
|
+
def test_compile_workflow_deployment_function_definition__all_args():
|
465
465
|
# GIVEN a mock Vellum client and deployment
|
466
466
|
mock_client = Mock()
|
467
467
|
mock_release = Mock()
|
@@ -497,7 +497,7 @@ def test_compile_deployment_workflow_function_definition__all_args():
|
|
497
497
|
deployment_config = {"deployment": "my_deployment", "release_tag": "latest"}
|
498
498
|
|
499
499
|
# WHEN compiling the deployment workflow function
|
500
|
-
compiled_function =
|
500
|
+
compiled_function = compile_workflow_deployment_function_definition(deployment_config, mock_client)
|
501
501
|
|
502
502
|
# THEN it should return the compiled function definition
|
503
503
|
assert compiled_function == FunctionDefinition(
|
@@ -524,7 +524,7 @@ def test_compile_deployment_workflow_function_definition__all_args():
|
|
524
524
|
)
|
525
525
|
|
526
526
|
|
527
|
-
def
|
527
|
+
def test_compile_workflow_deployment_function_definition__defaults():
|
528
528
|
# GIVEN a mock Vellum client and deployment
|
529
529
|
mock_client = Mock()
|
530
530
|
mock_release = Mock()
|
@@ -565,7 +565,7 @@ def test_compile_deployment_workflow_function_definition__defaults():
|
|
565
565
|
deployment_config = {"deployment": "my_deployment", "release_tag": "latest"}
|
566
566
|
|
567
567
|
# WHEN compiling the deployment workflow function
|
568
|
-
compiled_function =
|
568
|
+
compiled_function = compile_workflow_deployment_function_definition(deployment_config, mock_client)
|
569
569
|
|
570
570
|
# THEN it should return the compiled function definition with proper default handling
|
571
571
|
assert compiled_function == FunctionDefinition(
|