
    jj                        d dl Z d dlZd dlZd dlmZ d dlmZmZmZm	Z	m
Z
mZmZmZ d dlZd dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZmZmZmZm Z  d d
l!m"Z" d dl#m$Z$ d dl%m&Z&m'Z' g dZ(e'	 	 	 	 	 	 	 d8de)deee)ef      dee	e)      de
d   deee)ef      deee)ef      deee)ef      defd       Z*e	 	 	 	 	 	 	 d9de)deee)ef      dee	e)      dee)   dee)   dee)   de
d   de
d   deeeef   fd       Z+e	 	 	 	 	 	 	 d9ddde)deee)ef      dee	e)      dee)   dee)   dee)   de
d   de
d   defd        Z+e'	 	 	 	 	 	 	 d8de)deee)ef      dee	e)      de
d   deee)ef      deee)ef      deee)ef      deeeeeef   f   fd!       Z+e'	 	 	 	 	 	 	 	 d:d"ee)   d#ee,   d$ee)   de
d   deee)ef      deee)ef      deee)ef      defd%       Z-e	 	 	 	 	 	 	 	 d;d"ee)   d#ee,   d$ee)   dee)   dee)   dee)   de
d   d&e
d   deeeef   fd'       Z.e	 	 	 	 	 	 	 	 d;dd(d"ee)   d#ee,   d$ee)   dee)   dee)   dee)   de
d   d&e
d   defd)       Z.e'	 	 	 	 	 	 	 	 d:d"ee)   d#ee,   d$ee)   de
d   deee)ef      deee)ef      deee)ef      deeeeeef   f   fd*       Z.e'	 	 	 	 	 d<d+e)de
d   deee)ef      deee)ef      deee)ef      defd,       Z/e	 	 	 	 	 d=d+e)dee)   dee)   dee)   de
d   d-e
d   deeeef   fd.       Z0e	 	 	 	 	 d=dd/d+e)dee)   dee)   dee)   de
d   d-e
d   defd0       Z0e'	 	 	 	 	 d<d+e)de
d   deee)ef      deee)ef      deee)ef      deeeeeef   f   fd1       Z0e'	 	 	 	 	 d<d+e)de
d   deee)ef      deee)ef      deee)ef      de fd2       Z1e	 	 	 	 	 d=d+e)dee)   dee)   dee)   de
d   d3e
d   deeee f   fd4       Z2e	 	 	 	 	 d=dd5d+e)dee)   dee)   dee)   de
d   d3e
d   de fd6       Z2e'	 	 	 	 	 d<d+e)de
d   deee)ef      deee)ef      deee)ef      dee eeee f   f   fd7       Z2y)>    N)partial)Any	CoroutineDictListLiteralOptionalUnionoverload)request_timeout)ContainerRequestUtils)Logging)BaseContainerConfig)base_llm_http_handler)$ContainerCreateOptionalRequestParams"ContainerListOptionalRequestParamsContainerListResponseContainerObjectDeleteContainerResult)GenericLiteLLMParams)	CallTypes)ProviderConfigManagerclient)acreate_containeradelete_containeralist_containersaretrieve_containercreate_containerdelete_containerlist_containersretrieve_containeropenainameexpires_afterfile_idscustom_llm_providerextra_headersextra_query
extra_bodyreturnc                   K   t               }		 t        j                         }
d|d<   t        t        f| |||||||d|}t        j                         }t        |j                  |      }|
j                  d|       d{   }t        j                  |      r| d{   }|S |}|S 7 )7 # t        $ r}t        j                  d|||	|      d}~ww xY ww)a4  Asynchronously calls the `create_container` function with the given arguments and keyword arguments.

    Parameters:
    - `name` (str): Name of the container to create
    - `expires_after` (Optional[Dict[str, Any]]): Container expiration time settings
    - `file_ids` (Optional[List[str]]): IDs of files to copy to the container
    - `timeout` (int): Request timeout in seconds
    - `custom_llm_provider` (Optional[Literal["openai"]]): The LLM provider to use
    - `extra_headers` (Optional[Dict[str, Any]]): Additional headers
    - `extra_query` (Optional[Dict[str, Any]]): Additional query parameters
    - `extra_body` (Optional[Dict[str, Any]]): Additional body parameters
    - `kwargs` (dict): Additional keyword arguments

    Returns:
    - `response` (ContainerObject): The created container object
    T
async_call)r#   r$   r%   timeoutr&   r'   r(   r)   N modelr&   original_exceptioncompletion_kwargsextra_kwargs)localsasyncioget_event_loopr   r   contextvarscopy_contextrunrun_in_executoriscoroutine	Exceptionlitellmexception_type)r#   r$   r%   r-   r&   r'   r(   r)   kwargs
local_varsloopfuncctxfunc_with_contextinit_responseresponsees                    p/Users/manta/Documents/Projects/TheRoad-I1/backend/.venv/lib/python3.12/site-packages/litellm/containers/main.pyr   r   $   s     > J"
%%'#|
' 3'#!
 
 &&(#CGGT2"2249JKK}-**H  %H L +
  
$$ 3 (
 	

Y   CA1B- ?B) B- B+B- $C%B- (C)B- +B- -	C6CCCapi_keyapi_baseapi_versionr   Tc                     y N 
r#   r$   r%   r-   rJ   rK   rL   r&   r   r?   s
             rH   r   r   l            F)r   c                     y rN   rO   rP   s
             rH   r   r   }   rQ   rR   c           
      2   t               }		 |j                  d      }
|j                  d      }|j                  dd      du }|j                  d      }|2t        |t              rt        j                  |      }t        di |}|S t        di |}t        j                  t        j                  |            }|t        d	|       |	j                  |       t        j                   |	      }t        j"                  ||
      }|
j%                  dt'        |      d|i||       t(        j*                  j,                  |
_        t1        j2                  | ||||
||xs t4        |      S # t6        $ r}t        j8                  d|||	|      d}~ww xY w)a  Create a container using the OpenAI Container API.

    Currently supports OpenAI

    Example:
    ```python
    import litellm
    
    response = litellm.create_container(
        name="My Container",
        custom_llm_provider="openai",
    )
    print(response)
    ```
    litellm_logging_objlitellm_call_idr,   FTmock_responseNproviderz+container operations are not supported for )container_provider_config container_create_optional_paramsr.   r0   optional_paramslitellm_paramsr&   )r#   container_create_request_paramsrZ   r^   logging_objr'   r-   	_is_asyncr/   rO   )r4   popget
isinstancestrjsonloadsr   r   r   get_provider_container_configr=   LlmProviders
ValueErrorupdater   -get_requested_container_create_optional_param$get_optional_params_container_createupdate_environment_variablesdictr   r   value	call_typer   container_create_handlerDEFAULT_REQUEST_TIMEOUTr<   r>   )r#   r$   r%   r-   r&   r'   r(   r)   r?   r@   rU   rV   ra   rW   rF   r^   rZ   r[   r_   rG   s                       rH   r   r      s   @ JH
17<Q1R)/4E)FJJ|U3t;	 

?3$-- $

= 9&77HO .77 "?? --.AB 	" %,JK^J_`aa&! "OOPZ[ 	) "FF*C1Q 	( 	88 !@A!?1 !4 	9 	
 )2(B(B(H(H%$==,K&?)+'66	
 		
  
$$ 3 (
 	

s   A:E. C&E. .	F7FFafterlimitorderc                   K   t               }		 t        j                         }
d|d<   t        t        f| |||||||d|}t        j                         }t        |j                  |      }|
j                  d|       d{   }t        j                  |      r| d{   }|S |}|S 7 )7 # t        $ r}t        j                  d|||	|      d}~ww xY ww)a  Asynchronously list containers.

    Parameters:
    - `after` (Optional[str]): A cursor for pagination
    - `limit` (Optional[int]): Number of items to return (1-100, default 20)
    - `order` (Optional[str]): Sort order ('asc' or 'desc', default 'desc')
    - `timeout` (int): Request timeout in seconds
    - `custom_llm_provider` (Literal["openai"]): The LLM provider to use
    - `extra_headers` (Optional[Dict[str, Any]]): Additional headers
    - `extra_query` (Optional[Dict[str, Any]]): Additional query parameters
    - `extra_body` (Optional[Dict[str, Any]]): Additional body parameters
    - `kwargs` (dict): Additional keyword arguments

    Returns:
    - `response` (ContainerListResponse): The list of containers
    Tr,   )rt   ru   rv   r-   r&   r'   r(   r)   Nr.   r/   )r4   r5   r6   r   r    r7   r8   r9   r:   r;   r<   r=   r>   )rt   ru   rv   r-   r&   r'   r(   r)   r?   r@   rA   rB   rC   rD   rE   rF   rG   s                    rH   r   r      s     < J"
%%'#|
 3'#!
 
 &&(#CGGT2"2249JKK}-**H  %H L +
  
$$ 3 (
 	

rI   r   c                     y rN   rO   
rt   ru   rv   r-   rJ   rK   rL   r&   r   r?   s
             rH   r    r    C  rQ   rR   )r   c                     y rN   rO   ry   s
             rH   r    r    T  rQ   rR   c                    t               }		 |j                  d      }
|j                  d      }|j                  dd      du }|j                  d      }|2t        |t              rt        j                  |      }t        di |}|S t        di |}t        j                  t        j                  |            }|t        d	|       t        j                  |	      }|
j!                  d
t#        |      d|i||       t$        j&                  j(                  |
_        t-        j.                  |||
| |||||xs t0        |
      S # t2        $ r}t        j4                  d
|||	|      d}~ww xY w)zSList containers using the OpenAI Container API.

    Currently supports OpenAI
    rU   rV   r,   FTrW   NrX   2Container provider config not found for provider: r.   r\   )
rZ   r^   r`   rt   ru   rv   r'   r(   r-   ra   r/   rO   )r4   rb   rc   rd   re   rf   rg   r   r   r   rh   r=   ri   rj   r   +get_requested_container_list_optional_paramrn   ro   r   r    rp   rq   r   container_list_handlerrs   r<   r>   )rt   ru   rv   r-   r&   r'   r(   r)   r?   r@   rU   rV   ra   rW   rF   r^   rZ   container_list_optional_paramsrG   s                      rH   r    r    g  s   * JA
17<Q1R)/4E)FJJ|U3t;	 

?3$-- $

= 9,=}=HO .77 "?? --.AB 	" %,QReQfghh "MMjY 	'
 	88 !?@!?0 !4 	9 	
 )2(A(A(G(G%$;;&?)+'#66
 	
  
$$ 3 (
 	

s   A:E C E 	E0E++E0container_idc           
        K   t               }	 t        j                         }d|d<   t        t        f| |||||d|}	t        j                         }
t        |
j                  |	      }|j                  d|       d{   }t        j                  |      r| d{   }|S |}|S 7 )7 # t        $ r}t        j                  d||||      d}~ww xY ww)aK  Asynchronously retrieve a container.

    Parameters:
    - `container_id` (str): The ID of the container to retrieve
    - `timeout` (int): Request timeout in seconds
    - `custom_llm_provider` (Literal["openai"]): The LLM provider to use
    - `extra_headers` (Optional[Dict[str, Any]]): Additional headers
    - `extra_query` (Optional[Dict[str, Any]]): Additional query parameters
    - `extra_body` (Optional[Dict[str, Any]]): Additional body parameters
    - `kwargs` (dict): Additional keyword arguments

    Returns:
    - `response` (ContainerObject): The container object
    Tr,   r   r-   r&   r'   r(   r)   Nr.   r/   )r4   r5   r6   r   r!   r7   r8   r9   r:   r;   r<   r=   r>   r   r-   r&   r'   r(   r)   r?   r@   rA   rB   rC   rD   rE   rF   rG   s                  rH   r   r     s     4 J 
%%'#|	
% 3'#!	
 	
 &&(#CGGT2"2249JKK}-**H  %H L +
  
$$ 3 (
 	

Y   CA/B+ =B'>B+ B)B+ "C#B+ &C'B+ )B+ +	C4CCCr   c                     y rN   rO   r   r-   rJ   rK   rL   r&   r   r?   s           rH   r!   r!          rR   )r   c                     y rN   rO   r   s           rH   r!   r!     r   rR   c           
         t               }	 |j                  d      }|j                  d      }	|j                  dd      du }
|j                  d      }|2t        |t              rt        j                  |      }t        di |}|S t        di |}t        j                  t        j                  |            }|t        d	|       |j                  d
i d|	i|       t        j                   j"                  |_        t'        j(                  | ||||||xs t*        |
      S # t,        $ r}t        j.                  d
||||      d}~ww xY w)zXRetrieve a container using the OpenAI Container API.

    Currently supports OpenAI
    rU   rV   r,   FTrW   NrX   r|   r.   r\   r   rZ   r^   r`   r'   r(   r-   ra   r/   rO   )r4   rb   rc   rd   re   rf   rg   r   r   r   rh   r=   ri   rj   rn   r   r!   rp   rq   r   container_retrieve_handlerrs   r<   r>   r   r-   r&   r'   r(   r)   r?   r@   rU   rV   ra   rW   rF   r^   rZ   rG   s                   rH   r!   r!   "  sz   & J9
17<Q1R)/4E)FJJ|U3t;	 

?3$-- $

= 9&77HO .77 "?? --.AB 	" %,QReQfghh 	88!? !4 	9 	
 )2(D(D(J(J%$??%&?)+'#66	
 		
  
$$ 3 (
 	

   A:D& BD& &	E/E		Ec           
        K   t               }	 t        j                         }d|d<   t        t        f| |||||d|}	t        j                         }
t        |
j                  |	      }|j                  d|       d{   }t        j                  |      r| d{   }|S |}|S 7 )7 # t        $ r}t        j                  d||||      d}~ww xY ww)aL  Asynchronously delete a container.

    Parameters:
    - `container_id` (str): The ID of the container to delete
    - `timeout` (int): Request timeout in seconds
    - `custom_llm_provider` (Literal["openai"]): The LLM provider to use
    - `extra_headers` (Optional[Dict[str, Any]]): Additional headers
    - `extra_query` (Optional[Dict[str, Any]]): Additional query parameters
    - `extra_body` (Optional[Dict[str, Any]]): Additional body parameters
    - `kwargs` (dict): Additional keyword arguments

    Returns:
    - `response` (DeleteContainerResult): The deletion result
    Tr,   r   Nr.   r/   )r4   r5   r6   r   r   r7   r8   r9   r:   r;   r<   r=   r>   r   s                  rH   r   r   s  s     4 J 
%%'#|	
% 3'#!	
 	
 &&(#CGGT2"2249JKK}-**H  %H L +
  
$$ 3 (
 	

r   r   c                     y rN   rO   r   r-   rJ   rK   rL   r&   r   r?   s           rH   r   r     r   rR   )r   c                     y rN   rO   r   s           rH   r   r     r   rR   c           
         t               }	 |j                  d      }|j                  d      }	|j                  dd      du }
|j                  d      }|2t        |t              rt        j                  |      }t        di |}|S t        di |}t        j                  t        j                  |            }|t        d	|       |j                  d
i d|	i|       t        j                   j"                  |_        t'        j(                  | ||||||xs t*        |
      S # t,        $ r}t        j.                  d
||||      d}~ww xY w)zVDelete a container using the OpenAI Container API.

    Currently supports OpenAI
    rU   rV   r,   FTrW   NrX   r|   r.   r\   r   r/   rO   )r4   rb   rc   rd   re   rf   rg   r   r   r   rh   r=   ri   rj   rn   r   r   rp   rq   r   container_delete_handlerrs   r<   r>   r   s                   rH   r   r     sz   & J9
17<Q1R)/4E)FJJ|U3t;	 

?3$-- $

= 9,=}=HO .77 "?? --.AB 	" %,QReQfghh 	88!? !4 	9 	
 )2(B(B(H(H%$==%&?)+'#66	
 		
  
$$ 3 (
 	

r   )NNX  r"   NNN)NNr   NNNr"   )NNNr   r"   NNN)NNNr   NNNr"   )r   r"   NNN)r   NNNr"   )3r5   r7   rf   	functoolsr   typingr   r   r   r   r   r	   r
   r   r=   litellm.constantsr   rs   litellm.containers.utilsr   *litellm.litellm_core_utils.litellm_loggingr   LiteLLMLoggingObj/litellm.llms.base_llm.containers.transformationr   litellm.mainr   litellm.types.containers.mainr   r   r   r   r   litellm.types.routerr   litellm.types.utilsr   litellm.utilsr   r   __all__re   r   r   intr   r    r   r!   r   r   rO   rR   rH   <module>r      s
       Q Q Q  H : S O .  6 ) 7	  /3$(-5 /3,0+/A

A
DcN+A
 tCy!A
 !*A
 DcN+A
 $sCx.)A
 c3h(A
 A
 A
N 
 /3$(!"!%-5
DcN+ tCy!
 c] sm # !* t} sC() 
  
 /3$(!"!%-5 ).
DcN+ tCy!
 c] sm # !* u~  
$  /3$(-5 /3,0+/h

h
DcN+h
 tCy!h

 !*h
 DcN+h
 $sCx.)h
 c3h(h
 c3'(*h
 h
X -5 /3,0+/@
C=@
C=@
 C=@

 !*@
 DcN+@
 $sCx.)@
 c3h(@
 @
 @
J 
!"!%-5C=C= C=
 c] sm # !* dm sC../ 
  
!"!%-5 (-C=C= C=
 c] sm # !* en  
$ -5 /3,0+/V
C=V
C=V
 C=V

 !*V
 DcN+V
 $sCx.)V
 c3h(V
 c3--.0V
 V
t  -5 /3,0+/:
:
 !*:
 DcN+:
 $sCx.):
 c3h(:
 :
 :
~ 
 !"!%-5 c] sm	
 # !* ! sC() 
 
 !"!%-5 +0 c] sm	
 # !* !  
   -5 /3,0+/L
L
 !*L
 DcN+L
 $sCx.)L
 c3h(L
 c3'(*L
 L
`  -5 /3,0+/:
:
 !*:
 DcN+:
 $sCx.):
 c3h(:
 :
 :
~ 
 !"!%-5 c] sm	
 # !* t} sC../ 
 
 !"!%-5 ). c] sm	
 # !* u~  
   -5 /3,0+/L
L
 !*L
 DcN+L
 $sCx.)L
 c3h(L
 c3--.0L
 L
rR   