vectorvein 0.1.85__py3-none-any.whl → 0.1.87__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.
@@ -80,3 +80,12 @@ class Node:
80
80
  if isinstance(port, InputPort):
81
81
  return True
82
82
  return False
83
+
84
+ def has_port(self, port_name: str) -> bool:
85
+ return port_name in self.ports
86
+
87
+ def has_input_port(self, port_name: str) -> bool:
88
+ return port_name in self.ports and isinstance(self.ports[port_name], InputPort)
89
+
90
+ def has_output_port(self, port_name: str) -> bool:
91
+ return port_name in self.ports and isinstance(self.ports[port_name], OutputPort)
@@ -43,7 +43,7 @@ class Port:
43
43
  self.port_type = port_type
44
44
  self.required = required
45
45
  self.show = show
46
- self.value = value
46
+ self._value = value
47
47
  self.options = options
48
48
  self.field_type = field_type
49
49
  self.is_output = is_output
@@ -66,7 +66,7 @@ class Port:
66
66
  "field_type": self.port_type.value if isinstance(self.port_type, PortType) else self.port_type,
67
67
  "required": self.required,
68
68
  "show": self.show,
69
- "value": self.value,
69
+ "value": self._value,
70
70
  "options": self.options,
71
71
  "type": self.field_type,
72
72
  "is_output": self.is_output,
@@ -82,6 +82,17 @@ class Port:
82
82
  "list": self.list,
83
83
  }
84
84
 
85
+ @property
86
+ def value(self) -> Any:
87
+ return self._value
88
+
89
+ @value.setter
90
+ def value(self, value: Any) -> None:
91
+ if self.options:
92
+ if value not in map(lambda x: x["value"], self.options):
93
+ raise ValueError(f"Value `{value}` is not in Port `{self.name}` options {self.options}")
94
+ self._value = value
95
+
85
96
 
86
97
  class InputPort(Port):
87
98
  def __init__(
@@ -26,15 +26,39 @@ class Workflow:
26
26
  target_node: Union[str, Node],
27
27
  target_port: str,
28
28
  ):
29
+ # 获取源节点ID
29
30
  if isinstance(source_node, Node):
30
31
  source_node_id = source_node.id
31
32
  else:
32
33
  source_node_id = source_node
34
+
35
+ # 获取目标节点ID
33
36
  if isinstance(target_node, Node):
34
37
  target_node_id = target_node.id
35
38
  else:
36
39
  target_node_id = target_node
37
40
 
41
+ # 检查源节点是否存在
42
+ source_node_exists = any(node.id == source_node_id for node in self.nodes)
43
+ if not source_node_exists:
44
+ raise ValueError(f"源节点不存在: {source_node_id}")
45
+
46
+ # 检查目标节点是否存在
47
+ target_node_exists = any(node.id == target_node_id for node in self.nodes)
48
+ if not target_node_exists:
49
+ raise ValueError(f"目标节点不存在: {target_node_id}")
50
+
51
+ # 检查源节点的端口是否存在
52
+ source_node_obj = next(node for node in self.nodes if node.id == source_node_id)
53
+ if not source_node_obj.has_output_port(source_port):
54
+ raise ValueError(f"源节点 {source_node_id} 不存在输出端口: {source_port}")
55
+
56
+ # 检查目标节点的端口是否存在
57
+ target_node_obj = next(node for node in self.nodes if node.id == target_node_id)
58
+ if not target_node_obj.has_input_port(target_port):
59
+ raise ValueError(f"目标节点 {target_node_id} 不存在输入端口: {target_port}")
60
+
61
+ # 创建并添加边
38
62
  edge_id = f"vueflow__edge-{source_node_id}{source_port}-{target_node_id}{target_port}"
39
63
  edge = Edge(edge_id, source_node_id, source_port, target_node_id, target_port)
40
64
  self.add_edge(edge)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vectorvein
3
- Version: 0.1.85
3
+ Version: 0.1.87
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.1.85.dist-info/METADATA,sha256=liaNevO0Gdtzyor4mS1Wuo5Ma6LmkgexsYSKNNhWf3M,641
2
- vectorvein-0.1.85.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
- vectorvein-0.1.85.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
1
+ vectorvein-0.1.87.dist-info/METADATA,sha256=qaCzwLhxB8o0buhZ-_94iqCMM8tITVVbZQMGt_xi_Lk,641
2
+ vectorvein-0.1.87.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
+ vectorvein-0.1.87.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
4
  vectorvein/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  vectorvein/chat_clients/__init__.py,sha256=omQuG4PRRPNflSAgtdU--rwsWG6vMpwMEyIGZyFVHVQ,18596
6
6
  vectorvein/chat_clients/anthropic_client.py,sha256=PGIKldH4FnGrqozoY_FZ6LqhDHC-jY7NF5J1F1zT2Ok,38257
@@ -34,9 +34,9 @@ vectorvein/types/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
34
  vectorvein/utilities/media_processing.py,sha256=CTRq-lGlFkFgP_FSRhNwF_qUgmOrXPf2_1Ok9HY42_g,5887
35
35
  vectorvein/utilities/retry.py,sha256=6KFS9R2HdhqM3_9jkjD4F36ZSpEx2YNFGOVlpOsUetM,2208
36
36
  vectorvein/workflow/graph/edge.py,sha256=xLZEJmBjAfVB53cd7CuRcKhgE6QqXv9nz32wJn8cmyk,1064
37
- vectorvein/workflow/graph/node.py,sha256=nxDq4pTFcsm2x9MmNmZxghhc-HduSLRwH3Ct2i8bZ3o,2871
38
- vectorvein/workflow/graph/port.py,sha256=kv0YbAPqe9Hh9QPSoiB2PUTTWQT1xIdNeVD50OkWTzA,5684
39
- vectorvein/workflow/graph/workflow.py,sha256=BmS351-WSeHQ02Kh0jOQpxJbNgZ-AHwW0mSQLXcKceU,2805
37
+ vectorvein/workflow/graph/node.py,sha256=A3M_GghrSju1D3xc_HtPdGyr-7XSkplGPKJveOUiIF4,3256
38
+ vectorvein/workflow/graph/port.py,sha256=Q6HmI2cUi6viJ98ec6-MmMPMRtKS1-OgaudP3LMwVLA,6054
39
+ vectorvein/workflow/graph/workflow.py,sha256=uh8JzTbvaucKryvFUj3nAswtdOtaOw2Z4YfD9Q6r77s,3973
40
40
  vectorvein/workflow/nodes/__init__.py,sha256=jd4O27kIJdOtkij1FYZ6aJnJy2OQa7xtL1r-Yv8ylO0,3103
41
41
  vectorvein/workflow/nodes/audio_generation.py,sha256=ht2S0vnd0mIAt6FBaSWlADGbb7f_1DAySYrgYnvZT1Q,5726
42
42
  vectorvein/workflow/nodes/control_flows.py,sha256=Zc_uWuroYznLrU-BZCncyzvejC-zFl6EuN_VP8oq5mY,6573
@@ -54,4 +54,4 @@ vectorvein/workflow/nodes/vector_db.py,sha256=t6I17q6iR3yQreiDHpRrksMdWDPIvgqJs0
54
54
  vectorvein/workflow/nodes/video_generation.py,sha256=qmdg-t_idpxq1veukd-jv_ChICMOoInKxprV9Z4Vi2w,4118
55
55
  vectorvein/workflow/nodes/web_crawlers.py,sha256=LsqomfXfqrXfHJDO1cl0Ox48f4St7X_SL12DSbAMSOw,5415
56
56
  vectorvein/workflow/utils/json_to_code.py,sha256=F7dhDy8kGc8ndOeihGLRLGFGlquoxVlb02ENtxnQ0C8,5914
57
- vectorvein-0.1.85.dist-info/RECORD,,
57
+ vectorvein-0.1.87.dist-info/RECORD,,