Ë
    -Œ:j*  ã                   ó4	  — d Z ddlZddlmZmZ ddlZddlmZmZ ddl	m
Z
mZmZmZ ddlmZmZ  ee«      Z ej$                  deD � ci c]  } | | “Œ c} e¬	«      Z ee«      Z ej$                  d
eD �ci c]  }||“Œ c}e¬	«      Z ed¬«      Zej1                  dg d¢¬«      	 	 	 	 	 dRdeedz   ej2                  d¬«      f   deedz   ej2                  d¬«      f   deedz   ej2                  d¬«      f   de
deddfd„«       Zej1                  ddg¬«      	 dSdee ej6                  d¬«      f   deddfd„«       Zej1                  dg d ¢¬«      	 	 	 	 	 dTd!ee ej6                  d"¬«      f   d#eedz   ej2                  d$¬«      f   d%eedz   ej2                  d&¬«      f   d'ee ej2                  d(¬«      f   d)ee ej2                  d*¬«      f   deddfd+„«       Zej1                  d,g d-¢¬«      	 	 	 	 	 	 dUdee ej6                  d¬«      f   d!eedz   ej2                  d.¬«      f   d%eedz   ej2                  d/¬«      f   d0eedz   ej2                  d1¬«      f   d'eedz   ej2                  d2¬«      f   d3eedz   ej2                  d4¬«      f   deddfd5„«       Z ej1                  d6d7d8g¬«      	 	 dVdee ej6                  d¬«      f   d9ee ej2                  d:¬«      f   deddfd;„«       Z!ej1                  d<g d=¢¬«      	 	 	 dWdee ej6                  d¬«      f   d>ee ej6                  d?¬«      f   d@ee ej6                  dA¬«      f   dBeedz   ej2                  dC¬«      f   d)ee ej2                  dD¬«      f   deddfdE„«       Z"ej1                  dFdGdHg¬«      	 	 	 dXdee ej6                  d¬«      f   dIee ej6                  dJ¬«      f   dBeedz   ej2                  dK¬«      f   d0eedz   ej2                  dL¬«      f   deddfdM„«       Z#ej1                  dN«      	 	 dVdee ej6                  d¬«      f   dIee ej6                  dO¬«      f   d9ee ej2                  dP¬«      f   deddf
dQ„«       Z$yc c} w c c}w )Ya_  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Úget_args)ÚCollectionItemType_TÚCollectionSort_Té   )ÚLimitOptÚTokenOptÚ
get_hf_apiÚtyper_factory)Ú_dataclass_to_dictÚoutÚCollectionItemType)ÚtypeÚCollectionSortz%Interact with collections on the Hub.)Úhelpz	list | ls)zhf collections lsz hf collections ls --owner nvidiazLhf collections ls --item models/teknium/OpenHermes-2.5-Mistral-7B --limit 10)ÚexamplesÚ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ÚtokenÚreturnc                 óÆ   — t        |¬«      }|r|j                  nd}|j                  | |||¬«      D �cg c]  }t        |«      ‘Œ }}t	        j
                  |«       yc c}w )zList collections on the Hub.©r   N)r   r   r   r   )r
   ÚvalueÚlist_collectionsr   r   Útable)	r   r   r   r   r   ÚapiÚsort_keyÚ
collectionÚresultss	            úa/var/www/html/tokenscope/api/venv/lib/python3.12/site-packages/huggingface_hub/cli/collections.pyÚcollections_lsr#   :   sn   € ô6 ˜5Ô
!€CÙ!ˆt�zŠz t€Hð ×.Ñ.ØØØØð	 /ó 
öàô 	˜:Õ&ð€Gð ô ‡I�IˆgÕùòs   ´AÚinfoz/hf collections info username/my-collection-slugÚcollection_slugz7The collection slug (e.g., 'username/collection-slug').c                 óh   — t        |¬«      }|j                  | «      }t        j                  |«       y)z'Get info about a collection on the Hub.r   N)r
   Úget_collectionr   Údict)r%   r   r   r    s       r"   Úcollections_infor)   c   s*   € ô ˜5Ô
!€CØ×#Ñ# OÓ4€JÜ‡H�HˆZÕó    Ú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                 ó    — t        |¬«      }|j                  | ||||¬«      }t        j                  d|j                  |j
                  ¬«       y)z#Create a new collection on the Hub.r   )r,   r-   r.   r/   r0   zCollection created©ÚslugÚurlN)r
   Úcreate_collectionr   Úresultr3   r4   )r,   r-   r.   r/   r0   r   r   r    s           r"   Úcollections_creater7   s   sM   € ô: ˜5Ô
!€CØ×&Ñ&ØØØØØð 'ó €Jô ‡J�JÐ#¨*¯/©/¸z¿~¹~ÖNr*   Ú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                 ó¢   — t        |¬«      }|j                  | |||||¬«      }t        j                  d|j                  |j
                  ¬«       y)z*Update a collection's metadata on the Hub.r   )r%   r,   r.   r9   r/   r:   zCollection updatedr2   N)r
   Úupdate_collection_metadatar   r6   r3   r4   )	r%   r,   r.   r9   r/   r:   r   r   r    s	            r"   Úcollections_updater=   ›   sQ   € ôB ˜5Ô
!€CØ×/Ñ/Ø'ØØØØØð 0ó €Jô ‡J�JÐ#¨*¯/©/¸z¿~¹~ÖNr*   Ú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   — t        |¬«      }|j                  | |¬«       t        j                  d| ¬«       y)z!Delete a collection from the Hub.r   )r?   zCollection deleted©r3   N)r
   Údelete_collectionr   r6   )r%   r?   r   r   s       r"   Úcollections_deleterC   È   s0   € ô  ˜5Ô
!€CØ×Ñ˜/°jÐÔAÜ‡J�JÐ#¨/Ö:r*   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_typezGThe type of item (model, dataset, space, paper, collection, or bucket).Ú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                 ó    — t        |¬«      }|j                  | ||j                  ||¬«      }t        j                  d| |j
                  ¬«       y)zAdd an item to a collection.r   )r%   rD   rE   rF   r0   zItem added to collectionr2   N)r
   Úadd_collection_itemr   r   r6   r4   )r%   rD   rE   rF   r0   r   r   r    s           r"   Úcollections_add_itemrI   Ý   sM   € ô8 ˜5Ô
!€CØ×(Ñ(Ø'ØØ—/‘/ØØð )ó €Jô ‡J�JÐ)°ÀZÇ^Á^ÖTr*   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                 ót   — t        |¬«      }|j                  | |||¬«       t        j                  d| ¬«       y)zUpdate an item in a collection.r   )r%   rJ   rF   r9   zItem updated in collectionrA   N)r
   Úupdate_collection_itemr   r6   )r%   rJ   rF   r9   r   r   s         r"   Úcollections_update_itemrM     s>   € ô0 ˜5Ô
!€CØ×ÑØ'Ø%ØØð	 ô ô ‡J�JÐ+°/ÖBr*   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                 ór   — t        |¬«      }|j                  | ||¬«       t        j                  d| ¬«       y)z!Delete an item from a collection.r   )r%   rJ   r?   zItem deleted from collectionrA   N)r
   Údelete_collection_itemr   r6   )r%   rJ   r?   r   r   s        r"   Úcollections_delete_itemrP   &  s;   € ô  ˜5Ô
!€CØ×ÑØ'Ø%Øð ô ô
 ‡J�JÐ-°OÖDr*   )NNNé
   N)N)NNFFN)NNNNNN)FN)NFN)NNN)%Ú__doc__ÚenumÚtypingr   r   ÚtyperÚhuggingface_hub.hf_apir   r   Ú
_cli_utilsr   r	   r
   r   Ú_outputr   r   Ú_COLLECTION_ITEM_TYPESÚEnumÚstrr   Ú_COLLECTION_SORT_OPTIONSr   Úcollections_cliÚcommandÚOptionr#   ÚArgumentr)   Úboolr7   Úintr=   rC   rI   rM   rP   )ÚtÚss   00r"   ú<module>re      s¤  ðñó, ß &ã ç Iç EÓ Eß ,ñ "Ð"6Ó7Ð Ø�T—Y‘YÐ3ÐDZÖ5[¸q°a¸±dÒ5[ÐbeÔfÐ á#Ð$4Ó5Ð Ø�—‘Ð+Ð<TÖ-U°q¨a°©dÒ-UÐ\_Ô`€ñ  Ð%LÔM€ð ×ÑØòð ó ð 	ð 	ð 	ØØñ!ØØˆd‰
Øˆ�‰ÐEÔFð	Hñðð
 Øˆd‰
Øˆ�‰Ø~ô	
ð	ñðð Ø˜ÑØˆ�‰ÐPÔQð	Sñðð ðð  ð!ð" 
ò#óððB ×ÑØ
à9ðð ó ð ñØ˜s N E§N¡NÐ8qÔ$rÐrÑsðàðð 
òóðð ×ÑØòð ó ð 	ð 	ð 	ð 	Øñ%OØ�S˜.˜%Ÿ.™.Ð.LÔMÐMÑNðOàØˆd‰
Øˆ�‰ÐiÔjð	lñðOð Øˆd‰
Øˆ�‰Ð=Ô>ð	@ñðOð ØØˆ�‰Ð8Ô9ð	;ñðOð ØØˆ�‰ÐSÔTð	VñðOð$ ð%Oð& 
ò'OóðOð@ ×ÑØòð ó ð 	ð 	ð 	ð 	ð 	Øñ-"OØ˜s N E§N¡NÐ8qÔ$rÐrÑsð"OàØˆd‰
Øˆ�‰Ð=Ô>ð	@ñð"Oð Øˆd‰
Øˆ�‰ÐCÔDð	Fñð"Oð Øˆd‰
Øˆ�‰ÐSÔTð	Vñð"Oð Øˆt‰Øˆ�‰ÐEÔFð	Hñð"Oð$ Øˆd‰
Øˆ�‰ÐWÔXð	Zñð%"Oð, ð-"Oð. 
ò/"Oóð"OðJ ×ÑØà6ØCðð ó ð 	Øñ;Ø˜s N E§N¡NÐ8qÔ$rÐrÑsð;àØØˆ�‰ÐRÔSð	Uñð;ð ð;ð 
ò;óð;ð ×ÑØòð ó ð( 	ð 	Øñ#UØ˜s N E§N¡NÐ8qÔ$rÐrÑsðUàØˆ^ˆU�^‰^Ð!fÔgÐgñðUð
 ØØˆ�‰ÐeÔfð	hñðUð Øˆd‰
Øˆ�‰ÐNÔOð	QñðUð ØØˆ�‰Ð[Ô\ð	^ñðUð" ð#Uð$ 
ò%UóðUð> ×ÑØà`ØWðð ó ð  	ð 	ØñCØ˜s N E§N¡NÐ8qÔ$rÐrÑsðCàØØˆ�‰ÐrÔsð	uñðCð Øˆd‰
Øˆ�‰ÐIÔJð	LñðCð Øˆd‰
Øˆ�‰ÐKÔLð	NñðCð ðCð 
òCóðCð6 ×Ñ˜Ó'ð 	ØñEØ˜s N E§N¡NÐ8qÔ$rÐrÑsðEàØØˆ�‰ð Bô	
ð	ñðEð ØØˆ�‰ÐLÔMð	OñðEð ðEð 
òEó (ñEùòm 6\ùò .Vs   Á
R
Á4
R
