volcengine-python-sdk 4.0.28__py2.py3-none-any.whl → 4.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.

Potentially problematic release.


This version of volcengine-python-sdk might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: volcengine-python-sdk
3
- Version: 4.0.28
3
+ Version: 4.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-4.0.28.dist-info/licenses/LICENSE.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
2
- volcengine_python_sdk-4.0.28.dist-info/licenses/NOTICE.md,sha256=dqWX0O4-gFqGLdHJsXAiF6Q8JHlu_3nFaQSmrMHzujM,254
1
+ volcengine_python_sdk-4.0.29.dist-info/licenses/LICENSE.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
2
+ volcengine_python_sdk-4.0.29.dist-info/licenses/NOTICE.md,sha256=dqWX0O4-gFqGLdHJsXAiF6Q8JHlu_3nFaQSmrMHzujM,254
3
3
  volcenginesdkacep/__init__.py,sha256=3s-7qd2wmDxCNBxqB3hOyWRA-Y-ULFvO8s55SNaDK_0,5330
4
4
  volcenginesdkacep/api/__init__.py,sha256=MCzGEBg4XwY5aDIDy8nitUz4vu_2xmRRY83V6lqt460,138
5
5
  volcenginesdkacep/api/acep_api.py,sha256=-rT8B9FBEvCJqe5SDwT-T52On-E3JuUSWtKzawVbWx4,69095
@@ -1123,7 +1123,7 @@ volcenginesdkark/models/validation_set_for_get_model_customization_job_output.py
1123
1123
  volcenginesdkark/models/validation_set_for_list_model_customization_jobs_output.py,sha256=dFb4WCUsjz8yn5xW2uT2meRKwDKt7kt6u2ug1n3sOCE,5535
1124
1124
  volcenginesdkarkruntime/__init__.py,sha256=FYzidHcI2GwLEIuWYhktcQBf8PNL1Z5_31KD9ZyJYqA,624
1125
1125
  volcenginesdkarkruntime/_base_client.py,sha256=2PYXBY3bts6biNTCz2g7lrOyFBeuz4YSjWzY-narVCY,41584
1126
- volcenginesdkarkruntime/_client.py,sha256=6CKVDLDODNFoHIW69okl7A-5MCMxVCry6ge1NMFnZG4,21322
1126
+ volcenginesdkarkruntime/_client.py,sha256=txoMEMUv30vPPPkC8yB1k_Tzxc1z2CsIh8FiqYLosN4,21389
1127
1127
  volcenginesdkarkruntime/_compat.py,sha256=dDGQBZRyEamAVvDQxkO6j7f0e2mQ0a9RFKORU9R3A_I,7592
1128
1128
  volcenginesdkarkruntime/_constants.py,sha256=tuP_2Rs02LWpSC8qe-5eOR88uHhmJmbs4B4a0TzVFxo,1297
1129
1129
  volcenginesdkarkruntime/_exceptions.py,sha256=yrycAtmUhNCHzUpiMAH751VsnKOwiIOgmxPQSZVm-hQ,5611
@@ -1137,7 +1137,7 @@ volcenginesdkarkruntime/_streaming.py,sha256=Lb0208Nx0jS4xqcn0lNfoMk7GOoNTsFib6x
1137
1137
  volcenginesdkarkruntime/_types.py,sha256=Uxw2QRV5xxpFT-KMVZTfhPQ2fUxasBXd6_KOE0Lns0o,5711
1138
1138
  volcenginesdkarkruntime/pagination.py,sha256=JQL-FOVlq_hFBFWF7KIFxec_2tY49cbnbBCi5IQKJJc,3600
1139
1139
  volcenginesdkarkruntime/_utils/__init__.py,sha256=NqVO483WvJgVCEISA_9XYg8rqRtX9N_-FfEANE-97Qw,2370
1140
- volcenginesdkarkruntime/_utils/_key_agreement.py,sha256=aDPTlwAAPWJ4rzEq7zhCUXxKseI2jWh0UPF92Hy2bGY,7812
1140
+ volcenginesdkarkruntime/_utils/_key_agreement.py,sha256=XSZEW263XvQ0pbQferFqAOchOG0wF_GR4fmP1KV1ajo,7978
1141
1141
  volcenginesdkarkruntime/_utils/_logs.py,sha256=KDuFwKpOXO8ZKpWrOg50EWwHaJi0GwfasyZigrVKmAM,1062
1142
1142
  volcenginesdkarkruntime/_utils/_model_breaker.py,sha256=X_4p7urLGc2ywyroraalm1xgkGiUZNOykiAFFeVrTpk,2962
1143
1143
  volcenginesdkarkruntime/_utils/_streams.py,sha256=cxnM5nXHsX05Alk8swYqE8TTb0CzeSVqZUquuOwqN1g,734
@@ -1159,6 +1159,7 @@ volcenginesdkarkruntime/common/streaming/chat/_types.py,sha256=S6uKRNIdyLsoTu5U4
1159
1159
  volcenginesdkarkruntime/resources/__init__.py,sha256=USdf08NaOD74qnIZ1DmFeyH1P6eMcWQnvsDBGXkHR-Q,1667
1160
1160
  volcenginesdkarkruntime/resources/classification.py,sha256=jS-QhlQxYc-ldGZiWig1M-iNwE23RMh_v4Q0E0EAo_E,3932
1161
1161
  volcenginesdkarkruntime/resources/embeddings.py,sha256=Ln23pHlDGALn50aw_SnTdo8OPzzqFjlaJ5JdpYnTjYs,4189
1162
+ volcenginesdkarkruntime/resources/encryption.py,sha256=JljEvp9Xc8wJwm-gL-FOd_03IXi6rTZ4_cAvdZjhnLs,7712
1162
1163
  volcenginesdkarkruntime/resources/multimodal_embeddings.py,sha256=gNlD3kNLi-biLN-Zahscd-We-bLDpqgEMQbAhrjbHv8,4710
1163
1164
  volcenginesdkarkruntime/resources/tokenization.py,sha256=5bw_isLTjdvbn2MiF1t4rI2VhQiK6hdl2yx-HL3ib_4,3977
1164
1165
  volcenginesdkarkruntime/resources/batch/__init__.py,sha256=ZW11xRglBO85ZS-Z8SlCdAO18-oNIIPo6If1F3bhA3c,72
@@ -1171,18 +1172,18 @@ volcenginesdkarkruntime/resources/batch/chat/chat.py,sha256=Pheq0k_Ld9Em3HmkFFyg
1171
1172
  volcenginesdkarkruntime/resources/batch/chat/completions.py,sha256=DLbthi8RksTRSA4VUy5LDI2yxQ64_SxO8NIpjsyjrdU,13153
1172
1173
  volcenginesdkarkruntime/resources/batch_chat/__init__.py,sha256=3P5FoN2nk7vQMax7dNzYdkII0Hv6DU6T4ZEQ1dh7DS4,532
1173
1174
  volcenginesdkarkruntime/resources/batch_chat/chat.py,sha256=rmNmUjqB8OORcK0fSI4b9C0K8X_TFjE8lHvcTZ7rplk,973
1174
- volcenginesdkarkruntime/resources/batch_chat/completions.py,sha256=CPu583r8z-Kc2M85EG9X0LPAvu3_ixH1_W7L-fDtEck,18536
1175
+ volcenginesdkarkruntime/resources/batch_chat/completions.py,sha256=uH5Mf251EYFtOzRUIi67gsIJGMO2iwT2Naf8_Bvh0UA,12999
1175
1176
  volcenginesdkarkruntime/resources/beta/__init__.py,sha256=qGjUlIzRM_KEjS_F_u3noCoAIvCsfHlqoQrO8S_jt9k,445
1176
1177
  volcenginesdkarkruntime/resources/beta/beta.py,sha256=nzVyjqGrQss7zoDJOGvKGVPXSSzhZizISSm_8jQRb2I,2423
1177
1178
  volcenginesdkarkruntime/resources/beta/chat/__init__.py,sha256=A-NN9ktR3wUytfQk1djgQTM9A6x_PUN5bqzqNRyIEzU,621
1178
1179
  volcenginesdkarkruntime/resources/beta/chat/chat.py,sha256=mpHbn7PzeltaWn4ik_8micetGlTHiOjmLgKS0QBDc8Y,955
1179
- volcenginesdkarkruntime/resources/beta/chat/completions.py,sha256=9Db7VELigoTDoGCBC2psjHCwtOIIWbPcDRCqJlQLiso,18307
1180
+ volcenginesdkarkruntime/resources/beta/chat/completions.py,sha256=AnyV0qcMFTOhwP4REfsqdddQN9PQYJRky5QrpwggL-E,18884
1180
1181
  volcenginesdkarkruntime/resources/bot/__init__.py,sha256=YjHp05ym0Cfh-9i9R3ku7W0vZwn8bLi9H6tPIn73XFA,524
1181
1182
  volcenginesdkarkruntime/resources/bot/chat.py,sha256=Zj6GnTuZwpdnzCV7Q45HTvK363csEPQ7KyooPAqlvFM,965
1182
1183
  volcenginesdkarkruntime/resources/bot/completions.py,sha256=Dca7szOhyZTZYVIJVK4HB7qyQyY9RJkwC4ifPP1EJqc,9125
1183
1184
  volcenginesdkarkruntime/resources/chat/__init__.py,sha256=61VSlUJ3DwQpVJMwKE_kIqwqabLGIAiMuabAswDF1aw,512
1184
1185
  volcenginesdkarkruntime/resources/chat/chat.py,sha256=UCt3sfUpu-SPNLvHLAZNtOIv7VL9AAiuWUUGZsYjIr4,953
1185
- volcenginesdkarkruntime/resources/chat/completions.py,sha256=EKJXwMaSGK-SF3QN8G7lUxzytSo8XEyWJDjqncozXlA,18102
1186
+ volcenginesdkarkruntime/resources/chat/completions.py,sha256=fkjiHwjyV5dvV1N1gBBAT0AJdRLmfbLJeztyvb8aJDY,9887
1186
1187
  volcenginesdkarkruntime/resources/content_generation/__init__.py,sha256=eEtK2GEGtfVv_EWJN6BelShzUxyEQjWxNdHuvvXMgYk,643
1187
1188
  volcenginesdkarkruntime/resources/content_generation/content_generation.py,sha256=J3yiGK_IROqj8aTfcj15mh4bCBj69ooYaCB_J3QhjTQ,892
1188
1189
  volcenginesdkarkruntime/resources/content_generation/tasks.py,sha256=gHPzaJhRy6yVgezUKWiC5igVq8Qh1SaqDr9qX767Bdg,9637
@@ -1190,7 +1191,7 @@ volcenginesdkarkruntime/resources/context/__init__.py,sha256=IUvx1XilwE6K0upLvKu
1190
1191
  volcenginesdkarkruntime/resources/context/completions.py,sha256=1TDpqoVLTgDcNthnebxAUEA5W3kXb9AewZT8X8zSiZM,8647
1191
1192
  volcenginesdkarkruntime/resources/context/context.py,sha256=8ql5cSPH3KkhhJo5IruFi4m2LX0ERdKWomfqODhppL0,3694
1192
1193
  volcenginesdkarkruntime/resources/images/__init__.py,sha256=M3K0FIhxguASekiH-goR6t-iNt-OSlzBA5_E_JqoW5I,575
1193
- volcenginesdkarkruntime/resources/images/images.py,sha256=F4TpIS-UW2QIab2m_mrGsby5vxSwyyMPsgjWUN2vUU0,10568
1194
+ volcenginesdkarkruntime/resources/images/images.py,sha256=c5ysp9tJKBsGfqWhZJA6yu35Gw2WMjYE1008pD5Q0w8,11394
1194
1195
  volcenginesdkarkruntime/resources/responses/__init__.py,sha256=MKPYX2Bfz3fH4eBS8-nSBg6NXFrPWLZe6OSVMIZmtKg,623
1195
1196
  volcenginesdkarkruntime/resources/responses/input_items.py,sha256=K2kBo-Rz8ivV4Hf55w7DLAeA4bBcfag5_Tr8PJimvbU,9173
1196
1197
  volcenginesdkarkruntime/resources/responses/responses.py,sha256=eqwRX5nh0_kCEhuEQe-El6UHRSIPZ1Qfp-DRZSX6xRE,11749
@@ -1233,7 +1234,7 @@ volcenginesdkarkruntime/types/chat/completion_create_params.py,sha256=nvZYy845s_
1233
1234
  volcenginesdkarkruntime/types/chat/parsed_chat_completion.py,sha256=gGfw1v2xycPDAVux8ket6DjEqSE68e-ib_6U6nSsYhs,1801
1234
1235
  volcenginesdkarkruntime/types/chat/parsed_function_tool_call.py,sha256=dn3o68LxySJ-ODXUUshJLHbQs34rTZfOqH7rftKN_mM,1111
1235
1236
  volcenginesdkarkruntime/types/content_generation/__init__.py,sha256=qGjUlIzRM_KEjS_F_u3noCoAIvCsfHlqoQrO8S_jt9k,445
1236
- volcenginesdkarkruntime/types/content_generation/content_generation_task.py,sha256=HwTi1mBuenJQf1CuyHRP85ttN2Ts5hFPmEHnWFiC98U,1746
1237
+ volcenginesdkarkruntime/types/content_generation/content_generation_task.py,sha256=uhVlQI8QlGK4OiTpAambdDGAd8mMyBUQYgg57umCpwM,2127
1237
1238
  volcenginesdkarkruntime/types/content_generation/content_generation_task_id.py,sha256=AGFX0T-JbpRv73g_M5QqawYbtL3-rObG2ffCvZTo-EM,599
1238
1239
  volcenginesdkarkruntime/types/content_generation/create_task_content_param.py,sha256=8a8_aPM4Yp67oPtOFebukyTEyD84gdiTFf2R4ZhpQnE,1262
1239
1240
  volcenginesdkarkruntime/types/content_generation/list_content_generation_tasks_response.py,sha256=lPbt7JD6HZHZ3YyLWdfseXjjvqXlTBNdykdRamAGYS8,1062
@@ -1243,11 +1244,11 @@ volcenginesdkarkruntime/types/context/context_chat_completion_chunk.py,sha256=3u
1243
1244
  volcenginesdkarkruntime/types/context/context_create_params.py,sha256=7_dI5-bvEDts6z5DVdcYat1w0EzYTU4HTDHClGRIqSI,1540
1244
1245
  volcenginesdkarkruntime/types/context/create_context_response.py,sha256=_udIYj8gGQBeYHVe1EZ615drqLbiUQZfvLjo-ufAPUM,1173
1245
1246
  volcenginesdkarkruntime/types/context/truncation_strategy.py,sha256=2Eb8jGyRPUAwlKpgnGTccs4ddBRN5XiPhe99HxSyxj8,898
1246
- volcenginesdkarkruntime/types/images/__init__.py,sha256=6Df1UsTAI1YB4h4JHsuCxTu6GMvFGMbivLtNBeU2Olg,581
1247
+ volcenginesdkarkruntime/types/images/__init__.py,sha256=6DG33DNvt85JCOTHwCDkmJqjZDUBxhmBvfNKQpsrxsA,629
1247
1248
  volcenginesdkarkruntime/types/images/image_gen_completed_event.py,sha256=rORuqoDhCIF_61t430cmdwMbe3df3Y-k3oZ-Ps1fn8k,1326
1248
1249
  volcenginesdkarkruntime/types/images/image_gen_generating_event.py,sha256=9OBPmm7fuIiBmpxXdZaAjNlJKTO45Y0M5h4zyiitleU,1337
1249
1250
  volcenginesdkarkruntime/types/images/image_gen_stream_event.py,sha256=kd-gmU0xNJXpiuboLVjfWxV1vkvE1GIUnbLPf4NjeOU,880
1250
- volcenginesdkarkruntime/types/images/images.py,sha256=tWyYOenGsFayPGO879C4DemsSt8ofaTNIQNs2DbCwzw,1681
1251
+ volcenginesdkarkruntime/types/images/images.py,sha256=huxXapTPNJez-Rc_o_YDIVCnt9OAxRtuPL_D9QH-IA0,1815
1251
1252
  volcenginesdkarkruntime/types/multimodal_embedding/__init__.py,sha256=ds2bIDk8cPjW8gvQqTsUePR1k8wZLnsoAagtxiNwdN8,1138
1252
1253
  volcenginesdkarkruntime/types/multimodal_embedding/embedding_content_part_image_param.py,sha256=247-QJkW4PJTzwIZSKLJ3VI1SeYNvUQiiWdYMfJuaB0,933
1253
1254
  volcenginesdkarkruntime/types/multimodal_embedding/embedding_content_part_text_param.py,sha256=CsrlVCwUHoeUk5oyf5qVjdqgUNzOzAKuLjWzkks-IIM,797
@@ -1346,6 +1347,7 @@ volcenginesdkarkruntime/types/responses/tool_param.py,sha256=Ol4qEJFpG2dn-WNpTnV
1346
1347
  volcenginesdkarkruntime/types/responses/web_search_tool.py,sha256=rrEuYIkNVEh43obyXAYB6_z50VUrC_WGeTWC5DKehSs,1424
1347
1348
  volcenginesdkarkruntime/types/responses/web_search_tool_param.py,sha256=DCfJ3K3ja_oZuU0a7YYb_TliDBdBRZdJ86Dc3_iwwQQ,1493
1348
1349
  volcenginesdkarkruntime/types/shared/__init__.py,sha256=tCTl_UIdDzJt5IuaiFd_9ouOXaQurdXKPzE7fO-LVVQ,726
1350
+ volcenginesdkarkruntime/types/shared/reasoning_effort.py,sha256=JMFgGWQPaCAo516QvuwC6tUXjTv7U3fE6nQ6Cn7fvD0,636
1349
1351
  volcenginesdkarkruntime/types/shared/response_format_json_object.py,sha256=Y7CwtsU50-OdIZCcTP7eqtGjJVCBA82Co9Qdf34Sfpg,710
1350
1352
  volcenginesdkarkruntime/types/shared/response_format_json_schema.py,sha256=Wa2P5MpSsaUOE51GuJVTQQ_-PHA7622Zeu-g1kDKlmc,1807
1351
1353
  volcenginesdkarkruntime/types/shared/response_format_text.py,sha256=8dIt5hweiD9M6BgDToARo9H9uSXQ4RIUxxfa4pgeR_w,684
@@ -3718,8 +3720,8 @@ volcenginesdkcloudtrail20180101/models/trail_for_describe_trails_output.py,sha25
3718
3720
  volcenginesdkcloudtrail20180101/models/update_trail_request.py,sha256=B3ekQIluA7_EJS-lDVFfS9opp_Q0AA85o7feAxhRCuQ,12596
3719
3721
  volcenginesdkcloudtrail20180101/models/update_trail_response.py,sha256=Gw7FcSWqHtttRxkuWdFuh9A69ZHcwHWEf2K8S9AfWQQ,10744
3720
3722
  volcenginesdkcore/__init__.py,sha256=hXXJZvkXO1--TZxyZTuFowfJp0BoBo6c3KYbGNuVc9k,239
3721
- volcenginesdkcore/api_client.py,sha256=FA4RemZ45gsG5sK9KVZH0jt4oIfXian7sxRR5pFHgEw,18297
3722
- volcenginesdkcore/configuration.py,sha256=LVxdguKmOururWWsTQlw5Mta9gJhsSfpmbudNv7sLVg,11181
3723
+ volcenginesdkcore/api_client.py,sha256=5YKOCPoflprXwEReVptuo3RTJyM2Ye1Vrn00qcQpY0E,18297
3724
+ volcenginesdkcore/configuration.py,sha256=4b1EivuZIFfXL2F1pw2bMO4RJaxk7IaPdzxovpUMrhw,11181
3723
3725
  volcenginesdkcore/flatten.py,sha256=g3r61JS_AO7WV6ClRDkXgtnVXcw3c7tbZjeLAJxkSLc,3811
3724
3726
  volcenginesdkcore/metadata.py,sha256=uEwumzeIwgfu3_QBUk6BU_MQg_snF92Kke1J2L5TcGc,3419
3725
3727
  volcenginesdkcore/model.py,sha256=f3cvQ6QiQfecClucu-_-l5xVI3W5_vF-EKkjwZu7Vjc,177
@@ -15787,7 +15789,7 @@ volcenginesdkwafruntime/api/__init__.py,sha256=di_9IIKQ0HCuzkGrTyZ6h38iP7y1xelH8
15787
15789
  volcenginesdkwafruntime/api/waf_runtime_api.py,sha256=eWgdzFcwflEkhkNrPzZL1mqSid7O1OWiwHGUyWJvZNA,4035
15788
15790
  volcenginesdkwafruntime/models/__init__.py,sha256=di_9IIKQ0HCuzkGrTyZ6h38iP7y1xelH8_IJbKi4aWA,71
15789
15791
  volcenginesdkwafruntime/models/llm_stream_session.py,sha256=U9cig3fuZRBT4Ov8_cUsWDKXcMLNjBDxKt-7IoewoUw,1589
15790
- volcengine_python_sdk-4.0.28.dist-info/METADATA,sha256=QtHBWG2TUuewxKHoeUTEA8VPQrP7kogsAOXfaadCGH4,7166
15791
- volcengine_python_sdk-4.0.28.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
15792
- volcengine_python_sdk-4.0.28.dist-info/top_level.txt,sha256=G6o20WnuJE_ejkFO9rwzjW7R6BUcHe2IicZFnAbhuZA,2364
15793
- volcengine_python_sdk-4.0.28.dist-info/RECORD,,
15792
+ volcengine_python_sdk-4.0.29.dist-info/METADATA,sha256=SNmaI54r3ded8jKEk0BpNhW4W3IvSclTtt1gWdniXJ8,7166
15793
+ volcengine_python_sdk-4.0.29.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
15794
+ volcengine_python_sdk-4.0.29.dist-info/top_level.txt,sha256=G6o20WnuJE_ejkFO9rwzjW7R6BUcHe2IicZFnAbhuZA,2364
15795
+ volcengine_python_sdk-4.0.29.dist-info/RECORD,,
@@ -143,7 +143,7 @@ class Ark(SyncAPIClient):
143
143
  self._sts_token_manager = StsTokenManager(self.ak, self.sk, self.region)
144
144
  return self._sts_token_manager.get(endpoint_id)
145
145
 
146
- def _get_endpoint_certificate(self, endpoint_id: str) -> tuple[key_agreement_client, str, str]:
146
+ def _get_endpoint_certificate(self, endpoint_id: str) -> Tuple[key_agreement_client, str, str, float]:
147
147
  if self._certificate_manager is None:
148
148
  cert_path = os.environ.get("E2E_CERTIFICATE_PATH")
149
149
  if (
@@ -279,7 +279,7 @@ class AsyncArk(AsyncAPIClient):
279
279
  self._sts_token_manager = StsTokenManager(self.ak, self.sk, self.region)
280
280
  return self._sts_token_manager.get(bot_id, resource_type="bot")
281
281
 
282
- def _get_endpoint_certificate(self, endpoint_id: str) -> tuple[key_agreement_client, str, str]:
282
+ def _get_endpoint_certificate(self, endpoint_id: str) -> Tuple[key_agreement_client, str, str, float]:
283
283
  if self._certificate_manager is None:
284
284
  cert_path = os.environ.get("E2E_CERTIFICATE_PATH")
285
285
  if (
@@ -429,7 +429,7 @@ class E2ECertificateManager(object):
429
429
  base_url: str | URL = BASE_URL,
430
430
  api_key: str | None = None,
431
431
  ):
432
- self._certificate_manager: Dict[str, Tuple[key_agreement_client, str, str]] = {}
432
+ self._certificate_manager: Dict[str, Tuple[key_agreement_client, str, str, float]] = {}
433
433
 
434
434
  # local cache prepare
435
435
  self._init_local_cert_cache()
@@ -522,7 +522,7 @@ class E2ECertificateManager(object):
522
522
  cert_pem = None
523
523
  with open(cert_file_path, "r") as f:
524
524
  cert_pem = f.read()
525
- ring, key = get_cert_info(cert_pem)
525
+ ring, key, _ = get_cert_info(cert_pem)
526
526
  # check cert is complement with AICC/PCA
527
527
  if (ring == "" or key == "") and not self._aicc_enabled:
528
528
  return cert_pem
@@ -545,7 +545,7 @@ class E2ECertificateManager(object):
545
545
  "failed to create certificate directory %s: %s\n" % (self._cert_storage_path, e)
546
546
  )
547
547
 
548
- def get(self, ep: str) -> tuple[key_agreement_client, str, str]:
548
+ def get(self, ep: str) -> Tuple[key_agreement_client, str, str, float]:
549
549
  if ep not in self._certificate_manager:
550
550
  cert_pem = self._load_cert_locally(ep)
551
551
  if cert_pem is None:
@@ -556,12 +556,13 @@ class E2ECertificateManager(object):
556
556
  else:
557
557
  cert_pem = self._load_cert_by_ak_sk(ep)
558
558
  self._save_cert_to_file(ep, cert_pem)
559
- ring, key = get_cert_info(cert_pem)
559
+ ring, key, exp_time = get_cert_info(cert_pem)
560
560
  self._certificate_manager[ep] = (
561
561
  key_agreement_client(
562
562
  certificate_pem_string=cert_pem
563
563
  ),
564
564
  ring,
565
565
  key,
566
+ exp_time,
566
567
  )
567
568
  return self._certificate_manager[ep]
@@ -17,7 +17,7 @@ import base64
17
17
  from typing import Tuple
18
18
 
19
19
 
20
- def get_cert_info(cert_pem: str) -> Tuple[str, str]:
20
+ def get_cert_info(cert_pem: str) -> Tuple[str, str, float]:
21
21
  import re
22
22
  from cryptography import x509
23
23
  from cryptography.hazmat.backends import default_backend
@@ -27,10 +27,10 @@ def get_cert_info(cert_pem: str) -> Tuple[str, str]:
27
27
  dns = cert.extensions.get_extension_for_class(
28
28
  x509.SubjectAlternativeName).value.get_values_for_type(x509.DNSName)
29
29
  if dns and len(dns) > 1 and re.match(r"^ring\..*$", dns[0]) and re.match(r"^key\..*$", dns[1]):
30
- return dns[0][5:], dns[1][4:]
30
+ return dns[0][5:], dns[1][4:], cert.not_valid_after_utc.timestamp()
31
31
  except Exception:
32
32
  pass
33
- return "", ""
33
+ return "", "", cert.not_valid_after_utc.timestamp()
34
34
 
35
35
 
36
36
  def aes_gcm_encrypt_bytes(
@@ -92,6 +92,20 @@ def aes_gcm_decrypt_base64_string(key: bytes, nonce: bytes, ciphertext: str) ->
92
92
  base64_pattern = r'(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})'
93
93
 
94
94
 
95
+ def decrypt_corner_case(key: bytes, nonce: bytes, data: str) -> str:
96
+ """decrypt_corner_case Decrypt corner case data"""
97
+ if len(data) < 24:
98
+ return ''
99
+ for i in range(20, len(data), 4):
100
+ try:
101
+ decrypted = aes_gcm_decrypt_base64_string(key, nonce, data[:i+4])
102
+ if i+4 == len(data):
103
+ return decrypted
104
+ return decrypted + decrypt_corner_case(key, nonce, data[i+4:])
105
+ except Exception:
106
+ pass
107
+
108
+
95
109
  def aes_gcm_decrypt_base64_list(key: bytes, nonce: bytes, ciphertext: str) -> str:
96
110
  # Decrypt
97
111
  base64_array = re.findall(base64_pattern, ciphertext)
@@ -100,17 +114,7 @@ def aes_gcm_decrypt_base64_list(key: bytes, nonce: bytes, ciphertext: str) -> st
100
114
  try:
101
115
  result.append(aes_gcm_decrypt_base64_string(key, nonce, b64))
102
116
  except Exception:
103
- for i in range(20, len(b64), 4):
104
- try:
105
- decrypted = aes_gcm_decrypt_base64_string(
106
- key, nonce, b64[:i+4])
107
- result.append(decrypted)
108
- decrypted = aes_gcm_decrypt_base64_string(
109
- key, nonce, b64[i+4:])
110
- result.append(decrypted)
111
- break
112
- except Exception:
113
- pass
117
+ result.append(decrypt_corner_case(key, nonce, b64))
114
118
  return ''.join(result)
115
119
 
116
120
 
@@ -20,12 +20,11 @@ from typing import Dict, List, Union, Iterable, Optional, Callable
20
20
  from typing_extensions import Literal
21
21
 
22
22
  import httpx
23
- import warnings
24
23
 
25
24
  from ..._exceptions import ArkAPITimeoutError, ArkAPIConnectionError, ArkAPIStatusError
26
25
  from ..._types import Body, Query, Headers
27
- from ..._utils import with_sts_token, async_with_sts_token, deepcopy_minimal
28
- from ..._utils._key_agreement import aes_gcm_decrypt_base64_string
26
+ from ..._utils import with_sts_token, async_with_sts_token
27
+ from ..encryption import with_e2e_encryption, async_with_e2e_encryption
29
28
  from ..._base_client import make_request_options
30
29
  from ..._resource import SyncAPIResource, AsyncAPIResource
31
30
  from ..._compat import cached_property
@@ -50,43 +49,10 @@ from ..._constants import (
50
49
  __all__ = ["Completions", "AsyncCompletions"]
51
50
 
52
51
 
53
- def _process_messages(
54
- messages: Iterable[ChatCompletionMessageParam], f: Callable[[str], str]
55
- ):
56
- for message in messages:
57
- if message.get("content", None) is not None:
58
- current_content = message.get("content")
59
- if isinstance(current_content, str):
60
- message["content"] = f(current_content)
61
- elif isinstance(current_content, Iterable):
62
- for part in current_content:
63
- if part.get("type", None) == "text":
64
- part["text"] = f(part["text"])
65
- elif part.get("type", None) == "image_url":
66
- if part["image_url"]["url"].startswith("data:"):
67
- part["image_url"]["url"] = f(part["image_url"]["url"])
68
- else:
69
- warnings.warn(
70
- "encryption is not supported for image url, "
71
- "please use base64 image if you want encryption"
72
- )
73
- else:
74
- raise TypeError(
75
- "encryption is not supported for content type {}".format(
76
- type(part)
77
- )
78
- )
79
- else:
80
- raise TypeError(
81
- "encryption is not supported for content type {}".format(
82
- type(message.get("content"))
83
- )
84
- )
85
-
86
-
87
52
  def _calculate_retry_timeout(retry_times) -> float:
88
53
  nbRetries = min(retry_times, MAX_RETRY_DELAY / INITIAL_RETRY_DELAY)
89
- sleep_seconds = min(INITIAL_RETRY_DELAY * pow(2, nbRetries), MAX_RETRY_DELAY)
54
+ sleep_seconds = min(INITIAL_RETRY_DELAY *
55
+ pow(2, nbRetries), MAX_RETRY_DELAY)
90
56
  # Apply some jitter, plus-or-minus half a second.
91
57
  jitter = 1 - 0.25 * random()
92
58
  timeout = sleep_seconds * jitter
@@ -126,58 +92,8 @@ class Completions(SyncAPIResource):
126
92
  def with_raw_response(self) -> CompletionsWithRawResponse:
127
93
  return CompletionsWithRawResponse(self)
128
94
 
129
- def _process_messages(
130
- self, messages: Iterable[ChatCompletionMessageParam], f: Callable[[str], str]
131
- ):
132
- for message in messages:
133
- if message.get("content", None) is not None:
134
- current_content = message.get("content")
135
- if isinstance(current_content, str):
136
- message["content"] = f(current_content)
137
- elif isinstance(current_content, Iterable):
138
- raise TypeError(
139
- "content type {} is not supported end-to-end encryption".format(
140
- type(message.get("content"))
141
- )
142
- )
143
- else:
144
- raise TypeError(
145
- "content type {} is not supported end-to-end encryption".format(
146
- type(message.get("content"))
147
- )
148
- )
149
-
150
- def _encrypt(
151
- self,
152
- model: str,
153
- messages: Iterable[ChatCompletionMessageParam],
154
- extra_headers: Headers,
155
- ) -> tuple[bytes, bytes]:
156
- client = self._client._get_endpoint_certificate(model)
157
- _crypto_key, _crypto_nonce, session_token = client.generate_ecies_key_pair()
158
- extra_headers["X-Session-Token"] = session_token
159
- _process_messages(
160
- messages,
161
- lambda x: client.encrypt_string_with_key(_crypto_key, _crypto_nonce, x),
162
- )
163
- return _crypto_key, _crypto_nonce
164
-
165
- def _decrypt(
166
- self, key: bytes, nonce: bytes, resp: ChatCompletion
167
- ) -> ChatCompletion:
168
- if resp.choices is not None:
169
- for index, choice in enumerate(resp.choices):
170
- if (
171
- choice.message is not None and choice.finish_reason != 'content_filter'
172
- and choice.message.content is not None
173
- ):
174
- choice.message.content = aes_gcm_decrypt_base64_string(
175
- key, nonce, choice.message.content
176
- )
177
- resp.choices[index] = choice
178
- return resp
179
-
180
95
  @with_sts_token
96
+ @with_e2e_encryption
181
97
  def create(
182
98
  self,
183
99
  *,
@@ -208,14 +124,6 @@ class Completions(SyncAPIResource):
208
124
  extra_body: Body | None = None,
209
125
  timeout: float | httpx.Timeout | None = None,
210
126
  ) -> ChatCompletion:
211
- is_encrypt = False
212
- if (
213
- extra_headers is not None
214
- and extra_headers.get(ARK_E2E_ENCRYPTION_HEADER, None) == "true"
215
- ):
216
- is_encrypt = True
217
- messages = deepcopy_minimal(messages)
218
- e2e_key, e2e_nonce = self._encrypt(model, messages, extra_headers)
219
127
  retryTimes = 0
220
128
  last_time = self._get_request_last_time(timeout)
221
129
  model_breaker = self._client.get_model_breaker(model)
@@ -273,8 +181,6 @@ class Completions(SyncAPIResource):
273
181
  continue
274
182
  else:
275
183
  raise err
276
- if is_encrypt:
277
- resp = self._decrypt(e2e_key, e2e_nonce, resp)
278
184
  return resp
279
185
 
280
186
  def _get_request_last_time(self, timeout):
@@ -289,7 +195,8 @@ class Completions(SyncAPIResource):
289
195
  timeoutSeconds = timeout
290
196
  else:
291
197
  raise TypeError(
292
- "timeout type {} is not supported".format(type(self._client.timeout))
198
+ "timeout type {} is not supported".format(
199
+ type(self._client.timeout))
293
200
  )
294
201
  return datetime.now() + timedelta(seconds=timeoutSeconds)
295
202
 
@@ -299,37 +206,8 @@ class AsyncCompletions(AsyncAPIResource):
299
206
  def with_raw_response(self) -> AsyncCompletionsWithRawResponse:
300
207
  return AsyncCompletionsWithRawResponse(self)
301
208
 
302
- def _encrypt(
303
- self,
304
- model: str,
305
- messages: Iterable[ChatCompletionMessageParam],
306
- extra_headers: Headers,
307
- ) -> tuple[bytes, bytes]:
308
- client = self._client._get_endpoint_certificate(model)
309
- _crypto_key, _crypto_nonce, session_token = client.generate_ecies_key_pair()
310
- extra_headers["X-Session-Token"] = session_token
311
- _process_messages(
312
- messages,
313
- lambda x: client.encrypt_string_with_key(_crypto_key, _crypto_nonce, x),
314
- )
315
- return _crypto_key, _crypto_nonce
316
-
317
- async def _decrypt(
318
- self, key: bytes, nonce: bytes, resp: ChatCompletion
319
- ) -> ChatCompletion:
320
- if resp.choices is not None:
321
- for index, choice in enumerate(resp.choices):
322
- if (
323
- choice.message is not None and choice.finish_reason != 'content_filter'
324
- and choice.message.content is not None
325
- ):
326
- choice.message.content = aes_gcm_decrypt_base64_string(
327
- key, nonce, choice.message.content
328
- )
329
- resp.choices[index] = choice
330
- return resp
331
-
332
209
  @async_with_sts_token
210
+ @async_with_e2e_encryption
333
211
  async def create(
334
212
  self,
335
213
  *,
@@ -360,14 +238,6 @@ class AsyncCompletions(AsyncAPIResource):
360
238
  extra_body: Body | None = None,
361
239
  timeout: float | httpx.Timeout | None = None,
362
240
  ) -> ChatCompletion:
363
- is_encrypt = False
364
- if (
365
- extra_headers is not None
366
- and extra_headers.get(ARK_E2E_ENCRYPTION_HEADER, None) == "true"
367
- ):
368
- is_encrypt = True
369
- messages = deepcopy_minimal(messages)
370
- e2e_key, e2e_nonce = self._encrypt(model, messages, extra_headers)
371
241
 
372
242
  retryTimes = 0
373
243
  last_time = self._get_request_last_time(timeout)
@@ -426,8 +296,6 @@ class AsyncCompletions(AsyncAPIResource):
426
296
  continue
427
297
  else:
428
298
  raise err
429
- if is_encrypt:
430
- resp = await self._decrypt(e2e_key, e2e_nonce, resp)
431
299
  return resp
432
300
 
433
301
  def _get_request_last_time(self, timeout):
@@ -442,7 +310,8 @@ class AsyncCompletions(AsyncAPIResource):
442
310
  timeoutSeconds = timeout
443
311
  else:
444
312
  raise TypeError(
445
- "timeout type {} is not supported".format(type(self._client.timeout))
313
+ "timeout type {} is not supported".format(
314
+ type(self._client.timeout))
446
315
  )
447
316
  return datetime.now() + timedelta(seconds=timeoutSeconds)
448
317
 
@@ -56,6 +56,8 @@ from ....types.chat.chat_completion_stream_options_param import (
56
56
  from ....types.chat.chat_completion_tool_choice_option_param import (
57
57
  ChatCompletionToolChoiceOptionParam,
58
58
  )
59
+ from ....types.shared.reasoning_effort import ReasoningEffort
60
+
59
61
 
60
62
  __all__ = ["Completions", "AsyncCompletions"]
61
63
 
@@ -100,6 +102,7 @@ class Completions(SyncAPIResource):
100
102
  top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
101
103
  top_p: Optional[float] | NotGiven = NOT_GIVEN,
102
104
  user: str | NotGiven = NOT_GIVEN,
105
+ reasoning_effort: Optional[ReasoningEffort] | NotGiven = NOT_GIVEN,
103
106
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
104
107
  # The extra values given here take precedence over values defined on the client or passed to this method.
105
108
  extra_headers: Headers | None = None,
@@ -147,6 +150,7 @@ class Completions(SyncAPIResource):
147
150
  "top_logprobs": top_logprobs,
148
151
  "top_p": top_p,
149
152
  "user": user,
153
+ "reasoning_effort": reasoning_effort,
150
154
  },
151
155
  completion_create_params.CompletionCreateParams,
152
156
  ),
@@ -188,6 +192,7 @@ class Completions(SyncAPIResource):
188
192
  top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
189
193
  top_p: Optional[float] | NotGiven = NOT_GIVEN,
190
194
  user: str | NotGiven = NOT_GIVEN,
195
+ reasoning_effort: Optional[ReasoningEffort] | NotGiven = NOT_GIVEN,
191
196
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
192
197
  # The extra values given here take precedence over values defined on the client or passed to this method.
193
198
  extra_headers: Headers | None = None,
@@ -202,6 +207,7 @@ class Completions(SyncAPIResource):
202
207
 
203
208
  api_request: partial[Stream[ChatCompletionChunk]] = partial(
204
209
  self._client.chat.completions.create,
210
+ reasoning_effort=reasoning_effort,
205
211
  messages=messages,
206
212
  model=model,
207
213
  stream=True,
@@ -274,6 +280,7 @@ class AsyncCompletions(AsyncAPIResource):
274
280
  top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
275
281
  top_p: Optional[float] | NotGiven = NOT_GIVEN,
276
282
  user: str | NotGiven = NOT_GIVEN,
283
+ reasoning_effort: Optional[ReasoningEffort] | NotGiven = NOT_GIVEN,
277
284
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
278
285
  # The extra values given here take precedence over values defined on the client or passed to this method.
279
286
  extra_headers: Headers | None = None,
@@ -321,6 +328,7 @@ class AsyncCompletions(AsyncAPIResource):
321
328
  "top_logprobs": top_logprobs,
322
329
  "top_p": top_p,
323
330
  "user": user,
331
+ "reasoning_effort": reasoning_effort,
324
332
  },
325
333
  completion_create_params.CompletionCreateParams,
326
334
  ),
@@ -362,6 +370,7 @@ class AsyncCompletions(AsyncAPIResource):
362
370
  top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
363
371
  top_p: Optional[float] | NotGiven = NOT_GIVEN,
364
372
  user: str | NotGiven = NOT_GIVEN,
373
+ reasoning_effort: Optional[ReasoningEffort] | NotGiven = NOT_GIVEN,
365
374
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
366
375
  # The extra values given here take precedence over values defined on the client or passed to this method.
367
376
  extra_headers: Headers | None = None,
@@ -397,6 +406,7 @@ class AsyncCompletions(AsyncAPIResource):
397
406
  top_logprobs=top_logprobs,
398
407
  top_p=top_p,
399
408
  user=user,
409
+ reasoning_effort=reasoning_effort,
400
410
  extra_headers=extra_headers,
401
411
  extra_query=extra_query,
402
412
  extra_body=extra_body,