vectorvein 0.2.24__py3-none-any.whl → 0.2.25__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.
- vectorvein/workflow/graph/workflow.py +107 -1
- vectorvein/workflow/nodes/llms.py +97 -8
- {vectorvein-0.2.24.dist-info → vectorvein-0.2.25.dist-info}/METADATA +1 -1
- {vectorvein-0.2.24.dist-info → vectorvein-0.2.25.dist-info}/RECORD +6 -6
- {vectorvein-0.2.24.dist-info → vectorvein-0.2.25.dist-info}/WHEEL +0 -0
- {vectorvein-0.2.24.dist-info → vectorvein-0.2.25.dist-info}/entry_points.txt +0 -0
@@ -1,10 +1,17 @@
|
|
1
1
|
import json
|
2
|
-
from typing import List, Union
|
2
|
+
from typing import List, Union, TypedDict
|
3
3
|
|
4
4
|
from .node import Node
|
5
5
|
from .edge import Edge
|
6
6
|
|
7
7
|
|
8
|
+
class WorkflowCheckResult(TypedDict):
|
9
|
+
"""工作流检查结果类型。"""
|
10
|
+
|
11
|
+
no_cycle: bool # 工作流是否不包含环
|
12
|
+
no_isolated_nodes: bool # 工作流是否不包含孤立节点
|
13
|
+
|
14
|
+
|
8
15
|
class Workflow:
|
9
16
|
def __init__(self) -> None:
|
10
17
|
self.nodes: List[Node] = []
|
@@ -109,3 +116,102 @@ class Workflow:
|
|
109
116
|
lines.append(f" {source_label} -->|{label}| {target_label}")
|
110
117
|
|
111
118
|
return "\n".join(lines)
|
119
|
+
|
120
|
+
def _check_dag(self) -> WorkflowCheckResult:
|
121
|
+
"""检查流程图是否为有向无环图,并检测是否存在孤立节点。
|
122
|
+
|
123
|
+
Returns:
|
124
|
+
WorkflowCheckResult: 包含检查结果的字典
|
125
|
+
- no_cycle (bool): 如果流程图是有向无环图返回 True,否则返回 False
|
126
|
+
- no_isolated_nodes (bool): 如果不存在孤立节点返回 True,否则返回 False
|
127
|
+
"""
|
128
|
+
result: WorkflowCheckResult = {"no_cycle": True, "no_isolated_nodes": True}
|
129
|
+
|
130
|
+
# 过滤掉触发器节点和辅助节点
|
131
|
+
trigger_nodes = [
|
132
|
+
node.id
|
133
|
+
for node in self.nodes
|
134
|
+
if hasattr(node, "category") and (node.category == "triggers" or node.category == "assistedNodes")
|
135
|
+
]
|
136
|
+
|
137
|
+
# 获取需要检查的节点和边
|
138
|
+
regular_nodes = [node.id for node in self.nodes if node.id not in trigger_nodes]
|
139
|
+
regular_edges = [
|
140
|
+
edge for edge in self.edges if edge.source not in trigger_nodes and edge.target not in trigger_nodes
|
141
|
+
]
|
142
|
+
|
143
|
+
# ---------- 检查有向图是否有环 ----------
|
144
|
+
# 构建邻接表
|
145
|
+
adjacency = {node_id: [] for node_id in regular_nodes}
|
146
|
+
for edge in regular_edges:
|
147
|
+
if edge.source in adjacency: # 确保节点在字典中
|
148
|
+
adjacency[edge.source].append(edge.target)
|
149
|
+
|
150
|
+
# 三种状态: 0 = 未访问, 1 = 正在访问, 2 = 已访问完成
|
151
|
+
visited = {node_id: 0 for node_id in regular_nodes}
|
152
|
+
|
153
|
+
def dfs_cycle_detection(node_id):
|
154
|
+
# 如果节点正在被访问,说明找到了环
|
155
|
+
if visited[node_id] == 1:
|
156
|
+
return False
|
157
|
+
|
158
|
+
# 如果节点已经访问完成,无需再次访问
|
159
|
+
if visited[node_id] == 2:
|
160
|
+
return True
|
161
|
+
|
162
|
+
# 标记为正在访问
|
163
|
+
visited[node_id] = 1
|
164
|
+
|
165
|
+
# 访问所有邻居
|
166
|
+
for neighbor in adjacency[node_id]:
|
167
|
+
if neighbor in visited and not dfs_cycle_detection(neighbor):
|
168
|
+
return False
|
169
|
+
|
170
|
+
# 标记为已访问完成
|
171
|
+
visited[node_id] = 2
|
172
|
+
return True
|
173
|
+
|
174
|
+
# 对每个未访问的节点进行 DFS 检测环
|
175
|
+
for node_id in regular_nodes:
|
176
|
+
if visited[node_id] == 0:
|
177
|
+
if not dfs_cycle_detection(node_id):
|
178
|
+
result["no_cycle"] = False
|
179
|
+
break
|
180
|
+
|
181
|
+
# ---------- 检查是否存在孤立节点 ----------
|
182
|
+
# 构建无向图邻接表
|
183
|
+
undirected_adjacency = {node_id: [] for node_id in regular_nodes}
|
184
|
+
for edge in regular_edges:
|
185
|
+
if edge.source in undirected_adjacency and edge.target in undirected_adjacency:
|
186
|
+
undirected_adjacency[edge.source].append(edge.target)
|
187
|
+
undirected_adjacency[edge.target].append(edge.source)
|
188
|
+
|
189
|
+
# 深度优先搜索来检测连通分量
|
190
|
+
undirected_visited = set()
|
191
|
+
|
192
|
+
def dfs_connected_components(node_id):
|
193
|
+
undirected_visited.add(node_id)
|
194
|
+
for neighbor in undirected_adjacency[node_id]:
|
195
|
+
if neighbor not in undirected_visited:
|
196
|
+
dfs_connected_components(neighbor)
|
197
|
+
|
198
|
+
# 计算连通分量数量
|
199
|
+
connected_components_count = 0
|
200
|
+
for node_id in regular_nodes:
|
201
|
+
if node_id not in undirected_visited:
|
202
|
+
connected_components_count += 1
|
203
|
+
dfs_connected_components(node_id)
|
204
|
+
|
205
|
+
# 如果连通分量数量大于1,说明存在孤立节点
|
206
|
+
if connected_components_count > 1 and len(regular_nodes) > 0:
|
207
|
+
result["no_isolated_nodes"] = False
|
208
|
+
|
209
|
+
return result
|
210
|
+
|
211
|
+
def check(self) -> WorkflowCheckResult:
|
212
|
+
"""检查流程图的有效性。
|
213
|
+
|
214
|
+
Returns:
|
215
|
+
WorkflowCheckResult: 包含各种检查结果的字典
|
216
|
+
"""
|
217
|
+
return self._check_dag()
|
@@ -292,6 +292,8 @@ class Claude(Node):
|
|
292
292
|
port_type=PortType.SELECT,
|
293
293
|
value="claude-3-5-haiku",
|
294
294
|
options=[
|
295
|
+
{"value": "claude-3-7-sonnet-thinking", "label": "claude-3-7-sonnet-thinking"},
|
296
|
+
{"value": "claude-3-7-sonnet", "label": "claude-3-7-sonnet"},
|
295
297
|
{"value": "claude-3-5-sonnet", "label": "claude-3-5-sonnet"},
|
296
298
|
{"value": "claude-3-5-haiku", "label": "claude-3-5-haiku"},
|
297
299
|
{"value": "claude-3-opus", "label": "claude-3-opus"},
|
@@ -338,8 +340,8 @@ class Deepseek(Node):
|
|
338
340
|
value="deepseek-chat",
|
339
341
|
options=[
|
340
342
|
{"value": "deepseek-chat", "label": "deepseek-chat"},
|
341
|
-
{"value": "deepseek-reasoner", "label": "deepseek-
|
342
|
-
{"value": "deepseek-
|
343
|
+
{"value": "deepseek-reasoner", "label": "deepseek-r1"},
|
344
|
+
{"value": "deepseek-r1-distill-qwen-32b", "label": "deepseek-r1-distill-qwen-32b"},
|
343
345
|
],
|
344
346
|
),
|
345
347
|
"temperature": InputPort(
|
@@ -523,12 +525,10 @@ class LingYiWanWu(Node):
|
|
523
525
|
port_type=PortType.SELECT,
|
524
526
|
value="yi-lightning",
|
525
527
|
options=[
|
526
|
-
{
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
{"value": "yi-medium-200k", "label": "yi-medium-200k"},
|
531
|
-
{"value": "yi-spark", "label": "yi-spark"},
|
528
|
+
{
|
529
|
+
"value": "yi-lightning",
|
530
|
+
"label": "yi-lightning",
|
531
|
+
},
|
532
532
|
],
|
533
533
|
),
|
534
534
|
"temperature": InputPort(
|
@@ -746,6 +746,7 @@ class OpenAI(Node):
|
|
746
746
|
{"value": "gpt-4o-mini", "label": "gpt-4o-mini"},
|
747
747
|
{"value": "o1-mini", "label": "o1-mini"},
|
748
748
|
{"value": "o1-preview", "label": "o1-preview"},
|
749
|
+
{"value": "o3-mini", "label": "o3-mini"},
|
749
750
|
],
|
750
751
|
),
|
751
752
|
"temperature": InputPort(
|
@@ -893,3 +894,91 @@ class XAi(Node):
|
|
893
894
|
),
|
894
895
|
},
|
895
896
|
)
|
897
|
+
|
898
|
+
|
899
|
+
class CustomModel(Node):
|
900
|
+
def __init__(self, id: Optional[str] = None):
|
901
|
+
super().__init__(
|
902
|
+
node_type="CustomModel",
|
903
|
+
category="llms",
|
904
|
+
task_name="llms.custom_model",
|
905
|
+
node_id=id,
|
906
|
+
ports={
|
907
|
+
"prompt": InputPort(
|
908
|
+
name="prompt",
|
909
|
+
port_type=PortType.TEXTAREA,
|
910
|
+
value="",
|
911
|
+
),
|
912
|
+
"model_family": InputPort(
|
913
|
+
name="model_family",
|
914
|
+
port_type=PortType.SELECT,
|
915
|
+
value="",
|
916
|
+
options=[],
|
917
|
+
),
|
918
|
+
"llm_model": InputPort(
|
919
|
+
name="llm_model",
|
920
|
+
port_type=PortType.SELECT,
|
921
|
+
value="",
|
922
|
+
options=[],
|
923
|
+
),
|
924
|
+
"temperature": InputPort(
|
925
|
+
name="temperature",
|
926
|
+
port_type=PortType.TEMPERATURE,
|
927
|
+
value=0.7,
|
928
|
+
),
|
929
|
+
"top_p": InputPort(
|
930
|
+
name="top_p",
|
931
|
+
port_type=PortType.NUMBER,
|
932
|
+
value=0.95,
|
933
|
+
),
|
934
|
+
"stream": InputPort(
|
935
|
+
name="stream",
|
936
|
+
port_type=PortType.CHECKBOX,
|
937
|
+
value=False,
|
938
|
+
),
|
939
|
+
"system_prompt": InputPort(
|
940
|
+
name="system_prompt",
|
941
|
+
port_type=PortType.TEXTAREA,
|
942
|
+
value="",
|
943
|
+
),
|
944
|
+
"response_format": InputPort(
|
945
|
+
name="response_format",
|
946
|
+
port_type=PortType.SELECT,
|
947
|
+
value="text",
|
948
|
+
options=[
|
949
|
+
{"value": "text", "label": "Text"},
|
950
|
+
{"value": "json_object", "label": "JSON"},
|
951
|
+
],
|
952
|
+
),
|
953
|
+
"use_function_call": InputPort(
|
954
|
+
name="use_function_call",
|
955
|
+
port_type=PortType.CHECKBOX,
|
956
|
+
value=False,
|
957
|
+
),
|
958
|
+
"functions": InputPort(
|
959
|
+
name="functions",
|
960
|
+
port_type=PortType.SELECT,
|
961
|
+
value=[],
|
962
|
+
),
|
963
|
+
"function_call_mode": InputPort(
|
964
|
+
name="function_call_mode",
|
965
|
+
port_type=PortType.SELECT,
|
966
|
+
value="auto",
|
967
|
+
options=[
|
968
|
+
{"value": "auto", "label": "auto"},
|
969
|
+
{"value": "none", "label": "none"},
|
970
|
+
],
|
971
|
+
),
|
972
|
+
"output": OutputPort(
|
973
|
+
name="output",
|
974
|
+
),
|
975
|
+
"function_call_output": OutputPort(
|
976
|
+
name="function_call_output",
|
977
|
+
condition="return fieldsData.use_function_call.value",
|
978
|
+
),
|
979
|
+
"function_call_arguments": OutputPort(
|
980
|
+
name="function_call_arguments",
|
981
|
+
condition="return fieldsData.use_function_call.value",
|
982
|
+
),
|
983
|
+
},
|
984
|
+
)
|
@@ -1,6 +1,6 @@
|
|
1
|
-
vectorvein-0.2.
|
2
|
-
vectorvein-0.2.
|
3
|
-
vectorvein-0.2.
|
1
|
+
vectorvein-0.2.25.dist-info/METADATA,sha256=Q5GwQcPe2_hMU26jkaFftOxDlEkbYEPN-vw6KvImgRQ,4570
|
2
|
+
vectorvein-0.2.25.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
|
3
|
+
vectorvein-0.2.25.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
|
@@ -44,13 +44,13 @@ vectorvein/utilities/retry.py,sha256=6KFS9R2HdhqM3_9jkjD4F36ZSpEx2YNFGOVlpOsUetM
|
|
44
44
|
vectorvein/workflow/graph/edge.py,sha256=xLZEJmBjAfVB53cd7CuRcKhgE6QqXv9nz32wJn8cmyk,1064
|
45
45
|
vectorvein/workflow/graph/node.py,sha256=A3M_GghrSju1D3xc_HtPdGyr-7XSkplGPKJveOUiIF4,3256
|
46
46
|
vectorvein/workflow/graph/port.py,sha256=Q6HmI2cUi6viJ98ec6-MmMPMRtKS1-OgaudP3LMwVLA,6054
|
47
|
-
vectorvein/workflow/graph/workflow.py,sha256=
|
47
|
+
vectorvein/workflow/graph/workflow.py,sha256=XIoCHfJBNLEvdNf1xDur10o4cjAvhuqy2SjRLvRip1M,8200
|
48
48
|
vectorvein/workflow/nodes/__init__.py,sha256=jd4O27kIJdOtkij1FYZ6aJnJy2OQa7xtL1r-Yv8ylO0,3103
|
49
49
|
vectorvein/workflow/nodes/audio_generation.py,sha256=ht2S0vnd0mIAt6FBaSWlADGbb7f_1DAySYrgYnvZT1Q,5726
|
50
50
|
vectorvein/workflow/nodes/control_flows.py,sha256=Zc_uWuroYznLrU-BZCncyzvejC-zFl6EuN_VP8oq5mY,6573
|
51
51
|
vectorvein/workflow/nodes/file_processing.py,sha256=Rsjc8al0z-2KuweO0nIybWvceqxbqOPQyTs0-pgy5m4,3980
|
52
52
|
vectorvein/workflow/nodes/image_generation.py,sha256=fXOhLGodJ3OdKBPXO5a3rq4wN2GMJ0jwqKO_gJFdocU,32852
|
53
|
-
vectorvein/workflow/nodes/llms.py,sha256=
|
53
|
+
vectorvein/workflow/nodes/llms.py,sha256=rXN5Vgn6EvoglNb_BEzVUIrc4dCDxlinEYqznSE-Bek,38121
|
54
54
|
vectorvein/workflow/nodes/media_editing.py,sha256=Od0X0SdcyRhcJckWpDM4WvgWEKxaIsgMXpMifN8Sc5M,29405
|
55
55
|
vectorvein/workflow/nodes/media_processing.py,sha256=t-azYDphXmLRdOyHDfXFTS1tsEOyKqKskDyD0y232j8,19043
|
56
56
|
vectorvein/workflow/nodes/output.py,sha256=_UQxiddHtGv2rkjhUFE-KDgrjnh0AGJQJyq9-4Aji5A,12567
|
@@ -62,4 +62,4 @@ vectorvein/workflow/nodes/vector_db.py,sha256=t6I17q6iR3yQreiDHpRrksMdWDPIvgqJs0
|
|
62
62
|
vectorvein/workflow/nodes/video_generation.py,sha256=qmdg-t_idpxq1veukd-jv_ChICMOoInKxprV9Z4Vi2w,4118
|
63
63
|
vectorvein/workflow/nodes/web_crawlers.py,sha256=LsqomfXfqrXfHJDO1cl0Ox48f4St7X_SL12DSbAMSOw,5415
|
64
64
|
vectorvein/workflow/utils/json_to_code.py,sha256=F7dhDy8kGc8ndOeihGLRLGFGlquoxVlb02ENtxnQ0C8,5914
|
65
|
-
vectorvein-0.2.
|
65
|
+
vectorvein-0.2.25.dist-info/RECORD,,
|
File without changes
|
File without changes
|