+
    Pj@                        R t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
HtHt ^ RIHt ^ RIHt ^RIHtHtHtHtHtHt ^R	IHt ^R
IHtHt ]
'       d   ^RIHt ]P>                  ! ] 4      t!]PD                  ! R4      t#Rt$RRRR/t% ! R R4      t&]R+R R ll4       t' ! R R]4      t( ! R R]4      t)R,R R llt*R R lt+R R lt,R R  lt-R! R" lt.R# R$ lt/R% R& lt0R' R( lt1R) R* lt2R# )-z.Git LFS related type definitions and utilitiesN)Iterable)ceil)getsize)TYPE_CHECKINGBinaryIO	TypedDict)unquote)	constants)build_hf_headersfix_hf_endpoint_in_urlhf_raise_for_statushttp_backoffloggingvalidate_hf_hub_args)SliceFileObj)sha256sha_fileobj)CommitOperationAddz^[0-9a-f]{40}$zlfs-multipart-uploadAcceptzapplication/vnd.git-lfs+jsonzContent-Typec                     a  ] tR t^5t o RtRV 3R lR llt]V 3R lR l4       t]P                  V 3R lR l4       t]V 3R	 lR
 l4       t	V 3R lR lt
]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       tRtV tR# )
UploadInfoav  
Data structure holding required information to determine whether a blob
should be uploaded to the hub using the LFS protocol or the regular protocol.

The SHA256 of the blob is computed lazily: creating an `UploadInfo` from a local path only reads
the first 512 bytes of the file. The full file is read (and hashed) only if `sha256` is accessed
before it has been set. When a file is uploaded through the Xet protocol, the SHA256 is computed
during upload (single read pass) and set afterwards.

Args:
    size (`int`):
        Size in bytes of the blob
    sample (`bytes`):
        First 512 bytes of the blob
    sha256 (`bytes`, *optional*):
        SHA256 hash of the blob, if already known. Otherwise computed lazily from `source_path`.
    source_path (`str`, *optional*):
        Path to the local file the blob comes from. Required to lazily compute `sha256` if not provided.
Nc          	      N   < V ^8  d   QhRS[ RS[RS[R,          RS[R,          /# )   sizesampler   Nsource_path)intbytesstr)format__classdict__s   "l/Users/ahmed/devFolder/Ultron/claude-voice/gateway/.venv/lib/python3.14/site-packages/huggingface_hub/lfs.py__annotate__UploadInfo.__annotate__J   s;     ( (( ( 	(
 4Z(    c                \    Vf   Vf   \        R4      hWn        W n        W0n        W@n        R # )Nz2Either `sha256` or `source_path` must be provided.)
ValueErrorr   r   _sha256_source_path)selfr   r   r   r   s   &&&&&r!   __init__UploadInfo.__init__J   s/     >k1QRR	'r$   c                    < V ^8  d   QhRS[ /# r   returnr   )r   r    s   "r!   r"   r#   Y   s       r$   c                   V P                   fT   V P                  f   Q h\        V P                  R4      ;_uu_ 4       p\        V4      V n         RRR4       V P                   # V P                   #   + '       g   i     T P                   # ; i)zZSHA256 of the blob. If not set yet, reads the whole file from `source_path` to compute it.Nrb)r'   r(   openr   )r)   files   & r!   r   UploadInfo.sha256X   sl     <<$$000d''..$*40 /||t|| /.||s   A..B		c                $   < V ^8  d   QhRS[ RR/# )r   valuer.   Nr/   )r   r    s   "r!   r"   r#   b   s      E d r$   c                    Wn         R # )Nr'   )r)   r6   s   &&r!   r   r4   a   s    r$   c                    < V ^8  d   QhRS[ /# r-   )bool)r   r    s   "r!   r"   r#   f   s     ( (4 (r$   c                    V P                   RJ# )zVWhether the SHA256 is already known (accessing `sha256` will not trigger a file read).Nr8   )r)   s   &r!   	is_hashedUploadInfo.is_hashede   s     ||4''r$   c                    < V ^8  d   QhRS[ /# r-   r   )r   r    s   "r!   r"   r#   j   s     = =# =r$   c                |    V P                   e   V P                   P                  4       MRpRV P                   RV R2# )Nz<not computed>zUploadInfo(size=z	, sha256=))r'   hexr   )r)   shas   & r!   __repr__UploadInfo.__repr__j   s9    $(LL$<dll BR!$))IcU!<<r$   c                    < V ^8  d   QhRS[ /# )r   pathr?   )r   r    s   "r!   r"   r#   o   s     ? ?S ?r$   c                    \        V4      p\        VR 4      ;_uu_ 4       pVP                  R4      R,          pRRR4       V ! VXVR7      #   + '       g   i     L; i)r1      Ni   NN)r   r   r   )r   r2   peek)clsrG   r   r3   r   s   &&   r!   	from_pathUploadInfo.from_pathn   sI    t}$YYs^D)F V>> s   AA	c                    < V ^8  d   QhRS[ /# )r   datar/   )r   r    s   "r!   r"   r#   v   s     B Be Br$   c                j    \        V4      P                  4       pV ! \        V4      VR ,          VR7      # )rJ   )r   r   r   )r   digestlen)rL   rP   rC   s   && r!   
from_bytesUploadInfo.from_bytesu   s+    Tl!!#D	$t*SAAr$   c                    < V ^8  d   QhRS[ /# )r   fileobj)r   )r   r    s   "r!   r"   r#   {   s     9 98 9r$   c                    VP                  R 4      pVP                  ^ \        P                  4       \	        V4      pVP                  4       pVP                  ^ \        P                  4       V ! WCVR7      # )rI   )r   r   r   )readseekioSEEK_SETr   tell)rL   rW   r   rC   r   s   &&   r!   from_fileobjUploadInfo.from_fileobjz   sV    c"Q$'"||~Q$88r$   )r'   r(   r   r   )NN)__name__
__module____qualname____firstlineno____doc__r*   propertyr   setterr<   rD   classmethodrM   rT   r^   __static_attributes____classdictcell__r    s   @r!   r   r   5   s     (( (   ]]  ( (= = ? ? B B 9 9r$   r   c                ~   V ^8  d   QhR\         \        ,          R\        R,          R\        R\        R\        R,          R\        R,          R\        \        \        3,          R,          R	\        \        ,          R,          R
\
        \        \        ,          \        \        ,          \        R,          3,          /	# )r   upload_infostokenN	repo_typerepo_idrevisionendpointheaders	transfersr.   )r   r   r   dictlisttuple)r   s   "r!   r"   r"      s     X X:&X:X X 	X
 DjX DjX #s(^d"X Cy4X 4:tDz3:-.Xr$   c                T   Ve   TM\         P                  pRpV\         P                  9   d   \         P                  V,          pV RV V R2p	RRRVe   TMRR	.R
V  U
u. uF+  p
RV
P                  P	                  4       RV
P
                  /NK-  	  up
RR/pVe   R\        V4      /VR&   / \        C\        VR7      CT;'       g    / Cp\        RWVR7      p\        V4       VP                  4       pVP                  R
R4      p\        V\        4      '       g   \        R4      hVP                  R4      p\        V\         4      '       d   TMRpV Uu. uF  pRV9  g   K  \#        V4      NK  	  upV Uu. uF  pRV9   g   K  \%        V4      NK  	  upV3# u up
i u upi u upi )aa  
Requests the LFS batch endpoint to retrieve upload instructions

Learn more: https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md

Args:
    upload_infos (`Iterable` of `UploadInfo`):
        `UploadInfo` for the files that are being uploaded, typically obtained
        from `CommitOperationAdd.upload_info`
    token (`str` or `None`):
        An authentication token (see https://huggingface.co/settings/token).
        Pass `None` to fall back to the local cached token (or no token if unauthenticated).
    repo_type (`str`):
        Type of the repo to upload to: `"model"`, `"dataset"` or `"space"`.
    repo_id (`str`):
        A namespace (user or an organization) and a repo name separated
        by a `/`.
    revision (`str`, *optional*):
        The git revision to upload to.
    endpoint (`str`, *optional*):
        The Hub endpoint to send the request to. Defaults to the value of `HF_ENDPOINT`.
    headers (`dict`, *optional*):
        Additional headers to include in the request
    transfers (`list`, *optional*):
        List of transfer methods to use. Defaults to ["basic", "multipart"].

Returns:
    `LfsBatchInfo`: 3-tuple:
        - First element is the list of upload instructions from the server
        - Second element is a list of errors, if any
        - Third element is the chosen transfer adapter if provided by the server (e.g. "basic", "multipart", "xet")

Raises:
    [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
        If an argument is invalid or the server response is malformed.
    [`HfHubHTTPError`]
        If the server returned an error.
N /z.git/info/lfs/objects/batch	operationuploadrs   basic	multipartobjectsoidr   	hash_algor   nameref)rm   POSTrr   jsonzMalformed response from servertransfererror)r	   ENDPOINTREPO_TYPES_URL_PREFIXESr   rB   r   r   LFS_HEADERSr
   r   r   r   get
isinstanceru   r&   r   _validate_batch_actions_validate_batch_error)rl   rm   rn   ro   rp   rq   rr   rs   
url_prefix	batch_urlr{   payloadresp
batch_infor~   chosen_transferobjs   &&&&&&&&         r!   post_lfs_batch_infor      s   b $/xY5G5GHJI55566yA
*Aj\'2MNIX)"7Yg{=S
 '

 ' v}}((* '
 	XG  '("34


' ==bG
 	IDJnnY-Ggt$$9:: nnZ0O)3OS)I)IotO 29O#G3<N	%	 	%O/6Iw'S.	#	s	#wI 9
: 	PIs    1F	F $F 9	F%F%c                   ,   a  ] tR t^t o V 3R ltRtV tR# )PayloadPartTc                2   < V ^8  d   Qh/ S[ ;R&   S[;R&   # )r   
partNumberetag)r   r   )r   r    s   "r!   r"   PayloadPartT.__annotate__   s     O 
I r$    N)r`   ra   rb   rc   __annotate_func__rh   ri   rj   s   @r!   r   r      s      r$   r   c                   0   a  ] tR t^t o RtV 3R ltRtV tR# )CompletionPayloadTz?Payload that will be sent to the Hub when uploading multi-part.c                B   < V ^8  d   Qh/ S[ ;R&   S[S[,          ;R&   # )r   r   parts)r   ru   r   )r   r    s   "r!   r"   CompletionPayloadT.__annotate__   s#      
H  	 r$   r   N)r`   ra   rb   rc   rd   r   rh   ri   rj   s   @r!   r   r      s     I  r$   r   c                    V ^8  d   QhRRR\         R\        R,          R\         \        \        3,          R,          R\        R,          RR/# )	r   rz   r   lfs_batch_actionrm   Nrr   rq   r.   )rt   r   )r   s   "r!   r"   r"      si     JA JA#JAJA :JA #s(^d"	JA
 DjJA 
JAr$   c           	     b   \        V4       VP                  R4      pVf&   \        P                  RV P                   R24       R# VR,          R,          p\        V4       VR,          P                  R4      pVe   \        V4       VP                  R/ 4      pVP                  R4      p	\        VR	,          VR
7      p
V	e    \        V	4      p	\        YYR7       M\        W
R7       Ve}   \        V4       \        VR	,          V4      p\        RV\        W#R7      RV P                  P                  P!                  4       RV P                  P"                  /R7      p\%        V4       \        P                  V P                   R24       R#   \        \        3 d    \        RT	 R24      hi ; i)ae  
Handles uploading a given object to the Hub with the LFS protocol.

Can be a No-op if the content of the file is already present on the hub large file storage.

Args:
    operation (`CommitOperationAdd`):
        The add operation triggering this upload.
    lfs_batch_action (`dict`):
        Upload instructions from the LFS batch endpoint for this object. See [`~utils.lfs.post_lfs_batch_info`] for
        more details.
    token (`str`, *optional*):
        An authentication token (see https://huggingface.co/settings/token). Used to call the
        optional LFS verify step at the end of the upload. If `None`, falls back to the local
        cached token.
    headers (`dict`, *optional*):
        Headers to include in the request, including authentication and user agent headers.
    endpoint (`str`, *optional*):
        The Hub endpoint to send the request to. Defaults to the value of `HF_ENDPOINT`.

Raises:
    [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
        If `lfs_batch_action` is improperly formatted
    [`HfHubHTTPError`]
        If the upload resulted in an error
actionsNzContent of file z. is already present upstream - skipping uploadr{   verifyheader
chunk_sizehref)rq   zTMalformed response from LFS batch endpoint: `chunk_size` should be an integer. Got 'z'.)rz   r   r   
upload_url)rz   r   r   )rm   rr   r   r   r   z: Upload successful)r   r   loggerdebugpath_in_repo_validate_lfs_actionr   r   r&   	TypeError_upload_multi_part_upload_single_partr   r
   upload_infor   rB   r   r   )rz   r   rm   rr   rq   r   upload_actionverify_actionr   r   r   
verify_urlverify_resps   &&&&&        r!   
lfs_uploadr      s   D ,-""9-G'	(>(>'??mno %Y/9M'$Y/33H=M ]+ x,FL)J'f(=QJ	ZJ
 	Y*liG  ]++M&,A8L
"$5B..5599;VYEZEZE_E_`	
 	K(
LLI**++>?@' I& 	fgqfrrtu 	s   F !F.c                $    V ^8  d   QhR\         /# )r   
lfs_actionrt   )r   s   "r!   r"   r"   9  s      T r$   c                    \        V P                  R4      \        4      '       d9   V P                  R4      e1   \        V P                  R4      \        4      '       g   \	        R4      hV # ).validates response from the LFS batch endpointr   r   z"lfs_action is improperly formatted)r   r   r   rt   r&   )r   s   &r!   r   r   9  sQ     	:>>&)3//^^H%-JNN8<TVZ1[1[=>>r$   c                $    V ^8  d   QhR\         /# )r   lfs_batch_actionsr   )r   s   "r!   r"   r"   C  s      t r$   c                p   \        V P                  R4      \        4      '       d&   \        V P                  R4      \        4      '       g   \	        R4      hV P                  R/ 4      P                  R4      pV P                  R/ 4      P                  R4      pVe   \        V4       Ve   \        V4       V # )r   r   r   z)lfs_batch_actions is improperly formattedr   r{   r   )r   r   r   r   r&   r   )r   r   r   s   &  r!   r   r   C  s    (,,U3S99jIZI^I^_eIfhk>l>lDEE%)))R8<<XFM%)))R8<<XFM ]+ ]+r$   c                $    V ^8  d   QhR\         /# )r   lfs_batch_errorr   )r   s   "r!   r"   r"   Q  s      4 r$   c                   \        V P                  R4      \        4      '       d&   \        V P                  R4      \        4      '       g   \	        R4      hV P                  R4      p\        V\
        4      '       dK   \        VP                  R4      \        4      '       d&   \        VP                  R4      \        4      '       g   \	        R4      hV # )r   r   r   z'lfs_batch_error is improperly formattedr   messagecode)r   r   r   r   r&   rt   )r   
error_infos   & r!   r   r   Q  s    **51377JGZGZ[aGbdg<h<hBCC $$W-J:t$$z~~i0#66z~~f-s33BCCr$   c                ,    V ^8  d   QhRRR\         RR/# )r   rz   r   r   r.   Nr?   )r   s   "r!   r"   r"   _  s"     & &#7 &S &T &r$   c                    V P                  RR7      ;_uu_ 4       p\        RWR7      p\        V4       RRR4       R#   + '       g   i     R# ; i)a#  
Uploads `fileobj` as a single PUT HTTP request (basic LFS transfer protocol)

Args:
    upload_url (`str`):
        The URL to PUT the file to.
    fileobj:
        The file-like object holding the data to upload.

Raises:
    [`HfHubHTTPError`]
        If the upload resulted in an error.
T	with_tqdmPUTrP   N)as_filer   r   )rz   r   rW   responses   &&  r!   r   r   _  s=     
		T		*	*gz@H% 
+	*	*	*s	   >A	c          
      D    V ^8  d   QhRRR\         R\        R\        RR/# )r   rz   r   r   r   r   r.   N)rt   r   r   )r   s   "r!   r"   r"   s  s3     ( ("6 ( (RU (cf (ko (r$   c           	         \        WP                  VR7      p\        WVR7      p\        RV\	        WPP                  P
                  P                  4       4      \        R7      p\        V4       R# )z8
Uploads file using HF multipart LFS transfer protocol.
)r   r   r   )rz   sorted_parts_urlsr   r   )r   rr   N)	_get_sorted_parts_urlsr   _upload_parts_iterativelyr   _get_completion_payloadr   rB   r   r   )rz   r   r   r   r   response_headerscompletion_ress   &&&&   r!   r   r   s  sg    
 /fJ_J_lvw 1Z "$%57L7L7S7S7W7W7YZ	N 'r$   c          	      ^    V ^8  d   QhR\         R\        R\        R\        \        ,          /# )r   r   r   r   r.   )rt   r   r   ru   r   )r   s   "r!   r"   r"     s/     # #4 #j #c #VZ[^V_ #r$   c           
      ~   \        V P                  4        UUu. uF=  w  r4VP                  4       '       g   K  \        V4      ^ 8  g   K/  \	        V^
4      V3NK?  	  uppR R7       UUu. uF  w  rTVNK	  	  ppp\        V4      pV\        VP                  V,          4      8w  d   \        R4      hV# u uppi u uppi )    c                     V ^ ,          # )r   r   )ts   &r!   <lambda>(_get_sorted_parts_urls.<locals>.<lambda>  s    !A$r$   )keyz0Invalid server response to upload large LFS file)sorteditemsisdigitrS   r   r   r   r&   )r   r   r   part_numr   _sorted_part_upload_urls	num_partss   &&&     r!   r   r     s     $ -3LLN,:(H##% 0*-h-!*; 0Xr"J/,:
 


MA 	
  
 +,ID))J677KLL""
s   B3
B3

B3
*B9c                R    V ^8  d   QhR\         \        ,          R\        R\        /# )r   r   r   r.   )ru   rt   r   r   )r   s   "r!   r"   r"     s&     ( (d4j (s (GY (r$   c                     . p\        V 4       FU  w  r4VP                  R 4      pVe   VR8X  d   \        RV RV^,            24      hVP                  RV^,           R V/4       KW  	  RVRV/# )r   rx   zInvalid etag (`z`) returned for part r   r   r   )	enumerater   r&   append)r   r   r   part_numberr   r   s   &&    r!   r   r     s     "E()9:zz&!<42:tf4I+XY/IZ[\\kAo	
	  ; 3''r$   c          	      l    V ^8  d   QhRRR\         \        ,          R\        R\         \        ,          /# )r   rz   r   r   r   r.   )ru   r   r   rt   )r   s   "r!   r"   r"     s4      #8<S	OR	$Zr$   c                 x   . pV P                  R R7      ;_uu_ 4       p\        V4       F]  w  rV\        VW%,          VR7      ;_uu_ 4       p\        RWgR7      p\	        V4       VP                  VP                  4       RRR4       K_  	  RRR4       V#   + '       g   i     K|  ; i  + '       g   i     T# ; i)Tr   )	seek_from
read_limitr   r   N)r   r   r   r   r   r   rr   )	rz   r   r   rr   rW   part_idxpart_upload_urlfileobj_slicepart_upload_ress	   &&&      r!   r   r     s     G			T		*	*g)23D)E%H$/%  ".uo"Z#O4667  *F 
+ N   
+	* Ns#   -B(
4B>B(B%	B((B9	)NNNN)NNN)3rd   r[   recollections.abcr   mathr   os.pathr   typingr   r   r   urllib.parser   huggingface_hubr	   utilsr
   r   r   r   r   r   
utils._lfsr   	utils.shar   r   _commit_apir   
get_loggerr`   r   compile	OID_REGEXLFS_MULTIPART_UPLOAD_COMMANDr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r$   r!   <module>r     s    5 	 	 $   5 5   %  % * /			H	%JJ()	5  ,2L9 L9^ X Xv9 
 JAZ&((.#$(r$   