vectorvein 0.3.1__tar.gz → 0.3.3__tar.gz
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-0.3.1 → vectorvein-0.3.3}/PKG-INFO +1 -1
- {vectorvein-0.3.1 → vectorvein-0.3.3}/pyproject.toml +25 -1
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/api/client.py +81 -103
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/api/exceptions.py +1 -3
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/api/models.py +11 -11
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/anthropic_client.py +157 -169
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/base_client.py +257 -198
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/openai_compatible_client.py +150 -161
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/utils.py +44 -24
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/server/token_server.py +1 -1
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/settings/__init__.py +27 -27
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/types/defaults.py +32 -16
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/types/llm_parameters.py +40 -34
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/types/settings.py +10 -10
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/utilities/media_processing.py +1 -1
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/utilities/rate_limiter.py +5 -6
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/utilities/retry.py +6 -5
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/graph/edge.py +3 -3
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/graph/node.py +14 -26
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/graph/port.py +40 -39
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/graph/workflow.py +13 -25
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/nodes/audio_generation.py +5 -7
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/nodes/control_flows.py +7 -9
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/nodes/file_processing.py +4 -6
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/nodes/image_generation.py +20 -22
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/nodes/llms.py +13 -15
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/nodes/media_editing.py +26 -40
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/nodes/media_processing.py +19 -21
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/nodes/output.py +10 -12
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/nodes/relational_db.py +3 -5
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/nodes/text_processing.py +8 -10
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/nodes/tools.py +8 -10
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/nodes/triggers.py +1 -3
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/nodes/vector_db.py +3 -5
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/nodes/video_generation.py +4 -6
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/nodes/web_crawlers.py +4 -6
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/utils/analyse.py +5 -13
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/utils/check.py +6 -16
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/utils/json_to_code.py +6 -14
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/utils/layout.py +3 -5
- {vectorvein-0.3.1 → vectorvein-0.3.3}/README.md +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/__init__.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/api/__init__.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/__init__.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/baichuan_client.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/deepseek_client.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/ernie_client.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/gemini_client.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/groq_client.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/local_client.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/minimax_client.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/mistral_client.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/moonshot_client.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/openai_client.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/py.typed +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/qwen_client.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/stepfun_client.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/xai_client.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/yi_client.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/chat_clients/zhipuai_client.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/py.typed +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/settings/py.typed +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/types/__init__.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/types/enums.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/types/exception.py +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/types/py.typed +0 -0
- {vectorvein-0.3.1 → vectorvein-0.3.3}/src/vectorvein/workflow/nodes/__init__.py +0 -0
@@ -17,7 +17,7 @@ description = "VectorVein Python SDK"
|
|
17
17
|
name = "vectorvein"
|
18
18
|
readme = "README.md"
|
19
19
|
requires-python = ">=3.10"
|
20
|
-
version = "0.3.
|
20
|
+
version = "0.3.3"
|
21
21
|
|
22
22
|
[project.license]
|
23
23
|
text = "MIT"
|
@@ -59,6 +59,30 @@ excludes = [
|
|
59
59
|
cmd = "python"
|
60
60
|
env_file = ".env"
|
61
61
|
|
62
|
+
[tool.ruff]
|
63
|
+
line-length = 180
|
64
|
+
target-version = "py310"
|
65
|
+
|
66
|
+
[tool.ruff.lint]
|
67
|
+
select = [
|
68
|
+
"E",
|
69
|
+
"W",
|
70
|
+
"F",
|
71
|
+
"I",
|
72
|
+
"B",
|
73
|
+
"C4",
|
74
|
+
"UP",
|
75
|
+
]
|
76
|
+
ignore = [
|
77
|
+
"E501",
|
78
|
+
"I001",
|
79
|
+
]
|
80
|
+
|
81
|
+
[tool.ruff.format]
|
82
|
+
quote-style = "double"
|
83
|
+
indent-style = "space"
|
84
|
+
line-ending = "auto"
|
85
|
+
|
62
86
|
[tool.codeflash]
|
63
87
|
module-root = "src"
|
64
88
|
tests-root = "tests"
|
@@ -4,7 +4,7 @@ import time
|
|
4
4
|
import base64
|
5
5
|
import asyncio
|
6
6
|
from urllib.parse import quote
|
7
|
-
from typing import
|
7
|
+
from typing import Any, Literal, overload
|
8
8
|
|
9
9
|
import httpx
|
10
10
|
from Crypto.Cipher import AES
|
@@ -33,7 +33,7 @@ class VectorVeinClient:
|
|
33
33
|
API_VERSION = "20240508"
|
34
34
|
BASE_URL = "https://vectorvein.com/api/v1/open-api"
|
35
35
|
|
36
|
-
def __init__(self, api_key: str, base_url:
|
36
|
+
def __init__(self, api_key: str, base_url: str | None = None):
|
37
37
|
"""Initialize the client
|
38
38
|
|
39
39
|
Args:
|
@@ -64,11 +64,11 @@ class VectorVeinClient:
|
|
64
64
|
self,
|
65
65
|
method: str,
|
66
66
|
endpoint: str,
|
67
|
-
params:
|
68
|
-
json:
|
67
|
+
params: dict[str, Any] | None = None,
|
68
|
+
json: dict[str, Any] | None = None,
|
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:
|
@@ -107,13 +107,13 @@ class VectorVeinClient:
|
|
107
107
|
raise VectorVeinAPIError(message=result.get("msg", "Unknown error"), status_code=result["status"])
|
108
108
|
return result
|
109
109
|
except httpx.HTTPError as e:
|
110
|
-
raise RequestError(f"Request failed: {str(e)}")
|
110
|
+
raise RequestError(f"Request failed: {str(e)}") from e
|
111
111
|
|
112
112
|
@overload
|
113
113
|
def run_workflow(
|
114
114
|
self,
|
115
115
|
wid: str,
|
116
|
-
input_fields:
|
116
|
+
input_fields: list[WorkflowInputField],
|
117
117
|
output_scope: Literal["all", "output_fields_only"] = "output_fields_only",
|
118
118
|
wait_for_completion: Literal[False] = False,
|
119
119
|
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
@@ -124,7 +124,7 @@ class VectorVeinClient:
|
|
124
124
|
def run_workflow(
|
125
125
|
self,
|
126
126
|
wid: str,
|
127
|
-
input_fields:
|
127
|
+
input_fields: list[WorkflowInputField],
|
128
128
|
output_scope: Literal["all", "output_fields_only"] = "output_fields_only",
|
129
129
|
wait_for_completion: Literal[True] = True,
|
130
130
|
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
@@ -134,12 +134,12 @@ class VectorVeinClient:
|
|
134
134
|
def run_workflow(
|
135
135
|
self,
|
136
136
|
wid: str,
|
137
|
-
input_fields:
|
137
|
+
input_fields: list[WorkflowInputField],
|
138
138
|
output_scope: Literal["all", "output_fields_only"] = "output_fields_only",
|
139
139
|
wait_for_completion: bool = False,
|
140
140
|
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
141
141
|
timeout: int = 30,
|
142
|
-
) ->
|
142
|
+
) -> str | WorkflowRunResult:
|
143
143
|
"""Run workflow
|
144
144
|
|
145
145
|
Args:
|
@@ -161,10 +161,7 @@ class VectorVeinClient:
|
|
161
161
|
"wid": wid,
|
162
162
|
"output_scope": output_scope,
|
163
163
|
"wait_for_completion": wait_for_completion,
|
164
|
-
"input_fields": [
|
165
|
-
{"node_id": field.node_id, "field_name": field.field_name, "value": field.value}
|
166
|
-
for field in input_fields
|
167
|
-
],
|
164
|
+
"input_fields": [{"node_id": field.node_id, "field_name": field.field_name, "value": field.value} for field in input_fields],
|
168
165
|
}
|
169
166
|
|
170
167
|
result = self._request("POST", "workflow/run", json=payload, api_key_type=api_key_type)
|
@@ -191,18 +188,12 @@ class VectorVeinClient:
|
|
191
188
|
time.sleep(5)
|
192
189
|
|
193
190
|
@overload
|
194
|
-
def check_workflow_status(
|
195
|
-
self, rid: str, wid: Optional[str] = None, api_key_type: Literal["WORKFLOW"] = "WORKFLOW"
|
196
|
-
) -> WorkflowRunResult: ...
|
191
|
+
def check_workflow_status(self, rid: str, wid: str | None = None, api_key_type: Literal["WORKFLOW"] = "WORKFLOW") -> WorkflowRunResult: ...
|
197
192
|
|
198
193
|
@overload
|
199
|
-
def check_workflow_status(
|
200
|
-
self, rid: str, wid: str, api_key_type: Literal["VAPP"] = "VAPP"
|
201
|
-
) -> WorkflowRunResult: ...
|
194
|
+
def check_workflow_status(self, rid: str, wid: str, api_key_type: Literal["VAPP"] = "VAPP") -> WorkflowRunResult: ...
|
202
195
|
|
203
|
-
def check_workflow_status(
|
204
|
-
self, rid: str, wid: Optional[str] = None, api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW"
|
205
|
-
) -> WorkflowRunResult:
|
196
|
+
def check_workflow_status(self, rid: str, wid: str | None = None, api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW") -> WorkflowRunResult:
|
206
197
|
"""Check workflow run status
|
207
198
|
|
208
199
|
Args:
|
@@ -232,9 +223,7 @@ class VectorVeinClient:
|
|
232
223
|
else:
|
233
224
|
raise WorkflowError(f"Workflow execution failed: {response['msg']}")
|
234
225
|
|
235
|
-
def get_access_keys(
|
236
|
-
self, access_keys: Optional[List[str]] = None, get_type: Literal["selected", "all"] = "selected"
|
237
|
-
) -> List[AccessKey]:
|
226
|
+
def get_access_keys(self, access_keys: list[str] | None = None, get_type: Literal["selected", "all"] = "selected") -> list[AccessKey]:
|
238
227
|
"""Get access key information
|
239
228
|
|
240
229
|
Args:
|
@@ -256,22 +245,22 @@ class VectorVeinClient:
|
|
256
245
|
return [AccessKey(**key) for key in result["data"]]
|
257
246
|
except VectorVeinAPIError as e:
|
258
247
|
if e.status_code == 404:
|
259
|
-
raise AccessKeyError("Access key does not exist")
|
248
|
+
raise AccessKeyError("Access key does not exist") from e
|
260
249
|
elif e.status_code == 403:
|
261
|
-
raise AccessKeyError("Access key has expired")
|
250
|
+
raise AccessKeyError("Access key has expired") from e
|
262
251
|
raise
|
263
252
|
|
264
253
|
def create_access_keys(
|
265
254
|
self,
|
266
255
|
access_key_type: Literal["O", "M", "L"],
|
267
|
-
app_id:
|
268
|
-
app_ids:
|
256
|
+
app_id: str | None = None,
|
257
|
+
app_ids: list[str] | None = None,
|
269
258
|
count: int = 1,
|
270
|
-
expire_time:
|
271
|
-
max_credits:
|
272
|
-
max_use_count:
|
273
|
-
description:
|
274
|
-
) ->
|
259
|
+
expire_time: str | None = None,
|
260
|
+
max_credits: int | None = None,
|
261
|
+
max_use_count: int | None = None,
|
262
|
+
description: str | None = None,
|
263
|
+
) -> list[AccessKey]:
|
275
264
|
"""Create access key
|
276
265
|
|
277
266
|
Args:
|
@@ -316,9 +305,9 @@ class VectorVeinClient:
|
|
316
305
|
return [AccessKey(**key) for key in result["data"]]
|
317
306
|
except VectorVeinAPIError as e:
|
318
307
|
if e.status_code == 404:
|
319
|
-
raise AccessKeyError("The specified application does not exist")
|
308
|
+
raise AccessKeyError("The specified application does not exist") from e
|
320
309
|
elif e.status_code == 403:
|
321
|
-
raise AccessKeyError("No permission to create access key")
|
310
|
+
raise AccessKeyError("No permission to create access key") from e
|
322
311
|
raise
|
323
312
|
|
324
313
|
def list_access_keys(
|
@@ -327,9 +316,9 @@ class VectorVeinClient:
|
|
327
316
|
page_size: int = 10,
|
328
317
|
sort_field: str = "create_time",
|
329
318
|
sort_order: str = "descend",
|
330
|
-
app_id:
|
331
|
-
status:
|
332
|
-
access_key_type:
|
319
|
+
app_id: str | None = None,
|
320
|
+
status: list[str] | None = None,
|
321
|
+
access_key_type: Literal["O", "M", "L"] | None = None,
|
333
322
|
) -> AccessKeyListResponse:
|
334
323
|
"""List access keys
|
335
324
|
|
@@ -357,7 +346,7 @@ class VectorVeinClient:
|
|
357
346
|
result = self._request("POST", "vapp/access-key/list", json=payload)
|
358
347
|
return AccessKeyListResponse(**result["data"])
|
359
348
|
|
360
|
-
def delete_access_keys(self, app_id: str, access_keys:
|
349
|
+
def delete_access_keys(self, app_id: str, access_keys: list[str]) -> None:
|
361
350
|
"""Delete access key
|
362
351
|
|
363
352
|
Args:
|
@@ -369,15 +358,15 @@ class VectorVeinClient:
|
|
369
358
|
|
370
359
|
def update_access_keys(
|
371
360
|
self,
|
372
|
-
access_key:
|
373
|
-
access_keys:
|
374
|
-
app_id:
|
375
|
-
app_ids:
|
376
|
-
expire_time:
|
377
|
-
max_use_count:
|
378
|
-
max_credits:
|
379
|
-
description:
|
380
|
-
access_key_type:
|
361
|
+
access_key: str | None = None,
|
362
|
+
access_keys: list[str] | None = None,
|
363
|
+
app_id: str | None = None,
|
364
|
+
app_ids: list[str] | None = None,
|
365
|
+
expire_time: str | None = None,
|
366
|
+
max_use_count: int | None = None,
|
367
|
+
max_credits: int | None = None,
|
368
|
+
description: str | None = None,
|
369
|
+
access_key_type: Literal["O", "M", "L"] | None = None,
|
381
370
|
) -> None:
|
382
371
|
"""Update access key
|
383
372
|
|
@@ -414,7 +403,7 @@ class VectorVeinClient:
|
|
414
403
|
|
415
404
|
self._request("POST", "vapp/access-key/update", json=payload)
|
416
405
|
|
417
|
-
def add_apps_to_access_keys(self, access_keys:
|
406
|
+
def add_apps_to_access_keys(self, access_keys: list[str], app_ids: list[str]) -> None:
|
418
407
|
"""Add applications to access keys
|
419
408
|
|
420
409
|
Args:
|
@@ -424,7 +413,7 @@ class VectorVeinClient:
|
|
424
413
|
payload = {"access_keys": access_keys, "app_ids": app_ids}
|
425
414
|
self._request("POST", "vapp/access-key/add-apps", json=payload)
|
426
415
|
|
427
|
-
def remove_apps_from_access_keys(self, access_keys:
|
416
|
+
def remove_apps_from_access_keys(self, access_keys: list[str], app_ids: list[str]) -> None:
|
428
417
|
"""Remove applications from access keys
|
429
418
|
|
430
419
|
Args:
|
@@ -474,7 +463,7 @@ class AsyncVectorVeinClient:
|
|
474
463
|
API_VERSION = "20240508"
|
475
464
|
BASE_URL = "https://vectorvein.com/api/v1/open-api"
|
476
465
|
|
477
|
-
def __init__(self, api_key: str, base_url:
|
466
|
+
def __init__(self, api_key: str, base_url: str | None = None):
|
478
467
|
"""Initialize the async client
|
479
468
|
|
480
469
|
Args:
|
@@ -505,11 +494,11 @@ class AsyncVectorVeinClient:
|
|
505
494
|
self,
|
506
495
|
method: str,
|
507
496
|
endpoint: str,
|
508
|
-
params:
|
509
|
-
json:
|
497
|
+
params: dict[str, Any] | None = None,
|
498
|
+
json: dict[str, Any] | None = None,
|
510
499
|
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
511
500
|
**kwargs,
|
512
|
-
) ->
|
501
|
+
) -> dict[str, Any]:
|
513
502
|
"""Send asynchronous HTTP request
|
514
503
|
|
515
504
|
Args:
|
@@ -548,13 +537,13 @@ class AsyncVectorVeinClient:
|
|
548
537
|
raise VectorVeinAPIError(message=result.get("msg", "Unknown error"), status_code=result["status"])
|
549
538
|
return result
|
550
539
|
except httpx.HTTPError as e:
|
551
|
-
raise RequestError(f"Request failed: {str(e)}")
|
540
|
+
raise RequestError(f"Request failed: {str(e)}") from e
|
552
541
|
|
553
542
|
@overload
|
554
543
|
async def run_workflow(
|
555
544
|
self,
|
556
545
|
wid: str,
|
557
|
-
input_fields:
|
546
|
+
input_fields: list[WorkflowInputField],
|
558
547
|
output_scope: Literal["all", "output_fields_only"] = "output_fields_only",
|
559
548
|
wait_for_completion: Literal[False] = False,
|
560
549
|
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
@@ -565,7 +554,7 @@ class AsyncVectorVeinClient:
|
|
565
554
|
async def run_workflow(
|
566
555
|
self,
|
567
556
|
wid: str,
|
568
|
-
input_fields:
|
557
|
+
input_fields: list[WorkflowInputField],
|
569
558
|
output_scope: Literal["all", "output_fields_only"] = "output_fields_only",
|
570
559
|
wait_for_completion: Literal[True] = True,
|
571
560
|
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
@@ -575,12 +564,12 @@ class AsyncVectorVeinClient:
|
|
575
564
|
async def run_workflow(
|
576
565
|
self,
|
577
566
|
wid: str,
|
578
|
-
input_fields:
|
567
|
+
input_fields: list[WorkflowInputField],
|
579
568
|
output_scope: Literal["all", "output_fields_only"] = "output_fields_only",
|
580
569
|
wait_for_completion: bool = False,
|
581
570
|
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
582
571
|
timeout: int = 30,
|
583
|
-
) ->
|
572
|
+
) -> str | WorkflowRunResult:
|
584
573
|
"""Async run workflow
|
585
574
|
|
586
575
|
Args:
|
@@ -602,10 +591,7 @@ class AsyncVectorVeinClient:
|
|
602
591
|
"wid": wid,
|
603
592
|
"output_scope": output_scope,
|
604
593
|
"wait_for_completion": wait_for_completion,
|
605
|
-
"input_fields": [
|
606
|
-
{"node_id": field.node_id, "field_name": field.field_name, "value": field.value}
|
607
|
-
for field in input_fields
|
608
|
-
],
|
594
|
+
"input_fields": [{"node_id": field.node_id, "field_name": field.field_name, "value": field.value} for field in input_fields],
|
609
595
|
}
|
610
596
|
|
611
597
|
result = await self._request("POST", "workflow/run", json=payload, api_key_type=api_key_type)
|
@@ -632,18 +618,12 @@ class AsyncVectorVeinClient:
|
|
632
618
|
await asyncio.sleep(5)
|
633
619
|
|
634
620
|
@overload
|
635
|
-
async def check_workflow_status(
|
636
|
-
self, rid: str, wid: Optional[str] = None, api_key_type: Literal["WORKFLOW"] = "WORKFLOW"
|
637
|
-
) -> WorkflowRunResult: ...
|
621
|
+
async def check_workflow_status(self, rid: str, wid: str | None = None, api_key_type: Literal["WORKFLOW"] = "WORKFLOW") -> WorkflowRunResult: ...
|
638
622
|
|
639
623
|
@overload
|
640
|
-
async def check_workflow_status(
|
641
|
-
self, rid: str, wid: str, api_key_type: Literal["VAPP"] = "VAPP"
|
642
|
-
) -> WorkflowRunResult: ...
|
624
|
+
async def check_workflow_status(self, rid: str, wid: str, api_key_type: Literal["VAPP"] = "VAPP") -> WorkflowRunResult: ...
|
643
625
|
|
644
|
-
async def check_workflow_status(
|
645
|
-
self, rid: str, wid: Optional[str] = None, api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW"
|
646
|
-
) -> WorkflowRunResult:
|
626
|
+
async def check_workflow_status(self, rid: str, wid: str | None = None, api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW") -> WorkflowRunResult:
|
647
627
|
"""Async check workflow run status
|
648
628
|
|
649
629
|
Args:
|
@@ -670,9 +650,7 @@ class AsyncVectorVeinClient:
|
|
670
650
|
else:
|
671
651
|
raise WorkflowError(f"Workflow execution failed: {response['msg']}")
|
672
652
|
|
673
|
-
async def get_access_keys(
|
674
|
-
self, access_keys: Optional[List[str]] = None, get_type: Literal["selected", "all"] = "selected"
|
675
|
-
) -> List[AccessKey]:
|
653
|
+
async def get_access_keys(self, access_keys: list[str] | None = None, get_type: Literal["selected", "all"] = "selected") -> list[AccessKey]:
|
676
654
|
"""Async get access key information
|
677
655
|
|
678
656
|
Args:
|
@@ -694,22 +672,22 @@ class AsyncVectorVeinClient:
|
|
694
672
|
return [AccessKey(**key) for key in result["data"]]
|
695
673
|
except VectorVeinAPIError as e:
|
696
674
|
if e.status_code == 404:
|
697
|
-
raise AccessKeyError("Access key does not exist")
|
675
|
+
raise AccessKeyError("Access key does not exist") from e
|
698
676
|
elif e.status_code == 403:
|
699
|
-
raise AccessKeyError("Access key has expired")
|
677
|
+
raise AccessKeyError("Access key has expired") from e
|
700
678
|
raise
|
701
679
|
|
702
680
|
async def create_access_keys(
|
703
681
|
self,
|
704
682
|
access_key_type: Literal["O", "M", "L"],
|
705
|
-
app_id:
|
706
|
-
app_ids:
|
683
|
+
app_id: str | None = None,
|
684
|
+
app_ids: list[str] | None = None,
|
707
685
|
count: int = 1,
|
708
|
-
expire_time:
|
709
|
-
max_credits:
|
710
|
-
max_use_count:
|
711
|
-
description:
|
712
|
-
) ->
|
686
|
+
expire_time: str | None = None,
|
687
|
+
max_credits: int | None = None,
|
688
|
+
max_use_count: int | None = None,
|
689
|
+
description: str | None = None,
|
690
|
+
) -> list[AccessKey]:
|
713
691
|
"""Async create access key
|
714
692
|
|
715
693
|
Args:
|
@@ -754,9 +732,9 @@ class AsyncVectorVeinClient:
|
|
754
732
|
return [AccessKey(**key) for key in result["data"]]
|
755
733
|
except VectorVeinAPIError as e:
|
756
734
|
if e.status_code == 404:
|
757
|
-
raise AccessKeyError("The specified application does not exist")
|
735
|
+
raise AccessKeyError("The specified application does not exist") from e
|
758
736
|
elif e.status_code == 403:
|
759
|
-
raise AccessKeyError("No permission to create access key")
|
737
|
+
raise AccessKeyError("No permission to create access key") from e
|
760
738
|
raise
|
761
739
|
|
762
740
|
async def list_access_keys(
|
@@ -765,9 +743,9 @@ class AsyncVectorVeinClient:
|
|
765
743
|
page_size: int = 10,
|
766
744
|
sort_field: str = "create_time",
|
767
745
|
sort_order: str = "descend",
|
768
|
-
app_id:
|
769
|
-
status:
|
770
|
-
access_key_type:
|
746
|
+
app_id: str | None = None,
|
747
|
+
status: list[str] | None = None,
|
748
|
+
access_key_type: Literal["O", "M", "L"] | None = None,
|
771
749
|
) -> AccessKeyListResponse:
|
772
750
|
"""Async list access keys
|
773
751
|
|
@@ -795,7 +773,7 @@ class AsyncVectorVeinClient:
|
|
795
773
|
result = await self._request("POST", "vapp/access-key/list", json=payload)
|
796
774
|
return AccessKeyListResponse(**result["data"])
|
797
775
|
|
798
|
-
async def delete_access_keys(self, app_id: str, access_keys:
|
776
|
+
async def delete_access_keys(self, app_id: str, access_keys: list[str]) -> None:
|
799
777
|
"""Async delete access key
|
800
778
|
|
801
779
|
Args:
|
@@ -807,15 +785,15 @@ class AsyncVectorVeinClient:
|
|
807
785
|
|
808
786
|
async def update_access_keys(
|
809
787
|
self,
|
810
|
-
access_key:
|
811
|
-
access_keys:
|
812
|
-
app_id:
|
813
|
-
app_ids:
|
814
|
-
expire_time:
|
815
|
-
max_use_count:
|
816
|
-
max_credits:
|
817
|
-
description:
|
818
|
-
access_key_type:
|
788
|
+
access_key: str | None = None,
|
789
|
+
access_keys: list[str] | None = None,
|
790
|
+
app_id: str | None = None,
|
791
|
+
app_ids: list[str] | None = None,
|
792
|
+
expire_time: str | None = None,
|
793
|
+
max_use_count: int | None = None,
|
794
|
+
max_credits: int | None = None,
|
795
|
+
description: str | None = None,
|
796
|
+
access_key_type: Literal["O", "M", "L"] | None = None,
|
819
797
|
) -> None:
|
820
798
|
"""Async update access key
|
821
799
|
|
@@ -852,7 +830,7 @@ class AsyncVectorVeinClient:
|
|
852
830
|
|
853
831
|
await self._request("POST", "vapp/access-key/update", json=payload)
|
854
832
|
|
855
|
-
async def add_apps_to_access_keys(self, access_keys:
|
833
|
+
async def add_apps_to_access_keys(self, access_keys: list[str], app_ids: list[str]) -> None:
|
856
834
|
"""Async add applications to access keys
|
857
835
|
|
858
836
|
Args:
|
@@ -862,7 +840,7 @@ class AsyncVectorVeinClient:
|
|
862
840
|
payload = {"access_keys": access_keys, "app_ids": app_ids}
|
863
841
|
await self._request("POST", "vapp/access-key/add-apps", json=payload)
|
864
842
|
|
865
|
-
async def remove_apps_from_access_keys(self, access_keys:
|
843
|
+
async def remove_apps_from_access_keys(self, access_keys: list[str], app_ids: list[str]) -> None:
|
866
844
|
"""Async remove applications from access keys
|
867
845
|
|
868
846
|
Args:
|
@@ -1,12 +1,10 @@
|
|
1
1
|
"""VectorVein API Exception Definitions"""
|
2
2
|
|
3
|
-
from typing import Optional
|
4
|
-
|
5
3
|
|
6
4
|
class VectorVeinAPIError(Exception):
|
7
5
|
"""Base exception class for VectorVein API"""
|
8
6
|
|
9
|
-
def __init__(self, message: str, status_code:
|
7
|
+
def __init__(self, message: str, status_code: int | None = None):
|
10
8
|
super().__init__(message)
|
11
9
|
self.status_code = status_code
|
12
10
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"""VectorVein API data model definitions"""
|
2
2
|
|
3
3
|
from dataclasses import dataclass
|
4
|
-
from typing import
|
4
|
+
from typing import Any
|
5
5
|
|
6
6
|
|
7
7
|
@dataclass
|
@@ -11,8 +11,8 @@ class VApp:
|
|
11
11
|
app_id: str
|
12
12
|
title: str
|
13
13
|
description: str
|
14
|
-
info:
|
15
|
-
images:
|
14
|
+
info: dict[str, Any]
|
15
|
+
images: list[str]
|
16
16
|
|
17
17
|
|
18
18
|
@dataclass
|
@@ -22,18 +22,18 @@ class AccessKey:
|
|
22
22
|
access_key: str
|
23
23
|
access_key_type: str # O: one-time, M: multiple, L: long-term
|
24
24
|
use_count: int
|
25
|
-
max_use_count:
|
26
|
-
max_credits:
|
25
|
+
max_use_count: int | None
|
26
|
+
max_credits: int | None
|
27
27
|
used_credits: int
|
28
|
-
v_app:
|
29
|
-
v_apps:
|
30
|
-
records:
|
28
|
+
v_app: VApp | None
|
29
|
+
v_apps: list[VApp]
|
30
|
+
records: list[Any]
|
31
31
|
status: str # AC: valid, IN: invalid, EX: expired, US: used
|
32
32
|
access_scope: str # S: single application, M: multiple applications
|
33
33
|
description: str
|
34
34
|
create_time: str
|
35
35
|
expire_time: str
|
36
|
-
last_use_time:
|
36
|
+
last_use_time: str | None
|
37
37
|
|
38
38
|
|
39
39
|
@dataclass
|
@@ -61,14 +61,14 @@ class WorkflowRunResult:
|
|
61
61
|
rid: str
|
62
62
|
status: int
|
63
63
|
msg: str
|
64
|
-
data:
|
64
|
+
data: list[WorkflowOutput]
|
65
65
|
|
66
66
|
|
67
67
|
@dataclass
|
68
68
|
class AccessKeyListResponse:
|
69
69
|
"""Access key list response"""
|
70
70
|
|
71
|
-
access_keys:
|
71
|
+
access_keys: list[AccessKey]
|
72
72
|
total: int
|
73
73
|
page_size: int
|
74
74
|
page: int
|