Skip to content

Commit 76d618e

Browse files
feat(ark-context): add context clone api
1 parent b3a8b00 commit 76d618e

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

volcenginesdkarkruntime/resources/context/context.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from ..._base_client import (
1414
make_request_options,
1515
)
16-
from ...types.context import CreateContextResponse
16+
from ...types.context import CreateContextResponse, CloneContextResponse
1717
from ...types.context.context_create_params import TTLTypes, TruncationStrategy, to_optional_ttl
1818
from ...types.chat import ChatCompletionMessageParam
1919

@@ -56,6 +56,30 @@ def create(
5656
cast_to=CreateContextResponse,
5757
)
5858

59+
@with_sts_token
60+
def clone(
61+
self,
62+
*,
63+
context_id: str,
64+
extra_headers: Headers | None = None,
65+
extra_query: Query | None = None,
66+
extra_body: Body | None = None,
67+
timeout: float | httpx.Timeout | None = None,
68+
) -> CloneContextResponse:
69+
return self._post(
70+
"/context/clone",
71+
body={
72+
"context_id": context_id,
73+
},
74+
options=make_request_options(
75+
extra_headers=extra_headers,
76+
extra_query=extra_query,
77+
extra_body=extra_body,
78+
timeout=timeout,
79+
),
80+
cast_to=CloneContextResponse,
81+
)
82+
5983

6084
class AsyncContext(AsyncAPIResource):
6185
@cached_property

volcenginesdkarkruntime/types/context/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55
from .context_chat_completion_chunk import ContextChatCompletionChunk
66
from .context_chat_completion import ContextChatCompletion
7-
from .create_context_response import CreateContextResponse
7+
from .create_context_response import CreateContextResponse, CloneContextResponse
88
from .context_create_params import TruncationStrategy, TTLTypes

volcenginesdkarkruntime/types/context/create_context_response.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from ..._models import BaseModel
22
from .truncation_strategy import TruncationStrategy
33

4-
__all__ = ["CreateContextResponse"]
4+
__all__ = ["CreateContextResponse", "CloneContextResponse"]
55

66

77
class CreateContextResponse(BaseModel):
@@ -16,3 +16,7 @@ class CreateContextResponse(BaseModel):
1616
Controls for how a context will be truncated prior to the run.
1717
Use this to control the context window for the chat completion.
1818
"""
19+
20+
21+
class CloneContextResponse(CreateContextResponse):
22+
pass

0 commit comments

Comments
 (0)