
    h                         d dl Z d dlZd dlmZ d dlZd dlmZ er	 d Zd Zdej                  fdZ
ded	efd
Zdedej                  fdZdej                  fdZy)    N)TYPE_CHECKING)verbose_loggerc                  D   	 t        j                         j                  } | dk  rt        j                  d       d}d}d}d}d	}d
}d}|||dz
  z  z   |z   }	|||dz
  z  z   |z   }
t        j                  |dd      }t        j                  |dd      }t        j                  ddd      }t        j                  t        j                  |	dd             d|dz
  z  }t        j                  | d| d|        t        j                  t        j                  |
dd             t        j                  dd       t        j                  d| d| d       	 t               j                         }t        j                  d       t        j                  d       |S # t
        $ r8}t        j                  d|        t        j                  d       Y d}~d}~ww xY w# t        t        f$ r, t        j                  d       t        j                  d        w xY w)z/Create a styled blue box prompt for user input.
   z


zError getting terminal size: Nu   ┌u   ┐u   └u   ┘u   ─u   │P      blueT)fgboldz> cyan    z[2AF)nlz[1B )osget_terminal_sizelinesclickecho	Exceptionr   debugstyleinputstripKeyboardInterruptEOFError)terminal_heightetop_left	top_rightbottom_leftbottom_right
horizontalverticalwidthtop_linebottom_lineleft_borderright_borderprompt_textempty_space
user_inputs                   ^/var/www/Befach/backend/env/lib/python3.12/site-packages/litellm/proxy/client/cli/interface.pystyled_promptr/      s   	..066RJJx  HIKLJH E*	22Y>H
eai 88<GK ++h6=K;;xF>L++dvD9K 
JJu{{8T:; #K	JJ+a}Al^<= 
JJu{{;6=> 
JJyU#	JJK=+/E:W]]_
 	

9

2 g  <QC@A

8Z x( 

9

2	s$   8F  AG$  	G!)-GG!$;Hc                      g d} t        j                  d       | D ]!  \  }}t        j                  d|dd|        # t        j                          y)zDisplay available commands.))loginz*Authenticate with the LiteLLM proxy server)logoutzClear stored authentication)whoamiz"Show current authentication status)modelsz$Manage and view model configurations)credentialszManage API credentials)chatzInteractive chat with models)httpzMake HTTP requests to the proxy)keyszManage API keys)userszManage users)versionzShow version information)helpzShow this help message)quitzExit the interactive sessionzAvailable commands:z  z<20r   N)r   r   )commandscmddescriptions      r.   show_commandsr@   O   sK    H 
JJ$%$[

RCy+/0 %	JJL    ctxc                     ddl m}  |        | j                  j                  d      }t	        j
                  d| dd       t                y)	z:Set up the interactive shell with banner and initial info.r   show_bannerbase_urlzConnected to LiteLLM server: 
green)r
   N)!litellm.proxy.common_utils.bannerrE   objgetr   sechor@   )rB   rE   rF   s      r.   setup_shellrM   f   s;    =M ww{{:&H	KK/z<IOrA   r-   returnc                 8   | j                         dv rt        j                  d       y| j                         dk(  r t        j                  d       t                y| j                         dk(  r,t        j                          ddlm}  |        t                yy	)
zTHandle special commands like exit, help, clear. Returns True if command was handled.exitr<   zGoodbye!Tr;   r   clearr   rD   F)lowerr   r   r@   rR   rI   rE   )r-   rE   s     r.   handle_special_commandsrT   s   st    --

:				v	%

2				w	&ArA   c                    | j                         }|d   }t        |      dkD  r|dd ng }ddlm} |j                  }||j
                  vr.t        j                  d|        t        j                  d       y	 dg|gz   |z   t        _	        |j
                  |   }|j                         5  |j                  ||d	       ddd       y# 1 sw Y   yxY w# t        j                  $ r}|j                          Y d}~yd}~wt        j                  $ r t        j                  d
       Y yt        $ r Y yt        $ r"}t        j                  d|        Y d}~yd}~ww xY w)zParse and execute a command.r      N)mainzUnknown command: z&Type 'help' to see available commands.zlitellm-proxyF)parentstandalone_modezCommand aborted.zError executing command: )splitlenr   rW   clir=   r   r   sysargvscopeClickExceptionshowAbort
SystemExitr   )	r-   rB   partscommandargsrW   r\   r>   r   s	            r.   execute_commandrg      s=    EAhGE
Q59BD 
((C cll"

&wi01

;<4#$y047 ll7# YY[ 	HH %  	 	 	  	;; '

%&  4

.qc2334sN   :2C ,C
C 
CC C E)C>>+E+E5E=EEc                 ^   t        |        	 	 t        j                  d       t               }|s$t	        |      r|j                         dv ryCt        ||        O# t        t        f$ r t        j                  d       Y yt        $ r"}t        j                  d|        Y d}~Ld}~ww xY w)zRun the interactive shell.rG   rP   z	
Goodbye!zError: N)
rM   r   r   r/   rT   rS   rg   r   r   r   )rB   r-   r   s      r.   interactive_shellri      s    
	&JJt 'J 'z2##%)99 J,% ( "8, 	JJ|$ 	&JJ}%%	&s(   !A A A $B,B,
B''B,)r   r]   typingr   r   litellm._loggingr   r/   r@   ContextrM   strboolrT   rg   ri    rA   r.   <module>rp      sr    	 
    +=@.
U]] 
  &)4 )4%-- )4X&5== &rA   