
    h                        S SK Jr  S SKrS SKJrJrJr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JrJr  S	SKJrJr  \(       a  S SKJr  SS jr " S S\5      r " S S\5      r " S S5      rg)    )annotationsN)TYPE_CHECKINGListOptionalcast)ArgumentParser)Literal
NamedTuple   )
get_client)	BaseModel   )Stream)ChatCompletionRoleChatCompletionChunkCompletionCreateParams)CompletionCreateParamsStreaming"CompletionCreateParamsNonStreaming)_SubParsersActionc           
     "   U R                  S5      nUR                  R                  5         UR                  S5      nUR                  S5      nUR	                  SSSSSS	S
S9  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9  UR	                  S S!S"S#9  UR                  [        R                  [        S$9  g )%Nzchat.completions.createzrequired argumentszoptional argumentsz-gz	--messageappend   )ROLECONTENTzbA message in `{role} {content}` format. Use this argument multiple times to add multiple messages.T)actionnargsmetavarhelprequiredz-mz--modelzThe model to use.)r   r   z-nz--nz6How many completions to generate for the conversation.)r   typez-Mz--max-tokensz)The maximum number of tokens to generate.z-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--stopzCA stop sequence at which to stop generating tokens for the message.)r   z--streamz!Stream messages as they're ready.
store_true)r   r   )func
args_model)
add_parser_action_groupspopadd_argument_groupadd_argumentintfloatset_defaultsCLIChatCompletioncreateCLIChatCompletionCreateArgs)	subparsersubreqopts       R/var/www/html/env/lib/python3.13/site-packages/openai/cli/_api/chat/completions.pyregisterr4      sc   


8
9C

 
 !5
6C

 
 !5
6C#q    	   E	   T>0[bef$    6    R   Z&IR^_+22?Z[    c                  *    \ rS rSr% S\S'   S\S'   Srg)
CLIMessageO   r   rolestrcontent N)__name__
__module____qualname____firstlineno____annotations____static_attributes__r<   r5   r3   r7   r7   O   s    
Lr5   r7   c                  ~    \ rS rSr% S\S'   S\S'   SrS\S'   SrS\S	'   SrS
\S'   SrS
\S'   Sr	S\S'   Sr
S\S'   Srg)r.   T   zList[CLIMessage]messager:   modelNzOptional[int]n
max_tokenszOptional[float]temperaturetop_pzOptional[str]stopFboolstreamr<   )r=   r>   r?   r@   rA   rG   rH   rI   rJ   rK   rM   rB   r<   r5   r3   r.   r.   T   sI    JA} $J$#'K'!E?!D-FDr5   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,   _   c                   U R                   U R                   Vs/ s H-  n[        [        S   UR                  5      UR
                  S.PM/     snSS.nU R                  b  U R                  US'   U R                  b  U R                  US'   U R                  b  U R                  US'   U R                  b  U R                  US'   U R                  (       a  U R                  US	'   U R                  b  U R                  US
'   U R                  (       a#  [        R                  [        [        U5      5      $ [        R                  [        [         U5      5      $ s  snf )Nuser)r9   r;   F)rF   messagesrM   rI   rK   rJ   rG   rM   rH   )rF   rE   r   r	   r9   r;   rI   rK   rJ   rG   rM   rH   r,   _stream_creater   _creater   )argsrE   paramss      r3   r-   CLIChatCompletion.create`   s    ZZimiuiuiu^egfow||<Yiu *
 '$($4$4F=!99 !YYF6N::!"jjF7O66&&F3K;;#{{F8??&#'??F< ;;$33D9XZ`4abb ((.PRX)YZZ-s   4Ec                   [        5       R                  R                  R                  " S0 U D6n[	        UR
                  5      S:  nUR
                   H  nU(       a8  [        R                  R                  SR                  UR                  5      5        UR                  R                  b  UR                  R                  OSn[        R                  R                  U5        U(       d  UR                  S5      (       d  [        R                  R                  S5        [        R                  R                  5         M     g )N   ===== Chat Completion {} =====
None
r<   )r   chatcompletionsr-   lenchoicessysstdoutwriteformatindexrE   r;   endswithflush)rV   
completionshould_print_headerchoicer;   s        r3   rT   CLIChatCompletion._create|   s    \&&2299CFC
!*"4"459 ((F"

  !C!J!J6<<!XY060F0F0Rfnn,,X^GJJW%"'*:*:4*@*@

  &JJ )r5   c                   [        [        [           [        5       R                  R
                  R                  " S0 U D65      nU H  n[        UR                  5      S:  nUR                   H  nU(       a8  [        R                  R                  SR                  UR                  5      5        UR                  R                  =(       d    Sn[        R                  R                  U5        U(       a  [        R                  R                  S5        [        R                  R!                  5         M     M     [        R                  R                  S5        g )NrY   rZ    r\   r<   )r   r   r   r   r]   r^   r-   r_   r`   ra   rb   rc   rd   re   deltar;   rg   )rV   rM   chunkri   rj   r;   s         r3   rS    CLIChatCompletion._stream_create   s     &'):):)F)F)M)M)WPV)W
 E"%emm"4q"8--&JJ$$%G%N%Nv||%\] ,,..4"

  )&JJ$$T*

  " (  	

r5   r<   N)rU   r.   returnr[   )rV   r   rq   r[   )rV   r   rq   r[   )	r=   r>   r?   r@   staticmethodr-   rT   rS   rB   r<   r5   r3   r,   r,   _   s>    [ [6    r5   r,   )r/   z!_SubParsersAction[ArgumentParser]rq   r[   )
__future__r   ra   typingr   r   r   r   argparser   typing_extensionsr	   r
   _utilsr   _modelsr   
_streamingr   
types.chatr   r   r   #types.chat.completion_create_paramsr   r   r   r4   r7   r.   r,   r<   r5   r3   <module>r|      sb    " 
 6 6 # 1     ! 

 *3\l 
) A Ar5   