Skip to content

Commit a36693a

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

File tree

2 files changed

+23
-1
lines changed
  • volcenginesdkarkruntime/resources/context
  • volcenginesdkexamples/volcenginesdkarkruntime

2 files changed

+23
-1
lines changed

volcenginesdkarkruntime/resources/context/context.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def create(
5656
cast_to=CreateContextResponse,
5757
)
5858

59-
@with_sts_token
6059
def clone(
6160
self,
6261
*,

volcenginesdkexamples/volcenginesdkarkruntime/context.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,26 @@
4242
if not chunk.choices:
4343
continue
4444
print(chunk.choices[0].delta.content, end="")
45+
46+
# Clone:
47+
print("----- clone context -----")
48+
clone_response = client.context.clone(
49+
context_id=response.id,
50+
)
51+
print(clone_response)
52+
53+
print("----- streaming request -----")
54+
stream = client.context.completions.create(
55+
context_id=clone_response.id,
56+
model="${YOUR_ENDPOINT_ID}",
57+
messages=[
58+
{"role": "user", "content": "刚才你说了什么?"},
59+
],
60+
stream=True
61+
)
62+
for chunk in stream:
63+
if chunk.usage:
64+
print(chunk.usage)
65+
if not chunk.choices:
66+
continue
67+
print(chunk.choices[0].delta.content, end="")

0 commit comments

Comments
 (0)