@@ -107,7 +107,10 @@ def _decrypt_chunk(
107107 for chunk in resp :
108108 if chunk .choices is not None :
109109 for index , choice in enumerate (chunk .choices ):
110- if choice .delta is not None and choice .delta .content is not None :
110+ if (
111+ choice .delta is not None and choice .delta .content is not None
112+ and choice .finish_reason != 'content_filter'
113+ ):
111114 choice .delta .content = aes_gcm_decrypt_base64_string (
112115 key , nonce , choice .delta .content
113116 )
@@ -124,7 +127,7 @@ def _decrypt(
124127 if resp .choices is not None :
125128 for index , choice in enumerate (resp .choices ):
126129 if (
127- choice .message is not None
130+ choice .message is not None and choice . finish_reason != 'content_filter'
128131 and choice .message .content is not None
129132 ):
130133 choice .message .content = aes_gcm_decrypt_base64_string (
@@ -163,6 +166,7 @@ def create(
163166 tool_choice : ChatCompletionToolChoiceOptionParam | None = None ,
164167 response_format : completion_create_params .ResponseFormat | None = None ,
165168 thinking : completion_create_params .Thinking | None = None ,
169+ max_completion_tokens : Optional [int ] | None = None ,
166170 user : str | None = None ,
167171 extra_headers : Headers | None = None ,
168172 extra_query : Query | None = None ,
@@ -203,6 +207,7 @@ def create(
203207 "tool_choice" : tool_choice ,
204208 "response_format" : response_format ,
205209 "thinking" : thinking ,
210+ "max_completion_tokens" : max_completion_tokens ,
206211 },
207212 options = make_request_options (
208213 extra_headers = extra_headers ,
@@ -250,7 +255,10 @@ async def _decrypt_chunk(
250255 async for chunk in resp :
251256 if chunk .choices is not None :
252257 for index , choice in enumerate (chunk .choices ):
253- if choice .delta is not None and choice .delta .content is not None :
258+ if (
259+ choice .delta is not None and choice .delta .content is not None
260+ and choice .finish_reason != 'content_filter'
261+ ):
254262 choice .delta .content = aes_gcm_decrypt_base64_string (
255263 key , nonce , choice .delta .content
256264 )
@@ -267,7 +275,7 @@ async def _decrypt(
267275 if resp .choices is not None :
268276 for index , choice in enumerate (resp .choices ):
269277 if (
270- choice .message is not None
278+ choice .message is not None and choice . finish_reason != 'content_filter'
271279 and choice .message .content is not None
272280 ):
273281 choice .message .content = aes_gcm_decrypt_base64_string (
@@ -307,6 +315,7 @@ async def create(
307315 tool_choice : ChatCompletionToolChoiceOptionParam | None = None ,
308316 response_format : completion_create_params .ResponseFormat | None = None ,
309317 thinking : completion_create_params .Thinking | None = None ,
318+ max_completion_tokens : Optional [int ] | None = None ,
310319 extra_headers : Headers | None = None ,
311320 extra_query : Query | None = None ,
312321 extra_body : Body | None = None ,
@@ -346,6 +355,7 @@ async def create(
346355 "tool_choice" : tool_choice ,
347356 "response_format" : response_format ,
348357 "thinking" : thinking ,
358+ "max_completion_tokens" : max_completion_tokens ,
349359 },
350360 options = make_request_options (
351361 extra_headers = extra_headers ,
0 commit comments