22
33from __future__ import annotations
44
5- from typing import Dict , Iterable
5+ import typing_extensions
6+ from typing import Dict , Union , Iterable
67from typing_extensions import Literal
78
89import httpx
@@ -46,6 +47,7 @@ def with_streaming_response(self) -> ChatResourceWithStreamingResponse:
4647 """
4748 return ChatResourceWithStreamingResponse (self )
4849
50+ @typing_extensions .deprecated ("deprecated" )
4951 def create_completion (
5052 self ,
5153 * ,
@@ -66,6 +68,8 @@ def create_completion(
6668 n : float | Omit = omit ,
6769 presence_penalty : float | Omit = omit ,
6870 response_format : chat_create_completion_params .ResponseFormat | Omit = omit ,
71+ seed : int | Omit = omit ,
72+ stop : Union [str , SequenceNotStr [str ]] | Omit = omit ,
6973 stream : bool | Omit = omit ,
7074 temperature : float | Omit = omit ,
7175 tool_choice : Literal ["none" , "auto" , "required" ] | Omit = omit ,
@@ -80,9 +84,10 @@ def create_completion(
8084 extra_body : Body | None = None ,
8185 timeout : float | httpx .Timeout | None | NotGiven = not_given ,
8286 ) -> ChatCreateCompletionResponse :
83- """Chat with a language model .
87+ """**Deprecated**: Use `POST /v2/ai/openai/chat/completions` instead .
8488
85- This endpoint is consistent with the
89+ Chat with a
90+ language model. This endpoint is consistent with the
8691 [OpenAI Chat Completions API](https://platform.openai.com/docs/api-reference/chat)
8792 and may be used with the OpenAI JS or Python SDK.
8893
@@ -135,6 +140,13 @@ def create_completion(
135140 response_format: Use this is you want to guarantee a JSON output without defining a schema. For
136141 control over the schema, use `guided_json`.
137142
143+ seed: If specified, the system will make a best effort to sample deterministically,
144+ such that repeated requests with the same `seed` and parameters should return
145+ the same result.
146+
147+ stop: Up to 4 sequences where the API will stop generating further tokens. The
148+ returned text will not contain the stop sequence.
149+
138150 stream: Whether or not to stream data-only server-sent events as they become available.
139151
140152 temperature: Adjusts the "creativity" of the model. Lower values make the model more
@@ -187,6 +199,8 @@ def create_completion(
187199 "n" : n ,
188200 "presence_penalty" : presence_penalty ,
189201 "response_format" : response_format ,
202+ "seed" : seed ,
203+ "stop" : stop ,
190204 "stream" : stream ,
191205 "temperature" : temperature ,
192206 "tool_choice" : tool_choice ,
@@ -226,6 +240,7 @@ def with_streaming_response(self) -> AsyncChatResourceWithStreamingResponse:
226240 """
227241 return AsyncChatResourceWithStreamingResponse (self )
228242
243+ @typing_extensions .deprecated ("deprecated" )
229244 async def create_completion (
230245 self ,
231246 * ,
@@ -246,6 +261,8 @@ async def create_completion(
246261 n : float | Omit = omit ,
247262 presence_penalty : float | Omit = omit ,
248263 response_format : chat_create_completion_params .ResponseFormat | Omit = omit ,
264+ seed : int | Omit = omit ,
265+ stop : Union [str , SequenceNotStr [str ]] | Omit = omit ,
249266 stream : bool | Omit = omit ,
250267 temperature : float | Omit = omit ,
251268 tool_choice : Literal ["none" , "auto" , "required" ] | Omit = omit ,
@@ -260,9 +277,10 @@ async def create_completion(
260277 extra_body : Body | None = None ,
261278 timeout : float | httpx .Timeout | None | NotGiven = not_given ,
262279 ) -> ChatCreateCompletionResponse :
263- """Chat with a language model .
280+ """**Deprecated**: Use `POST /v2/ai/openai/chat/completions` instead .
264281
265- This endpoint is consistent with the
282+ Chat with a
283+ language model. This endpoint is consistent with the
266284 [OpenAI Chat Completions API](https://platform.openai.com/docs/api-reference/chat)
267285 and may be used with the OpenAI JS or Python SDK.
268286
@@ -315,6 +333,13 @@ async def create_completion(
315333 response_format: Use this is you want to guarantee a JSON output without defining a schema. For
316334 control over the schema, use `guided_json`.
317335
336+ seed: If specified, the system will make a best effort to sample deterministically,
337+ such that repeated requests with the same `seed` and parameters should return
338+ the same result.
339+
340+ stop: Up to 4 sequences where the API will stop generating further tokens. The
341+ returned text will not contain the stop sequence.
342+
318343 stream: Whether or not to stream data-only server-sent events as they become available.
319344
320345 temperature: Adjusts the "creativity" of the model. Lower values make the model more
@@ -367,6 +392,8 @@ async def create_completion(
367392 "n" : n ,
368393 "presence_penalty" : presence_penalty ,
369394 "response_format" : response_format ,
395+ "seed" : seed ,
396+ "stop" : stop ,
370397 "stream" : stream ,
371398 "temperature" : temperature ,
372399 "tool_choice" : tool_choice ,
@@ -388,33 +415,41 @@ class ChatResourceWithRawResponse:
388415 def __init__ (self , chat : ChatResource ) -> None :
389416 self ._chat = chat
390417
391- self .create_completion = to_raw_response_wrapper (
392- chat .create_completion ,
418+ self .create_completion = ( # pyright: ignore[reportDeprecated]
419+ to_raw_response_wrapper (
420+ chat .create_completion , # pyright: ignore[reportDeprecated],
421+ )
393422 )
394423
395424
396425class AsyncChatResourceWithRawResponse :
397426 def __init__ (self , chat : AsyncChatResource ) -> None :
398427 self ._chat = chat
399428
400- self .create_completion = async_to_raw_response_wrapper (
401- chat .create_completion ,
429+ self .create_completion = ( # pyright: ignore[reportDeprecated]
430+ async_to_raw_response_wrapper (
431+ chat .create_completion , # pyright: ignore[reportDeprecated],
432+ )
402433 )
403434
404435
405436class ChatResourceWithStreamingResponse :
406437 def __init__ (self , chat : ChatResource ) -> None :
407438 self ._chat = chat
408439
409- self .create_completion = to_streamed_response_wrapper (
410- chat .create_completion ,
440+ self .create_completion = ( # pyright: ignore[reportDeprecated]
441+ to_streamed_response_wrapper (
442+ chat .create_completion , # pyright: ignore[reportDeprecated],
443+ )
411444 )
412445
413446
414447class AsyncChatResourceWithStreamingResponse :
415448 def __init__ (self , chat : AsyncChatResource ) -> None :
416449 self ._chat = chat
417450
418- self .create_completion = async_to_streamed_response_wrapper (
419- chat .create_completion ,
451+ self .create_completion = ( # pyright: ignore[reportDeprecated]
452+ async_to_streamed_response_wrapper (
453+ chat .create_completion , # pyright: ignore[reportDeprecated],
454+ )
420455 )
0 commit comments