vectorvein 0.2.3__tar.gz → 0.2.5__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.2.3 → vectorvein-0.2.5}/PKG-INFO +1 -1
- {vectorvein-0.2.3 → vectorvein-0.2.5}/pyproject.toml +1 -1
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/api/client.py +205 -180
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/api/exceptions.py +7 -7
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/api/models.py +10 -10
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/nodes/text_processing.py +28 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/README.md +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/__init__.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/api/__init__.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/__init__.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/anthropic_client.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/baichuan_client.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/base_client.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/deepseek_client.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/gemini_client.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/groq_client.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/local_client.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/minimax_client.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/mistral_client.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/moonshot_client.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/openai_client.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/openai_compatible_client.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/py.typed +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/qwen_client.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/stepfun_client.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/utils.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/xai_client.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/yi_client.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/zhipuai_client.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/py.typed +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/server/token_server.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/settings/__init__.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/settings/py.typed +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/types/defaults.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/types/enums.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/types/exception.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/types/llm_parameters.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/types/py.typed +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/utilities/media_processing.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/utilities/rate_limiter.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/utilities/retry.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/graph/edge.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/graph/node.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/graph/port.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/graph/workflow.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/nodes/__init__.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/nodes/audio_generation.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/nodes/control_flows.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/nodes/file_processing.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/nodes/image_generation.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/nodes/llms.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/nodes/media_editing.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/nodes/media_processing.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/nodes/output.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/nodes/relational_db.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/nodes/tools.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/nodes/triggers.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/nodes/vector_db.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/nodes/video_generation.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/nodes/web_crawlers.py +0 -0
- {vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/workflow/utils/json_to_code.py +0 -0
@@ -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()
|
@@ -99,11 +99,10 @@ class VectorVeinClient:
|
|
99
99
|
headers=headers,
|
100
100
|
**kwargs,
|
101
101
|
)
|
102
|
-
response.raise_for_status()
|
103
102
|
result = response.json()
|
104
103
|
|
105
104
|
if result["status"] in [401, 403]:
|
106
|
-
raise APIKeyError("API
|
105
|
+
raise APIKeyError("API key is invalid or expired")
|
107
106
|
if result["status"] != 200 and result["status"] != 202:
|
108
107
|
raise VectorVeinAPIError(message=result.get("msg", "Unknown error"), status_code=result["status"])
|
109
108
|
return result
|
@@ -141,22 +140,22 @@ class VectorVeinClient:
|
|
141
140
|
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
142
141
|
timeout: int = 30,
|
143
142
|
) -> Union[str, WorkflowRunResult]:
|
144
|
-
"""
|
143
|
+
"""Run workflow
|
145
144
|
|
146
145
|
Args:
|
147
|
-
wid:
|
148
|
-
input_fields:
|
149
|
-
output_scope:
|
150
|
-
wait_for_completion:
|
151
|
-
api_key_type:
|
152
|
-
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)
|
153
152
|
|
154
153
|
Returns:
|
155
|
-
Union[str, WorkflowRunResult]:
|
154
|
+
Union[str, WorkflowRunResult]: Workflow run ID or run result
|
156
155
|
|
157
156
|
Raises:
|
158
|
-
WorkflowError:
|
159
|
-
TimeoutError:
|
157
|
+
WorkflowError: Workflow run error
|
158
|
+
TimeoutError: Timeout error
|
160
159
|
"""
|
161
160
|
payload = {
|
162
161
|
"wid": wid,
|
@@ -191,20 +190,35 @@ class VectorVeinClient:
|
|
191
190
|
|
192
191
|
time.sleep(5)
|
193
192
|
|
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
|
+
|
194
203
|
def check_workflow_status(
|
195
204
|
self, rid: str, wid: Optional[str] = None, api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW"
|
196
205
|
) -> WorkflowRunResult:
|
197
|
-
"""
|
206
|
+
"""Check workflow run status
|
198
207
|
|
199
208
|
Args:
|
200
|
-
rid:
|
201
|
-
wid:
|
202
|
-
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'
|
203
212
|
|
204
213
|
Returns:
|
205
|
-
WorkflowRunResult:
|
214
|
+
WorkflowRunResult: Workflow run result
|
215
|
+
|
216
|
+
Raises:
|
217
|
+
VectorVeinAPIError: Workflow error
|
206
218
|
"""
|
207
219
|
payload = {"rid": rid}
|
220
|
+
if api_key_type == "VAPP" and not wid:
|
221
|
+
raise VectorVeinAPIError("Workflow ID cannot be empty when api_key_type is 'VAPP'")
|
208
222
|
if wid:
|
209
223
|
payload["wid"] = wid
|
210
224
|
response = self._request("POST", "workflow/check-status", json=payload, api_key_type=api_key_type)
|
@@ -221,17 +235,17 @@ class VectorVeinClient:
|
|
221
235
|
def get_access_keys(
|
222
236
|
self, access_keys: Optional[List[str]] = None, get_type: Literal["selected", "all"] = "selected"
|
223
237
|
) -> List[AccessKey]:
|
224
|
-
"""
|
238
|
+
"""Get access key information
|
225
239
|
|
226
240
|
Args:
|
227
|
-
access_keys:
|
228
|
-
get_type:
|
241
|
+
access_keys: Access key list
|
242
|
+
get_type: Get type, optional values: 'selected' or 'all'
|
229
243
|
|
230
244
|
Returns:
|
231
|
-
List[AccessKey]:
|
245
|
+
List[AccessKey]: Access key information list
|
232
246
|
|
233
247
|
Raises:
|
234
|
-
AccessKeyError:
|
248
|
+
AccessKeyError: Access key does not exist or has expired
|
235
249
|
"""
|
236
250
|
params = {"get_type": get_type}
|
237
251
|
if access_keys:
|
@@ -242,9 +256,9 @@ class VectorVeinClient:
|
|
242
256
|
return [AccessKey(**key) for key in result["data"]]
|
243
257
|
except VectorVeinAPIError as e:
|
244
258
|
if e.status_code == 404:
|
245
|
-
raise AccessKeyError("
|
259
|
+
raise AccessKeyError("Access key does not exist")
|
246
260
|
elif e.status_code == 403:
|
247
|
-
raise AccessKeyError("
|
261
|
+
raise AccessKeyError("Access key has expired")
|
248
262
|
raise
|
249
263
|
|
250
264
|
def create_access_keys(
|
@@ -258,29 +272,29 @@ class VectorVeinClient:
|
|
258
272
|
max_use_count: Optional[int] = None,
|
259
273
|
description: Optional[str] = None,
|
260
274
|
) -> List[AccessKey]:
|
261
|
-
"""
|
275
|
+
"""Create access key
|
262
276
|
|
263
277
|
Args:
|
264
|
-
access_key_type:
|
265
|
-
app_id:
|
266
|
-
app_ids:
|
267
|
-
count:
|
268
|
-
expire_time:
|
269
|
-
max_credits:
|
270
|
-
max_use_count:
|
271
|
-
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
|
272
286
|
|
273
287
|
Returns:
|
274
|
-
List[AccessKey]:
|
288
|
+
List[AccessKey]: Created access key list
|
275
289
|
|
276
290
|
Raises:
|
277
|
-
AccessKeyError:
|
291
|
+
AccessKeyError: Failed to create access key, such as invalid type, application does not exist, etc.
|
278
292
|
"""
|
279
293
|
if access_key_type not in ["O", "M", "L"]:
|
280
|
-
raise AccessKeyError("
|
294
|
+
raise AccessKeyError("Invalid access key type, must be 'O'(one-time)、'M'(multiple) or 'L'(long-term)")
|
281
295
|
|
282
296
|
if app_id and app_ids:
|
283
|
-
raise AccessKeyError("
|
297
|
+
raise AccessKeyError("Cannot specify both app_id and app_ids")
|
284
298
|
|
285
299
|
payload = {"access_key_type": access_key_type, "count": count}
|
286
300
|
|
@@ -302,9 +316,9 @@ class VectorVeinClient:
|
|
302
316
|
return [AccessKey(**key) for key in result["data"]]
|
303
317
|
except VectorVeinAPIError as e:
|
304
318
|
if e.status_code == 404:
|
305
|
-
raise AccessKeyError("
|
319
|
+
raise AccessKeyError("The specified application does not exist")
|
306
320
|
elif e.status_code == 403:
|
307
|
-
raise AccessKeyError("
|
321
|
+
raise AccessKeyError("No permission to create access key")
|
308
322
|
raise
|
309
323
|
|
310
324
|
def list_access_keys(
|
@@ -317,19 +331,19 @@ class VectorVeinClient:
|
|
317
331
|
status: Optional[List[str]] = None,
|
318
332
|
access_key_type: Optional[Literal["O", "M", "L"]] = None,
|
319
333
|
) -> AccessKeyListResponse:
|
320
|
-
"""
|
334
|
+
"""List access keys
|
321
335
|
|
322
336
|
Args:
|
323
|
-
page:
|
324
|
-
page_size:
|
325
|
-
sort_field:
|
326
|
-
sort_order:
|
327
|
-
app_id:
|
328
|
-
status:
|
329
|
-
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)
|
330
344
|
|
331
345
|
Returns:
|
332
|
-
AccessKeyListResponse:
|
346
|
+
AccessKeyListResponse: Access key list response
|
333
347
|
"""
|
334
348
|
payload = {"page": page, "page_size": page_size, "sort_field": sort_field, "sort_order": sort_order}
|
335
349
|
|
@@ -344,11 +358,11 @@ class VectorVeinClient:
|
|
344
358
|
return AccessKeyListResponse(**result["data"])
|
345
359
|
|
346
360
|
def delete_access_keys(self, app_id: str, access_keys: List[str]) -> None:
|
347
|
-
"""
|
361
|
+
"""Delete access key
|
348
362
|
|
349
363
|
Args:
|
350
|
-
app_id:
|
351
|
-
access_keys:
|
364
|
+
app_id: Application ID
|
365
|
+
access_keys: List of access keys to delete
|
352
366
|
"""
|
353
367
|
payload = {"app_id": app_id, "access_keys": access_keys}
|
354
368
|
self._request("POST", "vapp/access-key/delete", json=payload)
|
@@ -365,18 +379,18 @@ class VectorVeinClient:
|
|
365
379
|
description: Optional[str] = None,
|
366
380
|
access_key_type: Optional[Literal["O", "M", "L"]] = None,
|
367
381
|
) -> None:
|
368
|
-
"""
|
382
|
+
"""Update access key
|
369
383
|
|
370
384
|
Args:
|
371
|
-
access_key:
|
372
|
-
access_keys:
|
373
|
-
app_id:
|
374
|
-
app_ids:
|
375
|
-
expire_time:
|
376
|
-
max_use_count:
|
377
|
-
max_credits:
|
378
|
-
description:
|
379
|
-
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)
|
380
394
|
"""
|
381
395
|
payload = {}
|
382
396
|
if access_key:
|
@@ -401,21 +415,21 @@ class VectorVeinClient:
|
|
401
415
|
self._request("POST", "vapp/access-key/update", json=payload)
|
402
416
|
|
403
417
|
def add_apps_to_access_keys(self, access_keys: List[str], app_ids: List[str]) -> None:
|
404
|
-
"""
|
418
|
+
"""Add applications to access keys
|
405
419
|
|
406
420
|
Args:
|
407
|
-
access_keys:
|
408
|
-
app_ids:
|
421
|
+
access_keys: Access key list
|
422
|
+
app_ids: List of application IDs to add
|
409
423
|
"""
|
410
424
|
payload = {"access_keys": access_keys, "app_ids": app_ids}
|
411
425
|
self._request("POST", "vapp/access-key/add-apps", json=payload)
|
412
426
|
|
413
427
|
def remove_apps_from_access_keys(self, access_keys: List[str], app_ids: List[str]) -> None:
|
414
|
-
"""
|
428
|
+
"""Remove applications from access keys
|
415
429
|
|
416
430
|
Args:
|
417
|
-
access_keys:
|
418
|
-
app_ids:
|
431
|
+
access_keys: Access key list
|
432
|
+
app_ids: List of application IDs to remove
|
419
433
|
"""
|
420
434
|
payload = {"access_keys": access_keys, "app_ids": app_ids}
|
421
435
|
self._request("POST", "vapp/access-key/remove-apps", json=payload)
|
@@ -428,17 +442,17 @@ class VectorVeinClient:
|
|
428
442
|
timeout: int = 15 * 60,
|
429
443
|
base_url: str = "https://vectorvein.com",
|
430
444
|
) -> str:
|
431
|
-
"""
|
445
|
+
"""Generate VApp access link
|
432
446
|
|
433
447
|
Args:
|
434
448
|
app_id: VApp ID
|
435
|
-
access_key:
|
436
|
-
key_id:
|
437
|
-
timeout:
|
438
|
-
base_url:
|
449
|
+
access_key: Access key
|
450
|
+
key_id: Key ID
|
451
|
+
timeout: Timeout (seconds)
|
452
|
+
base_url: Base URL
|
439
453
|
|
440
454
|
Returns:
|
441
|
-
str: VApp
|
455
|
+
str: VApp access link
|
442
456
|
"""
|
443
457
|
timestamp = int(time.time())
|
444
458
|
message = f"{app_id}:{access_key}:{timestamp}:{timeout}"
|
@@ -455,23 +469,23 @@ class VectorVeinClient:
|
|
455
469
|
|
456
470
|
|
457
471
|
class AsyncVectorVeinClient:
|
458
|
-
"""
|
472
|
+
"""VectorVein API Async Client"""
|
459
473
|
|
460
474
|
API_VERSION = "20240508"
|
461
475
|
BASE_URL = "https://vectorvein.com/api/v1/open-api"
|
462
476
|
|
463
477
|
def __init__(self, api_key: str, base_url: Optional[str] = None):
|
464
|
-
"""
|
478
|
+
"""Initialize the async client
|
465
479
|
|
466
480
|
Args:
|
467
|
-
api_key: API
|
468
|
-
base_url: API
|
481
|
+
api_key: API key
|
482
|
+
base_url: API base URL, default is https://vectorvein.com/api/v1/open-api
|
469
483
|
|
470
484
|
Raises:
|
471
|
-
APIKeyError: API
|
485
|
+
APIKeyError: API key is empty or not a string
|
472
486
|
"""
|
473
487
|
if not api_key or not isinstance(api_key, str):
|
474
|
-
raise APIKeyError("API
|
488
|
+
raise APIKeyError("API key cannot be empty and must be a string type")
|
475
489
|
|
476
490
|
self.api_key = api_key
|
477
491
|
self.base_url = base_url or self.BASE_URL
|
@@ -496,22 +510,22 @@ class AsyncVectorVeinClient:
|
|
496
510
|
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
497
511
|
**kwargs,
|
498
512
|
) -> Dict[str, Any]:
|
499
|
-
"""
|
513
|
+
"""Send asynchronous HTTP request
|
500
514
|
|
501
515
|
Args:
|
502
|
-
method: HTTP
|
503
|
-
endpoint: API
|
504
|
-
params: URL
|
505
|
-
json: JSON
|
506
|
-
**kwargs:
|
516
|
+
method: HTTP method
|
517
|
+
endpoint: API endpoint
|
518
|
+
params: URL parameters
|
519
|
+
json: JSON request body
|
520
|
+
**kwargs: Other request parameters
|
507
521
|
|
508
522
|
Returns:
|
509
|
-
Dict[str, Any]: API
|
523
|
+
Dict[str, Any]: API response
|
510
524
|
|
511
525
|
Raises:
|
512
|
-
RequestError:
|
513
|
-
VectorVeinAPIError: API
|
514
|
-
APIKeyError: API
|
526
|
+
RequestError: Request error
|
527
|
+
VectorVeinAPIError: API error
|
528
|
+
APIKeyError: API key is invalid or expired
|
515
529
|
"""
|
516
530
|
url = f"{self.base_url}/{endpoint}"
|
517
531
|
headers = self.default_headers.copy()
|
@@ -526,11 +540,10 @@ class AsyncVectorVeinClient:
|
|
526
540
|
headers=headers,
|
527
541
|
**kwargs,
|
528
542
|
)
|
529
|
-
response.raise_for_status()
|
530
543
|
result = response.json()
|
531
544
|
|
532
545
|
if result["status"] in [401, 403]:
|
533
|
-
raise APIKeyError("API
|
546
|
+
raise APIKeyError("API key is invalid or expired")
|
534
547
|
if result["status"] != 200 and result["status"] != 202:
|
535
548
|
raise VectorVeinAPIError(message=result.get("msg", "Unknown error"), status_code=result["status"])
|
536
549
|
return result
|
@@ -568,22 +581,22 @@ class AsyncVectorVeinClient:
|
|
568
581
|
api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW",
|
569
582
|
timeout: int = 30,
|
570
583
|
) -> Union[str, WorkflowRunResult]:
|
571
|
-
"""
|
584
|
+
"""Async run workflow
|
572
585
|
|
573
586
|
Args:
|
574
|
-
wid:
|
575
|
-
input_fields:
|
576
|
-
output_scope:
|
577
|
-
wait_for_completion:
|
578
|
-
api_key_type:
|
579
|
-
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)
|
580
593
|
|
581
594
|
Returns:
|
582
|
-
Union[str, WorkflowRunResult]:
|
595
|
+
Union[str, WorkflowRunResult]: Workflow run ID or run result
|
583
596
|
|
584
597
|
Raises:
|
585
|
-
WorkflowError:
|
586
|
-
TimeoutError:
|
598
|
+
WorkflowError: Workflow run error
|
599
|
+
TimeoutError: Timeout error
|
587
600
|
"""
|
588
601
|
payload = {
|
589
602
|
"wid": wid,
|
@@ -618,20 +631,32 @@ class AsyncVectorVeinClient:
|
|
618
631
|
|
619
632
|
await asyncio.sleep(5)
|
620
633
|
|
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
|
+
|
621
644
|
async def check_workflow_status(
|
622
645
|
self, rid: str, wid: Optional[str] = None, api_key_type: Literal["WORKFLOW", "VAPP"] = "WORKFLOW"
|
623
646
|
) -> WorkflowRunResult:
|
624
|
-
"""
|
647
|
+
"""Async check workflow run status
|
625
648
|
|
626
649
|
Args:
|
627
|
-
rid:
|
628
|
-
wid:
|
629
|
-
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'
|
630
653
|
|
631
|
-
|
632
|
-
|
654
|
+
Raises:
|
655
|
+
VectorVeinAPIError: Workflow error
|
633
656
|
"""
|
634
657
|
payload = {"rid": rid}
|
658
|
+
if api_key_type == "VAPP" and not wid:
|
659
|
+
raise VectorVeinAPIError("Workflow ID cannot be empty when api_key_type is 'VAPP'")
|
635
660
|
if wid:
|
636
661
|
payload["wid"] = wid
|
637
662
|
response = await self._request("POST", "workflow/check-status", json=payload, api_key_type=api_key_type)
|
@@ -648,17 +673,17 @@ class AsyncVectorVeinClient:
|
|
648
673
|
async def get_access_keys(
|
649
674
|
self, access_keys: Optional[List[str]] = None, get_type: Literal["selected", "all"] = "selected"
|
650
675
|
) -> List[AccessKey]:
|
651
|
-
"""
|
676
|
+
"""Async get access key information
|
652
677
|
|
653
678
|
Args:
|
654
|
-
access_keys:
|
655
|
-
get_type:
|
679
|
+
access_keys: Access key list
|
680
|
+
get_type: Get type, optional values: 'selected' or 'all'
|
656
681
|
|
657
682
|
Returns:
|
658
|
-
List[AccessKey]:
|
683
|
+
List[AccessKey]: Access key information list
|
659
684
|
|
660
685
|
Raises:
|
661
|
-
AccessKeyError:
|
686
|
+
AccessKeyError: Access key does not exist or has expired
|
662
687
|
"""
|
663
688
|
params = {"get_type": get_type}
|
664
689
|
if access_keys:
|
@@ -669,9 +694,9 @@ class AsyncVectorVeinClient:
|
|
669
694
|
return [AccessKey(**key) for key in result["data"]]
|
670
695
|
except VectorVeinAPIError as e:
|
671
696
|
if e.status_code == 404:
|
672
|
-
raise AccessKeyError("
|
697
|
+
raise AccessKeyError("Access key does not exist")
|
673
698
|
elif e.status_code == 403:
|
674
|
-
raise AccessKeyError("
|
699
|
+
raise AccessKeyError("Access key has expired")
|
675
700
|
raise
|
676
701
|
|
677
702
|
async def create_access_keys(
|
@@ -685,29 +710,29 @@ class AsyncVectorVeinClient:
|
|
685
710
|
max_use_count: Optional[int] = None,
|
686
711
|
description: Optional[str] = None,
|
687
712
|
) -> List[AccessKey]:
|
688
|
-
"""
|
713
|
+
"""Async create access key
|
689
714
|
|
690
715
|
Args:
|
691
|
-
access_key_type:
|
692
|
-
app_id:
|
693
|
-
app_ids:
|
694
|
-
count:
|
695
|
-
expire_time:
|
696
|
-
max_credits:
|
697
|
-
max_use_count:
|
698
|
-
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
|
699
724
|
|
700
725
|
Returns:
|
701
|
-
List[AccessKey]:
|
726
|
+
List[AccessKey]: Created access key list
|
702
727
|
|
703
728
|
Raises:
|
704
|
-
AccessKeyError:
|
729
|
+
AccessKeyError: Failed to create access key, such as invalid type, application does not exist, etc.
|
705
730
|
"""
|
706
731
|
if access_key_type not in ["O", "M", "L"]:
|
707
|
-
raise AccessKeyError("
|
732
|
+
raise AccessKeyError("Invalid access key type, must be 'O'(one-time) or 'M'(multiple) or 'L'(long-term)")
|
708
733
|
|
709
734
|
if app_id and app_ids:
|
710
|
-
raise AccessKeyError("
|
735
|
+
raise AccessKeyError("Cannot specify both app_id and app_ids")
|
711
736
|
|
712
737
|
payload = {"access_key_type": access_key_type, "count": count}
|
713
738
|
|
@@ -729,9 +754,9 @@ class AsyncVectorVeinClient:
|
|
729
754
|
return [AccessKey(**key) for key in result["data"]]
|
730
755
|
except VectorVeinAPIError as e:
|
731
756
|
if e.status_code == 404:
|
732
|
-
raise AccessKeyError("
|
757
|
+
raise AccessKeyError("The specified application does not exist")
|
733
758
|
elif e.status_code == 403:
|
734
|
-
raise AccessKeyError("
|
759
|
+
raise AccessKeyError("No permission to create access key")
|
735
760
|
raise
|
736
761
|
|
737
762
|
async def list_access_keys(
|
@@ -744,19 +769,19 @@ class AsyncVectorVeinClient:
|
|
744
769
|
status: Optional[List[str]] = None,
|
745
770
|
access_key_type: Optional[Literal["O", "M", "L"]] = None,
|
746
771
|
) -> AccessKeyListResponse:
|
747
|
-
"""
|
772
|
+
"""Async list access keys
|
748
773
|
|
749
774
|
Args:
|
750
|
-
page:
|
751
|
-
page_size:
|
752
|
-
sort_field:
|
753
|
-
sort_order:
|
754
|
-
app_id:
|
755
|
-
status:
|
756
|
-
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)
|
757
782
|
|
758
783
|
Returns:
|
759
|
-
AccessKeyListResponse:
|
784
|
+
AccessKeyListResponse: Access key list response
|
760
785
|
"""
|
761
786
|
payload = {"page": page, "page_size": page_size, "sort_field": sort_field, "sort_order": sort_order}
|
762
787
|
|
@@ -771,11 +796,11 @@ class AsyncVectorVeinClient:
|
|
771
796
|
return AccessKeyListResponse(**result["data"])
|
772
797
|
|
773
798
|
async def delete_access_keys(self, app_id: str, access_keys: List[str]) -> None:
|
774
|
-
"""
|
799
|
+
"""Async delete access key
|
775
800
|
|
776
801
|
Args:
|
777
|
-
app_id:
|
778
|
-
access_keys:
|
802
|
+
app_id: Application ID
|
803
|
+
access_keys: List of access keys to delete
|
779
804
|
"""
|
780
805
|
payload = {"app_id": app_id, "access_keys": access_keys}
|
781
806
|
await self._request("POST", "vapp/access-key/delete", json=payload)
|
@@ -792,18 +817,18 @@ class AsyncVectorVeinClient:
|
|
792
817
|
description: Optional[str] = None,
|
793
818
|
access_key_type: Optional[Literal["O", "M", "L"]] = None,
|
794
819
|
) -> None:
|
795
|
-
"""
|
820
|
+
"""Async update access key
|
796
821
|
|
797
822
|
Args:
|
798
|
-
access_key:
|
799
|
-
access_keys:
|
800
|
-
app_id:
|
801
|
-
app_ids:
|
802
|
-
expire_time:
|
803
|
-
max_use_count:
|
804
|
-
max_credits:
|
805
|
-
description:
|
806
|
-
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)
|
807
832
|
"""
|
808
833
|
payload = {}
|
809
834
|
if access_key:
|
@@ -828,21 +853,21 @@ class AsyncVectorVeinClient:
|
|
828
853
|
await self._request("POST", "vapp/access-key/update", json=payload)
|
829
854
|
|
830
855
|
async def add_apps_to_access_keys(self, access_keys: List[str], app_ids: List[str]) -> None:
|
831
|
-
"""
|
856
|
+
"""Async add applications to access keys
|
832
857
|
|
833
858
|
Args:
|
834
|
-
access_keys:
|
835
|
-
app_ids:
|
859
|
+
access_keys: Access key list
|
860
|
+
app_ids: List of application IDs to add
|
836
861
|
"""
|
837
862
|
payload = {"access_keys": access_keys, "app_ids": app_ids}
|
838
863
|
await self._request("POST", "vapp/access-key/add-apps", json=payload)
|
839
864
|
|
840
865
|
async def remove_apps_from_access_keys(self, access_keys: List[str], app_ids: List[str]) -> None:
|
841
|
-
"""
|
866
|
+
"""Async remove applications from access keys
|
842
867
|
|
843
868
|
Args:
|
844
|
-
access_keys:
|
845
|
-
app_ids:
|
869
|
+
access_keys: Access key list
|
870
|
+
app_ids: List of application IDs to remove
|
846
871
|
"""
|
847
872
|
payload = {"access_keys": access_keys, "app_ids": app_ids}
|
848
873
|
await self._request("POST", "vapp/access-key/remove-apps", json=payload)
|
@@ -855,17 +880,17 @@ class AsyncVectorVeinClient:
|
|
855
880
|
timeout: int = 15 * 60,
|
856
881
|
base_url: str = "https://vectorvein.com",
|
857
882
|
) -> str:
|
858
|
-
"""
|
883
|
+
"""Async generate VApp access link
|
859
884
|
|
860
885
|
Args:
|
861
886
|
app_id: VApp ID
|
862
|
-
access_key:
|
863
|
-
key_id:
|
864
|
-
timeout:
|
865
|
-
base_url:
|
887
|
+
access_key: Access key
|
888
|
+
key_id: Key ID
|
889
|
+
timeout: Timeout (seconds)
|
890
|
+
base_url: Base URL
|
866
891
|
|
867
892
|
Returns:
|
868
|
-
str: VApp
|
893
|
+
str: VApp access link
|
869
894
|
"""
|
870
895
|
timestamp = int(time.time())
|
871
896
|
message = f"{app_id}:{access_key}:{timestamp}:{timeout}"
|
@@ -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
|
@@ -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
|
+
)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{vectorvein-0.2.3 → vectorvein-0.2.5}/src/vectorvein/chat_clients/openai_compatible_client.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|