
    g;                         d Z ddlmZmZmZmZmZmZ ddlZddl	m
Z
mZ ddlmZ ddlmZmZ ddlmZ  G d	 d
e      Z G d de      Zdedee   defdZy)z:
- completion
- acompletion
- streaming
- async_streaming
    )AnyAsyncIteratorCallableIteratorOptionalUnionN)AsyncHTTPHandlerHTTPHandler)GenericStreamingChunk)ImageResponseModelResponse   )BaseLLMc                        e Zd Z fdZ xZS )CustomLLMErrorc                 T    || _         || _        t        |   | j                         y N)status_codemessagesuper__init__)selfr   r   	__class__s      L/var/www/openai/venv/lib/python3.12/site-packages/litellm/llms/custom_llm.pyr   zCustomLLMError.__init__   s(    
 'LL	
    )__name__
__module____qualname__r   __classcell__r   s   @r   r   r      s    	
 	
r   r   c                       e Zd Zd fdZdddi ddfdededededed	ed
ede	e
eej                  f      de	e   defdZdddi ddfdededededed	ed
ede	e
eej                  f      de	e   dee   fdZdddi ddfdededededed	ed
ede	e
eej                  f      de	e   defdZdddi ddfdededededed	ed
ede	e
eej                  f      de	e   dee   fdZ	 	 ddedede	e   de	e   ded
edede	e
eej                  f      de	e   defdZ	 	 ddededede	e   de	e   d
edede	e
eej                  f      de	e   defdZ xZS )	CustomLLMreturnNc                 "    t         |           y r   )r   r   )r   r   s    r   r   zCustomLLM.__init__$   s    r   modelmessagesapi_basecustom_prompt_dictmodel_responseprint_verboseoptional_paramstimeoutclientc                     t        dd      Ni  zNot implemented yet!)r   r   r   r   r%   r&   r'   r(   r)   r*   encodingapi_keylogging_objr+   acompletionlitellm_params	logger_fnheadersr,   r-   s                    r   
completionzCustomLLM.completion'       & 6LMMr   c                     t        dd      r/   r0   r1   s                    r   	streamingzCustomLLM.streaming<   r:   r   c                 $   K   t        dd      wr/   r0   r1   s                    r   r5   zCustomLLM.acompletionQ        & 6LMM   c                 $   K   t        dd      wr/   r0   r1   s                    r   
astreamingzCustomLLM.astreamingf   r>   r?   promptr3   r4   c
                     t        dd      r/   r0   )
r   r%   rB   r3   r'   r)   r+   r4   r,   r-   s
             r   image_generationzCustomLLM.image_generation{   s     6LMMr   c
                 $   K   t        dd      wr/   r0   )
r   r%   rB   r)   r3   r'   r+   r4   r,   r-   s
             r   aimage_generationzCustomLLM.aimage_generation   s       6LMMr?   )r#   N)NN)r   r   r   r   strlistdictr   r   r   r   floathttpxTimeoutr
   r9   r   r   r<   r	   r5   r   rA   r   r   rD   rF   r   r    s   @r   r"   r"   #   s    9=(,#NN N 	N
 !N &N  N N  %u}} 456!N" %#N$ 
%NB 9=(,#NN N 	N
 !N &N  N N  %u}} 456!N" %#N$ 
'	(%NB 9=-1#NN N 	N
 !N &N  N N  %u}} 456!N" )*#N$ 
%NB 9=-1#NN N 	N
 !N &N  N N  %u}} 456!N" )*#N$ 
,	-%N< :>(,NN N #	N
 3-N &N N N %u}} 456N %N 
N6 :>-1NN N &	N
 
N 
N N N %u}} 456N )*N 
Nr   r"   async_fnstream
custom_llmc                 n    | r|r|j                   S |j                  S |r|j                  S |j                  S )z
    Routes call to CustomLLM completion/acompletion/streaming/astreaming functions, based on call type

    Validates if response is in expected format
    )rA   r5   r<   r9   )rM   rN   rO   s      r   custom_chat_llm_routerrQ      s=     (((%%%###   r   )__doc__typingr   r   r   r   r   r   rK   &litellm.llms.custom_httpx.http_handlerr	   r
   litellm.types.utilsr   litellm.utilsr   r   baser   	Exceptionr   r"   boolrQ    r   r   <module>r[      s`    K J  P 5 6 

Y 

vN vNr!!$TN!8A!r   