
    QЦiw+                        S r SSKrSSKrSSKJrJrJr  SSKrSSKJ	r	J
r
  SSKJrJrJrJrJrJrJrJrJr  \" \	5      r\R,                  " S\ V s0 s H  o U _M     sn \S9r\" \
5      r\R,                  " S	\ Vs0 s H  oU_M     sn\S9r\" S
S9r\R9                  S/ SQS9SSSS\R:                  SS4S\\\   \R<                  " SS94   S\\\   \R<                  " SS94   S\\\   \R<                  " SS94   S\S\S\S\SS4S jj5       r\R9                  SS/S9 SUS\\\R@                  " S S94   S\SS4S! jj5       r!\R9                  S"/ S#QS9     SVS$\\\R@                  " S%S94   S&\\\   \R<                  " S'S94   S(\\\   \R<                  " S)S94   S*\\"\R<                  " S+S94   S,\\"\R<                  " S-S94   S\SS4S. jj5       r#\R9                  S// S0QS9      SWS\\\R@                  " S S94   S$\\\   \R<                  " S1S94   S(\\\   \R<                  " S2S94   S3\\\$   \R<                  " S4S94   S*\\\"   \R<                  " S5S94   S6\\\   \R<                  " S7S94   S\SS4S8 jj5       r%\R9                  S9S:S;/S9  SXS\\\R@                  " S S94   S<\\"\R<                  " S=S94   S\SS4S> jj5       r&\R9                  S?/ S@QS9   SYS\\\R@                  " S S94   SA\\\R@                  " SBS94   SC\\\R@                  " SDS94   SE\\\   \R<                  " SFS94   S,\\"\R<                  " SGS94   S\SS4SH jj5       r'\R9                  SISJSK/S9   SZS\\\R@                  " S S94   SL\\\R@                  " SMS94   SE\\\   \R<                  " SNS94   S3\\\$   \R<                  " SOS94   S\SS4SP jj5       r(\R9                  SQ5        SXS\\\R@                  " S S94   SL\\\R@                  " SRS94   S<\\"\R<                  " SSS94   S\SS4
ST jj5       r)gs  sn f s  snf )[a_  Contains commands to interact with collections on the Hugging Face Hub.

Usage:
    # list collections on the Hub
    hf collections ls

    # list collections for a specific user
    hf collections ls --owner username

    # get info about a collection
    hf collections info username/collection-slug

    # create a new collection
    hf collections create "My Collection" --description "A collection of models"

    # add an item to a collection
    hf collections add-item username/collection-slug username/model-name model

    # delete a collection
    hf collections delete username/collection-slug
    N)	AnnotatedOptionalget_args)CollectionItemType_TCollectionSort_T   )		FormatOptLimitOptOutputFormatQuietOptTokenOptapi_object_to_dict
get_hf_apiprint_list_outputtyper_factoryCollectionItemType)typeCollectionSortz%Interact with collections on the Hub.)helpls)zhf collections lsz hf collections ls --owner nvidiazLhf collections ls --item models/teknium/OpenHermes-2.5-Mistral-7B --limit 10)examples
   Fownerz)Filter by owner username or organization.itemzkFilter collections containing a specific item (e.g., "models/gpt2", "datasets/squad", "papers/2311.12983").sortz4Sort results by last modified, trending, or upvotes.limitformatquiettokenreturnc                     [        US9nU(       a  UR                  OSnUR                  U UUUS9 V	s/ s H  n	[        U	5      PM     n
n	[	        XUS9  gs  sn	f )zList collections on the Hub.r   N)r   r   r   r   )r   r   )r   valuelist_collectionsr   r   )r   r   r   r   r   r   r   apisort_key
collectionresultss              ^/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/huggingface_hub/cli/collections.pycollections_lsr*   D   ss    : 5
!C!tzztH ..	 / 

J 	:&
   gE:s   Ainfoz/hf collections info username/my-collection-slugcollection_slugz7The collection slug (e.g., 'username/collection-slug').c                     [        US9nUR                  U 5      n[        [        R                  " [        U5      SS95        g)z'Get info about a collection on the Hub.r"      indentN)r   get_collectionprintjsondumpsr   )r,   r   r%   r'   s       r)   collections_infor5   o   s7     5
!C##O4J	$**'
3A
>?    create)z!hf collections create "My Models"z^hf collections create "My Models" --description "A collection of my favorite models" --privatez9hf collections create "Org Collection" --namespace my-orgtitlezThe title of the collection.	namespacezMThe namespace (username or organization). Defaults to the authenticated user.descriptionz!A description for the collection.privatezCreate a private collection.	exists_okz7Do not raise an error if the collection already exists.c                     [        US9nUR                  U UUUUS9n[        SUR                   35        [        [        R
                  " [        U5      SS95        g)z#Create a new collection on the Hub.r"   )r8   r9   r:   r;   r<   zCollection created: r.   r/   N)r   create_collectionr2   urlr3   r4   r   )r8   r9   r:   r;   r<   r   r%   r'   s           r)   collections_creater@      sb    : 5
!C&& ' J 
  0
12	$**'
3A
>?r6   update)z@hf collections update username/my-collection --title "New Title"zPhf collections update username/my-collection --description "Updated description"zDhf collections update username/my-collection --private --theme greenz!The new title for the collection.z'The new description for the collection.positionz7The new position of the collection in the owner's list.z)Whether the collection should be private.themez;The theme color for the collection (e.g., 'green', 'blue').c           	          [        US9nUR                  U UUUUUS9n[        SUR                   35        [        [        R
                  " [        U5      SS95        g)z*Update a collection's metadata on the Hub.r"   )r,   r8   r:   rB   r;   rC   zCollection updated: r.   r/   N)r   update_collection_metadatar2   r?   r3   r4   r   )	r,   r8   r:   rB   r;   rC   r   r%   r'   s	            r)   collections_updaterF      sf    B 5
!C//' 0 J 
  0
12	$**'
3A
>?r6   deletez,hf collections delete username/my-collectionz9hf collections delete username/my-collection --missing-ok
missing_okz6Do not raise an error if the collection doesn't exist.c                 P    [        US9nUR                  XS9  [        SU  35        g)z!Delete a collection from the Hub.r"   )rH   zCollection deleted: N)r   delete_collectionr2   )r,   rH   r   r%   s       r)   collections_deleterK      s0      5
!C/A	  1
23r6   zadd-item)zGhf collections add-item username/my-collection moonshotai/kimi-k2 modelz`hf collections add-item username/my-collection Qwen/DeepPlanning dataset --note "Useful dataset"zGhf collections add-item username/my-collection Tongyi-MAI/Z-Image spaceitem_idzCThe ID of the item to add (repo_id for repos, paper ID for papers).	item_typez?The type of item (model, dataset, space, paper, or collection).notez2A note to attach to the item (max 500 characters).z?Do not raise an error if the item is already in the collection.c                     [        US9nUR                  U UUR                  UUS9n[        SU  35        [        [        R
                  " [        U5      SS95        g)zAdd an item to a collection.r"   )r,   rL   rM   rN   r<   zItem added to collection: r.   r/   N)r   add_collection_itemr#   r2   r3   r4   r   )r,   rL   rM   rN   r<   r   r%   r'   s           r)   collections_add_itemrQ      sb    8 5
!C(('// ) J 
&&7
89	$**'
3A
>?r6   zupdate-itemzVhf collections update-item username/my-collection ITEM_OBJECT_ID --note "Updated note"zMhf collections update-item username/my-collection ITEM_OBJECT_ID --position 0item_object_idzTThe ID of the item in the collection (from 'item_object_id' field, not the repo_id).z-A new note for the item (max 500 characters).z/The new position of the item in the collection.c                 V    [        US9nUR                  U UUUS9  [        SU  35        g)zUpdate an item in a collection.r"   )r,   rR   rN   rB   zItem updated in collection: N)r   update_collection_itemr2   )r,   rR   rN   rB   r   r%   s         r)   collections_update_itemrU     s@    0 5
!C'%	   
((9
:;r6   zdelete-itemznThe ID of the item in the collection (retrieved from `item_object_id` field returned by 'hf collections info'.z0Do not raise an error if the item doesn't exist.c                 T    [        US9nUR                  U UUS9  [        SU  35        g)z!Delete an item from a collection.r"   )r,   rR   rH   zItem deleted from collection: N)r   delete_collection_itemr2   )r,   rR   rH   r   r%   s        r)   collections_delete_itemrX   5  s=      5
!C'%  
 
*?*;
<=r6   )N)NNFFN)NNNNNN)FN)NFN)NNN)*__doc__enumr3   typingr   r   r   typerhuggingface_hub.hf_apir   r   
_cli_utilsr	   r
   r   r   r   r   r   r   r   _COLLECTION_ITEM_TYPESEnumstrr   _COLLECTION_SORT_OPTIONSr   collections_clicommandtableOptionr*   Argumentr5   boolr@   intrF   rK   rQ   rU   rX   )tss   00r)   <module>rl      s  ,   0 0  I
 
 
 ""67 YY3DZ5[DZqdDZ5[bef #$45 +<T-U<Tqd<T-U\_`  %LM    	 	 	$**% ;EF	H ;
 ~	
	 ;  PQ	S ;  ;  ! ;" # ;$ % ;& 
' ; ;F 
9   @sENN8q$rrs@@ 
@@    	 	 	 	%@S%...LMMN@ij	l@ =>	@@ 89	;@ ST	V@$ %@& 
'@@B    	 	 	 	 	-#@sENN8q$rrs#@=>	@#@ CD	F#@ ST	V#@ EF	H#@$ WX	Z%#@, -#@. 
/#@#@L 6C   	4sENN8q$rrs4RS	U4 4 
44   ( 	 	#@sENN8q$rrs@U^^!fgg@
 ]^	`@ NO	Q@ [\	^@" #@$ 
%@@@ `W    	 	<sENN8q$rrs<rs	u< IJ	L< KL	N< < 
<<6 ' 	>sENN8q$rrs> B	
	> LM	O> > 
> (>w 6\ .Vs   Q
;Q
