
    ^h                         S SK r S SKrS SKJrJrJr   " S S\ R                  5      rS\\\\	\\	4   4   S\	S\\   4S jr
S\	4S	 jrg)
    N)OptionalTupleUnionc                   4   ^  \ rS rSrS\S\4U 4S jjrSrU =r$ )InMemoryFile   contentnamec                 0   > [         TU ]  U5        X l        g )N)super__init__r
   )selfr	   r
   	__class__s      Z/home/james-whalen/.local/lib/python3.13/site-packages/litellm/router_utils/batch_utils.pyr   InMemoryFile.__init__   s    !	    r
   )	__name__
__module____qualname____firstlineno__bytesstrr   __static_attributes____classcell__)r   s   @r   r   r      s     S  r   r   file_contentnew_model_namereturnc                 T    [        U S5      (       a  U R                  5       nO[        U [        5      (       a  U S   nOU n[        U[        5      (       a  UR                  S5      nOUnUR                  5       n/ nU HY  n[        R                  " UR                  5       5      nSU;   a  XS   S'   UR                  [        R                  " U5      5        M[     SR                  U5      R                  S5      n[        USS9$ ! [        R                  [         ["        4 a     g f = f)	Nread   zutf-8bodymodel
zmodified_file.jsonlr   )hasattrr    
isinstancetupler   decode
splitlinesjsonloadsstripappenddumpsjoinencoder   JSONDecodeErrorUnicodeDecodeError	TypeError)	r   r   file_content_bytesfile_content_strlinesmodified_lineslinejson_objectmodified_file_contents	            r   replace_model_in_jsonlr;      s   ! <((!-!2!2!4e,,!-a!- (%00188A1 ++-D**TZZ\2K $/=F#G, !!$**["9:  !%		. 9 @ @ I18MNN  "4i@ s   DD D'&D'c                     SU ;   a  gg)z
Helper to return what the "metadata" field should be called in the request data

For all /thread or /assistant endpoints we need to call this "litellm_metadata"

For ALL other endpoints we call this "metadata
batchlitellm_metadatametadata )function_names    r   "_get_router_metadata_variable_namerB   3   s     -!r   )ior*   typingr   r   r   BytesIOr   r   r   r;   rB   r@   r   r   <module>rF      se    	  ) )2:: $uS%_556$HK$l$N r   