vectorvein 0.2.2__py3-none-any.whl → 0.2.4__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/api/client.py +97 -26
- {vectorvein-0.2.2.dist-info → vectorvein-0.2.4.dist-info}/METADATA +1 -1
- {vectorvein-0.2.2.dist-info → vectorvein-0.2.4.dist-info}/RECORD +5 -5
- {vectorvein-0.2.2.dist-info → vectorvein-0.2.4.dist-info}/WHEEL +0 -0
- {vectorvein-0.2.2.dist-info → vectorvein-0.2.4.dist-info}/entry_points.txt +0 -0
vectorvein/api/client.py
CHANGED
@@ -48,12 +48,11 @@ class VectorVeinClient:
|
|
48
48
|
|
49
49
|
self.api_key = api_key
|
50
50
|
self.base_url = base_url or self.BASE_URL
|
51
|
-
self.
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
)
|
51
|
+
self.default_headers = {
|
52
|
+
"VECTORVEIN-API-KEY": api_key,
|
53
|
+
"VECTORVEIN-API-VERSION": self.API_VERSION,
|
54
|
+
}
|
55
|
+
self._client = httpx.Client(timeout=60)
|
57
56
|
|
58
57
|
def __enter__(self):
|
59
58
|
return self
|
@@ -67,6 +66,7 @@ class VectorVeinClient:
|
|
67
66
|
endpoint: str,
|
68
67
|
params: Optional[Dict[str, Any]] = None,
|
69
68
|
json: Optional[Dict[str, Any]] = None,
|
69
|
+
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
70
70
|
**kwargs,
|
71
71
|
) -> Dict[str, Any]:
|
72
72
|
"""发送HTTP请求
|
@@ -87,9 +87,18 @@ class VectorVeinClient:
|
|
87
87
|
APIKeyError: API密钥无效或已过期
|
88
88
|
"""
|
89
89
|
url = f"{self.base_url}/{endpoint}"
|
90
|
+
headers = self.default_headers.copy()
|
91
|
+
if api_key_type == "VAPP":
|
92
|
+
headers["VECTORVEIN-API-KEY-TYPE"] = "VAPP"
|
90
93
|
try:
|
91
|
-
response = self._client.request(
|
92
|
-
|
94
|
+
response = self._client.request(
|
95
|
+
method=method,
|
96
|
+
url=url,
|
97
|
+
params=params,
|
98
|
+
json=json,
|
99
|
+
headers=headers,
|
100
|
+
**kwargs,
|
101
|
+
)
|
93
102
|
result = response.json()
|
94
103
|
|
95
104
|
if result["status"] in [401, 403]:
|
@@ -107,6 +116,7 @@ class VectorVeinClient:
|
|
107
116
|
input_fields: List[WorkflowInputField],
|
108
117
|
output_scope: Literal["all", "output_fields_only"] = "output_fields_only",
|
109
118
|
wait_for_completion: Literal[False] = False,
|
119
|
+
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
110
120
|
timeout: int = 30,
|
111
121
|
) -> str: ...
|
112
122
|
|
@@ -117,6 +127,7 @@ class VectorVeinClient:
|
|
117
127
|
input_fields: List[WorkflowInputField],
|
118
128
|
output_scope: Literal["all", "output_fields_only"] = "output_fields_only",
|
119
129
|
wait_for_completion: Literal[True] = True,
|
130
|
+
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
120
131
|
timeout: int = 30,
|
121
132
|
) -> WorkflowRunResult: ...
|
122
133
|
|
@@ -126,6 +137,7 @@ class VectorVeinClient:
|
|
126
137
|
input_fields: List[WorkflowInputField],
|
127
138
|
output_scope: Literal["all", "output_fields_only"] = "output_fields_only",
|
128
139
|
wait_for_completion: bool = False,
|
140
|
+
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
129
141
|
timeout: int = 30,
|
130
142
|
) -> Union[str, WorkflowRunResult]:
|
131
143
|
"""运行工作流
|
@@ -135,6 +147,7 @@ class VectorVeinClient:
|
|
135
147
|
input_fields: 输入字段列表
|
136
148
|
output_scope: 输出范围,可选值:'all' 或 'output_fields_only'
|
137
149
|
wait_for_completion: 是否等待完成
|
150
|
+
api_key_type: 密钥类型,可选值:'WORKFLOW' 或 'VAPP'
|
138
151
|
timeout: 超时时间(秒)
|
139
152
|
|
140
153
|
Returns:
|
@@ -154,7 +167,7 @@ class VectorVeinClient:
|
|
154
167
|
],
|
155
168
|
}
|
156
169
|
|
157
|
-
result = self._request("POST", "workflow/run", json=payload)
|
170
|
+
result = self._request("POST", "workflow/run", json=payload, api_key_type=api_key_type)
|
158
171
|
|
159
172
|
if not wait_for_completion:
|
160
173
|
return result["data"]["rid"]
|
@@ -166,7 +179,10 @@ class VectorVeinClient:
|
|
166
179
|
if time.time() - start_time > timeout:
|
167
180
|
raise TimeoutError(f"Workflow execution timed out after {timeout} seconds")
|
168
181
|
|
169
|
-
|
182
|
+
if api_key_type == "WORKFLOW":
|
183
|
+
result = self.check_workflow_status(rid, api_key_type=api_key_type)
|
184
|
+
else:
|
185
|
+
result = self.check_workflow_status(rid, wid=wid, api_key_type=api_key_type)
|
170
186
|
if result.status == 200:
|
171
187
|
return result
|
172
188
|
elif result.status == 500:
|
@@ -174,17 +190,38 @@ class VectorVeinClient:
|
|
174
190
|
|
175
191
|
time.sleep(5)
|
176
192
|
|
177
|
-
|
193
|
+
@overload
|
194
|
+
def check_workflow_status(
|
195
|
+
self, rid: str, wid: Optional[str] = None, api_key_type: Literal["WORKFLOW"] = "WORKFLOW"
|
196
|
+
) -> WorkflowRunResult: ...
|
197
|
+
|
198
|
+
@overload
|
199
|
+
def check_workflow_status(
|
200
|
+
self, rid: str, wid: str, api_key_type: Literal["VAPP"] = "VAPP"
|
201
|
+
) -> WorkflowRunResult: ...
|
202
|
+
|
203
|
+
def check_workflow_status(
|
204
|
+
self, rid: str, wid: Optional[str] = None, api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW"
|
205
|
+
) -> WorkflowRunResult:
|
178
206
|
"""检查工作流运行状态
|
179
207
|
|
180
208
|
Args:
|
181
209
|
rid: 工作流运行记录ID
|
210
|
+
wid: 工作流ID,非必填,api_key_type 为 'VAPP' 时必填
|
211
|
+
api_key_type: 密钥类型,可选值:'WORKFLOW' 或 'VAPP'
|
182
212
|
|
183
213
|
Returns:
|
184
214
|
WorkflowRunResult: 工作流运行结果
|
215
|
+
|
216
|
+
Raises:
|
217
|
+
VectorVeinAPIError: 工作流错误
|
185
218
|
"""
|
186
219
|
payload = {"rid": rid}
|
187
|
-
|
220
|
+
if api_key_type == "VAPP" and not wid:
|
221
|
+
raise VectorVeinAPIError("api_key_type 为 'VAPP' 时工作流 ID 不能为空")
|
222
|
+
if wid:
|
223
|
+
payload["wid"] = wid
|
224
|
+
response = self._request("POST", "workflow/check-status", json=payload, api_key_type=api_key_type)
|
188
225
|
if response["status"] in [200, 202]:
|
189
226
|
return WorkflowRunResult(
|
190
227
|
rid=rid,
|
@@ -452,12 +489,11 @@ class AsyncVectorVeinClient:
|
|
452
489
|
|
453
490
|
self.api_key = api_key
|
454
491
|
self.base_url = base_url or self.BASE_URL
|
455
|
-
self.
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
)
|
492
|
+
self.default_headers = {
|
493
|
+
"VECTORVEIN-API-KEY": api_key,
|
494
|
+
"VECTORVEIN-API-VERSION": self.API_VERSION,
|
495
|
+
}
|
496
|
+
self._client = httpx.AsyncClient(timeout=60)
|
461
497
|
|
462
498
|
async def __aenter__(self):
|
463
499
|
return self
|
@@ -471,6 +507,7 @@ class AsyncVectorVeinClient:
|
|
471
507
|
endpoint: str,
|
472
508
|
params: Optional[Dict[str, Any]] = None,
|
473
509
|
json: Optional[Dict[str, Any]] = None,
|
510
|
+
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
474
511
|
**kwargs,
|
475
512
|
) -> Dict[str, Any]:
|
476
513
|
"""发送异步HTTP请求
|
@@ -491,9 +528,18 @@ class AsyncVectorVeinClient:
|
|
491
528
|
APIKeyError: API密钥无效或已过期
|
492
529
|
"""
|
493
530
|
url = f"{self.base_url}/{endpoint}"
|
531
|
+
headers = self.default_headers.copy()
|
532
|
+
if api_key_type == "VAPP":
|
533
|
+
headers["VECTORVEIN-API-KEY-TYPE"] = "VAPP"
|
494
534
|
try:
|
495
|
-
response = await self._client.request(
|
496
|
-
|
535
|
+
response = await self._client.request(
|
536
|
+
method=method,
|
537
|
+
url=url,
|
538
|
+
params=params,
|
539
|
+
json=json,
|
540
|
+
headers=headers,
|
541
|
+
**kwargs,
|
542
|
+
)
|
497
543
|
result = response.json()
|
498
544
|
|
499
545
|
if result["status"] in [401, 403]:
|
@@ -511,6 +557,7 @@ class AsyncVectorVeinClient:
|
|
511
557
|
input_fields: List[WorkflowInputField],
|
512
558
|
output_scope: Literal["all", "output_fields_only"] = "output_fields_only",
|
513
559
|
wait_for_completion: Literal[False] = False,
|
560
|
+
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
514
561
|
timeout: int = 30,
|
515
562
|
) -> str: ...
|
516
563
|
|
@@ -521,6 +568,7 @@ class AsyncVectorVeinClient:
|
|
521
568
|
input_fields: List[WorkflowInputField],
|
522
569
|
output_scope: Literal["all", "output_fields_only"] = "output_fields_only",
|
523
570
|
wait_for_completion: Literal[True] = True,
|
571
|
+
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
524
572
|
timeout: int = 30,
|
525
573
|
) -> WorkflowRunResult: ...
|
526
574
|
|
@@ -530,6 +578,7 @@ class AsyncVectorVeinClient:
|
|
530
578
|
input_fields: List[WorkflowInputField],
|
531
579
|
output_scope: Literal["all", "output_fields_only"] = "output_fields_only",
|
532
580
|
wait_for_completion: bool = False,
|
581
|
+
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
533
582
|
timeout: int = 30,
|
534
583
|
) -> Union[str, WorkflowRunResult]:
|
535
584
|
"""异步运行工作流
|
@@ -539,6 +588,7 @@ class AsyncVectorVeinClient:
|
|
539
588
|
input_fields: 输入字段列表
|
540
589
|
output_scope: 输出范围,可选值:'all' 或 'output_fields_only'
|
541
590
|
wait_for_completion: 是否等待完成
|
591
|
+
api_key_type: 密钥类型,可选值:'WORKFLOW' 或 'VAPP'
|
542
592
|
timeout: 超时时间(秒)
|
543
593
|
|
544
594
|
Returns:
|
@@ -558,7 +608,7 @@ class AsyncVectorVeinClient:
|
|
558
608
|
],
|
559
609
|
}
|
560
610
|
|
561
|
-
result = await self._request("POST", "workflow/run", json=payload)
|
611
|
+
result = await self._request("POST", "workflow/run", json=payload, api_key_type=api_key_type)
|
562
612
|
|
563
613
|
if not wait_for_completion:
|
564
614
|
return result["data"]["rid"]
|
@@ -570,7 +620,10 @@ class AsyncVectorVeinClient:
|
|
570
620
|
if time.time() - start_time > timeout:
|
571
621
|
raise TimeoutError(f"Workflow execution timed out after {timeout} seconds")
|
572
622
|
|
573
|
-
|
623
|
+
if api_key_type == "WORKFLOW":
|
624
|
+
result = await self.check_workflow_status(rid, api_key_type=api_key_type)
|
625
|
+
else:
|
626
|
+
result = await self.check_workflow_status(rid, wid=wid, api_key_type=api_key_type)
|
574
627
|
if result.status == 200:
|
575
628
|
return result
|
576
629
|
elif result.status == 500:
|
@@ -578,17 +631,35 @@ class AsyncVectorVeinClient:
|
|
578
631
|
|
579
632
|
await asyncio.sleep(5)
|
580
633
|
|
581
|
-
|
634
|
+
@overload
|
635
|
+
async def check_workflow_status(
|
636
|
+
self, rid: str, wid: Optional[str] = None, api_key_type: Literal["WORKFLOW"] = "WORKFLOW"
|
637
|
+
) -> WorkflowRunResult: ...
|
638
|
+
|
639
|
+
@overload
|
640
|
+
async def check_workflow_status(
|
641
|
+
self, rid: str, wid: str, api_key_type: Literal["VAPP"] = "VAPP"
|
642
|
+
) -> WorkflowRunResult: ...
|
643
|
+
|
644
|
+
async def check_workflow_status(
|
645
|
+
self, rid: str, wid: Optional[str] = None, api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW"
|
646
|
+
) -> WorkflowRunResult:
|
582
647
|
"""异步检查工作流运行状态
|
583
648
|
|
584
649
|
Args:
|
585
650
|
rid: 工作流运行记录ID
|
651
|
+
wid: 工作流ID,非必填,api_key_type 为 'VAPP' 时必填
|
652
|
+
api_key_type: 密钥类型,可选值:'WORKFLOW' 或 'VAPP'
|
586
653
|
|
587
|
-
|
588
|
-
|
654
|
+
Raises:
|
655
|
+
VectorVeinAPIError: 工作流错误
|
589
656
|
"""
|
590
657
|
payload = {"rid": rid}
|
591
|
-
|
658
|
+
if api_key_type == "VAPP" and not wid:
|
659
|
+
raise VectorVeinAPIError("api_key_type 为 'VAPP' 时工作流 ID 不能为空")
|
660
|
+
if wid:
|
661
|
+
payload["wid"] = wid
|
662
|
+
response = await self._request("POST", "workflow/check-status", json=payload, api_key_type=api_key_type)
|
592
663
|
if response["status"] in [200, 202]:
|
593
664
|
return WorkflowRunResult(
|
594
665
|
rid=rid,
|
@@ -1,9 +1,9 @@
|
|
1
|
-
vectorvein-0.2.
|
2
|
-
vectorvein-0.2.
|
3
|
-
vectorvein-0.2.
|
1
|
+
vectorvein-0.2.4.dist-info/METADATA,sha256=TFMh4mGtTFrgaRTpXSj5wa9HMcVJ2j74Z1AwTockagI,4413
|
2
|
+
vectorvein-0.2.4.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
|
3
|
+
vectorvein-0.2.4.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
|
-
vectorvein/api/client.py,sha256=
|
6
|
+
vectorvein/api/client.py,sha256=K93a-EvmBqh6sz_iFkMK1VlM54mgZsjOabnRzJJnbWM,32732
|
7
7
|
vectorvein/api/exceptions.py,sha256=btfeXfNfc7zLykMKklpJePLnmJie5YSxCYHyMReCC9s,751
|
8
8
|
vectorvein/api/models.py,sha256=z5MeXMxWFHlNkP5vjVz6gEn5cxD1FbQ8pQvbx9KtgkE,1422
|
9
9
|
vectorvein/chat_clients/__init__.py,sha256=omQuG4PRRPNflSAgtdU--rwsWG6vMpwMEyIGZyFVHVQ,18596
|
@@ -59,4 +59,4 @@ vectorvein/workflow/nodes/vector_db.py,sha256=t6I17q6iR3yQreiDHpRrksMdWDPIvgqJs0
|
|
59
59
|
vectorvein/workflow/nodes/video_generation.py,sha256=qmdg-t_idpxq1veukd-jv_ChICMOoInKxprV9Z4Vi2w,4118
|
60
60
|
vectorvein/workflow/nodes/web_crawlers.py,sha256=LsqomfXfqrXfHJDO1cl0Ox48f4St7X_SL12DSbAMSOw,5415
|
61
61
|
vectorvein/workflow/utils/json_to_code.py,sha256=F7dhDy8kGc8ndOeihGLRLGFGlquoxVlb02ENtxnQ0C8,5914
|
62
|
-
vectorvein-0.2.
|
62
|
+
vectorvein-0.2.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|