File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
resources/content_generation Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -87,4 +87,18 @@ def _insert_sts_token(args, kwargs):
8787 elif ark_client .api_key is None and model and model .startswith ("bot-" ) and ark_client .ak and ark_client .sk :
8888 default_auth_header = {"Authorization" : "Bearer " + ark_client ._get_bot_sts_token (model )}
8989 extra_headers = kwargs .get ("extra_headers" ) if kwargs .get ("extra_headers" ) else {}
90- kwargs ["extra_headers" ] = {** default_auth_header , ** extra_headers }
90+ kwargs ["extra_headers" ] = {** default_auth_header , ** extra_headers }
91+
92+
93+ def disallow_aksk (func ):
94+ def wrapper (* args , ** kwargs ):
95+ _restrict_aksk (args , kwargs )
96+ return func (* args , ** kwargs )
97+
98+ return wrapper
99+
100+ def _restrict_aksk (args , kwargs ):
101+ assert len (args ) > 0
102+
103+ ark_client = args [0 ]._client
104+ assert ark_client .api_key is not None , "ak&sk authentication is currently not supported for this method, please use api key instead"
Original file line number Diff line number Diff line change 44import httpx
55
66from ..._types import Body , Query , Headers
7+ from ..._utils ._utils import disallow_aksk
78from ...types .content_generation .content_generation_task import ContentGenerationTask
89from ...types .content_generation .content_generation_task_id import ContentGenerationTaskID
910from volcenginesdkarkruntime ._base_client import make_request_options
1314
1415
1516class Tasks (SyncAPIResource ):
17+
18+ @disallow_aksk
1619 def create (
1720 self ,
1821 * ,
@@ -39,7 +42,7 @@ def create(
3942 )
4043 return resp
4144
42-
45+ @ disallow_aksk
4346 def get (
4447 self ,
4548 * ,
@@ -61,6 +64,7 @@ def get(
6164 )
6265 return resp
6366
67+ @disallow_aksk
6468 def list (
6569 self ,
6670 page_num : int | None = None ,
@@ -102,6 +106,7 @@ def list(
102106 )
103107 return resp
104108
109+ @disallow_aksk
105110 def delete (
106111 self ,
107112 task_id : str ,
You can’t perform that action at this time.
0 commit comments