vectorvein 0.2.3__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 CHANGED
@@ -1,4 +1,4 @@
1
- """向量脉络 API 客户端"""
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
- """向量脉络 API 客户端类"""
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基础URL,默认为https://vectorvein.com/api/v1/open-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
- """发送HTTP请求
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: 工作流ID
148
- input_fields: 输入字段列表
149
- output_scope: 输出范围,可选值:'all' 'output_fields_only'
150
- wait_for_completion: 是否等待完成
151
- api_key_type: 密钥类型,可选值:'WORKFLOW' 'VAPP'
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]: 工作流运行ID或运行结果
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: 工作流运行记录ID
201
- wid: 工作流ID,非必填
202
- api_key_type: 密钥类型,可选值:'WORKFLOW' 'VAPP'
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: 获取类型,可选值:'selected' 'all'
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: 密钥类型,可选值:'O'(一次性)、'M'(多次)、'L'(长期)
265
- app_id: 单个应用ID
266
- app_ids: 多个应用ID列表
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("无效的访问密钥类型,必须是 'O'(一次性)、'M'(多次) 'L'(长期)")
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("不能同时指定 app_id app_ids")
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: 应用ID
328
- status: 状态列表
329
- access_key_type: 密钥类型列表,可选值:'O'(一次性)、'M'(多次)、'L'(长期)
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: 应用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: 单个应用ID
374
- app_ids: 多个应用ID列表
375
- expire_time: 过期时间
376
- max_use_count: 最大使用次数
377
- max_credits: 最大积分限制
378
- description: 描述信息
379
- access_key_type: 密钥类型,可选值:'O'(一次性)、'M'(多次)、'L'(长期)
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: 要添加的应用ID列表
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: 要移除的应用ID列表
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
- """生成VApp访问链接
445
+ """Generate VApp access link
432
446
 
433
447
  Args:
434
448
  app_id: VApp ID
435
- access_key: 访问密钥
436
- key_id: 密钥ID
437
- timeout: 超时时间(秒)
438
- base_url: 基础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
- """向量脉络 API 异步客户端类"""
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基础URL,默认为https://vectorvein.com/api/v1/open-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
- """发送异步HTTP请求
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: 工作流ID
575
- input_fields: 输入字段列表
576
- output_scope: 输出范围,可选值:'all' 'output_fields_only'
577
- wait_for_completion: 是否等待完成
578
- api_key_type: 密钥类型,可选值:'WORKFLOW' 'VAPP'
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]: 工作流运行ID或运行结果
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: 工作流运行记录ID
628
- wid: 工作流ID,非必填
629
- api_key_type: 密钥类型,可选值:'WORKFLOW' 'VAPP'
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
- Returns:
632
- WorkflowRunResult: 工作流运行结果
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: 获取类型,可选值:'selected' 'all'
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: 密钥类型,可选值:'O'(一次性)、'M'(多次)、'L'(长期)
692
- app_id: 单个应用ID
693
- app_ids: 多个应用ID列表
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("无效的访问密钥类型,必须是 'O'(一次性)'M'(多次) 'L'(长期)")
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("不能同时指定 app_id app_ids")
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: 应用ID
755
- status: 状态列表
756
- access_key_type: 密钥类型列表,可选值:'O'(一次性)、'M'(多次)、'L'(长期)
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: 应用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: 单个应用ID
801
- app_ids: 多个应用ID列表
802
- expire_time: 过期时间
803
- max_use_count: 最大使用次数
804
- max_credits: 最大积分限制
805
- description: 描述信息
806
- access_key_type: 密钥类型,可选值:'O'(一次性)、'M'(多次)、'L'(长期)
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: 要添加的应用ID列表
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: 要移除的应用ID列表
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
- """异步生成VApp访问链接
883
+ """Async generate VApp access link
859
884
 
860
885
  Args:
861
886
  app_id: VApp ID
862
- access_key: 访问密钥
863
- key_id: 密钥ID
864
- timeout: 超时时间(秒)
865
- base_url: 基础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
- """向量脉络 API 异常类定义"""
1
+ """VectorVein API Exception Definitions"""
2
2
 
3
3
  from typing import Optional
4
4
 
5
5
 
6
6
  class VectorVeinAPIError(Exception):
7
- """向量脉络 API 基础异常类"""
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
- """向量脉络 API 数据模型定义"""
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: 一次性, M: 多次, L: 长期
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: 有效, IN: 无效, EX: 已过期, US: 已使用
32
- access_scope: str # S: 单应用, M: 多应用
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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vectorvein
3
- Version: 0.2.3
3
+ Version: 0.2.5
4
4
  Summary: VectorVein python SDK
5
5
  Author-Email: Anderson <andersonby@163.com>
6
6
  License: MIT
@@ -1,11 +1,11 @@
1
- vectorvein-0.2.3.dist-info/METADATA,sha256=c-trHoS2s_Hz1zCnciGNk6AdPwlNWZp0PBxzNaRCdhg,4413
2
- vectorvein-0.2.3.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
- vectorvein-0.2.3.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
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=C0TvmjzvZjYz9IpvDwGx5nMQzR9GyTJEU7aav4epeBc,31710
7
- vectorvein/api/exceptions.py,sha256=btfeXfNfc7zLykMKklpJePLnmJie5YSxCYHyMReCC9s,751
8
- vectorvein/api/models.py,sha256=z5MeXMxWFHlNkP5vjVz6gEn5cxD1FbQ8pQvbx9KtgkE,1422
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=cfepHoy8JaFDqWLUzl6lmlDlKaH0vk1gWQSm7T0wmn8,7503
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.3.dist-info/RECORD,,
62
+ vectorvein-0.2.5.dist-info/RECORD,,