vectorvein 0.2.33__py3-none-any.whl → 0.2.35__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.
@@ -4,6 +4,32 @@ from typing import Dict, Any, Optional, List, Union
4
4
  from .port import PortType, Port, InputPort, OutputPort
5
5
 
6
6
 
7
+ class PortsDict(Dict[str, Port]):
8
+ """自定义字典类,用于管理节点的端口,并强制执行端口添加权限。"""
9
+
10
+ def __init__(self, owner_node: "Node", *args, **kwargs):
11
+ super().__init__(*args, **kwargs)
12
+ self._owner_node = owner_node
13
+
14
+ def __setitem__(self, key: str, value: Port) -> None:
15
+ # 如果端口已存在,允许更新
16
+ if key in self:
17
+ super().__setitem__(key, value)
18
+ return
19
+
20
+ # 对于新端口,检查添加权限
21
+ if isinstance(value, OutputPort) and not self._owner_node.can_add_output_ports:
22
+ raise ValueError(
23
+ f"Node<{self._owner_node.id}> '{self._owner_node.type}' does not allow adding output ports"
24
+ )
25
+ elif isinstance(value, InputPort) and not self._owner_node.can_add_input_ports:
26
+ raise ValueError(
27
+ f"Node<{self._owner_node.id}> '{self._owner_node.type}' does not allow adding input ports"
28
+ )
29
+
30
+ super().__setitem__(key, value)
31
+
32
+
7
33
  class Node:
8
34
  def __init__(
9
35
  self,
@@ -25,7 +51,14 @@ class Node:
25
51
  self.category: str = category
26
52
  self.task_name: str = task_name
27
53
  self.description: str = description
28
- self.ports: Dict[str, Port] = ports or {}
54
+ self.can_add_input_ports: bool = can_add_input_ports
55
+ self.can_add_output_ports: bool = can_add_output_ports
56
+ # 初始化自定义PortsDict
57
+ self.ports = PortsDict(self)
58
+ # 如果提供了初始端口,将它们添加到字典中
59
+ if ports:
60
+ for name, port in ports.items():
61
+ self.ports[name] = port
29
62
  self.position: Dict[str, float] = position or {"x": 0, "y": 0}
30
63
  self.seleted_workflow_title: str = seleted_workflow_title
31
64
  self.is_template: bool = is_template
@@ -33,8 +66,6 @@ class Node:
33
66
  self.ignored: bool = False
34
67
  self.lock: bool = False
35
68
  self.shadow: bool = False
36
- self.can_add_input_ports: bool = can_add_input_ports
37
- self.can_add_output_ports: bool = can_add_output_ports
38
69
 
39
70
  def add_port(
40
71
  self,
@@ -97,7 +97,7 @@ class TextSplitters(Node):
97
97
  value="\\n",
98
98
  condition="return fieldsData.split_method.value == 'delimiter'",
99
99
  ),
100
- "output": OutputPort(),
100
+ "output": OutputPort(list=True),
101
101
  },
102
102
  )
103
103
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vectorvein
3
- Version: 0.2.33
3
+ Version: 0.2.35
4
4
  Summary: VectorVein Python SDK
5
5
  Author-Email: Anderson <andersonby@163.com>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
- vectorvein-0.2.33.dist-info/METADATA,sha256=NdnNIjJN4LboNo5a8s8eQNtBOEhC7q83EMvKL1_3kkk,4570
2
- vectorvein-0.2.33.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
- vectorvein-0.2.33.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
1
+ vectorvein-0.2.35.dist-info/METADATA,sha256=cIifHIbhWkmoBq64isEQVHa0BoZKKCp1aXuR3IAyKCw,4570
2
+ vectorvein-0.2.35.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
+ vectorvein-0.2.35.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
4
  vectorvein/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  vectorvein/api/__init__.py,sha256=lfY-XA46fgD2iIZTU0VYP8i07AwA03Egj4Qua0vUKrQ,738
6
6
  vectorvein/api/client.py,sha256=xF-leKDQzVyyy9FnIRaz0k4eElYW1XbbzeRLcpnyk90,33047
@@ -42,7 +42,7 @@ vectorvein/utilities/media_processing.py,sha256=7KtbLFzOYIn1e9QTN9G6C76NH8CBlV9k
42
42
  vectorvein/utilities/rate_limiter.py,sha256=dwolIUVw2wP83Odqpx0AAaE77de1GzxkYDGH4tM_u_4,10300
43
43
  vectorvein/utilities/retry.py,sha256=6KFS9R2HdhqM3_9jkjD4F36ZSpEx2YNFGOVlpOsUetM,2208
44
44
  vectorvein/workflow/graph/edge.py,sha256=1ckyyjCue_PLm7P1ItUfKOy6AKkemOpZ9m1WJ8UXIHQ,1072
45
- vectorvein/workflow/graph/node.py,sha256=3txou3HlxniY9aSPoS4JsRRiEbseJ3LJnAcYaMWXGVI,3769
45
+ vectorvein/workflow/graph/node.py,sha256=9eBS4hOjpiIOdO9ZmG6ctbRtsZeDO29SJqsu_3ELFFc,5033
46
46
  vectorvein/workflow/graph/port.py,sha256=Q6HmI2cUi6viJ98ec6-MmMPMRtKS1-OgaudP3LMwVLA,6054
47
47
  vectorvein/workflow/graph/workflow.py,sha256=l0rSDZeSd6OtHMwxzhIENfOKS0fJKKB4JUow-dV-LUI,8610
48
48
  vectorvein/workflow/nodes/__init__.py,sha256=a1fsitA0mf1UlDOSEz6QjSGjiFsvsQcuDE-p2q9SlhM,3181
@@ -55,11 +55,11 @@ vectorvein/workflow/nodes/media_editing.py,sha256=qJImXwBJt59Ud0tzsRVKItPvrVZws3
55
55
  vectorvein/workflow/nodes/media_processing.py,sha256=jkSP287gyhvF7hqY8Nohdc1Rdn-br3zAj9sklPs6PAs,19778
56
56
  vectorvein/workflow/nodes/output.py,sha256=_UQxiddHtGv2rkjhUFE-KDgrjnh0AGJQJyq9-4Aji5A,12567
57
57
  vectorvein/workflow/nodes/relational_db.py,sha256=zfzUhV25TpZGhkIzO18PmAT5xhcsJC4AXKy0zyA05w8,5408
58
- vectorvein/workflow/nodes/text_processing.py,sha256=uhVmPDpbtlsqdg2ZlsM2Vi9L32Or_HWFR7wRFrX0q9c,8333
58
+ vectorvein/workflow/nodes/text_processing.py,sha256=MRo_-oaC65hbzMxm7TYoeiS3rgvqh9y_Rny5RCfoATE,8342
59
59
  vectorvein/workflow/nodes/tools.py,sha256=uMlqJQI9oel3pG4WYrZdpSmWWy2pDQkAIzqOv5z3tB4,13811
60
60
  vectorvein/workflow/nodes/triggers.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
61
61
  vectorvein/workflow/nodes/vector_db.py,sha256=t6I17q6iR3yQreiDHpRrksMdWDPIvgqJs076z-7dlQQ,5712
62
62
  vectorvein/workflow/nodes/video_generation.py,sha256=qmdg-t_idpxq1veukd-jv_ChICMOoInKxprV9Z4Vi2w,4118
63
63
  vectorvein/workflow/nodes/web_crawlers.py,sha256=BhJBX1AZH7-22Gu95Ox4qJqmH5DU-m4dbUb5N5DTA-M,5559
64
64
  vectorvein/workflow/utils/json_to_code.py,sha256=F7dhDy8kGc8ndOeihGLRLGFGlquoxVlb02ENtxnQ0C8,5914
65
- vectorvein-0.2.33.dist-info/RECORD,,
65
+ vectorvein-0.2.35.dist-info/RECORD,,