import{s as fe,n as ce,o as ge}from"../chunks/scheduler.6062bdaf.js";import{S as de,i as be,g as i,s as l,r as j,A as _e,h as p,f as s,c as n,j as me,u as M,x as r,k as ue,y as $e,a,v as k,d as C,t as J,w as L}from"../chunks/index.4bca734e.js";import{C as O}from"../chunks/CodeBlock.cbbddafc.js";import{H as ee,E as we}from"../chunks/getInferenceSnippets.e6a3a5be.js";function He(te){let o,G,U,S,h,W,m,se="In this tutorial, you will learn how to search models, datasets and spaces on the Hub using <code>huggingface_hub</code>.",z,u,Z,f,ae=`<code>huggingface_hub</code> library includes an HTTP client <a href="/docs/huggingface_hub/main/en/package_reference/hf_api#huggingface_hub.HfApi">HfApi</a> to interact with the Hub.
Among other things, it can list models, datasets and spaces stored on the Hub:`,q,c,E,g,le='The output of <a href="/docs/huggingface_hub/main/en/package_reference/hf_api#huggingface_hub.HfApi.list_models">list_models()</a> is an iterator over the models stored on the Hub.',I,d,ne='Similarly, you can use <a href="/docs/huggingface_hub/main/en/package_reference/hf_api#huggingface_hub.HfApi.list_datasets">list_datasets()</a> to list datasets and <a href="/docs/huggingface_hub/main/en/package_reference/hf_api#huggingface_hub.HfApi.list_spaces">list_spaces()</a> to list Spaces.',X,b,A,_,ie=`Listing repositories is great but now you might want to filter your search.
The list helpers have several attributes like:`,N,$,pe="<li><code>filter</code></li> <li><code>author</code></li> <li><code>search</code></li> <li>…</li>",Q,w,oe="Let’s see an example to get all models on the Hub that does image classification, have been trained on the imagenet dataset and that runs with PyTorch.",R,H,Y,y,re=`While filtering, you can also sort the models and take only the top results. For example,
the following example fetches the top 5 most downloaded datasets on the Hub:`,B,x,F,T,he=`To explore available filters on the Hub, visit <a href="https://huggingface.co/models" rel="nofollow">models</a> and <a href="https://huggingface.co/datasets" rel="nofollow">datasets</a> pages
in your browser, search for some parameters and look at the values in the URL.`,K,v,V,P,D;return h=new ee({props:{title:"Search the Hub",local:"search-the-hub",headingTag:"h1"}}),u=new ee({props:{title:"How to list repositories ?",local:"how-to-list-repositories-",headingTag:"h2"}}),c=new O({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEhmQXBpJTBBYXBpJTIwJTNEJTIwSGZBcGkoKSUwQW1vZGVscyUyMCUzRCUyMGFwaS5saXN0X21vZGVscygp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> HfApi
<span class="hljs-meta">&gt;&gt;&gt; </span>api = HfApi()
<span class="hljs-meta">&gt;&gt;&gt; </span>models = api.list_models()`,wrap:!1}}),b=new ee({props:{title:"How to filter repositories ?",local:"how-to-filter-repositories-",headingTag:"h2"}}),H=new O({props:{code:"bW9kZWxzJTIwJTNEJTIwaGZfYXBpLmxpc3RfbW9kZWxzKGZpbHRlciUzRCU1QiUyMmltYWdlLWNsYXNzaWZpY2F0aW9uJTIyJTJDJTIwJTIycHl0b3JjaCUyMiUyQyUyMCUyMmltYWdlbmV0JTIyJTVEKQ==",highlighted:'models = hf_api.list_models(<span class="hljs-built_in">filter</span>=[<span class="hljs-string">&quot;image-classification&quot;</span>, <span class="hljs-string">&quot;pytorch&quot;</span>, <span class="hljs-string">&quot;imagenet&quot;</span>])',wrap:!1}}),x=new O({props:{code:"bGlzdChsaXN0X2RhdGFzZXRzKHNvcnQlM0QlMjJkb3dubG9hZHMlMjIlMkMlMjBkaXJlY3Rpb24lM0QtMSUyQyUyMGxpbWl0JTNENSkp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(list_datasets(sort=<span class="hljs-string">&quot;downloads&quot;</span>, direction=-<span class="hljs-number">1</span>, limit=<span class="hljs-number">5</span>))
[DatasetInfo(
	<span class="hljs-built_in">id</span>=<span class="hljs-string">&#x27;argilla/databricks-dolly-15k-curated-en&#x27;</span>,
	author=<span class="hljs-string">&#x27;argilla&#x27;</span>,
	sha=<span class="hljs-string">&#x27;4dcd1dedbe148307a833c931b21ca456a1fc4281&#x27;</span>,
	last_modified=datetime.datetime(<span class="hljs-number">2023</span>, <span class="hljs-number">10</span>, <span class="hljs-number">2</span>, <span class="hljs-number">12</span>, <span class="hljs-number">32</span>, <span class="hljs-number">53</span>, tzinfo=datetime.timezone.utc),
	private=<span class="hljs-literal">False</span>,
	downloads=<span class="hljs-number">8889377</span>,
	(...)`,wrap:!1}}),v=new we({props:{source:"https://github.com/huggingface/huggingface_hub/blob/main/docs/source/en/guides/search.md"}}),{c(){o=i("meta"),G=l(),U=i("p"),S=l(),j(h.$$.fragment),W=l(),m=i("p"),m.innerHTML=se,z=l(),j(u.$$.fragment),Z=l(),f=i("p"),f.innerHTML=ae,q=l(),j(c.$$.fragment),E=l(),g=i("p"),g.innerHTML=le,I=l(),d=i("p"),d.innerHTML=ne,X=l(),j(b.$$.fragment),A=l(),_=i("p"),_.textContent=ie,N=l(),$=i("ul"),$.innerHTML=pe,Q=l(),w=i("p"),w.textContent=oe,R=l(),j(H.$$.fragment),Y=l(),y=i("p"),y.textContent=re,B=l(),j(x.$$.fragment),F=l(),T=i("p"),T.innerHTML=he,K=l(),j(v.$$.fragment),V=l(),P=i("p"),this.h()},l(e){const t=_e("svelte-u9bgzb",document.head);o=p(t,"META",{name:!0,content:!0}),t.forEach(s),G=n(e),U=p(e,"P",{}),me(U).forEach(s),S=n(e),M(h.$$.fragment,e),W=n(e),m=p(e,"P",{"data-svelte-h":!0}),r(m)!=="svelte-1j3ajgu"&&(m.innerHTML=se),z=n(e),M(u.$$.fragment,e),Z=n(e),f=p(e,"P",{"data-svelte-h":!0}),r(f)!=="svelte-mu2vrn"&&(f.innerHTML=ae),q=n(e),M(c.$$.fragment,e),E=n(e),g=p(e,"P",{"data-svelte-h":!0}),r(g)!=="svelte-q7cwx0"&&(g.innerHTML=le),I=n(e),d=p(e,"P",{"data-svelte-h":!0}),r(d)!=="svelte-mzgq4j"&&(d.innerHTML=ne),X=n(e),M(b.$$.fragment,e),A=n(e),_=p(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-1x8b9ko"&&(_.textContent=ie),N=n(e),$=p(e,"UL",{"data-svelte-h":!0}),r($)!=="svelte-11piw8k"&&($.innerHTML=pe),Q=n(e),w=p(e,"P",{"data-svelte-h":!0}),r(w)!=="svelte-2psxgl"&&(w.textContent=oe),R=n(e),M(H.$$.fragment,e),Y=n(e),y=p(e,"P",{"data-svelte-h":!0}),r(y)!=="svelte-8rar3u"&&(y.textContent=re),B=n(e),M(x.$$.fragment,e),F=n(e),T=p(e,"P",{"data-svelte-h":!0}),r(T)!=="svelte-i3k2fd"&&(T.innerHTML=he),K=n(e),M(v.$$.fragment,e),V=n(e),P=p(e,"P",{}),me(P).forEach(s),this.h()},h(){ue(o,"name","hf:doc:metadata"),ue(o,"content",ye)},m(e,t){$e(document.head,o),a(e,G,t),a(e,U,t),a(e,S,t),k(h,e,t),a(e,W,t),a(e,m,t),a(e,z,t),k(u,e,t),a(e,Z,t),a(e,f,t),a(e,q,t),k(c,e,t),a(e,E,t),a(e,g,t),a(e,I,t),a(e,d,t),a(e,X,t),k(b,e,t),a(e,A,t),a(e,_,t),a(e,N,t),a(e,$,t),a(e,Q,t),a(e,w,t),a(e,R,t),k(H,e,t),a(e,Y,t),a(e,y,t),a(e,B,t),k(x,e,t),a(e,F,t),a(e,T,t),a(e,K,t),k(v,e,t),a(e,V,t),a(e,P,t),D=!0},p:ce,i(e){D||(C(h.$$.fragment,e),C(u.$$.fragment,e),C(c.$$.fragment,e),C(b.$$.fragment,e),C(H.$$.fragment,e),C(x.$$.fragment,e),C(v.$$.fragment,e),D=!0)},o(e){J(h.$$.fragment,e),J(u.$$.fragment,e),J(c.$$.fragment,e),J(b.$$.fragment,e),J(H.$$.fragment,e),J(x.$$.fragment,e),J(v.$$.fragment,e),D=!1},d(e){e&&(s(G),s(U),s(S),s(W),s(m),s(z),s(Z),s(f),s(q),s(E),s(g),s(I),s(d),s(X),s(A),s(_),s(N),s($),s(Q),s(w),s(R),s(Y),s(y),s(B),s(F),s(T),s(K),s(V),s(P)),s(o),L(h,e),L(u,e),L(c,e),L(b,e),L(H,e),L(x,e),L(v,e)}}}const ye='{"title":"Search the Hub","local":"search-the-hub","sections":[{"title":"How to list repositories ?","local":"how-to-list-repositories-","sections":[],"depth":2},{"title":"How to filter repositories ?","local":"how-to-filter-repositories-","sections":[],"depth":2}],"depth":1}';function xe(te){return ge(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ke extends de{constructor(o){super(),be(this,o,xe,He,fe,{})}}export{ke as component};
