Skip to content

Commit d0794a5

Browse files
author
liuhuiqi.7
committed
feat(arkruntime): e2ee batch chat
1 parent f5ad7bc commit d0794a5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

volcenginesdkarkruntime/resources/batch_chat/completions.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,10 @@ def _decrypt(
155155
) -> ChatCompletion:
156156
if resp.choices is not None:
157157
for index, choice in enumerate(resp.choices):
158-
if choice.message is not None and choice.message.content is not None:
158+
if (
159+
choice.finish_reason != 'content_filter' and choice.message is not None
160+
and choice.message.content is not None
161+
):
159162
choice.message.content = aes_gcm_decrypt_base64_string(
160163
key, nonce, choice.message.content
161164
)
@@ -299,7 +302,10 @@ async def _decrypt(
299302
) -> ChatCompletion:
300303
if resp.choices is not None:
301304
for index, choice in enumerate(resp.choices):
302-
if choice.message is not None and choice.message.content is not None:
305+
if (
306+
choice.finish_reason != 'content_filter' and choice.message is not None
307+
and choice.message.content is not None
308+
):
303309
choice.message.content = aes_gcm_decrypt_base64_string(
304310
key, nonce, choice.message.content
305311
)

0 commit comments

Comments
 (0)