huggingface-hub 0.25.2__py3-none-any.whl → 0.26.0rc0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of huggingface-hub might be problematic. Click here for more details.

Files changed (45) hide show
  1. huggingface_hub/__init__.py +45 -11
  2. huggingface_hub/_login.py +172 -33
  3. huggingface_hub/commands/user.py +125 -9
  4. huggingface_hub/constants.py +1 -1
  5. huggingface_hub/errors.py +6 -9
  6. huggingface_hub/file_download.py +2 -372
  7. huggingface_hub/hf_api.py +170 -13
  8. huggingface_hub/hf_file_system.py +3 -3
  9. huggingface_hub/hub_mixin.py +2 -1
  10. huggingface_hub/inference/_client.py +500 -145
  11. huggingface_hub/inference/_common.py +42 -4
  12. huggingface_hub/inference/_generated/_async_client.py +499 -144
  13. huggingface_hub/inference/_generated/types/__init__.py +37 -7
  14. huggingface_hub/inference/_generated/types/audio_classification.py +8 -5
  15. huggingface_hub/inference/_generated/types/automatic_speech_recognition.py +9 -7
  16. huggingface_hub/inference/_generated/types/chat_completion.py +23 -4
  17. huggingface_hub/inference/_generated/types/image_classification.py +8 -5
  18. huggingface_hub/inference/_generated/types/image_segmentation.py +9 -7
  19. huggingface_hub/inference/_generated/types/image_to_image.py +7 -5
  20. huggingface_hub/inference/_generated/types/image_to_text.py +4 -4
  21. huggingface_hub/inference/_generated/types/object_detection.py +11 -5
  22. huggingface_hub/inference/_generated/types/summarization.py +11 -13
  23. huggingface_hub/inference/_generated/types/text_classification.py +10 -5
  24. huggingface_hub/inference/_generated/types/text_generation.py +1 -0
  25. huggingface_hub/inference/_generated/types/text_to_audio.py +2 -2
  26. huggingface_hub/inference/_generated/types/text_to_image.py +9 -7
  27. huggingface_hub/inference/_generated/types/text_to_speech.py +107 -0
  28. huggingface_hub/inference/_generated/types/translation.py +17 -11
  29. huggingface_hub/inference/_generated/types/video_classification.py +2 -2
  30. huggingface_hub/repocard.py +2 -1
  31. huggingface_hub/repocard_data.py +10 -2
  32. huggingface_hub/serialization/_torch.py +7 -4
  33. huggingface_hub/utils/__init__.py +4 -20
  34. huggingface_hub/utils/{_token.py → _auth.py} +86 -3
  35. huggingface_hub/utils/_headers.py +1 -1
  36. huggingface_hub/utils/_hf_folder.py +1 -1
  37. huggingface_hub/utils/_http.py +10 -4
  38. huggingface_hub/utils/_runtime.py +1 -10
  39. {huggingface_hub-0.25.2.dist-info → huggingface_hub-0.26.0rc0.dist-info}/METADATA +12 -12
  40. {huggingface_hub-0.25.2.dist-info → huggingface_hub-0.26.0rc0.dist-info}/RECORD +44 -44
  41. huggingface_hub/inference/_templating.py +0 -102
  42. {huggingface_hub-0.25.2.dist-info → huggingface_hub-0.26.0rc0.dist-info}/LICENSE +0 -0
  43. {huggingface_hub-0.25.2.dist-info → huggingface_hub-0.26.0rc0.dist-info}/WHEEL +0 -0
  44. {huggingface_hub-0.25.2.dist-info → huggingface_hub-0.26.0rc0.dist-info}/entry_points.txt +0 -0
  45. {huggingface_hub-0.25.2.dist-info → huggingface_hub-0.26.0rc0.dist-info}/top_level.txt +0 -0
@@ -1,9 +1,9 @@
1
- huggingface_hub/__init__.py,sha256=1QDjM2QkpYYTWBVgy3KKfspMieA3IgvIL-SCN9qDfKQ,34573
1
+ huggingface_hub/__init__.py,sha256=OV4gdDzK7x3Nzzm-HzWON6NTyVOcOe5RBPTS1J7Qriw,35997
2
2
  huggingface_hub/_commit_api.py,sha256=Y9eTaW4bYzxtrZsSniVtfeAuFafqx8x1ofMI5es8hvM,31057
3
3
  huggingface_hub/_commit_scheduler.py,sha256=nlJS_vnLb8i92NLrRwJX8Mg9QZ7f3kfLbLlQuEd5YjU,13647
4
4
  huggingface_hub/_inference_endpoints.py,sha256=wzjD8P68VpUDHzIDbXzFXsM2Y-aNVSAap7BXsZFuthk,16750
5
5
  huggingface_hub/_local_folder.py,sha256=PBycy5l4iyugz0NCExSfbSon1IwqPiblC6Xy4eeFYCU,16392
6
- huggingface_hub/_login.py,sha256=WXVv4e7almLbmVQuq4NR78TPLm4RDmzNZr4vrl2gbLI,15484
6
+ huggingface_hub/_login.py,sha256=dlku1N_v4HPtsaJHdlssf3uYcy4uNOLK-aZuzAvxPfo,20878
7
7
  huggingface_hub/_multi_commits.py,sha256=mFmCP_5hNsruEgDF6kOVyaFkpnbSdNxPWfGUlFbl5O8,12535
8
8
  huggingface_hub/_snapshot_download.py,sha256=Vnvz0liOFTEARscOuOpA3WUTjnX5ufi6N5D5KIj9fwU,14847
9
9
  huggingface_hub/_space_api.py,sha256=QVOUNty2T4RxPoxf9FzUjXmjHiGXP0mqXJzqQ7GmoJo,5363
@@ -12,18 +12,18 @@ huggingface_hub/_upload_large_folder.py,sha256=hrm29zJXnWpxBgfJ-pmqaDwWl5WNYiYuQ
12
12
  huggingface_hub/_webhooks_payload.py,sha256=Xm3KaK7tCOGBlXkuZvbym6zjHXrT1XCrbUFWuXiBmNY,3617
13
13
  huggingface_hub/_webhooks_server.py,sha256=oCvpFrYjrhJjClAMw26SQfvN4DUItgK2IhFp1OVh2bU,15623
14
14
  huggingface_hub/community.py,sha256=4MtcoxEI9_0lmmilBEnvUEi8_O1Ivfa8p6eKxYU5-ts,12198
15
- huggingface_hub/constants.py,sha256=BG3n2gl4JbxMw_JRvNTFyMcNnZIPzvT3KXSH-jm2J08,8005
16
- huggingface_hub/errors.py,sha256=kENdHLaBExWdu_dFJumYz7FFgLiROI4qgSvt03fJRec,9261
15
+ huggingface_hub/constants.py,sha256=WshhUKAs6kyoBPN1ek9Zsr2JY-bvjof69VJOfuu8tm4,8090
16
+ huggingface_hub/errors.py,sha256=CbcLWbwQG5P1kReMUmCovPONciXmqLfTzAHXD-xJVDs,9276
17
17
  huggingface_hub/fastai_utils.py,sha256=o0BnmigoNP3H7Sf8w8bwuRaN-9FKlL6uoPawr4HSyjc,16647
18
- huggingface_hub/file_download.py,sha256=LYbLa0OKoSeis7d3j6mB2V-IJqAkV18wYwqRSl-VTKs,85412
19
- huggingface_hub/hf_api.py,sha256=wwxfPs9a6IHZB6DOnK0hHIMcV_NQJEAM_HbFDGcxCog,433714
20
- huggingface_hub/hf_file_system.py,sha256=-TfO8cnfsQTxwzd-K6vjrbGkziNrAyiSHDHu_ss1U-I,39148
21
- huggingface_hub/hub_mixin.py,sha256=ZeCxje9e42-pm78dVhUDoQZQchXH3i1svy5CzOL3l7o,37554
18
+ huggingface_hub/file_download.py,sha256=Y4ngJd_V37OCjJichBE0ZuHiP-Z_B4jaxgeeEGGJzXg,70630
19
+ huggingface_hub/hf_api.py,sha256=J6c9P9YBmg3qy7GJVNGdoYTBMlrFmYVX8ynWJT1_eqs,439645
20
+ huggingface_hub/hf_file_system.py,sha256=2i88wje7OcYZPgMv_TRXHZso1D26wmY6Sj3ZL5BqICo,39163
21
+ huggingface_hub/hub_mixin.py,sha256=H6gN5EBRn5A8zc6jHj1FpjGDLOar2M67wOssGkvin0M,37551
22
22
  huggingface_hub/inference_api.py,sha256=b4-NhPSn9b44nYKV8tDKXodmE4JVdEymMWL4CVGkzlE,8323
23
23
  huggingface_hub/keras_mixin.py,sha256=LReKRHE4y9kN-r7WdqtUYJY2mYKkhN1nJ8Jl6v52P7A,19483
24
24
  huggingface_hub/lfs.py,sha256=xQE8HTZmzILey8aqURpD-NO6_z1LUasOJssXiBcm0s4,16827
25
- huggingface_hub/repocard.py,sha256=2NkzYa4-0NT6Ydyq1TcgcJ07M35YgaP9_9hXUEL7WoE,34641
26
- huggingface_hub/repocard_data.py,sha256=tATP6rp7MOlbPXVCMGhNMaDP7RmKPQkX_pXtBVOYmRQ,32726
25
+ huggingface_hub/repocard.py,sha256=86FiLCufy9oLf6moGkfmi9h3euGwDDY4eLrs0GKWBRk,34732
26
+ huggingface_hub/repocard_data.py,sha256=lGC_QpmCZR4nMTO8E5-EpdOAARSe1_5uGRszPBuIg7s,33123
27
27
  huggingface_hub/repository.py,sha256=xVQR-MRKNDfJ_Z_99DwtXZB3xNO06eYG_GvRM4fLiTU,54557
28
28
  huggingface_hub/commands/__init__.py,sha256=AkbM2a-iGh0Vq_xAWhK3mu3uZ44km8-X5uWjKcvcrUQ,928
29
29
  huggingface_hub/commands/_cli_utils.py,sha256=Nt6CjbkYqQQRuh70bUXVA6rZpbZt_Sa1WqBUxjQLu6g,2095
@@ -37,41 +37,41 @@ huggingface_hub/commands/scan_cache.py,sha256=CSXyIDCzOcxSFwIc_SqUC6J_TIc7uHXjrt
37
37
  huggingface_hub/commands/tag.py,sha256=0LNQZyK-WKi0VIL9i1xWzKxJ1ILw1jxMF_E6t2weJss,6288
38
38
  huggingface_hub/commands/upload.py,sha256=xMExm68YcR8R_dDRi3bcIC1qVCvRFRW7aP_AGxGZ1rc,13656
39
39
  huggingface_hub/commands/upload_large_folder.py,sha256=LKvzEmKeRatBLlnJF__b5jFBQ8bcM2KQgN_Pcf1X5hE,6128
40
- huggingface_hub/commands/user.py,sha256=QApZJOCQEHADhjunM3hlQ72uqHsearCiCE4SdpzGdcc,6893
40
+ huggingface_hub/commands/user.py,sha256=imsUyvOD7ZF4YvKzBuuaX-Y8ytNv-xDD6ELdH4hHGfU,11162
41
41
  huggingface_hub/commands/version.py,sha256=vfCJn7GO1m-DtDmbdsty8_RTVtnZ7lX6MJsx0Bf4e-s,1266
42
42
  huggingface_hub/inference/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
- huggingface_hub/inference/_client.py,sha256=yZ8YPWiZk0PEhNIfRsUKuoJij3QKYFqIO3jnJZa8Sho,126997
44
- huggingface_hub/inference/_common.py,sha256=B-CpkIn3sBh9J2tW9rcwy1hk1Cq45pHbg4E3HZcpF6I,15121
45
- huggingface_hub/inference/_templating.py,sha256=xWPzz_TyQpGOZyVP_ev-gSo92swSRVK8whPAG3bbQpM,3976
43
+ huggingface_hub/inference/_client.py,sha256=W34WHKnZq5FpY7zxTE9UNZtQZVmrjYCApZEozK-kIkA,146734
44
+ huggingface_hub/inference/_common.py,sha256=_SgAkuM4a2FgONO8hoaOPDLsYFPzy9eZNkeYtq7hTJ4,16822
46
45
  huggingface_hub/inference/_generated/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
- huggingface_hub/inference/_generated/_async_client.py,sha256=_pfb8C0NV-3-ixB5bblL9-XPgjqh7ECXry7A_InEw6c,133489
48
- huggingface_hub/inference/_generated/types/__init__.py,sha256=uEsA0z8Gcu34q0gNAZVcqHFqJT5BPrhnM9qS_LQgN0Q,5215
49
- huggingface_hub/inference/_generated/types/audio_classification.py,sha256=wk4kUTLQZoXWLpiUOpKRHRRE-JYqqJlzGVe62VACR-0,1347
46
+ huggingface_hub/inference/_generated/_async_client.py,sha256=twguBoU27X-yH-uAJKRSQ3Q8nDxzeudUSZQBcOMPG6U,153274
47
+ huggingface_hub/inference/_generated/types/__init__.py,sha256=fJK7_Df3ftSTkZYaJngZUcV5YtVLPm9-Zd5WXrGr9m0,5768
48
+ huggingface_hub/inference/_generated/types/audio_classification.py,sha256=krHh0MaHokL6wFxjdRVB-1Tdstl_RCyi_AfRJTTxr6Y,1529
50
49
  huggingface_hub/inference/_generated/types/audio_to_audio.py,sha256=n7GeCepzt254yoSLsdjrI1j4fzYgjWzxoaKE5gZJc48,881
51
- huggingface_hub/inference/_generated/types/automatic_speech_recognition.py,sha256=-7UHu5QTGwSrJFnrbMgzeUFpJQOGyTmfK_QHgtnx6j8,5352
50
+ huggingface_hub/inference/_generated/types/automatic_speech_recognition.py,sha256=NHkz-IivdK8gHDuPalZ3Q9ubxESltjCnwrR1Z52KejY,5531
52
51
  huggingface_hub/inference/_generated/types/base.py,sha256=dQ-ej4weVueTJQXaDFLYFhKvlCUYVH2k9r-Ck0uhFIU,5870
53
- huggingface_hub/inference/_generated/types/chat_completion.py,sha256=k8VAiyauZDbSqxQuUQpMTVHBRUho49-ujedYBl3jy8w,8809
52
+ huggingface_hub/inference/_generated/types/chat_completion.py,sha256=FpY0K5ENGTdBSNLeioKwdOuegg1jvyEQYmsrrQVhD7Y,9462
54
53
  huggingface_hub/inference/_generated/types/depth_estimation.py,sha256=lmLmd8S313ZMCG94RblwquL0UN_0hJmXAhWUqSIrtwc,898
55
54
  huggingface_hub/inference/_generated/types/document_question_answering.py,sha256=_hBzK4Pu9X_zXsgOO4JNSloIKuVfE5m7eGwEw5YTfZ4,3264
56
55
  huggingface_hub/inference/_generated/types/feature_extraction.py,sha256=FYjXh60gaRKCwwrb9DFEshAY_7axO88RifzHfig7RNI,1490
57
56
  huggingface_hub/inference/_generated/types/fill_mask.py,sha256=JcYIbTDXc4f7k2FNY3fCWtJ9ke3HUZFz2pDOOrDuxOs,1714
58
- huggingface_hub/inference/_generated/types/image_classification.py,sha256=W1QVfc0j7t6qbxjICUQDwygRx43yPPGZKyStogHkHqg,1359
59
- huggingface_hub/inference/_generated/types/image_segmentation.py,sha256=nVQc5Qhv37qqmTn_M8xegpNgk14ozKelsGIYC8hba_0,1803
60
- huggingface_hub/inference/_generated/types/image_to_image.py,sha256=MbubS9pD8bFP9LoI4QoQxJwpUGeNXi5iSEk8Ymhbh0M,1797
61
- huggingface_hub/inference/_generated/types/image_to_text.py,sha256=mloLf-LO7oR_2HbPY1-XMM18BfjMODytRaxTXYkIXoY,4827
62
- huggingface_hub/inference/_generated/types/object_detection.py,sha256=F8ly6GSE8dupsekPVf6G5nI8teZAIP4iXw6u3zm1JiE,1569
57
+ huggingface_hub/inference/_generated/types/image_classification.py,sha256=GvJaHykIYmGF8oGabbLvz1Ski_AclnoCu-y8mVZKXs0,1541
58
+ huggingface_hub/inference/_generated/types/image_segmentation.py,sha256=fLvhgo_1eTeZFk8DuGXOY27ZagjIMJ_07HtkLXXRmO4,1947
59
+ huggingface_hub/inference/_generated/types/image_to_image.py,sha256=sNAJvUT9xJwLqFm0UngzDB6wEdqsJCGb7zhZDAtwPe0,1967
60
+ huggingface_hub/inference/_generated/types/image_to_text.py,sha256=QSU2VD1ibviqKrcjILlqzTk-YrxYF49qr3MSdqRD12U,4851
61
+ huggingface_hub/inference/_generated/types/object_detection.py,sha256=cyXvMsmHeA9LI2xKJEQCnSgFJMGC1gdEtc5QjnSiSII,1988
63
62
  huggingface_hub/inference/_generated/types/question_answering.py,sha256=xLDy5oA-k9JPncSU6NqPAPb8rWPerfTbU857G3e7JZ0,2884
64
63
  huggingface_hub/inference/_generated/types/sentence_similarity.py,sha256=edH-TWfnZ4J0zJD-zqfcRMLwOV0dTt1g5Y0caYnVuPc,1018
65
- huggingface_hub/inference/_generated/types/summarization.py,sha256=RWCXh7yftI_JWvLsr7JiDpQPexq1klYP158tUICUcbM,1574
64
+ huggingface_hub/inference/_generated/types/summarization.py,sha256=0LPPg0KxX4aIh4FVA3NxWy0OxPe8yTdPpe2tbfH2c9g,1490
66
65
  huggingface_hub/inference/_generated/types/table_question_answering.py,sha256=PuVZlR6dI6FEUK7pjMSVMtzkDgrcxdKjfcnDbVmPdSs,1569
67
66
  huggingface_hub/inference/_generated/types/text2text_generation.py,sha256=SZYfdhyraG5vZ2Jzm1C8k9w9IYLxMtm5UUu1tU2oOQk,1604
68
- huggingface_hub/inference/_generated/types/text_classification.py,sha256=vC7B1sBzZ4gdLjE2i2Y7w5cpdaFwQKK1dlWqW0asjIk,1347
69
- huggingface_hub/inference/_generated/types/text_generation.py,sha256=OIU_Hwrn2Sra8pUbLOwal9gnYCe4d01m5iebWwzLwX8,5776
70
- huggingface_hub/inference/_generated/types/text_to_audio.py,sha256=cgvECsiwsycgP9Tfs_GU1CJfo9AngVn6x9s4fHCP-g4,4819
71
- huggingface_hub/inference/_generated/types/text_to_image.py,sha256=oBGeJ-S9WfsMxVQlvEOll9yaCyMXZ277wsYFD8bt87U,1931
67
+ huggingface_hub/inference/_generated/types/text_classification.py,sha256=p7bvpM7ULZPnzPZutNYS7-3J6mtL8rToEnCVOGp-TzI,1392
68
+ huggingface_hub/inference/_generated/types/text_generation.py,sha256=TKJb26T03Gyw3As0IXmRzAritNeKUpturKfO_2OenzA,5798
69
+ huggingface_hub/inference/_generated/types/text_to_audio.py,sha256=9aGy51OiyvOu5G6pOmq6OLuEpUVj0c_b1wEguuSjY40,4841
70
+ huggingface_hub/inference/_generated/types/text_to_image.py,sha256=R-ecvxC7IrFB5wo9BBSLh_zvFAYpmMJdLF8KmtD3sBI,2007
71
+ huggingface_hub/inference/_generated/types/text_to_speech.py,sha256=_70NMzETkDoEkpV6t2Ts95cISeyHjIDKALfrZRd0cfg,4898
72
72
  huggingface_hub/inference/_generated/types/token_classification.py,sha256=7oL8AZOTWtf2bYD2T3236GDNMtUl7FtydaB6We7wbfw,1890
73
- huggingface_hub/inference/_generated/types/translation.py,sha256=MruCx6yhzQGlxSdBRXCVoEhRzRSa5Ks4bjZ1PDrlTeQ,1562
74
- huggingface_hub/inference/_generated/types/video_classification.py,sha256=BI2_PP-pxLT6w9TuX6QCZz4BsG-ZukTXnW6fWMchI5M,1579
73
+ huggingface_hub/inference/_generated/types/translation.py,sha256=lpyfGtFKCyWFD5wi7v8wPGn_vrJF4L8O9g7UigTDlJk,1767
74
+ huggingface_hub/inference/_generated/types/video_classification.py,sha256=uK1wYrAcnXSiLgL64idGWC2t-512N-zWtAcDcYaola0,1589
75
75
  huggingface_hub/inference/_generated/types/visual_question_answering.py,sha256=0PHNnjwxxHvG3SjOz7O7DckbBeGYDsRmlagG11qIkkM,1667
76
76
  huggingface_hub/inference/_generated/types/zero_shot_classification.py,sha256=u6jfFCqDv9XqeAN5E9_Xf7jqMZgqTRFF_S9PtWbiBUk,1963
77
77
  huggingface_hub/inference/_generated/types/zero_shot_image_classification.py,sha256=qVH6Ms0FjF8TraGy4BYiS8lmvGq9xiIDdXqGFynLHMA,1689
@@ -79,10 +79,11 @@ huggingface_hub/inference/_generated/types/zero_shot_object_detection.py,sha256=
79
79
  huggingface_hub/serialization/__init__.py,sha256=z5MLxMqz0Y2qST-3Lj0PZHUONL-SGRlc0g4Z6MdL6rw,988
80
80
  huggingface_hub/serialization/_base.py,sha256=JZneES-HgcRH9C2SQehIGRDtT7nS7emu-RRV4ZjB6xo,8124
81
81
  huggingface_hub/serialization/_tensorflow.py,sha256=zHOvEMg-JHC55Fm4roDT3LUCDO5zB9qtXZffG065RAM,3625
82
- huggingface_hub/serialization/_torch.py,sha256=Q-pRHTU6jnZeLwKMDhQh_2i_KersYKgMrCHMJMHMkwk,26422
82
+ huggingface_hub/serialization/_torch.py,sha256=i6UFAHk1MDx_RONaXYolsISVa0V3a_YH-bdQtCYnmtg,26498
83
83
  huggingface_hub/templates/datasetcard_template.md,sha256=W-EMqR6wndbrnZorkVv56URWPG49l7MATGeI015kTvs,5503
84
84
  huggingface_hub/templates/modelcard_template.md,sha256=4AqArS3cqdtbit5Bo-DhjcnDFR-pza5hErLLTPM4Yuc,6870
85
- huggingface_hub/utils/__init__.py,sha256=ARTtov4ejkwUempOiSxHVBrkb330J6wOrTsu8dqfzaw,3621
85
+ huggingface_hub/utils/__init__.py,sha256=aMEsiXGi93z-dXz1W7FFma71tAMeKw0SoKVZSQUeE_4,3525
86
+ huggingface_hub/utils/_auth.py,sha256=-9p3SSOtWKMMCDKlsM_-ebsIGX0sSgKTSnC-_O4kTxg,8294
86
87
  huggingface_hub/utils/_cache_assets.py,sha256=kai77HPQMfYpROouMBQCr_gdBCaeTm996Sqj0dExbNg,5728
87
88
  huggingface_hub/utils/_cache_manager.py,sha256=kfuZDQy6FbWXrwKqp5sAJHte1BooTYKnjyuS0kbR6Eo,34495
88
89
  huggingface_hub/utils/_chunk_utils.py,sha256=kRCaj5228_vKcyLWspd8Xq01f17Jz6ds5Sr9ed5d_RU,2130
@@ -91,17 +92,16 @@ huggingface_hub/utils/_deprecation.py,sha256=HZhRGGUX_QMKBBBwHHlffLtmCSK01TOpeXH
91
92
  huggingface_hub/utils/_experimental.py,sha256=crCPH6k6-11wwH2GZuZzZzZbjUotay49ywV1SSJhMHM,2395
92
93
  huggingface_hub/utils/_fixes.py,sha256=C-feEQOZtXGHP4E2Qlg2VyxWSZhdCVmd0_B6zgiPcWA,4045
93
94
  huggingface_hub/utils/_git_credential.py,sha256=SDdsiREr1TcAR2Ze2TB0E5cYzVJgvDZrs60od9lAsMc,4596
94
- huggingface_hub/utils/_headers.py,sha256=05sDPAi7-Fs3Z4YLbrTJTAbIT7yjSX9DEqotd6gHqhQ,9593
95
- huggingface_hub/utils/_hf_folder.py,sha256=gWH-TT9h_6X_CyrtLTtKNEawf9kKlCHraFiOu09BuLk,3613
96
- huggingface_hub/utils/_http.py,sha256=YSxfEopSdHNWNvtuqLe53JIu_v3o1MiJGCo9JTuuEtQ,22339
95
+ huggingface_hub/utils/_headers.py,sha256=qZY8SQAFq3b7MaxQmZdSvNy6OuPyIBElL1Zvfa5sC8k,9592
96
+ huggingface_hub/utils/_hf_folder.py,sha256=cffdBqvvk0E_DW9rkaaVXLYOTFsOREDB_Y98evp_nWI,3612
97
+ huggingface_hub/utils/_http.py,sha256=-dfsV0Bs9pb8EStpcJvDGOfp_sKYD-re-XbIVITVAyo,22670
97
98
  huggingface_hub/utils/_lfs.py,sha256=EC0Oz6Wiwl8foRNkUOzrETXzAWlbgpnpxo5a410ovFY,3957
98
99
  huggingface_hub/utils/_pagination.py,sha256=hzLFLd8i_DKkPRVYzOx2CxLt5lcocEiAxDJriQUjAjY,1841
99
100
  huggingface_hub/utils/_paths.py,sha256=w1ZhFmmD5ykWjp_hAvhjtOoa2ZUcOXJrF4a6O3QpAWo,5042
100
- huggingface_hub/utils/_runtime.py,sha256=9CtsnxcYYFnCgccq_ea_ElaN_s-cFcuEvPItIzbqM3I,11331
101
+ huggingface_hub/utils/_runtime.py,sha256=tUyWylDgqaOXnMg39rvyusiruVN5ulcqiSwUEkQ9jjg,11195
101
102
  huggingface_hub/utils/_safetensors.py,sha256=GW3nyv7xQcuwObKYeYoT9VhURVzG1DZTbKBKho8Bbos,4458
102
103
  huggingface_hub/utils/_subprocess.py,sha256=6GpGD4qE9-Z1-Ocs3JuCLjR4NcRlknA-hAuQlqiprYY,4595
103
104
  huggingface_hub/utils/_telemetry.py,sha256=54LXeIJU5pEGghPAh06gqNAR-UoxOjVLvKqAQscwqZs,4890
104
- huggingface_hub/utils/_token.py,sha256=nZftxjMfr1rO5hNH9MJ3tXzRr_-beIkBhrfM8Y936X8,5643
105
105
  huggingface_hub/utils/_typing.py,sha256=UO0-GeTbiKFV9GqDh4YNRyScQSRAAZRoUeEYQX4P0rE,2882
106
106
  huggingface_hub/utils/_validators.py,sha256=dDsVG31iooTYrIyi5Vwr1DukL0fEmJwu3ceVNduhsuE,9204
107
107
  huggingface_hub/utils/endpoint_helpers.py,sha256=9VtIAlxQ5H_4y30sjCAgbu7XCqAtNLC7aRYxaNn0hLI,2366
@@ -109,9 +109,9 @@ huggingface_hub/utils/insecure_hashlib.py,sha256=OjxlvtSQHpbLp9PWSrXBDJ0wHjxCBU-
109
109
  huggingface_hub/utils/logging.py,sha256=Cp03s0uEl3kDM9XHQW9a8GAoExODQ-e7kEtgMt-_To8,4728
110
110
  huggingface_hub/utils/sha.py,sha256=OFnNGCba0sNcT2gUwaVCJnldxlltrHHe0DS_PCpV3C4,2134
111
111
  huggingface_hub/utils/tqdm.py,sha256=jQiVYwRG78HK4_54u0vTtz6Kt9IMGiHy3ixbIn3h2TU,9368
112
- huggingface_hub-0.25.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
113
- huggingface_hub-0.25.2.dist-info/METADATA,sha256=xheDBkEyFMEpIuQCCJW8k-eAibnHsbLsFtZuMVDiNCQ,13054
114
- huggingface_hub-0.25.2.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
115
- huggingface_hub-0.25.2.dist-info/entry_points.txt,sha256=Y3Z2L02rBG7va_iE6RPXolIgwOdwUFONyRN3kXMxZ0g,131
116
- huggingface_hub-0.25.2.dist-info/top_level.txt,sha256=8KzlQJAY4miUvjAssOAJodqKOw3harNzuiwGQ9qLSSk,16
117
- huggingface_hub-0.25.2.dist-info/RECORD,,
112
+ huggingface_hub-0.26.0rc0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
113
+ huggingface_hub-0.26.0rc0.dist-info/METADATA,sha256=RggpUdwAedV3_bejO9s-AQKxNzdSUTFyxt3tl9CGKe8,13094
114
+ huggingface_hub-0.26.0rc0.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
115
+ huggingface_hub-0.26.0rc0.dist-info/entry_points.txt,sha256=Y3Z2L02rBG7va_iE6RPXolIgwOdwUFONyRN3kXMxZ0g,131
116
+ huggingface_hub-0.26.0rc0.dist-info/top_level.txt,sha256=8KzlQJAY4miUvjAssOAJodqKOw3harNzuiwGQ9qLSSk,16
117
+ huggingface_hub-0.26.0rc0.dist-info/RECORD,,
@@ -1,102 +0,0 @@
1
- from functools import lru_cache
2
- from typing import Callable, Dict, List, Optional, Union
3
-
4
- from ..errors import HfHubHTTPError, RepositoryNotFoundError, TemplateError
5
- from ..utils import is_minijinja_available
6
-
7
-
8
- def _import_minijinja():
9
- if not is_minijinja_available():
10
- raise ImportError("Cannot render template. Please install minijinja using `pip install minijinja`.")
11
- import minijinja # noqa: F401
12
-
13
- return minijinja
14
-
15
-
16
- def render_chat_prompt(
17
- *,
18
- model_id: str,
19
- messages: List[Dict[str, str]],
20
- token: Union[str, bool, None] = None,
21
- add_generation_prompt: bool = True,
22
- **kwargs,
23
- ) -> str:
24
- """Render a chat prompt using a model's chat template.
25
-
26
- Args:
27
- model_id (`str`):
28
- The model id.
29
- messages (`List[Dict[str, str]]`):
30
- The list of messages to render.
31
- token (`str` or `bool`, *optional*):
32
- Hugging Face token. Will default to the locally saved token if not provided.
33
-
34
- Returns:
35
- `str`: The rendered chat prompt.
36
-
37
- Raises:
38
- `TemplateError`: If there's any issue while fetching, compiling or rendering the chat template.
39
- """
40
- minijinja = _import_minijinja()
41
- template = _fetch_and_compile_template(model_id=model_id, token=token)
42
-
43
- try:
44
- return template(messages=messages, add_generation_prompt=add_generation_prompt, **kwargs)
45
- except minijinja.TemplateError as e:
46
- raise TemplateError(f"Error while trying to render chat prompt for model '{model_id}': {e}") from e
47
-
48
-
49
- @lru_cache # TODO: lru_cache for raised exceptions
50
- def _fetch_and_compile_template(*, model_id: str, token: Union[str, None]) -> Callable:
51
- """Fetch and compile a model's chat template.
52
-
53
- Method is cached to avoid fetching the same model's config multiple times.
54
-
55
- Args:
56
- model_id (`str`):
57
- The model id.
58
- token (`str` or `bool`, *optional*):
59
- Hugging Face token. Will default to the locally saved token if not provided.
60
-
61
- Returns:
62
- `Callable`: A callable that takes a list of messages and returns the rendered chat prompt.
63
- """
64
- from huggingface_hub.hf_api import HfApi
65
-
66
- minijinja = _import_minijinja()
67
-
68
- # 1. fetch config from API
69
- try:
70
- config = HfApi(token=token).model_info(model_id).config
71
- except RepositoryNotFoundError as e:
72
- raise TemplateError(f"Cannot render chat template: model '{model_id}' not found.") from e
73
- except HfHubHTTPError as e:
74
- raise TemplateError(f"Error while trying to fetch chat template for model '{model_id}': {e}") from e
75
-
76
- # 2. check config validity
77
- if config is None:
78
- raise TemplateError(f"Config not found for model '{model_id}'.")
79
- tokenizer_config = config.get("tokenizer_config")
80
- if tokenizer_config is None:
81
- raise TemplateError(f"Tokenizer config not found for model '{model_id}'.")
82
- if tokenizer_config.get("chat_template") is None:
83
- raise TemplateError(f"Chat template not found in tokenizer_config for model '{model_id}'.")
84
- chat_template = tokenizer_config["chat_template"]
85
- if not isinstance(chat_template, str):
86
- raise TemplateError(f"Chat template must be a string, not '{type(chat_template)}' (model: {model_id}).")
87
-
88
- special_tokens: Dict[str, Optional[str]] = {}
89
- for key, value in tokenizer_config.items():
90
- if "token" in key:
91
- if isinstance(value, str):
92
- special_tokens[key] = value
93
- elif isinstance(value, dict) and value.get("__type") == "AddedToken":
94
- special_tokens[key] = value.get("content")
95
-
96
- # 3. compile template and return
97
- env = minijinja.Environment()
98
- try:
99
- env.add_template("chat_template", chat_template)
100
- except minijinja.TemplateError as e:
101
- raise TemplateError(f"Error while trying to compile chat template for model '{model_id}': {e}") from e
102
- return lambda **kwargs: env.render_template("chat_template", **kwargs, **special_tokens)