
    h                        S SK Jr  S SKrS SKJrJrJr  S SKJr  S SK	J
r
  S SKJr  SSKJr  S	S
KJrJr  S	SKJr  SSKJr  SSKJr  S	SKJr  \(       a  S SKJr  SS jr " S S\5      r " S S5      rg)    )annotationsN)TYPE_CHECKINGOptionalcast)ArgumentParser)partial)
Completion   )
get_client   )	NOT_GIVEN
NotGivenOr)is_given)CLIError)	BaseModel)Stream)_SubParsersActionc                   U R                  S5      nUR                  SSSSS9  UR                  SSS	S
9  UR                  SSSS9  UR                  SSS[        S9  UR                  SSS[        S9  UR                  SSS[        S9  UR                  SSS[        S9  UR                  SS[        S9  UR                  SS[        S9  UR                  S S!SS9  UR                  S"S#[        S9  UR                  S$S%[        S9  UR                  S&S'S
9  UR                  S(S)S
9  UR                  S*S+S
9  UR	                  [
        R                  [        S,9  g )-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--temperaturezWhat 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_ofzGenerates `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_penaltyzPositive 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_penaltyzPositive 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     M/var/www/html/env/lib/python3.13/site-packages/openai/cli/_api/completions.pyregisterr'      s   


3
4C 	   T:,QRZ&GP\]T>0Zade$    6    D	    T  
  d  
 A  
  m  
  `  
 Z&bcX$YZq  
 .//<ST    c                      \ rS rSr% S\S'   SrS\S'   SrS\S	'   \rS
\S'   \r	S\S'   \r
S\S'   \rS\S'   \rS\S'   \rS
\S'   \rS\S'   \rS
\S'   \rS
\S'   \rS\S'   \rS\S'   \rS\S'   Srg)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____firstlineno____annotations__r.   r/   r   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   __static_attributes__r<   r(   r&   r#   r#   ]   s    JFD FM "A"%D/%%D/%&D
&'FO'(G_((E( )Ho)"+J+%.K".*3'3+4(4r(   r#   c                  P    \ rS rSr\SS j5       r\SS j5       r\S	S j5       rSrg)
r!   p   c                   [        U R                  5      (       a,  U R                  S:  a  U R                  (       a  [        S5      e[	        [        5       R                  R                  U R                  U R                  U R                  U R                  U R                  U R                  U R                  U R                  U R                  U R                   U R"                  U R$                  U R&                  U R(                  S9nU R                  (       a.  [*        R-                  [/        [0        [2           U" SS95      5      $ [*        R5                  U" 5       5      $ )N   z6Can't stream completions with n>1 with the current CLI)r0   r3   r1   r2   r,   r6   r/   r4   r5   r7   r8   r9   r:   r;   T)r.   )r   r0   r.   r   r   r   completionsr"   r3   r1   r2   r,   r6   r/   r4   r5   r7   r8   r9   r:   r;   r!   _stream_creater   r   r	   _create)argsmake_requests     r&   r"   CLICompletions.createq   s    DFF
t{{STTL$$++ff****;;;;LL]]((!22"44
$ ;;!00VJ'T)BC 
 %%ln55r(   c                   [        U R                  5      S:  nU R                   H  nU(       a8  [        R                  R	                  SR                  UR                  5      5        [        R                  R	                  UR                  5        U(       d   UR                  R                  S5      (       d  [        R                  R	                  S5        [        R                  R                  5         M     g )NrF   z===== Completion {} =====

)
lenchoicessysstdoutwriteformatindextextendswithflush)
completionshould_print_headerchoices      r&   rI   CLICompletions._create   s    !*"4"459 ((F"

  !>!E!Efll!STJJV[[)"&++*>*>t*D*D

  &JJ )r(   c                   U  H  n[        UR                  5      S:  n[        UR                  S S9 H  nU(       a8  [        R                  R                  SR                  UR                  5      5        [        R                  R                  UR                  5        U(       a  [        R                  R                  S5        [        R                  R                  5         M     M     [        R                  R                  S5        g )NrF   c                    U R                   $ )N)rU   )cs    r&   <lambda>/CLICompletions._stream_create.<locals>.<lambda>   s    177r(   )keyz===== Chat Completion {} =====
rN   )
rO   rP   sortedrQ   rR   rS   rT   rU   rV   rX   )r.   rY   rZ   r[   s       r&   rH   CLICompletions._stream_create   s     J"%j&8&8"9A"= !3!39JK&JJ$$%G%N%Nv||%\]

  -&JJ$$T*

  " L ! 	

r(   r<   N)rJ   r#   returnNone)rY   r	   re   rf   )r.   zStream[Completion]re   rf   )	r=   r>   r?   r@   staticmethodr"   rI   rH   rB   r<   r(   r&   r!   r!   p   s<    6 6<    r(   r!   )r$   z!_SubParsersAction[ArgumentParser]re   rf   )
__future__r   rQ   typingr   r   r   argparser   	functoolsr   openai.types.completionr	   _utilsr   _typesr   r   r   _errorsr   _modelsr   
_streamingr   r   r'   r#   r!   r<   r(   r&   <module>rr      sP    " 
 0 0 #  .  +     *EUP5i 5&= =r(   