vellum-ai 0.12.3__py3-none-any.whl → 0.12.5__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/client/resources/workflows/client.py +32 -0
  3. vellum/client/types/chat_message_prompt_block.py +1 -1
  4. vellum/client/types/function_definition.py +26 -7
  5. vellum/client/types/jinja_prompt_block.py +1 -1
  6. vellum/client/types/plain_text_prompt_block.py +1 -1
  7. vellum/client/types/rich_text_prompt_block.py +1 -1
  8. vellum/client/types/variable_prompt_block.py +1 -1
  9. vellum/plugins/vellum_mypy.py +20 -23
  10. vellum/workflows/nodes/displayable/bases/inline_prompt_node/node.py +21 -8
  11. vellum/workflows/nodes/displayable/inline_prompt_node/tests/__init__.py +0 -0
  12. vellum/workflows/nodes/displayable/inline_prompt_node/tests/test_node.py +64 -0
  13. vellum/workflows/sandbox.py +51 -0
  14. vellum/workflows/tests/__init__.py +0 -0
  15. vellum/workflows/tests/test_sandbox.py +62 -0
  16. vellum/workflows/types/core.py +2 -52
  17. vellum/workflows/utils/functions.py +41 -4
  18. vellum/workflows/utils/tests/test_functions.py +93 -0
  19. {vellum_ai-0.12.3.dist-info → vellum_ai-0.12.5.dist-info}/METADATA +1 -1
  20. {vellum_ai-0.12.3.dist-info → vellum_ai-0.12.5.dist-info}/RECORD +33 -28
  21. vellum_cli/__init__.py +14 -0
  22. vellum_cli/pull.py +16 -2
  23. vellum_cli/tests/test_pull.py +45 -0
  24. vellum_ee/workflows/display/nodes/base_node_vellum_display.py +2 -2
  25. vellum_ee/workflows/display/nodes/vellum/code_execution_node.py +1 -3
  26. vellum_ee/workflows/display/nodes/vellum/conditional_node.py +18 -18
  27. vellum_ee/workflows/display/nodes/vellum/search_node.py +19 -15
  28. vellum_ee/workflows/display/nodes/vellum/templating_node.py +1 -1
  29. vellum_ee/workflows/display/nodes/vellum/utils.py +4 -4
  30. vellum_ee/workflows/display/utils/vellum.py +1 -2
  31. {vellum_ai-0.12.3.dist-info → vellum_ai-0.12.5.dist-info}/LICENSE +0 -0
  32. {vellum_ai-0.12.3.dist-info → vellum_ai-0.12.5.dist-info}/WHEEL +0 -0
  33. {vellum_ai-0.12.3.dist-info → vellum_ai-0.12.5.dist-info}/entry_points.txt +0 -0
@@ -28,7 +28,9 @@ class VariableIdMap:
28
28
 
29
29
 
30
30
  class BaseSearchNodeDisplay(BaseNodeVellumDisplay[_SearchNodeType], Generic[_SearchNodeType]):
31
- input_variable_ids_by_logical_id: Optional[Dict[str, str]] = None
31
+ # A mapping between the id of the operand (e.g. "lhs_variable_id" or "rhs_variable_id") and the id of the node input
32
+ # that the operand is pointing to.
33
+ metadata_filter_input_id_by_operand_id: Dict[UUID, UUID] = {}
32
34
 
33
35
  def serialize(
34
36
  self, display_context: WorkflowDisplayContext, error_output_id: Optional[UUID] = None, **kwargs
@@ -149,18 +151,20 @@ class BaseSearchNodeDisplay(BaseNodeVellumDisplay[_SearchNodeType], Generic[_Sea
149
151
  variables,
150
152
  )
151
153
  elif isinstance(logical_expression, VellumValueLogicalConditionRequest):
152
- lhs_variable_id = str(logical_expression.lhs_variable.value)
153
- rhs_variable_id = str(logical_expression.rhs_variable.value)
154
- lhs_query_input_id = (
155
- self.input_variable_ids_by_logical_id[lhs_variable_id]
156
- if self.input_variable_ids_by_logical_id
157
- else str(uuid4_from_hash(f"{self.node_id}|{hash(tuple(path))}"))
158
- )
159
- rhs_query_input_id = (
160
- self.input_variable_ids_by_logical_id[rhs_variable_id]
161
- if self.input_variable_ids_by_logical_id
162
- else str(uuid4_from_hash(f"{self.node_id}|{hash(tuple(path))}"))
163
- )
154
+ lhs_variable_id = logical_expression.lhs_variable.value
155
+ if not isinstance(lhs_variable_id, str):
156
+ raise TypeError(f"Expected lhs_variable_id to be a string, got {type(lhs_variable_id)}")
157
+
158
+ rhs_variable_id = logical_expression.rhs_variable.value
159
+ if not isinstance(rhs_variable_id, str):
160
+ raise TypeError(f"Expected rhs_variable_id to be a string, got {type(rhs_variable_id)}")
161
+
162
+ lhs_query_input_id: UUID = self.metadata_filter_input_id_by_operand_id.get(
163
+ UUID(lhs_variable_id)
164
+ ) or uuid4_from_hash(f"{self.node_id}|{hash(tuple(path))}")
165
+ rhs_query_input_id: UUID = self.metadata_filter_input_id_by_operand_id.get(
166
+ UUID(rhs_variable_id)
167
+ ) or uuid4_from_hash(f"{self.node_id}|{hash(tuple(path))}")
164
168
 
165
169
  return (
166
170
  {
@@ -173,7 +177,7 @@ class BaseSearchNodeDisplay(BaseNodeVellumDisplay[_SearchNodeType], Generic[_Sea
173
177
  create_node_input(
174
178
  self.node_id,
175
179
  f"vellum-query-builder-variable-{lhs_variable_id}",
176
- lhs_query_input_id,
180
+ str(lhs_query_input_id),
177
181
  display_context,
178
182
  input_id=UUID(lhs_variable_id),
179
183
  pointer_type=InputVariablePointer,
@@ -181,7 +185,7 @@ class BaseSearchNodeDisplay(BaseNodeVellumDisplay[_SearchNodeType], Generic[_Sea
181
185
  create_node_input(
182
186
  self.node_id,
183
187
  f"vellum-query-builder-variable-{rhs_variable_id}",
184
- rhs_query_input_id,
188
+ str(rhs_query_input_id),
185
189
  display_context,
186
190
  input_id=UUID(rhs_variable_id),
187
191
  pointer_type=InputVariablePointer,
@@ -25,7 +25,7 @@ class BaseTemplatingNodeDisplay(BaseNodeVellumDisplay[_TemplatingNodeType], Gene
25
25
 
26
26
  template_input_id = self.template_input_id or next(
27
27
  (
28
- input_id
28
+ UUID(input_id) if isinstance(input_id, str) else input_id
29
29
  for input_name, input_id in self.node_input_ids_by_name.items()
30
30
  if input_name == TEMPLATE_INPUT_NAME
31
31
  ),
@@ -1,5 +1,5 @@
1
1
  from uuid import UUID
2
- from typing import Any, List, Optional, Type, cast
2
+ from typing import Any, List, Optional, Type, Union, cast
3
3
 
4
4
  from vellum.workflows.descriptors.base import BaseDescriptor
5
5
  from vellum.workflows.expressions.coalesce_expression import CoalesceExpression
@@ -27,10 +27,10 @@ def create_node_input(
27
27
  input_name: str,
28
28
  value: Any,
29
29
  display_context: WorkflowDisplayContext,
30
- input_id: Optional[UUID],
30
+ input_id: Union[Optional[UUID], Optional[str]],
31
31
  pointer_type: Optional[Type[NodeInputValuePointerRule]] = ConstantValuePointer,
32
32
  ) -> NodeInput:
33
- input_id = input_id or uuid4_from_hash(f"{node_id}|{input_name}")
33
+ input_id = str(input_id) if input_id else str(uuid4_from_hash(f"{node_id}|{input_name}"))
34
34
  if (
35
35
  isinstance(value, OutputReference)
36
36
  and value.outputs_class._node_class
@@ -42,7 +42,7 @@ def create_node_input(
42
42
 
43
43
  rules = create_node_input_value_pointer_rules(value, display_context, pointer_type=pointer_type)
44
44
  return NodeInput(
45
- id=str(input_id),
45
+ id=input_id,
46
46
  key=input_name,
47
47
  value=NodeInputValuePointer(
48
48
  rules=rules,
@@ -9,7 +9,6 @@ from vellum.workflows.references import OutputReference, WorkflowInputReference
9
9
  from vellum.workflows.references.execution_count import ExecutionCountReference
10
10
  from vellum.workflows.references.node import NodeReference
11
11
  from vellum.workflows.references.vellum_secret import VellumSecretReference
12
- from vellum.workflows.types.core import VellumValuePrimitive
13
12
  from vellum.workflows.utils.vellum_variables import primitive_type_to_vellum_variable_type
14
13
  from vellum.workflows.vellum_client import create_vellum_client
15
14
  from vellum_ee.workflows.display.types import WorkflowDisplayContext
@@ -93,7 +92,7 @@ def create_node_input_value_pointer_rule(
93
92
  raise ValueError(f"Unsupported descriptor type: {value.__class__.__name__}")
94
93
 
95
94
 
96
- def primitive_to_vellum_value(value: VellumValuePrimitive) -> VellumValue:
95
+ def primitive_to_vellum_value(value: Any) -> VellumValue:
97
96
  """Converts a python primitive to a VellumVariableValue"""
98
97
 
99
98
  if isinstance(value, str):