|
29 | 29 |
|
30 | 30 | from ..._types import Body, Query, Headers |
31 | 31 | from ..._utils._utils import deepcopy_minimal, with_sts_token, async_with_sts_token |
32 | | -from ..._utils._key_agreement import aes_gcm_decrypt_base64_string |
| 32 | +from ..._utils._key_agreement import aes_gcm_decrypt_base64_string, aes_gcm_decrypt_base64_list |
33 | 33 | from ..._base_client import make_request_options |
34 | 34 | from ..._resource import SyncAPIResource, AsyncAPIResource |
35 | 35 | from ..._compat import cached_property |
@@ -142,9 +142,14 @@ def _decrypt( |
142 | 142 | choice.message is not None and choice.finish_reason != 'content_filter' |
143 | 143 | and choice.message.content is not None |
144 | 144 | ): |
145 | | - choice.message.content = aes_gcm_decrypt_base64_string( |
| 145 | + content = aes_gcm_decrypt_base64_string( |
146 | 146 | key, nonce, choice.message.content |
147 | 147 | ) |
| 148 | + if content == '': |
| 149 | + content = aes_gcm_decrypt_base64_list( |
| 150 | + key, nonce, choice.message.content |
| 151 | + ) |
| 152 | + choice.message.content = content |
148 | 153 | resp.choices[index] = choice |
149 | 154 | return resp |
150 | 155 | else: |
@@ -291,9 +296,14 @@ async def _decrypt( |
291 | 296 | choice.message is not None and choice.finish_reason != 'content_filter' |
292 | 297 | and choice.message.content is not None |
293 | 298 | ): |
294 | | - choice.message.content = aes_gcm_decrypt_base64_string( |
| 299 | + content = aes_gcm_decrypt_base64_string( |
295 | 300 | key, nonce, choice.message.content |
296 | 301 | ) |
| 302 | + if content == '': |
| 303 | + content = aes_gcm_decrypt_base64_list( |
| 304 | + key, nonce, choice.message.content |
| 305 | + ) |
| 306 | + choice.message.content = content |
297 | 307 | resp.choices[index] = choice |
298 | 308 | return resp |
299 | 309 | else: |
|
0 commit comments