vellum-ai 0.14.43__py3-none-any.whl → 0.14.44__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.
@@ -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.14.43",
21
+ "X-Fern-SDK-Version": "0.14.44",
22
22
  }
23
23
  headers["X-API-KEY"] = self.api_key
24
24
  return headers
@@ -2,7 +2,7 @@ from typing import Any, Dict, Iterator, Optional, Set, Tuple, Type
2
2
 
3
3
  from vellum.workflows.outputs.base import BaseOutput, BaseOutputs
4
4
  from vellum.workflows.ports.port import Port
5
- from vellum.workflows.ports.utils import validate_ports
5
+ from vellum.workflows.ports.utils import get_port_groups, validate_ports
6
6
  from vellum.workflows.state.base import BaseState
7
7
  from vellum.workflows.types.core import ConditionType
8
8
 
@@ -54,7 +54,8 @@ class NodePorts(metaclass=_NodePortsMeta):
54
54
  resolved_condition = port.resolve_condition(state)
55
55
  if resolved_condition:
56
56
  invoked_ports.add(port)
57
- break
57
+ if len(get_port_groups(all_ports)) <= 1:
58
+ break
58
59
 
59
60
  elif port._condition_type == ConditionType.ELSE and not invoked_ports:
60
61
  invoked_ports.add(port)
@@ -11,30 +11,63 @@ PORT_TYPE_PRIORITIES = {
11
11
  }
12
12
 
13
13
 
14
- def validate_ports(ports: List[Port]) -> bool:
14
+ def get_port_groups(ports: List[Port]) -> List[List[ConditionType]]:
15
15
  # We don't want to validate ports with no condition (default ports)
16
16
  port_types = [port._condition_type for port in ports if port._condition_type is not None]
17
- sorted_port_types = sorted(port_types, key=lambda port_type: PORT_TYPE_PRIORITIES[port_type])
18
17
 
19
- if sorted_port_types != port_types:
20
- raise ValueError("Port conditions must be in the following order: on_if, on_elif, on_else")
18
+ ports_class = f"{ports[0].node_class}.Ports"
19
+
20
+ # Check all ports by port groups
21
+ port_groups: List[List[ConditionType]] = []
22
+ current_port_group: List[ConditionType] = []
23
+
24
+ for port_type in port_types:
25
+ # Start a new group only if we see an IF
26
+ if port_type == ConditionType.IF:
27
+ # Only append the current group if it's not empty and starts with an IF
28
+ if current_port_group and current_port_group[0] == ConditionType.IF:
29
+ port_groups.append(current_port_group)
30
+ current_port_group = [port_type]
31
+ else:
32
+ # If we see an ELIF or ELSE without a preceding IF, that's an error
33
+ if not current_port_group:
34
+ raise ValueError(f"Class {ports_class} must have ports in the following order: on_if, on_elif, on_else")
35
+ current_port_group.append(port_type)
36
+
37
+ if current_port_group and current_port_group[0] == ConditionType.IF:
38
+ port_groups.append(current_port_group)
39
+ elif current_port_group:
40
+ # If the last group doesn't start with IF, that's an error
41
+ raise ValueError(f"Class {ports_class} must have ports in the following order: on_if, on_elif, on_else")
21
42
 
22
- counter = Counter(port_types)
23
- number_of_if_ports = counter[ConditionType.IF]
24
- number_of_elif_ports = counter[ConditionType.ELIF]
25
- number_of_else_ports = counter[ConditionType.ELSE]
43
+ return port_groups
44
+
45
+
46
+ def validate_ports(ports: List[Port]) -> bool:
26
47
  ports_class = f"{ports[0].node_class}.Ports"
48
+ port_groups = get_port_groups(ports)
49
+ # Validate each port group
50
+ for group in port_groups:
51
+ # Check that each port group is in the correct order
52
+ sorted_group = sorted(group, key=lambda port_type: PORT_TYPE_PRIORITIES[port_type])
53
+ if sorted_group != group:
54
+ raise ValueError(f"Class {ports_class} must have ports in the following order: on_if, on_elif, on_else")
55
+
56
+ # Count the types in this port group
57
+ counter = Counter(group)
58
+ number_of_if_ports = counter[ConditionType.IF]
59
+ number_of_elif_ports = counter[ConditionType.ELIF]
60
+ number_of_else_ports = counter[ConditionType.ELSE]
27
61
 
28
- if number_of_if_ports == 0 and (number_of_elif_ports > 0 or number_of_else_ports > 0):
29
- raise ValueError(
30
- f"Class {ports_class} containing on_elif or on_else port conditions must have at least one on_if condition"
31
- )
62
+ # Apply the rules to each port group
63
+ if number_of_if_ports != 1:
64
+ raise ValueError(f"Class {ports_class} must have exactly one on_if condition")
32
65
 
33
- if number_of_elif_ports > 0 and number_of_if_ports != 1:
34
- raise ValueError(f"Class {ports_class} containing on_elif ports must have exactly one on_if condition")
66
+ if number_of_elif_ports > 0 and number_of_if_ports != 1:
67
+ raise ValueError(f"Class {ports_class} containing on_elif ports must have exactly one on_if condition")
35
68
 
36
- if number_of_else_ports > 1:
37
- raise ValueError(f"Class {ports_class} must have at most one on_else port condition")
69
+ if number_of_else_ports > 1:
70
+ raise ValueError(f"Class {ports_class} must have at most one on_else condition")
38
71
 
39
- enforce_single_invoked_conditional_port = number_of_elif_ports > 0 or number_of_if_ports <= 1
72
+ enforce_single_invoked_conditional_port = len(port_groups) <= 1
40
73
  return enforce_single_invoked_conditional_port
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vellum-ai
3
- Version: 0.14.43
3
+ Version: 0.14.44
4
4
  Summary:
5
5
  License: MIT
6
6
  Requires-Python: >=3.9,<4.0
@@ -130,7 +130,7 @@ vellum/client/README.md,sha256=JkCJjmMZl4jrPj46pkmL9dpK4gSzQQmP5I7z4aME4LY,4749
130
130
  vellum/client/__init__.py,sha256=Z-JHK2jGxhtTtmkLeOaUGGJWIUNYGNVBLvUewC6lp6w,118148
131
131
  vellum/client/core/__init__.py,sha256=SQ85PF84B9MuKnBwHNHWemSGuy-g_515gFYNFhvEE0I,1438
132
132
  vellum/client/core/api_error.py,sha256=RE8LELok2QCjABadECTvtDp7qejA1VmINCh6TbqPwSE,426
133
- vellum/client/core/client_wrapper.py,sha256=gOQ_e1s2iQI79ioggNAaNo71Ue9CGaAkWTvlVyZxaMI,1869
133
+ vellum/client/core/client_wrapper.py,sha256=cnTC1fgCzqUC_BZ21rLn2Wi6ACUHsyWmxx9o2etyN28,1869
134
134
  vellum/client/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
135
135
  vellum/client/core/file.py,sha256=X9IbmkZmB2bB_DpmZAO3crWdXagOakAyn6UCOCImCPg,2322
136
136
  vellum/client/core/http_client.py,sha256=R0pQpCppnEtxccGvXl4uJ76s7ro_65Fo_erlNNLp_AI,19228
@@ -1642,9 +1642,9 @@ vellum/workflows/nodes/utils.py,sha256=ziHJc5uU4foxIvacl0Vg7fEJJ0jiznqqhyvURVj0F
1642
1642
  vellum/workflows/outputs/__init__.py,sha256=AyZ4pRh_ACQIGvkf0byJO46EDnSix1ZCAXfvh-ms1QE,94
1643
1643
  vellum/workflows/outputs/base.py,sha256=1OGHqBJVk7i8cW8uewFWOhIjuMlRRpzCDrGE30ZwDjw,8763
1644
1644
  vellum/workflows/ports/__init__.py,sha256=bZuMt-R7z5bKwpu4uPW7LlJeePOQWmCcDSXe5frUY5g,101
1645
- vellum/workflows/ports/node_ports.py,sha256=g4A-8iUAvEJSkaWppbvzAR8XU02R9U-qLN4rP2Kq4Aw,2743
1645
+ vellum/workflows/ports/node_ports.py,sha256=2Uo9gwNVCuH86J-GXcpc95QSDh5I-XVvhHJCMSWe-S8,2825
1646
1646
  vellum/workflows/ports/port.py,sha256=eI2SOZPZ5rsC3jMsxW6Rbn0NpaYQsrR7AapiIbbiy8Q,3635
1647
- vellum/workflows/ports/utils.py,sha256=pEjVNJKw9LhD_cFN-o0MWBOW2ejno7jv26qqzjLxwS4,1662
1647
+ vellum/workflows/ports/utils.py,sha256=cWJ9xX1KrHBTiU3xe6t7Rs0yaOy9RV18GMtHaAshAsc,3094
1648
1648
  vellum/workflows/references/__init__.py,sha256=glHFC1VfXmcbNvH5VzFbkT03d8_D7MMcvEcsUBrzLIs,591
1649
1649
  vellum/workflows/references/constant.py,sha256=6yUT4q1sMj1hkI_tzzQ9AYcmeeDYFUNCqUq_W2DN0S8,540
1650
1650
  vellum/workflows/references/environment_variable.py,sha256=-gfOcdYwVp9ztSUYz6h2WI2Cg95zqxq5hhFf3Yr7aQg,791
@@ -1698,8 +1698,8 @@ vellum/workflows/workflows/event_filters.py,sha256=GSxIgwrX26a1Smfd-6yss2abGCnad
1698
1698
  vellum/workflows/workflows/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1699
1699
  vellum/workflows/workflows/tests/test_base_workflow.py,sha256=8P5YIsNMO78_CR1NNK6wkEdkMB4b3Q_Ni1qxh78OnHo,20481
1700
1700
  vellum/workflows/workflows/tests/test_context.py,sha256=VJBUcyWVtMa_lE5KxdhgMu0WYNYnUQUDvTF7qm89hJ0,2333
1701
- vellum_ai-0.14.43.dist-info/LICENSE,sha256=hOypcdt481qGNISA784bnAGWAE6tyIf9gc2E78mYC3E,1574
1702
- vellum_ai-0.14.43.dist-info/METADATA,sha256=_cI_OM2v1FvIfRXuOWWaVpZdA0DFUSezO_ENVULlBbI,5484
1703
- vellum_ai-0.14.43.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
1704
- vellum_ai-0.14.43.dist-info/entry_points.txt,sha256=HCH4yc_V3J_nDv3qJzZ_nYS8llCHZViCDP1ejgCc5Ak,42
1705
- vellum_ai-0.14.43.dist-info/RECORD,,
1701
+ vellum_ai-0.14.44.dist-info/LICENSE,sha256=hOypcdt481qGNISA784bnAGWAE6tyIf9gc2E78mYC3E,1574
1702
+ vellum_ai-0.14.44.dist-info/METADATA,sha256=m4i-IppU7qrX6bueYqy1ma0QUBht58aQCd-FP7Lekxc,5484
1703
+ vellum_ai-0.14.44.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
1704
+ vellum_ai-0.14.44.dist-info/entry_points.txt,sha256=HCH4yc_V3J_nDv3qJzZ_nYS8llCHZViCDP1ejgCc5Ak,42
1705
+ vellum_ai-0.14.44.dist-info/RECORD,,