Skip to content

Commit 6cf728f

Browse files
Merge 'integration_2025-01-09_670215300610' into 'master'
merge branch integration_2025-01-09_670215300610 into master See merge request: !485
2 parents 1686f2e + 3a64473 commit 6cf728f

File tree

123 files changed

+15331
-328
lines changed

Some content is hidden

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

123 files changed

+15331
-328
lines changed

meta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"lasted": "1.0.119",
3-
"meta_commit": "f2326846ef3a795006ca4714fc86a0ae789228a0"
2+
"lasted": "1.0.120",
3+
"meta_commit": "2428138214fb3bef64559ff5955ba6313384ba85"
44
}

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.119"
6+
VERSION = "1.0.120"
77
# To install the library, run the following
88
#
99
# python setup.py install

volcenginesdkarkruntime/_base_client.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,44 @@ def post(
557557
ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
558558
)
559559

560+
def get(
561+
self,
562+
path: str,
563+
*,
564+
cast_to: Type[ResponseT],
565+
params: list[tuple[str, str]] | None = None,
566+
options: ExtraRequestOptions = {},
567+
stream: bool = False,
568+
stream_cls: type[_StreamT] | None = None,
569+
) -> ResponseT | _StreamT:
570+
opts = RequestOptions.construct(
571+
method="get",
572+
url=path,
573+
params=params,
574+
**options,
575+
)
576+
577+
return cast(
578+
ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
579+
)
580+
581+
def delete(
582+
self,
583+
path: str,
584+
*,
585+
cast_to: Type[ResponseT],
586+
params: list[tuple[str, str]] | None = None,
587+
options: ExtraRequestOptions = {},
588+
) -> ResponseT:
589+
opts = RequestOptions.construct( # type: ignore
590+
method="delete",
591+
url=path,
592+
params=params,
593+
**options,
594+
)
595+
596+
return cast(ResponseT, self.request(cast_to, opts))
597+
560598
def request(
561599
self,
562600
cast_to: Type[ResponseT],
@@ -681,6 +719,42 @@ async def post(
681719

682720
return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
683721

722+
async def get(
723+
self,
724+
path: str,
725+
*,
726+
cast_to: Type[ResponseT],
727+
params: list[tuple[str, str]] | None = None,
728+
options: ExtraRequestOptions = {},
729+
stream: bool = False,
730+
stream_cls: type[_AsyncStreamT] | None = None,
731+
) -> ResponseT | _AsyncStreamT:
732+
opts = RequestOptions.construct(
733+
method="get",
734+
url=path,
735+
params=params,
736+
**options,
737+
)
738+
739+
return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
740+
741+
async def delete(
742+
self,
743+
path: str,
744+
*,
745+
cast_to: Type[ResponseT],
746+
params: list[tuple[str, str]] | None = None,
747+
options: ExtraRequestOptions = {},
748+
) -> ResponseT:
749+
opts = RequestOptions.construct(
750+
method="delete",
751+
url=path,
752+
params=params,
753+
**options,
754+
)
755+
756+
return await self.request(cast_to, opts)
757+
684758
async def request(
685759
self,
686760
cast_to: Type[ResponseT],

volcenginesdkarkruntime/_client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class Ark(SyncAPIClient):
3838
embeddings: resources.Embeddings
3939
tokenization: resources.Tokenization
4040
context: resources.Context
41+
content_generation: resources.ContentGeneration
4142

4243
def __init__(
4344
self,
@@ -96,6 +97,7 @@ def __init__(
9697
self.embeddings = resources.Embeddings(self)
9798
self.tokenization = resources.Tokenization(self)
9899
self.context = resources.Context(self)
100+
self.content_generation = resources.ContentGeneration(self)
99101
# self.classification = resources.Classification(self)
100102

101103
def _get_endpoint_sts_token(self, endpoint_id: str):
@@ -133,6 +135,7 @@ class AsyncArk(AsyncAPIClient):
133135
embeddings: resources.AsyncEmbeddings
134136
tokenization: resources.AsyncTokenization
135137
context: resources.AsyncContext
138+
content_generation: resources.AsyncContentGeneration
136139

137140
def __init__(
138141
self,
@@ -190,6 +193,7 @@ def __init__(
190193
self.embeddings = resources.AsyncEmbeddings(self)
191194
self.tokenization = resources.AsyncTokenization(self)
192195
self.context = resources.AsyncContext(self)
196+
self.content_generation = resources.AsyncContentGeneration(self)
193197
# self.classification = resources.AsyncClassification(self)
194198

195199
def _get_endpoint_sts_token(self, endpoint_id: str):

volcenginesdkarkruntime/_resource.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class SyncAPIResource:
1010
def __init__(self, client: "Ark") -> None:
1111
self._client = client
1212
self._post = client.post
13+
self._get = client.get
14+
self._delete = client.delete
1315

1416

1517
class AsyncAPIResource:
@@ -18,3 +20,5 @@ class AsyncAPIResource:
1820
def __init__(self, client: "AsyncArk") -> None:
1921
self._client = client
2022
self._post = client.post
23+
self._get = client.get
24+
self._delete = client.delete

volcenginesdkarkruntime/_utils/_utils.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
cast,
1212
TypeVar,
1313
)
14+
1415
from typing_extensions import TypeGuard
1516

1617
from .._types import NotGiven
@@ -87,4 +88,28 @@ def _insert_sts_token(args, kwargs):
8788
elif ark_client.api_key is None and model and model.startswith("bot-") and ark_client.ak and ark_client.sk:
8889
default_auth_header = {"Authorization": "Bearer " + ark_client._get_bot_sts_token(model)}
8990
extra_headers = kwargs.get("extra_headers") if kwargs.get("extra_headers") else {}
90-
kwargs["extra_headers"] = {**default_auth_header, **extra_headers}
91+
kwargs["extra_headers"] = {**default_auth_header, **extra_headers}
92+
93+
94+
def apikey_required(func):
95+
def wrapper(*args, **kwargs):
96+
_assert_apikey(args, kwargs)
97+
return func(*args, **kwargs)
98+
99+
return wrapper
100+
101+
102+
def async_apikey_required(func):
103+
async def wrapper(*args, **kwargs):
104+
_assert_apikey(args, kwargs)
105+
return await func(*args, **kwargs)
106+
107+
return wrapper
108+
109+
110+
def _assert_apikey(args, kwargs):
111+
assert len(args) > 0
112+
113+
ark_client = args[0]._client
114+
assert ark_client.api_key is not None, \
115+
"ak&sk authentication is currently not supported for this method, please use api key instead"

volcenginesdkarkruntime/resources/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .classification import Classification, AsyncClassification
55
from .bot import BotChat, AsyncBotChat
66
from .context import Context, AsyncContext
7+
from .content_generation import ContentGeneration, AsyncContentGeneration
78

89
__all__ = [
910
"Chat",
@@ -15,5 +16,7 @@
1516
"Tokenization",
1617
"AsyncTokenization",
1718
"Context",
18-
"AsyncContext"
19+
"AsyncContext",
20+
"ContentGeneration",
21+
"AsyncContentGeneration"
1922
]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from volcenginesdkarkruntime.resources.content_generation.content_generation import ContentGeneration, \
2+
AsyncContentGeneration
3+
4+
__all__ = ["ContentGeneration", "AsyncContentGeneration"]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from __future__ import annotations
2+
3+
from .tasks import Tasks, AsyncTasks
4+
from ..._compat import cached_property
5+
from ..._resource import SyncAPIResource, AsyncAPIResource
6+
7+
8+
class ContentGeneration(SyncAPIResource):
9+
@cached_property
10+
def tasks(self) -> Tasks:
11+
return Tasks(self._client)
12+
13+
14+
class AsyncContentGeneration(AsyncAPIResource):
15+
@cached_property
16+
def tasks(self) -> AsyncTasks:
17+
return AsyncTasks(self._client)

0 commit comments

Comments
 (0)