
    Cj                    j   S SK Jr  S SKrS SKrS SKrS SKJrJrJr  S SK	J
r
Jr  S SKrSSKJrJrJrJrJrJrJr  SSKJrJrJrJrJr  \
" S5      rSS	 jrSS
 jrSS.SS jjr\SS j5       r\SS j5       rSS jrSS jr S S jr!\SS j5       r"\SS j5       r"SS jr"SS jr#S S jr$S!S jr%S"S jr&g)#    )annotationsN)Sequencecastoverload)TypeVar	TypeGuard   )	FileTypesFileContentRequestFilesHttpxFileTypesBase64FileInputHttpxFileContentHttpxRequestFiles)is_list
is_mapping
is_tuple_tis_mapping_tis_sequence_t_Tc                x    [        U [        R                  5      =(       d    [        U [        R                  5      $ N)
isinstanceioIOBaseosPathLikeobjs    _/home/rurouni/.local/share/pipx/venvs/strix-agent/lib/python3.13/site-packages/openai/_files.pyis_base64_file_inputr!      s#    c299%EC)EE    c                    [        U [        5      =(       dR    [        U [        5      =(       d;    [        U [        R                  5      =(       d    [        U [
        R                  5      $ r   )r   bytestupler   r   r   r   r   s    r    is_file_contentr&      sB    3v*S%"8vJsBII<VvZdehjljujuZvr"   )keyc               z    [        U 5      (       d+  Ub  SU S3OSU < S3n[        U S[        U 5       S35      S eg )NzExpected entry at ``zExpected file input `zF to be bytes, an io.IOBase instance, PathLike or a tuple but received zL instead. See https://github.com/openai/openai-python/tree/main#file-uploads)r&   RuntimeErrortype)r   r'   prefixs      r    assert_is_file_contentr-   #   se    314&se1-H]^a]ddeFfh\]abe]f\g  ht  u
	  r"   c                    g r    filess    r    to_httpx_filesr2   +   s    ),r"   c                    g r   r/   r0   s    r    r2   r2   /   s    >Ar"   c                8   U c  g [        U 5      (       a0  U R                  5        VVs0 s H  u  pU[        U5      _M     n nnU $ [        U 5      (       a#  U  VVs/ s H  u  pU[        U5      4PM     n nnU $ [	        S[        U 5       S35      es  snnf s  snnf NzUnexpected file type input z, expected mapping or sequence)r   items_transform_filer   	TypeErrorr+   r1   r'   files      r    r2   r2   3   s    }E=B[[]K]	od++]K L 
u		?DEu)##t,-uE L 5d5k]B`abb	 LEs   BBc                0   [        U 5      (       aS  [        U [        R                  5      (       a2  [        R
                  " U 5      nUR                  UR                  5       4$ U $ [        U 5      (       a  U S   [        U S   5      /U SS  Q7$ [        S5      eNr   r	      zCExpected file types input to be a FileContent type or to be a tuple)r&   r   r   r   pathlibPathname
read_bytesr   read_file_contentr8   r:   paths     r    r7   r7   A   s    tdBKK((<<%DIIt011$Q*473?d12h??
Y
[[r"   c                    [        U [        R                  5      (       a$  [        R                  " U 5      R                  5       $ U $ r   )r   r   r   r>   r?   rA   r:   s    r    rB   rB   O   s0    $$$||D!,,..Kr"   c                   #    g 7fr   r/   r0   s    r    async_to_httpx_filesrH   U   s     58   c                   #    g 7fr   r/   r0   s    r    rH   rH   Y   s     JMrI   c                h  #    U c  g [        U 5      (       a8  U R                  5        VVs0 s H  u  pU[        U5      I S h  vN _M     n nnU $ [        U 5      (       a+  U  VVs/ s H  u  pU[        U5      I S h  vN 4PM     n nnU $ [	        S[        U 5       S35      e N`s  snnf  N.s  snnf 7fr5   )r   r6   _async_transform_filer   r8   r+   r9   s      r    rH   rH   ]   s     }EINWIC1$777W L 
u		KPQ5ic#248895Q L 5d5k]B`abb	 8W8QsL   (B2B$B"B$
B2$B,;B*<	B,B2"B$$B2*B,,B2c                `  #    [        U 5      (       a[  [        U [        R                  5      (       a:  [        R
                  " U 5      nUR                  UR                  5       I S h  vN 4$ U $ [        U 5      (       a!  U S   [        U S   5      I S h  vN /U SS  Q7$ [        S5      e NC N7fr<   )r&   r   r   r   anyior?   r@   rA   r   async_read_file_contentr8   rC   s     r    rL   rL   k   s     tdBKK((::d#DIIT__%6677$Q6tAw??K$qr(KK
Y
[[  7
 @s$   A$B.&B*',B.B,B.,B.c                   #    [        U [        R                  5      (       a,  [        R                  " U 5      R                  5       I S h  vN $ U $  N7fr   )r   r   r   rN   r?   rA   rF   s    r    rO   rO   y   s;     $$$ZZ%00222K 3s   AA	A
Ac                    [        XS5      $ )a  Copy only the containers along the given paths.

Used to guard against mutation by extract_files without copying the entire structure.
Only dicts and lists that lie on a path are copied; everything else
is returned by reference.

For example, given paths=[["foo", "files", "file"]] and the structure:
    {
        "foo": {
            "bar": {"baz": {}},
            "files": {"file": <content>}
        }
    }
The root dict, "foo", and "files" are copied (they lie on the path).
"bar" and "baz" are returned by reference (off the path).
r   )_deepcopy_with_paths)itempathss     r    deepcopy_with_pathsrU      s    "  Q//r"   c                z   U(       d  U $ [        U 5      (       a  0 nU H7  nU[        U5      :  d  M  UR                  XB   / 5      R                  U5        M9     U(       d  U $ [	        U 5      nUR                  5        H  u  pgXe;   d  M  [        XV   XrS-   5      XV'   M!     [        [        U5      $ [        U 5      (       aq  U Vs/ s H  oB[        U5      :  d  M  XB   S:X  d  M  UPM!     nnU(       d  [        [        U 5      $ [        [        U  V	s/ s H  n	[        XUS-   5      PM     sn	5      $ U $ s  snf s  sn	f )Nr	   z<array>)
r   len
setdefaultappenddictr6   rR   r   r   r   )
rS   rT   indexkey_to_pathsrD   resultr'   subpathsarray_pathsentrys
             r    rR   rR      s   $79Ds4y ''R8??E 
 Kd)//1MC}26;RS)T 2 Bt}}(-`T1Btt{V_G_t` D>!BZ^_Z^QV-e%!)LZ^_``K a
 `s   D3D3$D3D8
)r   objectreturnzTypeGuard[Base64FileInput])r   ra   rb   zTypeGuard[FileContent])r   ra   r'   z
str | Nonerb   None)r1   rc   rb   rc   )r1   r   rb   r   )r1   zRequestFiles | Nonerb   zHttpxRequestFiles | None)r:   r
   rb   r   )r:   r   rb   r   )rS   r   rT   Sequence[Sequence[str]]rb   r   )rS   r   rT   rd   r[   intrb   r   )'
__future__r   r   r   r>   typingr   r   r   typing_extensionsr   r   rN   _typesr
   r   r   r   r   r   r   _utilsr   r   r   r   r   r   r!   r&   r-   r2   r7   rB   rH   rL   rO   rU   rR   r/   r"   r    <module>rk      s    " 	 	  + + 0    Q PT]F >B  
 , 
 , 
 A 
 A\ 
 8 
 8 
 M 
 M\0(r"   