vectorvein 0.2.4__py3-none-any.whl → 0.2.5__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 +180 -180
- vectorvein/api/exceptions.py +7 -7
- vectorvein/api/models.py +10 -10
- vectorvein/workflow/nodes/text_processing.py +28 -0
- {vectorvein-0.2.4.dist-info → vectorvein-0.2.5.dist-info}/METADATA +1 -1
- {vectorvein-0.2.4.dist-info → vectorvein-0.2.5.dist-info}/RECORD +8 -8
- {vectorvein-0.2.4.dist-info → vectorvein-0.2.5.dist-info}/WHEEL +0 -0
- {vectorvein-0.2.4.dist-info → vectorvein-0.2.5.dist-info}/entry_points.txt +0 -0
vectorvein/api/client.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""VectorVein API Client"""
|
2
2
|
|
3
3
|
import time
|
4
4
|
import base64
|
@@ -28,23 +28,23 @@ from .models import (
|
|
28
28
|
|
29
29
|
|
30
30
|
class VectorVeinClient:
|
31
|
-
"""
|
31
|
+
"""VectorVein API Sync Client"""
|
32
32
|
|
33
33
|
API_VERSION = "20240508"
|
34
34
|
BASE_URL = "https://vectorvein.com/api/v1/open-api"
|
35
35
|
|
36
36
|
def __init__(self, api_key: str, base_url: Optional[str] = None):
|
37
|
-
"""
|
37
|
+
"""Initialize the client
|
38
38
|
|
39
39
|
Args:
|
40
|
-
api_key: API
|
41
|
-
base_url: API
|
40
|
+
api_key: API key
|
41
|
+
base_url: API base URL, default is https://vectorvein.com/api/v1/open-api
|
42
42
|
|
43
43
|
Raises:
|
44
|
-
APIKeyError: API
|
44
|
+
APIKeyError: API key is empty or not a string
|
45
45
|
"""
|
46
46
|
if not api_key or not isinstance(api_key, str):
|
47
|
-
raise APIKeyError("API
|
47
|
+
raise APIKeyError("API key cannot be empty and must be a string type")
|
48
48
|
|
49
49
|
self.api_key = api_key
|
50
50
|
self.base_url = base_url or self.BASE_URL
|
@@ -69,22 +69,22 @@ class VectorVeinClient:
|
|
69
69
|
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
70
70
|
**kwargs,
|
71
71
|
) -> Dict[str, Any]:
|
72
|
-
"""
|
72
|
+
"""Send HTTP request
|
73
73
|
|
74
74
|
Args:
|
75
|
-
method: HTTP
|
76
|
-
endpoint: API
|
77
|
-
params: URL
|
78
|
-
json: JSON
|
79
|
-
**kwargs:
|
75
|
+
method: HTTP method
|
76
|
+
endpoint: API endpoint
|
77
|
+
params: URL parameters
|
78
|
+
json: JSON request body
|
79
|
+
**kwargs: Other request parameters
|
80
80
|
|
81
81
|
Returns:
|
82
|
-
Dict[str, Any]: API
|
82
|
+
Dict[str, Any]: API response
|
83
83
|
|
84
84
|
Raises:
|
85
|
-
RequestError:
|
86
|
-
VectorVeinAPIError: API
|
87
|
-
APIKeyError: API
|
85
|
+
RequestError: Request error
|
86
|
+
VectorVeinAPIError: API error
|
87
|
+
APIKeyError: API key is invalid or expired
|
88
88
|
"""
|
89
89
|
url = f"{self.base_url}/{endpoint}"
|
90
90
|
headers = self.default_headers.copy()
|
@@ -102,7 +102,7 @@ class VectorVeinClient:
|
|
102
102
|
result = response.json()
|
103
103
|
|
104
104
|
if result["status"] in [401, 403]:
|
105
|
-
raise APIKeyError("API
|
105
|
+
raise APIKeyError("API key is invalid or expired")
|
106
106
|
if result["status"] != 200 and result["status"] != 202:
|
107
107
|
raise VectorVeinAPIError(message=result.get("msg", "Unknown error"), status_code=result["status"])
|
108
108
|
return result
|
@@ -140,22 +140,22 @@ class VectorVeinClient:
|
|
140
140
|
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
141
141
|
timeout: int = 30,
|
142
142
|
) -> Union[str, WorkflowRunResult]:
|
143
|
-
"""
|
143
|
+
"""Run workflow
|
144
144
|
|
145
145
|
Args:
|
146
|
-
wid:
|
147
|
-
input_fields:
|
148
|
-
output_scope:
|
149
|
-
wait_for_completion:
|
150
|
-
api_key_type:
|
151
|
-
timeout:
|
146
|
+
wid: Workflow ID
|
147
|
+
input_fields: Input fields list
|
148
|
+
output_scope: Output scope, optional values: 'all' or 'output_fields_only'
|
149
|
+
wait_for_completion: Whether to wait for completion
|
150
|
+
api_key_type: Key type, optional values: 'WORKFLOW' or 'VAPP'
|
151
|
+
timeout: Timeout (seconds)
|
152
152
|
|
153
153
|
Returns:
|
154
|
-
Union[str, WorkflowRunResult]:
|
154
|
+
Union[str, WorkflowRunResult]: Workflow run ID or run result
|
155
155
|
|
156
156
|
Raises:
|
157
|
-
WorkflowError:
|
158
|
-
TimeoutError:
|
157
|
+
WorkflowError: Workflow run error
|
158
|
+
TimeoutError: Timeout error
|
159
159
|
"""
|
160
160
|
payload = {
|
161
161
|
"wid": wid,
|
@@ -203,22 +203,22 @@ class VectorVeinClient:
|
|
203
203
|
def check_workflow_status(
|
204
204
|
self, rid: str, wid: Optional[str] = None, api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW"
|
205
205
|
) -> WorkflowRunResult:
|
206
|
-
"""
|
206
|
+
"""Check workflow run status
|
207
207
|
|
208
208
|
Args:
|
209
|
-
rid:
|
210
|
-
wid:
|
211
|
-
api_key_type:
|
209
|
+
rid: Workflow run record ID
|
210
|
+
wid: Workflow ID, not required, required when api_key_type is 'VAPP'
|
211
|
+
api_key_type: Key type, optional values: 'WORKFLOW' or 'VAPP'
|
212
212
|
|
213
213
|
Returns:
|
214
|
-
WorkflowRunResult:
|
214
|
+
WorkflowRunResult: Workflow run result
|
215
215
|
|
216
216
|
Raises:
|
217
|
-
VectorVeinAPIError:
|
217
|
+
VectorVeinAPIError: Workflow error
|
218
218
|
"""
|
219
219
|
payload = {"rid": rid}
|
220
220
|
if api_key_type == "VAPP" and not wid:
|
221
|
-
raise VectorVeinAPIError("api_key_type
|
221
|
+
raise VectorVeinAPIError("Workflow ID cannot be empty when api_key_type is 'VAPP'")
|
222
222
|
if wid:
|
223
223
|
payload["wid"] = wid
|
224
224
|
response = self._request("POST", "workflow/check-status", json=payload, api_key_type=api_key_type)
|
@@ -235,17 +235,17 @@ class VectorVeinClient:
|
|
235
235
|
def get_access_keys(
|
236
236
|
self, access_keys: Optional[List[str]] = None, get_type: Literal["selected", "all"] = "selected"
|
237
237
|
) -> List[AccessKey]:
|
238
|
-
"""
|
238
|
+
"""Get access key information
|
239
239
|
|
240
240
|
Args:
|
241
|
-
access_keys:
|
242
|
-
get_type:
|
241
|
+
access_keys: Access key list
|
242
|
+
get_type: Get type, optional values: 'selected' or 'all'
|
243
243
|
|
244
244
|
Returns:
|
245
|
-
List[AccessKey]:
|
245
|
+
List[AccessKey]: Access key information list
|
246
246
|
|
247
247
|
Raises:
|
248
|
-
AccessKeyError:
|
248
|
+
AccessKeyError: Access key does not exist or has expired
|
249
249
|
"""
|
250
250
|
params = {"get_type": get_type}
|
251
251
|
if access_keys:
|
@@ -256,9 +256,9 @@ class VectorVeinClient:
|
|
256
256
|
return [AccessKey(**key) for key in result["data"]]
|
257
257
|
except VectorVeinAPIError as e:
|
258
258
|
if e.status_code == 404:
|
259
|
-
raise AccessKeyError("
|
259
|
+
raise AccessKeyError("Access key does not exist")
|
260
260
|
elif e.status_code == 403:
|
261
|
-
raise AccessKeyError("
|
261
|
+
raise AccessKeyError("Access key has expired")
|
262
262
|
raise
|
263
263
|
|
264
264
|
def create_access_keys(
|
@@ -272,29 +272,29 @@ class VectorVeinClient:
|
|
272
272
|
max_use_count: Optional[int] = None,
|
273
273
|
description: Optional[str] = None,
|
274
274
|
) -> List[AccessKey]:
|
275
|
-
"""
|
275
|
+
"""Create access key
|
276
276
|
|
277
277
|
Args:
|
278
|
-
access_key_type:
|
279
|
-
app_id:
|
280
|
-
app_ids:
|
281
|
-
count:
|
282
|
-
expire_time:
|
283
|
-
max_credits:
|
284
|
-
max_use_count:
|
285
|
-
description:
|
278
|
+
access_key_type: Key type, optional values: 'O'(one-time)、'M'(multiple)、'L'(long-term)
|
279
|
+
app_id: Single application ID
|
280
|
+
app_ids: Multiple application ID list
|
281
|
+
count: Create quantity
|
282
|
+
expire_time: Expiration time
|
283
|
+
max_credits: Maximum credit limit
|
284
|
+
max_use_count: Maximum use count
|
285
|
+
description: Description information
|
286
286
|
|
287
287
|
Returns:
|
288
|
-
List[AccessKey]:
|
288
|
+
List[AccessKey]: Created access key list
|
289
289
|
|
290
290
|
Raises:
|
291
|
-
AccessKeyError:
|
291
|
+
AccessKeyError: Failed to create access key, such as invalid type, application does not exist, etc.
|
292
292
|
"""
|
293
293
|
if access_key_type not in ["O", "M", "L"]:
|
294
|
-
raise AccessKeyError("
|
294
|
+
raise AccessKeyError("Invalid access key type, must be 'O'(one-time)、'M'(multiple) or 'L'(long-term)")
|
295
295
|
|
296
296
|
if app_id and app_ids:
|
297
|
-
raise AccessKeyError("
|
297
|
+
raise AccessKeyError("Cannot specify both app_id and app_ids")
|
298
298
|
|
299
299
|
payload = {"access_key_type": access_key_type, "count": count}
|
300
300
|
|
@@ -316,9 +316,9 @@ class VectorVeinClient:
|
|
316
316
|
return [AccessKey(**key) for key in result["data"]]
|
317
317
|
except VectorVeinAPIError as e:
|
318
318
|
if e.status_code == 404:
|
319
|
-
raise AccessKeyError("
|
319
|
+
raise AccessKeyError("The specified application does not exist")
|
320
320
|
elif e.status_code == 403:
|
321
|
-
raise AccessKeyError("
|
321
|
+
raise AccessKeyError("No permission to create access key")
|
322
322
|
raise
|
323
323
|
|
324
324
|
def list_access_keys(
|
@@ -331,19 +331,19 @@ class VectorVeinClient:
|
|
331
331
|
status: Optional[List[str]] = None,
|
332
332
|
access_key_type: Optional[Literal["O", "M", "L"]] = None,
|
333
333
|
) -> AccessKeyListResponse:
|
334
|
-
"""
|
334
|
+
"""List access keys
|
335
335
|
|
336
336
|
Args:
|
337
|
-
page:
|
338
|
-
page_size:
|
339
|
-
sort_field:
|
340
|
-
sort_order:
|
341
|
-
app_id:
|
342
|
-
status:
|
343
|
-
access_key_type:
|
337
|
+
page: Page number
|
338
|
+
page_size: Number of items per page
|
339
|
+
sort_field: Sort field
|
340
|
+
sort_order: Sort order
|
341
|
+
app_id: Application ID
|
342
|
+
status: Status list
|
343
|
+
access_key_type: Key type list, optional values: 'O'(one-time)、'M'(multiple)、'L'(long-term)
|
344
344
|
|
345
345
|
Returns:
|
346
|
-
AccessKeyListResponse:
|
346
|
+
AccessKeyListResponse: Access key list response
|
347
347
|
"""
|
348
348
|
payload = {"page": page, "page_size": page_size, "sort_field": sort_field, "sort_order": sort_order}
|
349
349
|
|
@@ -358,11 +358,11 @@ class VectorVeinClient:
|
|
358
358
|
return AccessKeyListResponse(**result["data"])
|
359
359
|
|
360
360
|
def delete_access_keys(self, app_id: str, access_keys: List[str]) -> None:
|
361
|
-
"""
|
361
|
+
"""Delete access key
|
362
362
|
|
363
363
|
Args:
|
364
|
-
app_id:
|
365
|
-
access_keys:
|
364
|
+
app_id: Application ID
|
365
|
+
access_keys: List of access keys to delete
|
366
366
|
"""
|
367
367
|
payload = {"app_id": app_id, "access_keys": access_keys}
|
368
368
|
self._request("POST", "vapp/access-key/delete", json=payload)
|
@@ -379,18 +379,18 @@ class VectorVeinClient:
|
|
379
379
|
description: Optional[str] = None,
|
380
380
|
access_key_type: Optional[Literal["O", "M", "L"]] = None,
|
381
381
|
) -> None:
|
382
|
-
"""
|
382
|
+
"""Update access key
|
383
383
|
|
384
384
|
Args:
|
385
|
-
access_key:
|
386
|
-
access_keys:
|
387
|
-
app_id:
|
388
|
-
app_ids:
|
389
|
-
expire_time:
|
390
|
-
max_use_count:
|
391
|
-
max_credits:
|
392
|
-
description:
|
393
|
-
access_key_type:
|
385
|
+
access_key: Single access key
|
386
|
+
access_keys: Multiple access key list
|
387
|
+
app_id: Single application ID
|
388
|
+
app_ids: Multiple application ID list
|
389
|
+
expire_time: Expiration time
|
390
|
+
max_use_count: Maximum use count
|
391
|
+
max_credits: Maximum credit limit
|
392
|
+
description: Description information
|
393
|
+
access_key_type: Key type, optional values: 'O'(one-time)、'M'(multiple)、'L'(long-term)
|
394
394
|
"""
|
395
395
|
payload = {}
|
396
396
|
if access_key:
|
@@ -415,21 +415,21 @@ class VectorVeinClient:
|
|
415
415
|
self._request("POST", "vapp/access-key/update", json=payload)
|
416
416
|
|
417
417
|
def add_apps_to_access_keys(self, access_keys: List[str], app_ids: List[str]) -> None:
|
418
|
-
"""
|
418
|
+
"""Add applications to access keys
|
419
419
|
|
420
420
|
Args:
|
421
|
-
access_keys:
|
422
|
-
app_ids:
|
421
|
+
access_keys: Access key list
|
422
|
+
app_ids: List of application IDs to add
|
423
423
|
"""
|
424
424
|
payload = {"access_keys": access_keys, "app_ids": app_ids}
|
425
425
|
self._request("POST", "vapp/access-key/add-apps", json=payload)
|
426
426
|
|
427
427
|
def remove_apps_from_access_keys(self, access_keys: List[str], app_ids: List[str]) -> None:
|
428
|
-
"""
|
428
|
+
"""Remove applications from access keys
|
429
429
|
|
430
430
|
Args:
|
431
|
-
access_keys:
|
432
|
-
app_ids:
|
431
|
+
access_keys: Access key list
|
432
|
+
app_ids: List of application IDs to remove
|
433
433
|
"""
|
434
434
|
payload = {"access_keys": access_keys, "app_ids": app_ids}
|
435
435
|
self._request("POST", "vapp/access-key/remove-apps", json=payload)
|
@@ -442,17 +442,17 @@ class VectorVeinClient:
|
|
442
442
|
timeout: int = 15 * 60,
|
443
443
|
base_url: str = "https://vectorvein.com",
|
444
444
|
) -> str:
|
445
|
-
"""
|
445
|
+
"""Generate VApp access link
|
446
446
|
|
447
447
|
Args:
|
448
448
|
app_id: VApp ID
|
449
|
-
access_key:
|
450
|
-
key_id:
|
451
|
-
timeout:
|
452
|
-
base_url:
|
449
|
+
access_key: Access key
|
450
|
+
key_id: Key ID
|
451
|
+
timeout: Timeout (seconds)
|
452
|
+
base_url: Base URL
|
453
453
|
|
454
454
|
Returns:
|
455
|
-
str: VApp
|
455
|
+
str: VApp access link
|
456
456
|
"""
|
457
457
|
timestamp = int(time.time())
|
458
458
|
message = f"{app_id}:{access_key}:{timestamp}:{timeout}"
|
@@ -469,23 +469,23 @@ class VectorVeinClient:
|
|
469
469
|
|
470
470
|
|
471
471
|
class AsyncVectorVeinClient:
|
472
|
-
"""
|
472
|
+
"""VectorVein API Async Client"""
|
473
473
|
|
474
474
|
API_VERSION = "20240508"
|
475
475
|
BASE_URL = "https://vectorvein.com/api/v1/open-api"
|
476
476
|
|
477
477
|
def __init__(self, api_key: str, base_url: Optional[str] = None):
|
478
|
-
"""
|
478
|
+
"""Initialize the async client
|
479
479
|
|
480
480
|
Args:
|
481
|
-
api_key: API
|
482
|
-
base_url: API
|
481
|
+
api_key: API key
|
482
|
+
base_url: API base URL, default is https://vectorvein.com/api/v1/open-api
|
483
483
|
|
484
484
|
Raises:
|
485
|
-
APIKeyError: API
|
485
|
+
APIKeyError: API key is empty or not a string
|
486
486
|
"""
|
487
487
|
if not api_key or not isinstance(api_key, str):
|
488
|
-
raise APIKeyError("API
|
488
|
+
raise APIKeyError("API key cannot be empty and must be a string type")
|
489
489
|
|
490
490
|
self.api_key = api_key
|
491
491
|
self.base_url = base_url or self.BASE_URL
|
@@ -510,22 +510,22 @@ class AsyncVectorVeinClient:
|
|
510
510
|
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
511
511
|
**kwargs,
|
512
512
|
) -> Dict[str, Any]:
|
513
|
-
"""
|
513
|
+
"""Send asynchronous HTTP request
|
514
514
|
|
515
515
|
Args:
|
516
|
-
method: HTTP
|
517
|
-
endpoint: API
|
518
|
-
params: URL
|
519
|
-
json: JSON
|
520
|
-
**kwargs:
|
516
|
+
method: HTTP method
|
517
|
+
endpoint: API endpoint
|
518
|
+
params: URL parameters
|
519
|
+
json: JSON request body
|
520
|
+
**kwargs: Other request parameters
|
521
521
|
|
522
522
|
Returns:
|
523
|
-
Dict[str, Any]: API
|
523
|
+
Dict[str, Any]: API response
|
524
524
|
|
525
525
|
Raises:
|
526
|
-
RequestError:
|
527
|
-
VectorVeinAPIError: API
|
528
|
-
APIKeyError: API
|
526
|
+
RequestError: Request error
|
527
|
+
VectorVeinAPIError: API error
|
528
|
+
APIKeyError: API key is invalid or expired
|
529
529
|
"""
|
530
530
|
url = f"{self.base_url}/{endpoint}"
|
531
531
|
headers = self.default_headers.copy()
|
@@ -543,7 +543,7 @@ class AsyncVectorVeinClient:
|
|
543
543
|
result = response.json()
|
544
544
|
|
545
545
|
if result["status"] in [401, 403]:
|
546
|
-
raise APIKeyError("API
|
546
|
+
raise APIKeyError("API key is invalid or expired")
|
547
547
|
if result["status"] != 200 and result["status"] != 202:
|
548
548
|
raise VectorVeinAPIError(message=result.get("msg", "Unknown error"), status_code=result["status"])
|
549
549
|
return result
|
@@ -581,22 +581,22 @@ class AsyncVectorVeinClient:
|
|
581
581
|
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
582
582
|
timeout: int = 30,
|
583
583
|
) -> Union[str, WorkflowRunResult]:
|
584
|
-
"""
|
584
|
+
"""Async run workflow
|
585
585
|
|
586
586
|
Args:
|
587
|
-
wid:
|
588
|
-
input_fields:
|
589
|
-
output_scope:
|
590
|
-
wait_for_completion:
|
591
|
-
api_key_type:
|
592
|
-
timeout:
|
587
|
+
wid: Workflow ID
|
588
|
+
input_fields: Input field list
|
589
|
+
output_scope: Output scope, optional values: 'all' or 'output_fields_only'
|
590
|
+
wait_for_completion: Whether to wait for completion
|
591
|
+
api_key_type: Key type, optional values: 'WORKFLOW' or 'VAPP'
|
592
|
+
timeout: Timeout (seconds)
|
593
593
|
|
594
594
|
Returns:
|
595
|
-
Union[str, WorkflowRunResult]:
|
595
|
+
Union[str, WorkflowRunResult]: Workflow run ID or run result
|
596
596
|
|
597
597
|
Raises:
|
598
|
-
WorkflowError:
|
599
|
-
TimeoutError:
|
598
|
+
WorkflowError: Workflow run error
|
599
|
+
TimeoutError: Timeout error
|
600
600
|
"""
|
601
601
|
payload = {
|
602
602
|
"wid": wid,
|
@@ -644,19 +644,19 @@ class AsyncVectorVeinClient:
|
|
644
644
|
async def check_workflow_status(
|
645
645
|
self, rid: str, wid: Optional[str] = None, api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW"
|
646
646
|
) -> WorkflowRunResult:
|
647
|
-
"""
|
647
|
+
"""Async check workflow run status
|
648
648
|
|
649
649
|
Args:
|
650
|
-
rid:
|
651
|
-
wid:
|
652
|
-
api_key_type:
|
650
|
+
rid: Workflow run record ID
|
651
|
+
wid: Workflow ID, required when api_key_type is 'VAPP'
|
652
|
+
api_key_type: Key type, optional values: 'WORKFLOW' or 'VAPP'
|
653
653
|
|
654
654
|
Raises:
|
655
|
-
VectorVeinAPIError:
|
655
|
+
VectorVeinAPIError: Workflow error
|
656
656
|
"""
|
657
657
|
payload = {"rid": rid}
|
658
658
|
if api_key_type == "VAPP" and not wid:
|
659
|
-
raise VectorVeinAPIError("api_key_type
|
659
|
+
raise VectorVeinAPIError("Workflow ID cannot be empty when api_key_type is 'VAPP'")
|
660
660
|
if wid:
|
661
661
|
payload["wid"] = wid
|
662
662
|
response = await self._request("POST", "workflow/check-status", json=payload, api_key_type=api_key_type)
|
@@ -673,17 +673,17 @@ class AsyncVectorVeinClient:
|
|
673
673
|
async def get_access_keys(
|
674
674
|
self, access_keys: Optional[List[str]] = None, get_type: Literal["selected", "all"] = "selected"
|
675
675
|
) -> List[AccessKey]:
|
676
|
-
"""
|
676
|
+
"""Async get access key information
|
677
677
|
|
678
678
|
Args:
|
679
|
-
access_keys:
|
680
|
-
get_type:
|
679
|
+
access_keys: Access key list
|
680
|
+
get_type: Get type, optional values: 'selected' or 'all'
|
681
681
|
|
682
682
|
Returns:
|
683
|
-
List[AccessKey]:
|
683
|
+
List[AccessKey]: Access key information list
|
684
684
|
|
685
685
|
Raises:
|
686
|
-
AccessKeyError:
|
686
|
+
AccessKeyError: Access key does not exist or has expired
|
687
687
|
"""
|
688
688
|
params = {"get_type": get_type}
|
689
689
|
if access_keys:
|
@@ -694,9 +694,9 @@ class AsyncVectorVeinClient:
|
|
694
694
|
return [AccessKey(**key) for key in result["data"]]
|
695
695
|
except VectorVeinAPIError as e:
|
696
696
|
if e.status_code == 404:
|
697
|
-
raise AccessKeyError("
|
697
|
+
raise AccessKeyError("Access key does not exist")
|
698
698
|
elif e.status_code == 403:
|
699
|
-
raise AccessKeyError("
|
699
|
+
raise AccessKeyError("Access key has expired")
|
700
700
|
raise
|
701
701
|
|
702
702
|
async def create_access_keys(
|
@@ -710,29 +710,29 @@ class AsyncVectorVeinClient:
|
|
710
710
|
max_use_count: Optional[int] = None,
|
711
711
|
description: Optional[str] = None,
|
712
712
|
) -> List[AccessKey]:
|
713
|
-
"""
|
713
|
+
"""Async create access key
|
714
714
|
|
715
715
|
Args:
|
716
|
-
access_key_type:
|
717
|
-
app_id:
|
718
|
-
app_ids:
|
719
|
-
count:
|
720
|
-
expire_time:
|
721
|
-
max_credits:
|
722
|
-
max_use_count:
|
723
|
-
description:
|
716
|
+
access_key_type: Key type, optional values: 'O'(one-time)、'M'(multiple)、'L'(long-term)
|
717
|
+
app_id: Single application ID
|
718
|
+
app_ids: Multiple application ID list
|
719
|
+
count: Create quantity
|
720
|
+
expire_time: Expiration time
|
721
|
+
max_credits: Maximum credit limit
|
722
|
+
max_use_count: Maximum use count
|
723
|
+
description: Description
|
724
724
|
|
725
725
|
Returns:
|
726
|
-
List[AccessKey]:
|
726
|
+
List[AccessKey]: Created access key list
|
727
727
|
|
728
728
|
Raises:
|
729
|
-
AccessKeyError:
|
729
|
+
AccessKeyError: Failed to create access key, such as invalid type, application does not exist, etc.
|
730
730
|
"""
|
731
731
|
if access_key_type not in ["O", "M", "L"]:
|
732
|
-
raise AccessKeyError("
|
732
|
+
raise AccessKeyError("Invalid access key type, must be 'O'(one-time) or 'M'(multiple) or 'L'(long-term)")
|
733
733
|
|
734
734
|
if app_id and app_ids:
|
735
|
-
raise AccessKeyError("
|
735
|
+
raise AccessKeyError("Cannot specify both app_id and app_ids")
|
736
736
|
|
737
737
|
payload = {"access_key_type": access_key_type, "count": count}
|
738
738
|
|
@@ -754,9 +754,9 @@ class AsyncVectorVeinClient:
|
|
754
754
|
return [AccessKey(**key) for key in result["data"]]
|
755
755
|
except VectorVeinAPIError as e:
|
756
756
|
if e.status_code == 404:
|
757
|
-
raise AccessKeyError("
|
757
|
+
raise AccessKeyError("The specified application does not exist")
|
758
758
|
elif e.status_code == 403:
|
759
|
-
raise AccessKeyError("
|
759
|
+
raise AccessKeyError("No permission to create access key")
|
760
760
|
raise
|
761
761
|
|
762
762
|
async def list_access_keys(
|
@@ -769,19 +769,19 @@ class AsyncVectorVeinClient:
|
|
769
769
|
status: Optional[List[str]] = None,
|
770
770
|
access_key_type: Optional[Literal["O", "M", "L"]] = None,
|
771
771
|
) -> AccessKeyListResponse:
|
772
|
-
"""
|
772
|
+
"""Async list access keys
|
773
773
|
|
774
774
|
Args:
|
775
|
-
page:
|
776
|
-
page_size:
|
777
|
-
sort_field:
|
778
|
-
sort_order:
|
779
|
-
app_id:
|
780
|
-
status:
|
781
|
-
access_key_type:
|
775
|
+
page: Page number
|
776
|
+
page_size: Number of items per page
|
777
|
+
sort_field: Sort field
|
778
|
+
sort_order: Sort order
|
779
|
+
app_id: Application ID
|
780
|
+
status: Status list
|
781
|
+
access_key_type: Key type list, optional values: 'O'(one-time)、'M'(multiple)、'L'(long-term)
|
782
782
|
|
783
783
|
Returns:
|
784
|
-
AccessKeyListResponse:
|
784
|
+
AccessKeyListResponse: Access key list response
|
785
785
|
"""
|
786
786
|
payload = {"page": page, "page_size": page_size, "sort_field": sort_field, "sort_order": sort_order}
|
787
787
|
|
@@ -796,11 +796,11 @@ class AsyncVectorVeinClient:
|
|
796
796
|
return AccessKeyListResponse(**result["data"])
|
797
797
|
|
798
798
|
async def delete_access_keys(self, app_id: str, access_keys: List[str]) -> None:
|
799
|
-
"""
|
799
|
+
"""Async delete access key
|
800
800
|
|
801
801
|
Args:
|
802
|
-
app_id:
|
803
|
-
access_keys:
|
802
|
+
app_id: Application ID
|
803
|
+
access_keys: List of access keys to delete
|
804
804
|
"""
|
805
805
|
payload = {"app_id": app_id, "access_keys": access_keys}
|
806
806
|
await self._request("POST", "vapp/access-key/delete", json=payload)
|
@@ -817,18 +817,18 @@ class AsyncVectorVeinClient:
|
|
817
817
|
description: Optional[str] = None,
|
818
818
|
access_key_type: Optional[Literal["O", "M", "L"]] = None,
|
819
819
|
) -> None:
|
820
|
-
"""
|
820
|
+
"""Async update access key
|
821
821
|
|
822
822
|
Args:
|
823
|
-
access_key:
|
824
|
-
access_keys:
|
825
|
-
app_id:
|
826
|
-
app_ids:
|
827
|
-
expire_time:
|
828
|
-
max_use_count:
|
829
|
-
max_credits:
|
830
|
-
description:
|
831
|
-
access_key_type:
|
823
|
+
access_key: Single access key
|
824
|
+
access_keys: Multiple access key list
|
825
|
+
app_id: Single application ID
|
826
|
+
app_ids: Multiple application ID list
|
827
|
+
expire_time: Expiration time
|
828
|
+
max_use_count: Maximum use count
|
829
|
+
max_credits: Maximum credit limit
|
830
|
+
description: Description
|
831
|
+
access_key_type: Key type, optional values: 'O'(one-time)、'M'(multiple)、'L'(long-term)
|
832
832
|
"""
|
833
833
|
payload = {}
|
834
834
|
if access_key:
|
@@ -853,21 +853,21 @@ class AsyncVectorVeinClient:
|
|
853
853
|
await self._request("POST", "vapp/access-key/update", json=payload)
|
854
854
|
|
855
855
|
async def add_apps_to_access_keys(self, access_keys: List[str], app_ids: List[str]) -> None:
|
856
|
-
"""
|
856
|
+
"""Async add applications to access keys
|
857
857
|
|
858
858
|
Args:
|
859
|
-
access_keys:
|
860
|
-
app_ids:
|
859
|
+
access_keys: Access key list
|
860
|
+
app_ids: List of application IDs to add
|
861
861
|
"""
|
862
862
|
payload = {"access_keys": access_keys, "app_ids": app_ids}
|
863
863
|
await self._request("POST", "vapp/access-key/add-apps", json=payload)
|
864
864
|
|
865
865
|
async def remove_apps_from_access_keys(self, access_keys: List[str], app_ids: List[str]) -> None:
|
866
|
-
"""
|
866
|
+
"""Async remove applications from access keys
|
867
867
|
|
868
868
|
Args:
|
869
|
-
access_keys:
|
870
|
-
app_ids:
|
869
|
+
access_keys: Access key list
|
870
|
+
app_ids: List of application IDs to remove
|
871
871
|
"""
|
872
872
|
payload = {"access_keys": access_keys, "app_ids": app_ids}
|
873
873
|
await self._request("POST", "vapp/access-key/remove-apps", json=payload)
|
@@ -880,17 +880,17 @@ class AsyncVectorVeinClient:
|
|
880
880
|
timeout: int = 15 * 60,
|
881
881
|
base_url: str = "https://vectorvein.com",
|
882
882
|
) -> str:
|
883
|
-
"""
|
883
|
+
"""Async generate VApp access link
|
884
884
|
|
885
885
|
Args:
|
886
886
|
app_id: VApp ID
|
887
|
-
access_key:
|
888
|
-
key_id:
|
889
|
-
timeout:
|
890
|
-
base_url:
|
887
|
+
access_key: Access key
|
888
|
+
key_id: Key ID
|
889
|
+
timeout: Timeout (seconds)
|
890
|
+
base_url: Base URL
|
891
891
|
|
892
892
|
Returns:
|
893
|
-
str: VApp
|
893
|
+
str: VApp access link
|
894
894
|
"""
|
895
895
|
timestamp = int(time.time())
|
896
896
|
message = f"{app_id}:{access_key}:{timestamp}:{timeout}"
|
vectorvein/api/exceptions.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
"""
|
1
|
+
"""VectorVein API Exception Definitions"""
|
2
2
|
|
3
3
|
from typing import Optional
|
4
4
|
|
5
5
|
|
6
6
|
class VectorVeinAPIError(Exception):
|
7
|
-
"""
|
7
|
+
"""Base exception class for VectorVein API"""
|
8
8
|
|
9
9
|
def __init__(self, message: str, status_code: Optional[int] = None):
|
10
10
|
super().__init__(message)
|
@@ -12,30 +12,30 @@ class VectorVeinAPIError(Exception):
|
|
12
12
|
|
13
13
|
|
14
14
|
class APIKeyError(VectorVeinAPIError):
|
15
|
-
"""API
|
15
|
+
"""API key related errors"""
|
16
16
|
|
17
17
|
pass
|
18
18
|
|
19
19
|
|
20
20
|
class WorkflowError(VectorVeinAPIError):
|
21
|
-
"""
|
21
|
+
"""Workflow related errors"""
|
22
22
|
|
23
23
|
pass
|
24
24
|
|
25
25
|
|
26
26
|
class AccessKeyError(VectorVeinAPIError):
|
27
|
-
"""
|
27
|
+
"""Access key related errors"""
|
28
28
|
|
29
29
|
pass
|
30
30
|
|
31
31
|
|
32
32
|
class RequestError(VectorVeinAPIError):
|
33
|
-
"""
|
33
|
+
"""Request related errors"""
|
34
34
|
|
35
35
|
pass
|
36
36
|
|
37
37
|
|
38
38
|
class TimeoutError(VectorVeinAPIError):
|
39
|
-
"""
|
39
|
+
"""Timeout errors"""
|
40
40
|
|
41
41
|
pass
|
vectorvein/api/models.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"""
|
1
|
+
"""VectorVein API data model definitions"""
|
2
2
|
|
3
3
|
from dataclasses import dataclass
|
4
4
|
from typing import List, Dict, Optional, Any
|
@@ -6,7 +6,7 @@ from typing import List, Dict, Optional, Any
|
|
6
6
|
|
7
7
|
@dataclass
|
8
8
|
class VApp:
|
9
|
-
"""VApp
|
9
|
+
"""VApp information"""
|
10
10
|
|
11
11
|
app_id: str
|
12
12
|
title: str
|
@@ -17,10 +17,10 @@ class VApp:
|
|
17
17
|
|
18
18
|
@dataclass
|
19
19
|
class AccessKey:
|
20
|
-
"""
|
20
|
+
"""Access key information"""
|
21
21
|
|
22
22
|
access_key: str
|
23
|
-
access_key_type: str # O:
|
23
|
+
access_key_type: str # O: one-time, M: multiple, L: long-term
|
24
24
|
use_count: int
|
25
25
|
max_use_count: Optional[int]
|
26
26
|
max_credits: Optional[int]
|
@@ -28,8 +28,8 @@ class AccessKey:
|
|
28
28
|
v_app: Optional[VApp]
|
29
29
|
v_apps: List[VApp]
|
30
30
|
records: List[Any]
|
31
|
-
status: str # AC:
|
32
|
-
access_scope: str # S:
|
31
|
+
status: str # AC: valid, IN: invalid, EX: expired, US: used
|
32
|
+
access_scope: str # S: single application, M: multiple applications
|
33
33
|
description: str
|
34
34
|
create_time: str
|
35
35
|
expire_time: str
|
@@ -38,7 +38,7 @@ class AccessKey:
|
|
38
38
|
|
39
39
|
@dataclass
|
40
40
|
class WorkflowInputField:
|
41
|
-
"""
|
41
|
+
"""Workflow input field"""
|
42
42
|
|
43
43
|
node_id: str
|
44
44
|
field_name: str
|
@@ -47,7 +47,7 @@ class WorkflowInputField:
|
|
47
47
|
|
48
48
|
@dataclass
|
49
49
|
class WorkflowOutput:
|
50
|
-
"""
|
50
|
+
"""Workflow output result"""
|
51
51
|
|
52
52
|
type: str
|
53
53
|
title: str
|
@@ -56,7 +56,7 @@ class WorkflowOutput:
|
|
56
56
|
|
57
57
|
@dataclass
|
58
58
|
class WorkflowRunResult:
|
59
|
-
"""
|
59
|
+
"""Workflow run result"""
|
60
60
|
|
61
61
|
rid: str
|
62
62
|
status: int
|
@@ -66,7 +66,7 @@ class WorkflowRunResult:
|
|
66
66
|
|
67
67
|
@dataclass
|
68
68
|
class AccessKeyListResponse:
|
69
|
-
"""
|
69
|
+
"""Access key list response"""
|
70
70
|
|
71
71
|
access_keys: List[AccessKey]
|
72
72
|
total: int
|
@@ -216,3 +216,31 @@ class TemplateCompose(Node):
|
|
216
216
|
"output": OutputPort(),
|
217
217
|
},
|
218
218
|
)
|
219
|
+
|
220
|
+
|
221
|
+
class RegexExtract(Node):
|
222
|
+
def __init__(self, id: Optional[str] = None):
|
223
|
+
super().__init__(
|
224
|
+
node_type="RegexExtract",
|
225
|
+
category="text_processing",
|
226
|
+
task_name="text_processing.regex_extract",
|
227
|
+
node_id=id,
|
228
|
+
ports={
|
229
|
+
"text": InputPort(
|
230
|
+
name="text",
|
231
|
+
port_type=PortType.TEXTAREA,
|
232
|
+
value="",
|
233
|
+
),
|
234
|
+
"pattern": InputPort(
|
235
|
+
name="pattern",
|
236
|
+
port_type=PortType.INPUT,
|
237
|
+
value="```.*?\\n(.*?)\\n```",
|
238
|
+
),
|
239
|
+
"first_match": InputPort(
|
240
|
+
name="first_match",
|
241
|
+
port_type=PortType.CHECKBOX,
|
242
|
+
value=True,
|
243
|
+
),
|
244
|
+
"output": OutputPort(),
|
245
|
+
},
|
246
|
+
)
|
@@ -1,11 +1,11 @@
|
|
1
|
-
vectorvein-0.2.
|
2
|
-
vectorvein-0.2.
|
3
|
-
vectorvein-0.2.
|
1
|
+
vectorvein-0.2.5.dist-info/METADATA,sha256=Q2ZnX1A2RBPY5hoLa7YIuWAPT0IbpvEMCBJYKjnoE5w,4413
|
2
|
+
vectorvein-0.2.5.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
|
3
|
+
vectorvein-0.2.5.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=
|
7
|
-
vectorvein/api/exceptions.py,sha256=
|
8
|
-
vectorvein/api/models.py,sha256=
|
6
|
+
vectorvein/api/client.py,sha256=xF-leKDQzVyyy9FnIRaz0k4eElYW1XbbzeRLcpnyk90,33047
|
7
|
+
vectorvein/api/exceptions.py,sha256=uS_PAdx0ksC0r3dgfSGWdbLMZm4qdLeWSSqCv1g3_Gc,772
|
8
|
+
vectorvein/api/models.py,sha256=xtPWMsB0yIJI7i-gY4B6MtvXv0ZIXnoeKspmeInH6fU,1449
|
9
9
|
vectorvein/chat_clients/__init__.py,sha256=omQuG4PRRPNflSAgtdU--rwsWG6vMpwMEyIGZyFVHVQ,18596
|
10
10
|
vectorvein/chat_clients/anthropic_client.py,sha256=Zk6X1feIvv7Az5dgyipJXbm9TkgWgpFghSTxLiXKKA8,38405
|
11
11
|
vectorvein/chat_clients/baichuan_client.py,sha256=CVMvpgjdrZGv0BWnTOBD-f2ufZ3wq3496wqukumsAr4,526
|
@@ -52,11 +52,11 @@ vectorvein/workflow/nodes/media_editing.py,sha256=Od0X0SdcyRhcJckWpDM4WvgWEKxaIs
|
|
52
52
|
vectorvein/workflow/nodes/media_processing.py,sha256=t-azYDphXmLRdOyHDfXFTS1tsEOyKqKskDyD0y232j8,19043
|
53
53
|
vectorvein/workflow/nodes/output.py,sha256=_UQxiddHtGv2rkjhUFE-KDgrjnh0AGJQJyq9-4Aji5A,12567
|
54
54
|
vectorvein/workflow/nodes/relational_db.py,sha256=zfzUhV25TpZGhkIzO18PmAT5xhcsJC4AXKy0zyA05w8,5408
|
55
|
-
vectorvein/workflow/nodes/text_processing.py,sha256=
|
55
|
+
vectorvein/workflow/nodes/text_processing.py,sha256=K99VDV2FKLMy7BSa4jsfdLoxYhYgYTQtN-0YkMQZALg,8414
|
56
56
|
vectorvein/workflow/nodes/tools.py,sha256=uMlqJQI9oel3pG4WYrZdpSmWWy2pDQkAIzqOv5z3tB4,13811
|
57
57
|
vectorvein/workflow/nodes/triggers.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
58
58
|
vectorvein/workflow/nodes/vector_db.py,sha256=t6I17q6iR3yQreiDHpRrksMdWDPIvgqJs076z-7dlQQ,5712
|
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.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|