
    h
              !          d dl Z d dlmZ d dlZd dlZd dlZddlmZ  ej                         d        Zej                          ej                  d       ej                  ddd	d
       ej                  dded       ej                  ded       ej                  ded       ej                  ded       ej                  ded       ej                  ded       ej                  ded      ej                  	 	 	 	 	 	 	 d'dej                   dedeedf   dee   d ee   d!ee   d"ee   d#ee   d$ee   d%ee   fd&                                                                             Zy)(    N)Optional   )
ChatClientc                       y)z1Chat with models through the LiteLLM proxy serverN r       b/var/www/Befach/backend/env/lib/python3.12/site-packages/litellm/proxy/client/cli/commands/chat.pychatr
      s     	r   modelz	--messagez-mTzWMessages in 'role:content' format (e.g. 'user:Hello'). Can be specified multiple times.)multiplehelpz--temperaturez-tz$Sampling temperature between 0 and 2)typer   z--top-pz*Nucleus sampling parameter between 0 and 1z--nz!Number of completions to generatez--max-tokensz$Maximum number of tokens to generatez--presence-penaltyz%Presence penalty between -2.0 and 2.0z--frequency-penaltyz&Frequency penalty between -2.0 and 2.0z--userz"Unique identifier for the end userctxmessage.temperaturetop_pn
max_tokenspresence_penaltyfrequency_penaltyuserc
                    |st        j                  d      g }
|D ]H  }	 |j                  dd      \  }}|
j                  |j	                         |j	                         d       J t        | j                  d   | j                  d         }	 |j                  ||
|||||||			      }t        j                  |
       y# t
        $ r t        j                  d| d      w xY w# t        j                  j                  $ r}t        j                  d|j                   j"                   d       	 |j                   j%                         }t        j                  |
       t        j*                         # t$        j&                  $ rA t        j                  |j                   j(                  d       Y t        j*                         w xY wd}~ww xY w)zCreate a chat completionz At least one message is required:   )rolecontentzInvalid message format: z!. Expected format: 'role:content'base_urlapi_key)	r   messagesr   r   r   r   r   r   r   )datazError: HTTP T)errN)click
UsageErrorsplitappendstrip
ValueErrorBadParameterr   objcompletionsrich
print_jsonrequests
exceptions	HTTPErrorechoresponsestatus_codejsonJSONDecodeErrortextAbort)r   r   r   r   r   r   r   r   r   r   r   msgr   r   clientr1   e
error_bodys                     r	   r*   r*      s   t ABB H	hIIc1-MD'OOTZZ\gmmoNO  
+SWWY-?@F%%#!-/ & 

 	X&!  	h$$'?uDe%fgg	h" (( 

\!**"8"8!9:E	2*JOO, kkm ## 	2JJqzzD1kkm	2sH   AB?0C% ?#C"%G.G10E5!G5>G	3GG		GG)NNNNNNN)r3   typingr   r"   r+   r-   r
   r   groupcommandargumentoptionfloatintstrpass_contextContexttupler*   r   r   r	   <module>rF      s         	 	
 	b	 		/	 		5
 			,
 		/
 		0
 		1
 		-
 
 $(! $(,)-.	.. 38_. %	.
 E?. }. . uo.  . 3-.   Z.r   