Skip to content

Commit d3b2ec3

Browse files
committed
Merge branch 'integration_2024-05-30_272922903810' into 'master'
merge branch integration_2024-05-30_272922903810 into master See merge request iaasng/volcengine-python-sdk!314
2 parents 2068ee2 + 6eec377 commit d3b2ec3

File tree

684 files changed

+130710
-160
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

684 files changed

+130710
-160
lines changed

meta.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"lasted": "1.0.83",
3-
"meta_commit": "dbced919d27fc04b92b10148f0771d171e63cf37"
4-
}
2+
"lasted": "1.0.84",
3+
"meta_commit": "60964df89935b212f82fe97624e3638432316a31"
4+
}

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from setuptools import setup, find_packages # noqa: H301
44

55
NAME = "volcengine-python-sdk"
6-
VERSION = "1.0.83"
6+
VERSION = "1.0.84"
77
# To install the library, run the following
88
#
99
# python setup.py install

volcenginesdkarkruntime/_client.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def __init__(
3838
base_url: str | URL = BASE_URL,
3939
ak: str | None = None,
4040
sk: str | None = None,
41+
api_key: str | None = None,
4142
timeout: float | Timeout | None = DEFAULT_TIMEOUT,
4243
max_retries: int = DEFAULT_MAX_RETRIES,
4344
http_client: Client | None = None,
@@ -48,6 +49,7 @@ def __init__(
4849
Args:
4950
ak: access key id
5051
sk: secret access key
52+
api_key: api key,this api key will not be refreshed
5153
timeout: timeout of client. default httpx.Timeout(timeout=60.0, connect=60.0)
5254
max_retries: times of retry when request failed. default 1
5355
http_client: specify customized http_client
@@ -59,8 +61,13 @@ def __init__(
5961
ak = os.environ.get("VOLC_ACCESSKEY")
6062
if sk is None:
6163
sk = os.environ.get("VOLC_SECRETKEY")
64+
if api_key is None:
65+
api_key = os.environ.get("ARK_API_KEY")
6266
self.ak = ak
6367
self.sk = sk
68+
self.api_key = api_key
69+
70+
assert (api_key is not None) or (ak is not None and sk is not None), "you need to support api_key or ak&sk"
6471

6572
super().__init__(
6673
base_url=base_url,
@@ -82,6 +89,11 @@ def _get_endpoint_sts_token(self, endpoint_id: str):
8289
self._sts_token_manager = StsTokenManager(self.ak, self.sk)
8390
return self._sts_token_manager.get(endpoint_id)
8491

92+
@property
93+
def auth_headers(self) -> dict[str, str]:
94+
api_key = self.api_key
95+
return {"Authorization": f"Bearer {api_key}"}
96+
8597

8698
class AsyncArk(AsyncAPIClient):
8799
chat: resources.AsyncChat
@@ -91,6 +103,7 @@ def __init__(
91103
*,
92104
ak: str | None = None,
93105
sk: str | None = None,
106+
api_key: str | None = None,
94107
base_url: str | URL = BASE_URL,
95108
timeout: float | Timeout | None = DEFAULT_TIMEOUT,
96109
max_retries: int = DEFAULT_MAX_RETRIES,
@@ -101,6 +114,7 @@ def __init__(
101114
Args:
102115
ak: access key id
103116
sk: secret access key
117+
api_key: api key,this api key will not be refreshed
104118
timeout: timeout of client. default httpx.Timeout(timeout=60.0, connect=60.0)
105119
max_retries: times of retry when request failed. default 1
106120
http_client: specify customized http_client
@@ -112,8 +126,13 @@ def __init__(
112126
ak = os.environ.get("VOLC_ACCESSKEY")
113127
if sk is None:
114128
sk = os.environ.get("VOLC_SECRETKEY")
129+
if api_key is None:
130+
api_key = os.environ.get("ARK_API_KEY")
115131
self.ak = ak
116132
self.sk = sk
133+
self.api_key = api_key
134+
135+
assert (api_key is not None) or (ak is not None and sk is not None), "you need to support api_key or ak&sk"
117136

118137
super().__init__(
119138
base_url=base_url,
@@ -135,6 +154,11 @@ def _get_endpoint_sts_token(self, endpoint_id: str):
135154
self._sts_token_manager = StsTokenManager(self.ak, self.sk)
136155
return self._sts_token_manager.get(endpoint_id)
137156

157+
@property
158+
def auth_headers(self) -> dict[str, str]:
159+
api_key = self.api_key
160+
return {"Authorization": f"Bearer {api_key}"}
161+
138162

139163
class StsTokenManager(object):
140164

volcenginesdkarkruntime/_utils/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,6 @@ def _insert_sts_token(args, kwargs):
8080

8181
ark_client = args[0]._client
8282
model = kwargs.get("model", "")
83-
if model and model.startswith("ep-") and ark_client.ak and ark_client.sk:
83+
if ark_client.api_key is None and model and model.startswith("ep-") and ark_client.ak and ark_client.sk:
8484
default_auth_header = {"Authorization": "Bearer " + ark_client._get_endpoint_sts_token(model)}
8585
kwargs["extra_headers"] = {**default_auth_header, **kwargs.get("extra_headers", {})}

volcenginesdkcdn/__init__.py

Lines changed: 643 additions & 0 deletions
Large diffs are not rendered by default.

volcenginesdkcdn/api/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from __future__ import absolute_import
2+
3+
# flake8: noqa
4+
5+
# import apis into api package
6+
from volcenginesdkcdn.api.cdn_api import CDNApi

0 commit comments

Comments
 (0)