§
    Ý
@g  ã                  óì   — 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dS )é    )ÚannotationsN)ÚTYPE_CHECKINGÚOptionalÚcast)ÚArgumentParser)Úpartial)Ú
Completioné   )Ú
get_clienté   )Ú	NOT_GIVENÚ
NotGivenOr)Úis_given)ÚCLIError)Ú	BaseModel)ÚStream)Ú_SubParsersActionÚ	subparserú!_SubParsersAction[ArgumentParser]ÚreturnÚNonec                ó   — |                       d¦  «        }|                     dddd¬¦  «         |                     ddd	¬
¦  «         |                     ddd¬¦  «         |                     dddt          ¬¦  «         |                     dddt          ¬¦  «         |                     dddt          ¬¦  «         |                     dddt          ¬¦  «         |                     ddt          ¬¦  «         |                     ddt          ¬¦  «         |                     d d!d¬¦  «         |                     d"d#t          ¬¦  «         |                     d$d%t          ¬¦  «         |                     d&d'¬
¦  «         |                     d(d)¬
¦  «         |                     d*d+¬
¦  «         |                     t
          j        t          ¬,¦  «         d S )-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)r   Úsubs     úO/var/www/piapp/venv/lib/python3.11/site-packages/openai/cli/_api/completions.pyÚregisterr*      st  € Ø
×
Ò
Ð3Ñ
4Ô
4€Cð ×ÒØØØØð	 ñ ô ð ð ×Ò�T˜:Ð,QÐÑRÔRÐRØ×Ò�ZÐ&GÐP\ÐÑ]Ô]Ð]Ø×Ò�T˜>Ð0ZÕadÐÑeÔeÐeØ×ÒØØð$õ ð ñ ô ð ð ×ÒØØð6õ ð ñ ô ð ð ×ÒØØØDÝð	 ñ ô ð ð ×ÒØð TÝð ñ ô ð ð
 ×ÒØð dÝð ñ ô ð ð
 ×ÒØØAØð ñ ô ð ð
 ×ÒØð mÝð ñ ô ð ð
 ×ÒØð `Ýð ñ ô ð ð
 ×Ò�ZÐ&bÐÑcÔcÐcØ×Ò�XÐ$YÐÑZÔZÐZØ×ÒØØqð ñ ô ð ð
 ×Ò�.Ô/Õ<SÐÑTÔTÐTÐTÐ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<   dS )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__r0   r1   r   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   © r+   r)   r'   r'   ]   s  € € € € € € Ø€J€J�JØ€FÐÐÐÑà €FÐ Ð Ð Ñ Ø"€AÐ"Ð"Ð"Ñ"Ø%€DÐ%Ð%Ð%Ñ%Ø%€DÐ%Ð%Ð%Ñ%Ø&€DÐ&Ð&Ð&Ñ&Ø'€FÐ'Ð'Ð'Ñ'Ø(€GÐ(Ð(Ð(Ñ(Ø(€EÐ(Ð(Ð(Ñ(Ø )€HÐ)Ð)Ð)Ñ)Ø"+€JÐ+Ð+Ð+Ñ+Ø%.€KÐ.Ð.Ð.Ñ.Ø*3ÐÐ3Ð3Ð3Ñ3Ø+4ÐÐ4Ð4Ð4Ñ4Ð4Ð4r+   r'   c                  óV   — e Zd Zedd„¦   «         Zedd„¦   «         Zedd„¦   «         ZdS )r%   Úargsr'   r   r   c                ó6  — t          | j        ¦  «        r!| j        dk    r| j        rt          d¦  «        ‚t	          t          ¦   «         j        j        | j        | j        | j	        | j
        | j        | j        | j        | j        | j        | j        | j        | j        | j        | j        ¬¦  «        }| j        rBt*                               t/          t0          t2                    |d¬¦  «        ¦  «        ¦  «        S t*                                |¦   «         ¦  «        S )Né   z6Can't stream completions with n>1 with the current CLI)r2   r5   r3   r4   r.   r8   r1   r6   r7   r9   r:   r;   r<   r=   T)r0   )r   r2   r0   r   r   r   Úcompletionsr&   r5   r3   r4   r.   r8   r1   r6   r7   r9   r:   r;   r<   r=   r%   Ú_stream_creater   r   r	   Ú_create)rD   Úmake_requests     r)   r&   zCLICompletions.createq   sý   € å�D”FÑÔð 	U ¤¨¢
 
¨t¬{ 
ÝÐSÑTÔTÐTåÝ‰LŒLÔ$Ô+ØŒfØ”Ø”Ø”Ø”*Ø”*Ø”;Ø”;Ø”LØ”]Ø”ØÔ(Ø!Ô2Ø"Ô4ð
ñ 
ô 
ˆð$ Œ;ð 	Ý!×0Ò0å•V�JÔ'¨¨¸TÐ)BÑ)BÔ)BÑCÔCñô ð õ
 ×%Ò% l l¡n¤nÑ5Ô5Ð5r+   Ú
completionr	   c                ó¶  — t          | j        ¦  «        dk    }| j        D ]¸}|r7t          j                             d                     |j        ¦  «        ¦  «         t          j                             |j        ¦  «         |s|j                             d¦  «        st          j                             d¦  «         t          j         	                    ¦   «          Œ¹d S )NrF   z===== Completion {} =====
ú
)
ÚlenÚchoicesÚsysÚstdoutÚwriteÚformatÚindexÚtextÚendswithÚflush)rK   Úshould_print_headerÚchoices      r)   rI   zCLICompletions._create�   sÈ   € å! *Ô"4Ñ5Ô5¸Ò9ÐØ Ô(ð 		ð 		ˆFØ"ð UÝ”
× Ò Ð!>×!EÒ!EÀfÄlÑ!SÔ!SÑTÔTÐTåŒJ×Ò˜Vœ[Ñ)Ô)Ð)à"ð '¨&¬+×*>Ò*>¸tÑ*DÔ*Dð 'Ý”
× Ò  Ñ&Ô&Ð&åŒJ×ÒÑÔÐÐð		ð 		r+   r0   úStream[Completion]c                óê  — | D ]Ð}t          |j        ¦  «        dk    }t          |j        d„ ¬¦  «        D ]ž}|r7t          j                             d                     |j        ¦  «        ¦  «         t          j                             |j        ¦  «         |rt          j                             d¦  «         t          j         	                    ¦   «          ŒŸŒÑt          j                             d¦  «         d S )NrF   c                ó   — | j         S )N)rT   )Úcs    r)   ú<lambda>z/CLICompletions._stream_create.<locals>.<lambda>¢   s   € À1Ä7€ r+   )Úkeyz===== Chat Completion {} =====
rM   )
rN   rO   ÚsortedrP   rQ   rR   rS   rT   rU   rW   )r0   rK   rX   rY   s       r)   rH   zCLICompletions._stream_createž   sê   € à ð 	#ð 	#ˆJÝ"% jÔ&8Ñ"9Ô"9¸AÒ"=ÐÝ  Ô!3Ð9JÐ9JÐKÑKÔKð 	#ð 	#�Ø&ð ^Ý”J×$Ò$Ð%G×%NÒ%NÈvÌ|Ñ%\Ô%\Ñ]Ô]Ð]å”
× Ò  ¤Ñ-Ô-Ð-à&ð +Ý”J×$Ò$ TÑ*Ô*Ð*å”
× Ò Ñ"Ô"Ð"Ð"ð	#õ 	Œ
×Ò˜ÑÔÐÐÐr+   N)rD   r'   r   r   )rK   r	   r   r   )r0   rZ   r   r   )r>   r?   r@   Ústaticmethodr&   rI   rH   rB   r+   r)   r%   r%   p   sr   € € € € € Øð6ð 6ð 6ñ „\ð6ð< ðð ð ñ „\ðð ðð ð ñ „\ðð ð r+   r%   )r   r   r   r   )Ú
__future__r   rP   Útypingr   r   r   Úargparser   Ú	functoolsr   Úopenai.types.completionr	   Ú_utilsr   Ú_typesr   r   r   Ú_errorsr   Ú_modelsr   Ú
_streamingr   r   r*   r'   r%   rB   r+   r)   ú<module>rl      sy  ðØ "Ð "Ð "Ð "Ð "Ð "à 
€
€
€
Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø #Ð #Ð #Ð #Ð #Ð #Ø Ð Ð Ð Ð Ð à .Ð .Ð .Ð .Ð .Ð .à Ð Ð Ð Ð Ð Ø +Ð +Ð +Ð +Ð +Ð +Ð +Ð +Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  àð +Ø*Ð*Ð*Ð*Ð*Ð*ðEUð EUð EUð EUðP5ð 5ð 5ð 5ð 5˜iñ 5ô 5ð 5ð&=ð =ð =ð =ð =ñ =ô =ð =ð =ð =r+   