Ë
    $Æ%h  ã                  óÞ   — d dl mZ d dlZd dlmZmZmZ d dlmZ d dl	m
Z
 d dlmZ ddlmZ d	d
lmZmZ d	dlmZ ddlmZ ddlmZ d	dlmZ erd dlmZ dd„Z G d„ de«      Z G d„ d«      Zy)é    )ÚannotationsN)ÚTYPE_CHECKINGÚOptionalÚcast)ÚArgumentParser)Úpartial)Ú
Completioné   )Ú
get_clienté   )Ú	NOT_GIVENÚ
NotGivenOr)Úis_given)ÚCLIError)Ú	BaseModel)ÚStream)Ú_SubParsersActionc                ó  — | j                  d«      }|j                  dddd¬«       |j                  ddd	¬
«       |j                  ddd¬«       |j                  dddt        ¬«       |j                  dddt        ¬«       |j                  dddt        ¬«       |j                  dddt        ¬«       |j                  ddt        ¬«       |j                  ddt        ¬«       |j                  d d!d¬«       |j                  d"d#t        ¬«       |j                  d$d%t        ¬«       |j                  d&d'¬
«       |j                  d(d)¬
«       |j                  d*d+¬
«       |j	                  t
        j                  t        ¬,«       y )-Nzcompletions.createz-mz--modelzThe model to useT)ÚhelpÚrequiredz-pz--promptz#An optional prompt to complete from)r   z--streamzStream tokens as they're ready.Ú
store_true)r   Úactionz-Mz--max-tokensz(The maximum number of tokens to generate)r   Útypez-tz--temperaturezÜWhat sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer.

Mutually exclusive with `top_p`.z-Pz--top_pa  An alternative to sampling with temperature, called nucleus sampling, where the considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10%% probability mass are considered.

            Mutually exclusive with `temperature`.z-nz--nz5How many sub-completions to generate for each prompt.z
--logprobsa  Include the log probabilities on the `logprobs` most likely tokens, as well the chosen tokens. So for example, if `logprobs` is 10, the API will return a list of the 10 most likely tokens. If `logprobs` is 0, only the chosen tokens will have logprobs returned.z	--best_ofz”Generates `best_of` completions server-side and returns the 'best' (the one with the highest log probability per token). Results cannot be streamed.z--echoz2Echo back the prompt in addition to the completionz--frequency_penaltyz�Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.z--presence_penaltyz�Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.z--suffixz:The suffix that comes after a completion of inserted text.z--stopz3A stop sequence at which to stop generating tokens.z--userzbA unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.)ÚfuncÚ
args_model)Ú
add_parserÚadd_argumentÚintÚfloatÚset_defaultsÚCLICompletionsÚcreateÚCLICompletionCreateArgs)Ú	subparserÚsubs     úY/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/openai/cli/_api/completions.pyÚregisterr'      sæ  € Ø
×
Ñ
Ð3Ó
4€Cð ×ÑØØØØð	 ô ð ×Ñ�T˜:Ð,QÐÔRØ×Ñ�ZÐ&GÐP\ÐÔ]Ø×Ñ�T˜>Ð0ZÔadÐÔeØ×ÑØØð$ô ð ô ð ×ÑØØð6ô ð ô ð ×ÑØØØDÜð	 ô ð ×ÑØð TÜð ô ð
 ×ÑØð dÜð ô ð
 ×ÑØØAØð ô ð
 ×ÑØð mÜð ô ð
 ×ÑØð `Üð ô ð
 ×Ñ�ZÐ&bÐÔcØ×Ñ�XÐ$YÐÔZØ×ÑØØqð ô ð
 ×Ñœ.×/Ñ/Ô<SÐÕTó    c                  óÜ   — e Zd ZU ded<   dZded<   dZded<   eZd	ed
<   eZded<   eZ	ded<   eZ
ded<   eZded<   eZd	ed<   eZded<   eZd	ed<   eZd	ed<   eZded<   eZded<   eZded<   y)r#   ÚstrÚmodelFÚboolÚstreamNzOptional[str]ÚpromptzNotGivenOr[int]ÚnzNotGivenOr[str]ÚstopÚuserzNotGivenOr[bool]ÚechoÚsuffixÚbest_ofzNotGivenOr[float]Útop_pÚlogprobsÚ
max_tokensÚtemperatureÚpresence_penaltyÚfrequency_penalty)Ú__name__Ú
__module__Ú__qualname__Ú__annotations__r-   r.   r   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   © r(   r&   r#   r#   ]   sš   … ØƒJØ€FˆDÓà €FˆMÓ Ø"€A€Ó"Ø%€Dˆ/Ó%Ø%€Dˆ/Ó%Ø&€DÐ
Ó&Ø'€FˆOÓ'Ø(€Gˆ_Ó(Ø(€EÐÓ(Ø )€HˆoÓ)Ø"+€J�Ó+Ø%.€KÐ"Ó.Ø*3ÐÐ'Ó3Ø+4ÐÐ(Ô4r(   r#   c                  óB   — e Zd Zedd„«       Zedd„«       Zedd„«       Zy)r!   c                óª  — t        | j                  «      r&| j                  dkD  r| j                  rt        d«      ‚t	        t        «       j                  j                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  | j                   | j"                  | j$                  | j&                  | j(                  ¬«      }| j                  r1t*        j-                  t/        t0        t2            |d¬«      «      «      S t*        j5                   |«       «      S )Né   z6Can't stream completions with n>1 with the current CLI)r/   r2   r0   r1   r+   r5   r.   r3   r4   r6   r7   r8   r9   r:   T)r-   )r   r/   r-   r   r   r   Úcompletionsr"   r2   r0   r1   r+   r5   r.   r3   r4   r6   r7   r8   r9   r:   r!   Ú_stream_creater   r   r	   Ú_create)ÚargsÚmake_requests     r&   r"   zCLICompletions.createq   sò   € ä�D—F‘FÔ §¡¨¢
¨t¯{ª{ÜÐSÓTÐTäÜ‹L×$Ñ$×+Ñ+Ø�f‰fØ—‘Ø—‘Ø—‘Ø—*‘*Ø—*‘*Ø—;‘;Ø—;‘;Ø—L‘LØ—]‘]Ø—‘Ø×(Ñ(Ø!×2Ñ2Ø"×4Ñ4ô
ˆð$ �;Š;Ü!×0Ñ0ä”VœJÑ'©¸TÔ)BÓCóð ô
 ×%Ñ%¡l£nÓ5Ð5r(   c                óÐ  — t        | j                  «      dkD  }| j                  D ]¿  }|r8t        j                  j	                  dj                  |j                  «      «       t        j                  j	                  |j                  «       |s|j                  j                  d«      st        j                  j	                  d«       t        j                  j                  «        ŒÁ y )NrB   z===== Completion {} =====
ú
)
ÚlenÚchoicesÚsysÚstdoutÚwriteÚformatÚindexÚtextÚendswithÚflush)Ú
completionÚshould_print_headerÚchoices      r&   rE   zCLICompletions._create�   sž   € ä! *×"4Ñ"4Ó5¸Ñ9ÐØ ×(Ñ(ò 		ˆFÙ"Ü—
‘
× Ñ Ð!>×!EÑ!EÀfÇlÁlÓ!SÔTä�J‰J×Ñ˜VŸ[™[Ô)á"¨&¯+©+×*>Ñ*>¸tÔ*DÜ—
‘
× Ñ  Ô&ä�J‰J×ÑÕñ		r(   c                óþ  — | D ]Ù  }t        |j                  «      dkD  }t        |j                  d„ ¬«      D ]¤  }|r8t        j                  j                  dj                  |j                  «      «       t        j                  j                  |j                  «       |rt        j                  j                  d«       t        j                  j                  «        Œ¦ ŒÛ t        j                  j                  d«       y )NrB   c                ó   — | j                   S )N)rP   )Úcs    r&   ú<lambda>z/CLICompletions._stream_create.<locals>.<lambda>¢   s
   € À1Ç7Á7€ r(   )Úkeyz===== Chat Completion {} =====
rI   )
rJ   rK   ÚsortedrL   rM   rN   rO   rP   rQ   rS   )r-   rT   rU   rV   s       r&   rD   zCLICompletions._stream_createž   s¸   € à ò 	#ˆJÜ"% j×&8Ñ&8Ó"9¸AÑ"=ÐÜ  ×!3Ñ!3Ñ9JÔKò 	#�Ù&Ü—J‘J×$Ñ$Ð%G×%NÑ%NÈvÏ|É|Ó%\Ô]ä—
‘
× Ñ  §¡Ô-á&Ü—J‘J×$Ñ$ TÔ*ä—
‘
× Ñ Õ"ñ	#ð	#ô 	�
‰
×Ñ˜Õr(   N)rF   r#   ÚreturnÚNone)rT   r	   r]   r^   )r-   zStream[Completion]r]   r^   )r;   r<   r=   Ústaticmethodr"   rE   rD   r?   r(   r&   r!   r!   p   s<   „ Øò6ó ð6ð< òó ðð òó ñr(   r!   )r$   z!_SubParsersAction[ArgumentParser]r]   r^   )Ú
__future__r   rL   Útypingr   r   r   Úargparser   Ú	functoolsr   Úopenai.types.completionr	   Ú_utilsr   Ú_typesr   r   r   Ú_errorsr   Ú_modelsr   Ú
_streamingr   r   r'   r#   r!   r?   r(   r&   ú<module>rj      sP   ðÝ "ã 
ß 0Ñ 0Ý #Ý å .å ß +Ý Ý Ý Ý  áÝ*óEUôP5˜iô 5÷&=ò =r(   