volcengine-python-sdk 5.0.28__py2.py3-none-any.whl → 5.0.29__py2.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: volcengine-python-sdk
3
- Version: 5.0.28
3
+ Version: 5.0.29
4
4
  Summary: Volcengine SDK for Python
5
5
  Home-page: https://github.com/volcengine/volcengine-python-sdk
6
6
  Author-email: volc-engine <volc-sdk-team@bytedance.com>
@@ -1,5 +1,5 @@
1
- volcengine_python_sdk-5.0.28.dist-info/licenses/LICENSE.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
2
- volcengine_python_sdk-5.0.28.dist-info/licenses/NOTICE.md,sha256=dqWX0O4-gFqGLdHJsXAiF6Q8JHlu_3nFaQSmrMHzujM,254
1
+ volcengine_python_sdk-5.0.29.dist-info/licenses/LICENSE.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
2
+ volcengine_python_sdk-5.0.29.dist-info/licenses/NOTICE.md,sha256=dqWX0O4-gFqGLdHJsXAiF6Q8JHlu_3nFaQSmrMHzujM,254
3
3
  volcenginesdkacep/__init__.py,sha256=GZCeL2Dsp5v1XblcgInhNJzKW7X37XxrpMIE2Q3VL-c,31200
4
4
  volcenginesdkacep/api/__init__.py,sha256=MCzGEBg4XwY5aDIDy8nitUz4vu_2xmRRY83V6lqt460,138
5
5
  volcenginesdkacep/api/acep_api.py,sha256=ollQvh5qkrmNbENVBBh2JRha9aGDMUwtO7V6Q1A3-Js,410621
@@ -5321,8 +5321,8 @@ volcenginesdkconfig/models/update_rule_response.py,sha256=f16EgPddqWulPRT1Yw225x
5321
5321
  volcenginesdkconfig/models/update_rule_template_request.py,sha256=k4JyMyOEhL8Zvg9N6siac_6MlcB38ZoDeKfx5uVV4xo,10129
5322
5322
  volcenginesdkconfig/models/update_rule_template_response.py,sha256=eiATOg0bsvElLzs-K0Jt8x8k4JaLxlXUcsg3toMteCM,2814
5323
5323
  volcenginesdkcore/__init__.py,sha256=WkgQAEhL6zg4ofQI82LD-3K-ij28yT-lpMiDoKmppwM,318
5324
- volcenginesdkcore/api_client.py,sha256=-DDGRzXZglw7Kx2hKoF5J-SZ8aLH-DSARL51akr5lfs,29339
5325
- volcenginesdkcore/configuration.py,sha256=7nqeVP0qPVMopRxaGPxK9zk2Vv1bUo8BVEw0gLsAnIw,12082
5324
+ volcenginesdkcore/api_client.py,sha256=EUSW7Q2HgutLsZGGzKFLOnahDNgVbSx6zXsTeBTjf3c,29339
5325
+ volcenginesdkcore/configuration.py,sha256=P847DktE7lDkrekY9PevLZ2UKGcqgvlM0f5Cl4DcfPY,12082
5326
5326
  volcenginesdkcore/flatten.py,sha256=g3r61JS_AO7WV6ClRDkXgtnVXcw3c7tbZjeLAJxkSLc,3811
5327
5327
  volcenginesdkcore/metadata.py,sha256=lHsOz9JcwdM7oqBb5dhSl6z3qF-M3TnTFbCzxRV89f4,4529
5328
5328
  volcenginesdkcore/model.py,sha256=f3cvQ6QiQfecClucu-_-l5xVI3W5_vF-EKkjwZu7Vjc,177
@@ -12438,9 +12438,9 @@ volcenginesdkllmscan/models/update_model_request.py,sha256=eI1ArAPIdVQSl0qOVirT8
12438
12438
  volcenginesdkllmscan/models/update_model_response.py,sha256=ktFFthWDmELTOvnvZuC83mOE14Ln1Y8QiPjLlHwjCVQ,3448
12439
12439
  volcenginesdkllmscan/models/update_time_for_list_agent_input.py,sha256=sFVS6AZYhPiFdBSnVPu3hHDQ9XmHMLPlhiAmifq-jp4,4292
12440
12440
  volcenginesdkllmscan/models/update_time_for_list_model_application_input.py,sha256=RPpDUd5xbHofzWr7FYvDBX4hqsinx9GyZqBpBYQ05FI,4435
12441
- volcenginesdkllmshield/__init__.py,sha256=wzsglE_PsOzewQxicaK_IX7RqPbO1-RkP3Nw-FTjWpc,1883
12441
+ volcenginesdkllmshield/__init__.py,sha256=a5taqFNnotoKq3ld8kLzR8SrbOD301viRYgbR-Z79mA,1991
12442
12442
  volcenginesdkllmshield/api/__init__.py,sha256=di_9IIKQ0HCuzkGrTyZ6h38iP7y1xelH8_IJbKi4aWA,71
12443
- volcenginesdkllmshield/api/llm_shield_sdk_v2.py,sha256=rFw9te6cR7Jd8jQ354UTMK_H95xQtjjZZNBj284M_9c,18637
12443
+ volcenginesdkllmshield/api/llm_shield_sdk_v2.py,sha256=gRUq6_fUKrnV8IUprknCXAc_Hbc5yRLAynimvCyjuhg,19567
12444
12444
  volcenginesdkllmshield/models/__init__.py,sha256=OpEdwHNrJ0rcWEdVt0Km58pboIBWP4WYA8zv2LhzzWc,259
12445
12445
  volcenginesdkllmshield/models/llm_shield_sign.py,sha256=LUwWZdkWXa2O0s-DYBSQtGqGBSdRGTp5JSwUb7vakps,5955
12446
12446
  volcenginesdkmcdn/__init__.py,sha256=T6n7RhmCZfockyBT_7tbkB5Zb7moirVG3hC_l6lgUbw,19051
@@ -21779,7 +21779,7 @@ volcenginesdkwafruntime/api/__init__.py,sha256=di_9IIKQ0HCuzkGrTyZ6h38iP7y1xelH8
21779
21779
  volcenginesdkwafruntime/api/waf_runtime_api.py,sha256=eWgdzFcwflEkhkNrPzZL1mqSid7O1OWiwHGUyWJvZNA,4035
21780
21780
  volcenginesdkwafruntime/models/__init__.py,sha256=di_9IIKQ0HCuzkGrTyZ6h38iP7y1xelH8_IJbKi4aWA,71
21781
21781
  volcenginesdkwafruntime/models/llm_stream_session.py,sha256=U9cig3fuZRBT4Ov8_cUsWDKXcMLNjBDxKt-7IoewoUw,1589
21782
- volcengine_python_sdk-5.0.28.dist-info/METADATA,sha256=5J8VAiCeSkCLypH59eWlqgYOZN5XPUS3_bDXviGGS10,8435
21783
- volcengine_python_sdk-5.0.28.dist-info/WHEEL,sha256=Mk1ST5gDzEO5il5kYREiBnzzM469m5sI8ESPl7TRhJY,110
21784
- volcengine_python_sdk-5.0.28.dist-info/top_level.txt,sha256=5WqcZekpvUb3i18eYFJiDRtYbyhhcc18vhyo3Nf91wM,2795
21785
- volcengine_python_sdk-5.0.28.dist-info/RECORD,,
21782
+ volcengine_python_sdk-5.0.29.dist-info/METADATA,sha256=trcZH5qsJ4LYWxXv3k_E9gEu2bKpBTJuEC0lKzBF8Lc,8435
21783
+ volcengine_python_sdk-5.0.29.dist-info/WHEEL,sha256=TdQ5LtNwLuxTCjgxN51AgdU5w-KkB9ttmLbzjTH02pg,109
21784
+ volcengine_python_sdk-5.0.29.dist-info/top_level.txt,sha256=5WqcZekpvUb3i18eYFJiDRtYbyhhcc18vhyo3Nf91wM,2795
21785
+ volcengine_python_sdk-5.0.29.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.10.2)
2
+ Generator: setuptools (82.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any
@@ -69,7 +69,7 @@ class ApiClient(object):
69
69
  self.default_headers[header_name] = header_value
70
70
  self.cookie = cookie
71
71
  # Set default User-Agent.
72
- self.user_agent = 'volcstack-python-sdk/5.0.28'
72
+ self.user_agent = 'volcstack-python-sdk/5.0.29'
73
73
  self.client_side_validation = configuration.client_side_validation
74
74
 
75
75
  self.interceptor_chain = InterceptorChain()
@@ -291,7 +291,7 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
291
291
  "OS: {env}\n" \
292
292
  "Python Version: {pyversion}\n" \
293
293
  "Version of the API: 0.1.0\n" \
294
- "SDK Package Version: 5.0.28".\
294
+ "SDK Package Version: 5.0.29".\
295
295
  format(env=sys.platform, pyversion=sys.version)
296
296
 
297
297
  @property
@@ -21,7 +21,10 @@ from volcenginesdkllmshield.api.llm_shield_sdk_v2 import (
21
21
  DecisionTypeV2,
22
22
  UserAction,
23
23
  MatchSource,
24
+ ExtensionsKey,
24
25
  MultiPart,
26
+ FunctionCall,
27
+ ToolCall,
25
28
  MessageV2,
26
29
  ModerateV2Request,
27
30
  RiskMatchV2,
@@ -58,8 +61,11 @@ __all__ = [
58
61
  'DecisionTypeV2',
59
62
  'UserAction',
60
63
  'MatchSource',
64
+ 'ExtensionsKey',
61
65
  # 数据模型
62
66
  'MultiPart',
67
+ 'FunctionCall',
68
+ 'ToolCall',
63
69
  'MessageV2',
64
70
  'ModerateV2Request',
65
71
  'RiskMatchV2',
@@ -1,5 +1,5 @@
1
1
  from pydantic import BaseModel, field_validator, Field
2
- from typing import List, Optional, Any, Union
2
+ from typing import Dict, List, Optional, Any, Union
3
3
  from datetime import datetime, date
4
4
  from uuid import UUID
5
5
  import requests
@@ -46,6 +46,15 @@ class MatchSource:
46
46
  USER_CONTENTLIB = 3
47
47
 
48
48
 
49
+ # 定义扩展字段Key常量
50
+ class ExtensionsKey:
51
+ USER_ID = "user_id"
52
+ RUN_ID = "run_id"
53
+ SESSION_ID = "session_id"
54
+ CONTEXT_ID = "context_id"
55
+ HOOK_NAME = "hook_name"
56
+
57
+
49
58
  # 定义消息结构体
50
59
  class MultiPart(BaseModel):
51
60
  content: str = Field("", alias="Content")
@@ -55,12 +64,33 @@ class MultiPart(BaseModel):
55
64
  populate_by_name = True
56
65
 
57
66
 
67
+ # 定义函数调用结构体
68
+ class FunctionCall(BaseModel):
69
+ name: str = Field("", alias="Name")
70
+ arguments: str = Field("", alias="Arguments")
71
+
72
+ class Config:
73
+ populate_by_name = True
74
+
75
+
76
+ # 定义工具调用结构体
77
+ class ToolCall(BaseModel):
78
+ id: str = Field("", alias="ID")
79
+ type: str = Field("", alias="Type")
80
+ function: Optional[FunctionCall] = Field(None, alias="Function")
81
+
82
+ class Config:
83
+ populate_by_name = True
84
+
85
+
58
86
  # 定义消息结构体
59
87
  class MessageV2(BaseModel):
60
88
  role: str = Field("", alias="Role")
61
89
  content: str = Field("", alias="Content")
62
90
  content_type: int = Field(ContentTypeV2.TEXT, alias="ContentType")
63
91
  multi_part: Optional[List[MultiPart]] = Field(None, alias="MultiPart")
92
+ tool_call_id: Optional[str] = Field(None, alias="ToolCallID")
93
+ tool_call: Optional[List[ToolCall]] = Field(None, alias="ToolCall")
64
94
 
65
95
  class Config:
66
96
  populate_by_name = True
@@ -73,6 +103,7 @@ class ModerateV2Request(BaseModel):
73
103
  use_stream: int = Field(0, alias="UseStream")
74
104
  scene: str = Field("", alias="Scene")
75
105
  history: List[MessageV2] = Field([], alias="History")
106
+ extensions: Optional[Dict[str, str]] = Field(None, alias="Extensions")
76
107
 
77
108
  class Config:
78
109
  populate_by_name = True
@@ -359,7 +390,7 @@ class ClientV2:
359
390
  if request is None:
360
391
  request = ModerateV2Request()
361
392
 
362
- request_body = request.model_dump_json(by_alias=True).encode("utf-8")
393
+ request_body = request.model_dump_json(by_alias=True, exclude_none=True).encode("utf-8")
363
394
 
364
395
  header = {
365
396
  }
@@ -430,7 +461,7 @@ class ClientV2:
430
461
 
431
462
  # 3. 序列化请求(使用 Pydantic 的 model_dump 方法)
432
463
  try:
433
- request_body = session.request.model_dump_json(by_alias=True).encode("utf-8")
464
+ request_body = session.request.model_dump_json(by_alias=True, exclude_none=True).encode("utf-8")
434
465
  # request_str = session.request.model_dump_json(by_alias=True)
435
466
  except Exception as e:
436
467
  raise IOError(f"Failed to serialize request: {str(e)}")
@@ -439,7 +470,7 @@ class ClientV2:
439
470
  }
440
471
  sign_header = request_sign(headers, self.ak, self.sk, self.region, self.url, path, action, request_body)
441
472
  try:
442
- response = requests.post(
473
+ response = self.http_client.post(
443
474
  url=self.url + path + "?Action=" + action + "&Version=" + Version,
444
475
  data=request_body,
445
476
  headers=sign_header
@@ -474,7 +505,7 @@ class ClientV2:
474
505
  request = GenerateStreamV2Request()
475
506
 
476
507
  # 将请求结构体序列化为 JSON
477
- requestBody = request.model_dump_json(by_alias=True).encode("utf-8")
508
+ requestBody = request.model_dump_json(by_alias=True, exclude_none=True).encode("utf-8")
478
509
 
479
510
  headers = {
480
511
  # "Content-Type": "application/json",