import{s as fe,n as he,o as ce}from"../chunks/scheduler.505acc25.js";import{S as de,i as ge,e as i,s as a,c as p,h as Me,a as o,d as n,b as s,f as re,g as r,j as u,k as ue,l as we,m as l,n as f,t as h,o as c,p as d}from"../chunks/index.fbb49fb4.js";import{C as be}from"../chunks/CopyLLMTxtMenu.564b44fd.js";import{C as D}from"../chunks/CodeBlock.7f0851b7.js";import{H as ee}from"../chunks/Heading.511e0027.js";import{E as ye}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.8c19e80e.js";function $e(te){let m,k,W,H,g,_,M,C,w,ne="<strong>LlamaHub is a registry of hundreds of integrations, agents and tools that you can use within LlamaIndex.</strong>",E,b,le='<img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit2/llama-index/llama-hub.png" alt="LlamaHub"/>',V,y,ae="We will be using various integrations in this course, so let’s first look at the LlamaHub and how it can help us.",S,$,se="Let’s see how to find and install the dependencies for the components we need.",Y,T,Q,v,ie=`LlamaIndex installation instructions are available as a well-structured <strong>overview on <a href="https://llamahub.ai/" rel="nofollow">LlamaHub</a></strong>.
This might be a bit overwhelming at first, but most of the <strong>installation commands generally follow an easy-to-remember format</strong>:`,F,U,P,J,oe='Let’s try to install the dependencies for an LLM and embedding component using the <a href="https://llamahub.ai/l/llms/llama-index-llms-huggingface-api?from=llms" rel="nofollow">Hugging Face inference API integration</a>.',R,Z,X,j,z,x,me=`Once installed, we can see the usage patterns. You’ll notice that the import paths follow the install command!
Underneath, we can see an example of the usage of <strong>the Hugging Face inference API for an LLM component</strong>.`,A,I,q,B,pe=`Wonderful, we now know how to find, install and use the integrations for the components we need.
<strong>Let’s dive deeper into the components</strong> and see how we can use them to build our own agents.`,N,L,O,G,K;return g=new be({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),M=new ee({props:{title:"Introduction to the LlamaHub",local:"introduction-to-the-llamahub",headingTag:"h1"}}),T=new ee({props:{title:"Installation",local:"installation",headingTag:"h2"}}),U=new D({props:{code:"cGlwJTIwaW5zdGFsbCUyMGxsYW1hLWluZGV4LSU3QmNvbXBvbmVudC10eXBlJTdELSU3QmZyYW1ld29yay1uYW1lJTdE",highlighted:"pip install llama-index-{component-type}-{framework-name}",wrap:!1}}),Z=new D({props:{code:"cGlwJTIwaW5zdGFsbCUyMGxsYW1hLWluZGV4LWxsbXMtaHVnZ2luZ2ZhY2UtYXBpJTIwbGxhbWEtaW5kZXgtZW1iZWRkaW5ncy1odWdnaW5nZmFjZQ==",highlighted:"pip install llama-index-llms-huggingface-api llama-index-embeddings-huggingface",wrap:!1}}),j=new ee({props:{title:"Usage",local:"usage",headingTag:"h2"}}),I=new D({props:{code:"ZnJvbSUyMGxsYW1hX2luZGV4LmxsbXMuaHVnZ2luZ2ZhY2VfYXBpJTIwaW1wb3J0JTIwSHVnZ2luZ0ZhY2VJbmZlcmVuY2VBUEklMEFpbXBvcnQlMjBvcyUwQWZyb20lMjBkb3RlbnYlMjBpbXBvcnQlMjBsb2FkX2RvdGVudiUwQSUwQSUyMyUyMExvYWQlMjB0aGUlMjAuZW52JTIwZmlsZSUwQWxvYWRfZG90ZW52KCklMEElMEElMjMlMjBSZXRyaWV2ZSUyMEhGX1RPS0VOJTIwZnJvbSUyMHRoZSUyMGVudmlyb25tZW50JTIwdmFyaWFibGVzJTBBaGZfdG9rZW4lMjAlM0QlMjBvcy5nZXRlbnYoJTIySEZfVE9LRU4lMjIpJTBBJTBBbGxtJTIwJTNEJTIwSHVnZ2luZ0ZhY2VJbmZlcmVuY2VBUEkoJTBBJTIwJTIwJTIwJTIwbW9kZWxfbmFtZSUzRCUyMlF3ZW4lMkZRd2VuMi41LUNvZGVyLTMyQi1JbnN0cnVjdCUyMiUyQyUwQSUyMCUyMCUyMCUyMHRlbXBlcmF0dXJlJTNEMC43JTJDJTBBJTIwJTIwJTIwJTIwbWF4X3Rva2VucyUzRDEwMCUyQyUwQSUyMCUyMCUyMCUyMHRva2VuJTNEaGZfdG9rZW4lMkMlMEElMjAlMjAlMjAlMjBwcm92aWRlciUzRCUyMmF1dG8lMjIlMEEpJTBBJTBBcmVzcG9uc2UlMjAlM0QlMjBsbG0uY29tcGxldGUoJTIySGVsbG8lMkMlMjBob3clMjBhcmUlMjB5b3UlM0YlMjIpJTBBcHJpbnQocmVzcG9uc2UpJTBBJTIzJTIwSSUyMGFtJTIwZ29vZCUyQyUyMGhvdyUyMGNhbiUyMEklMjBoZWxwJTIweW91JTIwdG9kYXklM0Y=",highlighted:`<span class="hljs-keyword">from</span> llama_index.llms.huggingface_api <span class="hljs-keyword">import</span> HuggingFaceInferenceAPI
<span class="hljs-keyword">import</span> os
<span class="hljs-keyword">from</span> dotenv <span class="hljs-keyword">import</span> load_dotenv

<span class="hljs-comment"># Load the .env file</span>
load_dotenv()

<span class="hljs-comment"># Retrieve HF_TOKEN from the environment variables</span>
hf_token = os.getenv(<span class="hljs-string">&quot;HF_TOKEN&quot;</span>)

llm = HuggingFaceInferenceAPI(
    model_name=<span class="hljs-string">&quot;Qwen/Qwen2.5-Coder-32B-Instruct&quot;</span>,
    temperature=<span class="hljs-number">0.7</span>,
    max_tokens=<span class="hljs-number">100</span>,
    token=hf_token,
    provider=<span class="hljs-string">&quot;auto&quot;</span>
)

response = llm.complete(<span class="hljs-string">&quot;Hello, how are you?&quot;</span>)
<span class="hljs-built_in">print</span>(response)
<span class="hljs-comment"># I am good, how can I help you today?</span>`,wrap:!1}}),L=new ye({props:{source:"https://github.com/huggingface/agents-course/blob/main/units/en/unit2/llama-index/llama-hub.mdx"}}),{c(){m=i("meta"),k=a(),W=i("p"),H=a(),p(g.$$.fragment),_=a(),p(M.$$.fragment),C=a(),w=i("p"),w.innerHTML=ne,E=a(),b=i("p"),b.innerHTML=le,V=a(),y=i("p"),y.textContent=ae,S=a(),$=i("p"),$.textContent=se,Y=a(),p(T.$$.fragment),Q=a(),v=i("p"),v.innerHTML=ie,F=a(),p(U.$$.fragment),P=a(),J=i("p"),J.innerHTML=oe,R=a(),p(Z.$$.fragment),X=a(),p(j.$$.fragment),z=a(),x=i("p"),x.innerHTML=me,A=a(),p(I.$$.fragment),q=a(),B=i("p"),B.innerHTML=pe,N=a(),p(L.$$.fragment),O=a(),G=i("p"),this.h()},l(e){const t=Me("svelte-u9bgzb",document.head);m=o(t,"META",{name:!0,content:!0}),t.forEach(n),k=s(e),W=o(e,"P",{}),re(W).forEach(n),H=s(e),r(g.$$.fragment,e),_=s(e),r(M.$$.fragment,e),C=s(e),w=o(e,"P",{"data-svelte-h":!0}),u(w)!=="svelte-6kawnq"&&(w.innerHTML=ne),E=s(e),b=o(e,"P",{"data-svelte-h":!0}),u(b)!=="svelte-jjjeyj"&&(b.innerHTML=le),V=s(e),y=o(e,"P",{"data-svelte-h":!0}),u(y)!=="svelte-fohn1k"&&(y.textContent=ae),S=s(e),$=o(e,"P",{"data-svelte-h":!0}),u($)!=="svelte-5c6p8c"&&($.textContent=se),Y=s(e),r(T.$$.fragment,e),Q=s(e),v=o(e,"P",{"data-svelte-h":!0}),u(v)!=="svelte-169w10d"&&(v.innerHTML=ie),F=s(e),r(U.$$.fragment,e),P=s(e),J=o(e,"P",{"data-svelte-h":!0}),u(J)!=="svelte-5m0iju"&&(J.innerHTML=oe),R=s(e),r(Z.$$.fragment,e),X=s(e),r(j.$$.fragment,e),z=s(e),x=o(e,"P",{"data-svelte-h":!0}),u(x)!=="svelte-1dpkd4c"&&(x.innerHTML=me),A=s(e),r(I.$$.fragment,e),q=s(e),B=o(e,"P",{"data-svelte-h":!0}),u(B)!=="svelte-13kdhye"&&(B.innerHTML=pe),N=s(e),r(L.$$.fragment,e),O=s(e),G=o(e,"P",{}),re(G).forEach(n),this.h()},h(){ue(m,"name","hf:doc:metadata"),ue(m,"content",Te)},m(e,t){we(document.head,m),l(e,k,t),l(e,W,t),l(e,H,t),f(g,e,t),l(e,_,t),f(M,e,t),l(e,C,t),l(e,w,t),l(e,E,t),l(e,b,t),l(e,V,t),l(e,y,t),l(e,S,t),l(e,$,t),l(e,Y,t),f(T,e,t),l(e,Q,t),l(e,v,t),l(e,F,t),f(U,e,t),l(e,P,t),l(e,J,t),l(e,R,t),f(Z,e,t),l(e,X,t),f(j,e,t),l(e,z,t),l(e,x,t),l(e,A,t),f(I,e,t),l(e,q,t),l(e,B,t),l(e,N,t),f(L,e,t),l(e,O,t),l(e,G,t),K=!0},p:he,i(e){K||(h(g.$$.fragment,e),h(M.$$.fragment,e),h(T.$$.fragment,e),h(U.$$.fragment,e),h(Z.$$.fragment,e),h(j.$$.fragment,e),h(I.$$.fragment,e),h(L.$$.fragment,e),K=!0)},o(e){c(g.$$.fragment,e),c(M.$$.fragment,e),c(T.$$.fragment,e),c(U.$$.fragment,e),c(Z.$$.fragment,e),c(j.$$.fragment,e),c(I.$$.fragment,e),c(L.$$.fragment,e),K=!1},d(e){e&&(n(k),n(W),n(H),n(_),n(C),n(w),n(E),n(b),n(V),n(y),n(S),n($),n(Y),n(Q),n(v),n(F),n(P),n(J),n(R),n(X),n(z),n(x),n(A),n(q),n(B),n(N),n(O),n(G)),n(m),d(g,e),d(M,e),d(T,e),d(U,e),d(Z,e),d(j,e),d(I,e),d(L,e)}}}const Te='{"title":"Introduction to the LlamaHub","local":"introduction-to-the-llamahub","sections":[{"title":"Installation","local":"installation","sections":[],"depth":2},{"title":"Usage","local":"usage","sections":[],"depth":2}],"depth":1}';function ve(te){return ce(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Be extends de{constructor(m){super(),ge(this,m,ve,$e,fe,{})}}export{Be as component};
