§
    }Štjˆ'  ã                   ó¨  — d Z ddlZddlmZm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 ddlmZmZ  ee¦  «        Z ej        d	d
„ eD ¦   «         e¬¦  «        Z ee¦  «        Z ej        dd„ eD ¦   «         e¬¦  «        Z ed¬¦  «        Ze                     dg d¢¬¦  «        	 	 	 	 	 dWdeedz   ed¬¦  «        f         deedz   ed¬¦  «        f         deedz   ed¬¦  «        f         de	de
ddfd„¦   «         Ze                     ddg¬¦  «        	 dXd ee ed!¬¦  «        f         de
ddfd"„¦   «         Ze                     d#g d$¢¬¦  «        	 	 	 	 	 dYd&ee ed'¬¦  «        f         d(eedz   ed)¬¦  «        f         d*eedz   ed+¬¦  «        f         d,ee ed-¬¦  «        f         d.ee ed/¬¦  «        f         de
ddfd0„¦   «         Ze                     d1g d2¢¬¦  «        	 	 	 	 	 	 dZd ee ed!¬¦  «        f         d&eedz   ed3¬¦  «        f         d*eedz   ed4¬¦  «        f         d5eedz   ed6¬¦  «        f         d,eedz   ed7¬¦  «        f         d8eedz   ed9¬¦  «        f         de
ddfd:„¦   «         Z e                     d;d<d=g¬¦  «        	 	 d[d ee ed!¬¦  «        f         d>ee ed?¬¦  «        f         de
ddfd@„¦   «         Z!e                     dAg dB¢¬¦  «        	 	 	 d\d ee ed!¬¦  «        f         dCee edD¬¦  «        f         dEee edF¬¦  «        f         dGeedz   edH¬¦  «        f         d.ee edI¬¦  «        f         de
ddfdJ„¦   «         Z"e                     dKdLdMg¬¦  «        	 	 	 d]d ee ed!¬¦  «        f         dNee edO¬¦  «        f         dGeedz   edP¬¦  «        f         d5eedz   edQ¬¦  «        f         de
ddfdR„¦   «         Z#e                     dS¦  «        	 	 d[d ee ed!¬¦  «        f         dNee edT¬¦  «        f         d>ee edU¬¦  «        f         de
ddf
dV„¦   «         Z$dS )^zGContains commands to interact with collections on the Hugging Face Hub.é    N)Ú	AnnotatedÚget_args)ÚCollectionItemType_TÚCollectionSort_Té   )ÚLimitOptÚTokenOptÚ
get_hf_apiÚtyper_factory)ÚArgumentÚOption)Ú_dataclass_to_dictÚoutÚCollectionItemTypec                 ó   — i | ]}||“ŒS © r   )Ú.0Úts     ú]/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/huggingface_hub/cli/collections.pyú
<dictcomp>r      s   € Ð5[Ð5[Ð5[¸q°a¸Ð5[Ð5[Ð5[ó    )ÚtypeÚCollectionSortc                 ó   — i | ]}||“ŒS r   r   )r   Úss     r   r   r      s   € Ð-UÐ-UÐ-U°q¨a°Ð-UÐ-UÐ-Ur   z%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}d„ |                     | |||¬¦  «        D ¦   «         }t          j        |¦  «         dS )zList collections on the Hub.©r#   Nc                 ó,   — g | ]}t          |¦  «        ‘ŒS r   )r   )r   Ú
collections     r   ú
<listcomp>z"collections_ls.<locals>.<listcomp>B   s0   € ð ð ð àõ 	˜:Ñ&Ô&ðð ð r   )r   r    r!   r"   )r
   ÚvalueÚlist_collectionsr   Útable)r   r    r!   r"   r#   ÚapiÚsort_keyÚresultss           r   Úcollections_lsr0   %   s{   € õ6 ˜5Ð
!Ñ
!Ô
!€CØ!Ð+ˆtŒzˆz t€Hðð à×.Ò.ØØØØð	 /ñ 
ô 
ðñ ô €Gõ „IˆgÑÔÐÐÐr   Úinfoz/hf collections info username/my-collection-slugÚcollection_slugz7The collection slug (e.g., 'username/collection-slug').c                 óx   — t          |¬¦  «        }|                     | ¦  «        }t          j        |¦  «         dS )z'Get info about a collection on the Hub.r&   N)r
   Úget_collectionr   Údict)r2   r#   r-   r(   s       r   Úcollections_infor6   N   s=   € õ ˜5Ð
!Ñ
!Ô
!€CØ×#Ò# OÑ4Ô4€JÝ„HˆZÑÔÐÐÐr   Ú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-orgFÚtitlezThe title of the collection.Ú	namespacezMThe namespace (username or organization). Defaults to the authenticated user.Údescriptionz6A description for the collection (max 150 characters).ÚprivatezCreate a private collection.Ú	exists_okz7Do not raise an error if the collection already exists.c                 óœ   — t          |¬¦  «        }|                     | ||||¬¦  «        }t          j        d|j        |j        ¬¦  «         dS )z#Create a new collection on the Hub.r&   )r8   r9   r:   r;   r<   zCollection created©ÚslugÚurlN)r
   Úcreate_collectionr   Úresultr?   r@   )r8   r9   r:   r;   r<   r#   r-   r(   s           r   Úcollections_createrC   ^   sa   € õ: ˜5Ð
!Ñ
!Ô
!€CØ×&Ò&ØØØØØð 'ñ ô €Jõ „JÐ#¨*¬/¸z¼~ÐNÑNÔNÐNÐNÐ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 (max 150 characters).Ú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          |¬¦  «        }|                     | |||||¬¦  «        }t          j        d|j        |j        ¬¦  «         dS )z*Update a collection's metadata on the Hub.r&   )r2   r8   r:   rE   r;   rF   zCollection updatedr>   N)r
   Úupdate_collection_metadatar   rB   r?   r@   )	r2   r8   r:   rE   r;   rF   r#   r-   r(   s	            r   Úcollections_updaterI   †   se   € õB ˜5Ð
!Ñ
!Ô
!€CØ×/Ò/Ø'ØØØØØð 0ñ ô €Jõ „JÐ#¨*¬/¸z¼~ÐNÑNÔNÐNÐNÐ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                 ó€   — t          |¬¦  «        }|                     | |¬¦  «         t          j        d| ¬¦  «         dS )z!Delete a collection from the Hub.r&   )rK   zCollection deleted©r?   N)r
   Údelete_collectionr   rB   )r2   rK   r#   r-   s       r   Úcollections_deleterO   ³   sI   € õ  ˜5Ð
!Ñ
!Ô
!€CØ×Ò˜/°jÐÑAÔAÐAÝ„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        ||¬¦  «        }t          j        d| |j        ¬¦  «         dS )zAdd an item to a collection.r&   )r2   rP   rQ   rR   r<   zItem added to collectionr>   N)r
   Úadd_collection_itemr*   r   rB   r@   )r2   rP   rQ   rR   r<   r#   r-   r(   s           r   Úcollections_add_itemrU   È   sa   € õ4 ˜5Ð
!Ñ
!Ô
!€CØ×(Ò(Ø'ØØ”/ØØð )ñ ô €Jõ „JÐ)°ÀZÄ^ÐTÑTÔTÐTÐTÐ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        d| ¬¦  «         dS )zUpdate an item in a collection.r&   )r2   rV   rR   rE   zItem updated in collectionrM   N)r
   Úupdate_collection_itemr   rB   )r2   rV   rR   rE   r#   r-   s         r   Úcollections_update_itemrY   í   s[   € õ0 ˜5Ð
!Ñ
!Ô
!€CØ×ÒØ'Ø%ØØð	 ñ ô ð õ „JÐ+°/ÐBÑBÔBÐBÐBÐ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                 ó‚   — t          |¬¦  «        }|                     | ||¬¦  «         t          j        d| ¬¦  «         dS )z!Delete an item from a collection.r&   )r2   rV   rK   zItem deleted from collectionrM   N)r
   Údelete_collection_itemr   rB   )r2   rV   rK   r#   r-   s        r   Úcollections_delete_itemr\     sX   € õ  ˜5Ð
!Ñ
!Ô
!€CØ×ÒØ'Ø%Øð ñ ô ð õ
 „JÐ-°OÐDÑDÔDÐDÐDÐDr   )NNNr   N)N)NNFFN)NNNNNN)FN)NFN)NNN)%Ú__doc__ÚenumÚtypingr   r   Úhuggingface_hub.hf_apir   r   Ú
_cli_utilsr   r	   r
   r   Ú
_frameworkr   r   Ú_outputr   r   Ú_COLLECTION_ITEM_TYPESÚEnumÚstrr   Ú_COLLECTION_SORT_OPTIONSr   Úcollections_cliÚcommandr0   r6   ÚboolrC   ÚintrI   rO   rU   rY   r\   r   r   r   ú<module>rl      sp	  ðð NÐ Mà €€€Ø &Ð &Ð &Ð &Ð &Ð &Ð &Ð &à IÐ IÐ IÐ IÐ IÐ IÐ IÐ Ià EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EØ (Ð (Ð (Ð (Ð (Ð (Ð (Ð (Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,ð "˜Ð"6Ñ7Ô7Ð Ø�T”YÐ3Ð5[Ð5[ÐDZÐ5[Ñ5[Ô5[ÐbeÐfÑfÔfÐ à#˜8Ð$4Ñ5Ô5Ð Ø�”Ð+Ð-UÐ-UÐ<TÐ-UÑ-UÔ-UÐ\_Ð`Ñ`Ô`€ð  �-Ð%LÐMÑMÔM€ð ×ÒØðð ð ð ñ ô ð 	ð 	ð 	ØØð!ð ØØˆd‰
ØˆÐ?Ð@Ñ@Ô@ð	Bôðð
 Øˆd‰
ØˆØ~ð	
ñ 	
ô 	
ð	ôðð Ø˜ÑØˆÐJÐKÑKÔKð	Môðð ðð  ð!ð" 
ð#ð ð ñô ððB ×ÒØ
à9ðð ñ ô ð ðð Ø˜s H HÐ2kÐ$lÑ$lÔ$lÐlÔmðàðð 
ðð ð ñô ðð ×ÒØðð ð ð ñ ô ð 	ð 	ð 	ð 	Øð%Oð OØ�S˜(˜(Ð(FÐGÑGÔGÐGÔHðOàØˆd‰
ØˆÐcÐdÑdÔdð	fôðOð Øˆd‰
ØˆÐLÐMÑMÔMð	OôðOð ØØˆÐ2Ð3Ñ3Ô3ð	5ôðOð ØØˆÐMÐNÑNÔNð	PôðOð$ ð%Oð& 
ð'Oð Oð Oñô ðOð@ ×ÒØðð ð ð ñ ô ð 	ð 	ð 	ð 	ð 	Øð-"Oð "OØ˜s H HÐ2kÐ$lÑ$lÔ$lÐlÔmð"OàØˆd‰
ØˆÐ7Ð8Ñ8Ô8ð	:ôð"Oð Øˆd‰
ØˆÐRÐSÑSÔSð	Uôð"Oð Øˆd‰
ØˆÐMÐNÑNÔNð	Pôð"Oð Øˆt‰ØˆÐ?Ð@Ñ@Ô@ð	Bôð"Oð$ Øˆd‰
ØˆÐQÐRÑRÔRð	Tôð%"Oð, ð-"Oð. 
ð/"Oð "Oð "Oñô ð"OðJ ×ÒØà6ØCðð ñ ô ð 	Øð;ð ;Ø˜s H HÐ2kÐ$lÑ$lÔ$lÐlÔmð;àØØˆÐLÐMÑMÔMð	Oôð;ð ð;ð 
ð;ð ;ð ;ñô ð;ð ×ÒØðð ð ð ñ ô ð$ 	ð 	ØðUð UØ˜s H HÐ2kÐ$lÑ$lÔ$lÐlÔmðUà�s˜H˜HÐ*oÐpÑpÔpÐpÔqðUð ØØˆÐ_Ð`Ñ`Ô`ð	bôðUð Øˆd‰
ØˆÐHÐIÑIÔIð	KôðUð ØØˆÐUÐVÑVÔVð	XôðUð ðUð  
ð!Uð Uð Uñô ðUð: ×ÒØà`ØWðð ñ ô ð  	ð 	ØðCð CØ˜s H HÐ2kÐ$lÑ$lÔ$lÐlÔmðCàØØˆÐlÐmÑmÔmð	oôðCð Øˆd‰
ØˆÐCÐDÑDÔDð	FôðCð Øˆd‰
ØˆÐEÐFÑFÔFð	HôðCð ðCð 
ðCð Cð Cñô ðCð6 ×Ò˜Ñ'Ô'ð 	ØðEð EØ˜s H HÐ2kÐ$lÑ$lÔ$lÐlÔmðEàØØˆð Bð	
ñ 	
ô 	
ð	ôðEð ØØˆÐFÐGÑGÔGð	IôðEð ðEð 
ðEð Eð Eñ (Ô'ðEð Eð Er   