import{S as O_,i as L_,s as S_,e as i,k as h,w as d,t as s,M as N_,c as l,d as t,m,a as p,x as c,h as n,b as u,N as fr,G as o,g as r,y as g,q as w,o as _,B as v,v as W_}from"../chunks/vendor-hf-doc-builder.js";import{T as ie}from"../chunks/Tip-hf-doc-builder.js";import{I as F}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as y}from"../chunks/CodeBlock-hf-doc-builder.js";function z_(T){let f,k,$,b,x;return{c(){f=i("p"),k=s(`If you are not aware of what tools and agents are in the context of transformers, we recommend you read the
`),$=i("a"),b=s("Transformers Agents"),x=s(" page first."),this.h()},l(E){f=l(E,"P",{});var q=p(f);k=n(q,`If you are not aware of what tools and agents are in the context of transformers, we recommend you read the
`),$=l(q,"A",{href:!0});var A=p($);b=n(A,"Transformers Agents"),A.forEach(t),x=n(q," page first."),q.forEach(t),this.h()},h(){u($,"href","transformers_agents")},m(E,q){r(E,f,q),o(f,k),o(f,$),o($,b),o(f,x)},d(E){E&&t(f)}}}function M_(T){let f,k;return{c(){f=i("p"),k=s(`Transformers Agent is an experimental API that is subject to change at any time. Results returned by the agents
can vary as the APIs or underlying models are prone to change.`)},l($){f=l($,"P",{});var b=p(f);k=n(b,`Transformers Agent is an experimental API that is subject to change at any time. Results returned by the agents
can vary as the APIs or underlying models are prone to change.`),b.forEach(t)},m($,b){r($,f,b),o(f,k)},d($){$&&t(f)}}}function F_(T){let f,k,$,b,x;return{c(){f=i("p"),k=s(`Check the naming and description of the curated Transformers tools to better understand what name and
description a tool is expected to have. You can see all tools with the `),$=i("code"),b=s("Agent.toolbox"),x=s(" property.")},l(E){f=l(E,"P",{});var q=p(f);k=n(q,`Check the naming and description of the curated Transformers tools to better understand what name and
description a tool is expected to have. You can see all tools with the `),$=l(q,"CODE",{});var A=p($);b=n(A,"Agent.toolbox"),A.forEach(t),x=n(q," property."),q.forEach(t)},m(E,q){r(E,f,q),o(f,k),o(f,$),o($,b),o(f,x)},d(E){E&&t(f)}}}function G_(T){let f,k;return{c(){f=i("p"),k=s(`Agents are still brittle for many use cases, especially when it comes to
slightly more complex use cases like generating an image of multiple objects.
Both the agent itself and the underlying prompt will be further improved in the coming
months making sure that agents become more robust to a variety of user inputs.`)},l($){f=l($,"P",{});var b=p(f);k=n(b,`Agents are still brittle for many use cases, especially when it comes to
slightly more complex use cases like generating an image of multiple objects.
Both the agent itself and the underlying prompt will be further improved in the coming
months making sure that agents become more robust to a variety of user inputs.`),b.forEach(t)},m($,b){r($,f,b),o(f,k)},d($){$&&t(f)}}}function U_(T){let f,k,$,b,x,E,q,A,H,D,O;return{c(){f=i("p"),k=s("Please make sure to have the "),$=i("code"),b=s("<<all_tools>>"),x=s(" string and the "),E=i("code"),q=s("<<prompt>>"),A=s(" defined somewhere in the "),H=i("code"),D=s("template"),O=s(` so that the agent can be aware
of the tools, it has available to it as well as correctly insert the user\u2019s prompt.`)},l(M){f=l(M,"P",{});var j=p(f);k=n(j,"Please make sure to have the "),$=l(j,"CODE",{});var dt=p($);b=n(dt,"<<all_tools>>"),dt.forEach(t),x=n(j," string and the "),E=l(j,"CODE",{});var le=p(E);q=n(le,"<<prompt>>"),le.forEach(t),A=n(j," defined somewhere in the "),H=l(j,"CODE",{});var Mo=p(H);D=n(Mo,"template"),Mo.forEach(t),O=n(j,` so that the agent can be aware
of the tools, it has available to it as well as correctly insert the user\u2019s prompt.`),j.forEach(t)},m(M,j){r(M,f,j),o(f,k),o(f,$),o($,b),o(f,x),o(f,E),o(E,q),o(f,A),o(f,H),o(H,D),o(f,O)},d(M){M&&t(f)}}}function B_(T){let f,k,$,b,x,E,q,A;return{c(){f=i("p"),k=s("Please make sure to have the "),$=i("code"),b=s("<<all_tools>>"),x=s(" string defined somewhere in the "),E=i("code"),q=s("template"),A=s(` so that the agent can be aware
of the tools, it has available to it.`)},l(H){f=l(H,"P",{});var D=p(f);k=n(D,"Please make sure to have the "),$=l(D,"CODE",{});var O=p($);b=n(O,"<<all_tools>>"),O.forEach(t),x=n(D," string defined somewhere in the "),E=l(D,"CODE",{});var M=p(E);q=n(M,"template"),M.forEach(t),A=n(D,` so that the agent can be aware
of the tools, it has available to it.`),D.forEach(t)},m(H,D){r(H,f,D),o(f,k),o(f,$),o($,b),o(f,x),o(f,E),o(E,q),o(f,A)},d(H){H&&t(f)}}}function R_(T){let f,k;return{c(){f=i("p"),k=s(`Overwriting existing tools can be beneficial if we want to use a custom tool exactly for the same task as an existing tool
because the agent is well-versed in using the specific task. Beware that the custom tool should follow the exact same API
as the overwritten tool in this case, or you should adapt the prompt template to make sure all examples using that
tool are updated.`)},l($){f=l($,"P",{});var b=p(f);k=n(b,`Overwriting existing tools can be beneficial if we want to use a custom tool exactly for the same task as an existing tool
because the agent is well-versed in using the specific task. Beware that the custom tool should follow the exact same API
as the overwritten tool in this case, or you should adapt the prompt template to make sure all examples using that
tool are updated.`),b.forEach(t)},m($,b){r($,f,b),o(f,k)},d($){$&&t(f)}}}function Y_(T){let f,k;return{c(){f=i("p"),k=s(`Depending on the LLM, some are quite brittle and require very exact prompts in order to work well. Having a well-defined
name and description of the tool is paramount to having it be leveraged by the agent.`)},l($){f=l($,"P",{});var b=p(f);k=n(b,`Depending on the LLM, some are quite brittle and require very exact prompts in order to work well. Having a well-defined
name and description of the tool is paramount to having it be leveraged by the agent.`),b.forEach(t)},m($,b){r($,f,b),o(f,k)},d($){$&&t(f)}}}function Q_(T){let f,k;return{c(){f=i("p"),k=s(`Beware when replacing tools with others! This will also adjust the agent\u2019s prompt. This can be good if you have a better
prompt suited for the task, but it can also result in your tool being selected way more than others or for other
tools to be selected instead of the one you have defined.`)},l($){f=l($,"P",{});var b=p(f);k=n(b,`Beware when replacing tools with others! This will also adjust the agent\u2019s prompt. This can be good if you have a better
prompt suited for the task, but it can also result in your tool being selected way more than others or for other
tools to be selected instead of the one you have defined.`),b.forEach(t)},m($,b){r($,f,b),o(f,k)},d($){$&&t(f)}}}function J_(T){let f,k,$,b,x;return{c(){f=i("p"),k=s("gradio-tools requires "),$=i("em"),b=s("textual"),x=s(` inputs and outputs, even when working with different modalities. This implementation
works with image and audio objects. The two are currently incompatible, but will rapidly become compatible as we
work to improve the support.`)},l(E){f=l(E,"P",{});var q=p(f);k=n(q,"gradio-tools requires "),$=l(q,"EM",{});var A=p($);b=n(A,"textual"),A.forEach(t),x=n(q,` inputs and outputs, even when working with different modalities. This implementation
works with image and audio objects. The two are currently incompatible, but will rapidly become compatible as we
work to improve the support.`),q.forEach(t)},m(E,q){r(E,f,q),o(f,k),o(f,$),o($,b),o(f,x)},d(E){E&&t(f)}}}function K_(T){let f,k,$,b,x,E,q,A,H,D,O,M,j,dt,le,Mo,ur,Q,es,Up,Bp,ts,Rp,Yp,os,Qp,dr,pe,Ee,as,ct,Jp,ss,Kp,cr,I,Vp,Fo,Xp,Zp,Go,eh,th,Uo,oh,ah,ns,sh,nh,rs,rh,ih,is,lh,ph,gr,he,qe,ls,gt,hh,ps,mh,wr,Bo,fh,_r,G,hs,ms,fs,uh,dh,us,Ro,wt,ch,ds,gh,wh,_h,cs,Yo,gs,vh,$h,ws,Qo,_s,bh,vr,xe,yh,vs,kh,Eh,$r,_t,br,Te,qh,$s,xh,Th,yr,L,Ah,bs,Ph,jh,ys,Ih,Ch,ks,Dh,Hh,Es,Oh,Lh,kr,vt,Er,Jo,Sh,qr,$t,xr,Ko,Nh,Tr,bt,Ar,Vo,Wh,Pr,Xo,zh,jr,Ae,Ir,Zo,Mh,Cr,ea,Fh,Dr,yt,Hr,ta,Gh,Or,Pe,Uh,kt,Bh,Rh,Lr,oa,Yh,Sr,Et,Nr,aa,Qh,Wr,qt,zr,J,Jh,qs,Kh,Vh,xs,Xh,Zh,Mr,je,em,Ts,tm,om,Fr,xt,Gr,P,am,As,sm,nm,Ps,rm,im,js,lm,pm,Is,hm,mm,Cs,fm,um,Ds,dm,cm,Hs,gm,wm,Os,_m,vm,Ur,K,$m,Ls,bm,ym,Ss,km,Em,Br,Tt,Rr,U,qm,Ns,xm,Tm,Ws,Am,Pm,zs,jm,Im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,Tu,vn,Au,Pu,$n,ju,Iu,bn,Cu,Du,vl,Qe,Hu,yn,Ou,Lu,$l,_o,bl,ja,Su,yl,R,_e,Nu,kn,Wu,zu,En,Mu,Fu,Gu,vo,Uu,qn,Bu,Ru,Yu,N,xn,Qu,Ju,Tn,Ku,Vu,An,Xu,Zu,Pn,ed,td,jn,od,ad,sd,$o,nd,In,rd,id,kl,Ia,ld,El,bo,ql,Je,pd,Cn,hd,md,xl,yo,Tl,ae,fd,Dn,ud,dd,Hn,cd,gd,Al,ko,Pl,Ca,wd,jl,ve,Ke,On,Eo,_d,Ln,vd,Il,Da,$d,Cl,qo,Dl,Ve,bd,Sn,yd,kd,Hl,xo,Ol,Ha,Ed,Ll,To,Sl,Oa,qd,Nl,Xe,Nn,Wn,zn,Mn,xd,Td,Fn,Gn,Un,La,Sa,cc,Wl,Ze,zl,$e,et,Bn,Ao,Ad,Rn,Pd,Ml,Na,jd,Fl,Po,Gl,tt,Ul,be,ot,Yn,jo,Id,Qn,Cd,Bl,Io,Co,Dd,Hd,Rl,W,Od,Jn,Ld,Sd,Kn,Nd,Wd,Vn,zd,Md,Xn,Fd,Gd,Yl,at,Ud,Zn,Bd,Rd,Ql,Do,Jl,st,Yd,er,Qd,Jd,Kl,Ho,Vl,nt,Kd,tr,Vd,Xd,Xl,Oo,Zl,Wa,Zd,ep,Lo,tp,za,ec,op,Ma,gc,ap,rt,sp,ye,it,or,So,tc,ar,oc,np,lt,ac,sr,sc,nc,rp,Fa,rc,ip,pt,ic,No,lc,pc,lp;return E=new F({}),O=new ie({props:{$$slots:{default:[z_]},$$scope:{ctx:T}}}),j=new ie({props:{warning:!0,$$slots:{default:[M_]},$$scope:{ctx:T}}}),ct=new F({}),gt=new F({}),_t=new y({props:{code:`I will ask you to perform a task, your job is to come up with a series of simple commands in Python that will perform the task.
[...]
You can print intermediate results if it makes sense to do so.

Tools:
- document_qa: This is a tool that answers a question about a document (pdf). It takes an input named \`document\` which should be the document containing the information, as well as a \`question\` that is the question about the document. It returns a text that contains the answer to the question.
- image_captioner: This is a tool that generates a description of an image. It takes an input named \`image\` which should be the image to the caption and returns a text that contains the description in English.
[...]

Task: "Answer the question in the variable \`question\` about the image stored in the variable \`image\`. The question is in French."

I will use the following tools: \`translator\` to translate the question into English and then \`image_qa\` to answer the question on the input image.

Answer:
\`\`\`py
translated_question = translator(question=question, src_lang="French", tgt_lang="English")
print(f"The translated question is {translated_question}.")
answer = image_qa(image=image, question=translated_question)
print(f"The answer is {answer}")
\`\`\`

Task: "Identify the oldest person in the \`document\` and create an image showcasing the result as a banner."

I will use the following tools: \`document_qa\` to find the oldest person in the document, then \`image_generator\` to generate an image according to the answer.

Answer:
\`\`\`py
answer = document_qa(document, question="What is the oldest person?")
print(f"The answer is {answer}.")
image = image_generator("A banner showing " + answer)
\`\`\`

[...]

Task: "Draw me a picture of rivers and lakes"

I will use the following`,highlighted:`I will ask you to perform a task, your job is to come up with a series of simple commands in Python that will perform the task.
[...]
You can print intermediate results if it makes sense to do so.

Tools:
- document_qa: This is a tool that answers a question about a document (pdf). It takes an input named \`document\` which should be the document containing the information, as well as a \`question\` that is the question about the document. It returns a text that contains the answer to the question.
- image_captioner: This is a tool that generates a description of an image. It takes an input named \`image\` which should be the image to the caption and returns a text that contains the description in English.
[...]

Task: &quot;Answer the question in the variable \`question\` about the image stored in the variable \`image\`. The question is in French.&quot;

I will use the following tools: \`translator\` to translate the question into English and then \`image_qa\` to answer the question on the input image.

Answer:
\`\`\`py
translated_question = translator(question=question, src_lang=&quot;French&quot;, tgt_lang=&quot;English&quot;)
print(f&quot;The translated question is {translated_question}.&quot;)
answer = image_qa(image=image, question=translated_question)
print(f&quot;The answer is {answer}&quot;)
\`\`\`

Task: &quot;Identify the oldest person in the \`document\` and create an image showcasing the result as a banner.&quot;

I will use the following tools: \`document_qa\` to find the oldest person in the document, then \`image_generator\` to generate an image according to the answer.

Answer:
\`\`\`py
answer = document_qa(document, question=&quot;What is the oldest person?&quot;)
print(f&quot;The answer is {answer}.&quot;)
image = image_generator(&quot;A banner showing &quot; + answer)
\`\`\`

[...]

Task: &quot;Draw me a picture of rivers and lakes&quot;

I will use the following`}}),vt=new y({props:{code:"- <tool.name>: <tool.description>",highlighted:"- &lt;tool.name&gt;: &lt;tool.description&gt;"}}),$t=new y({props:{code:`from transformers import load_tool

document_qa = load_tool("document-question-answering")
print(f"- {document_qa.name}: {document_qa.description}")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> load_tool

document_qa = load_tool(<span class="hljs-string">&quot;document-question-answering&quot;</span>)
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;- <span class="hljs-subst">{document_qa.name}</span>: <span class="hljs-subst">{document_qa.description}</span>&quot;</span>)`}}),bt=new y({props:{code:"- document_qa: This is a tool that answers a question about a document (pdf). It takes an input named `document` which should be the document containing the information, as well as a `question` that is the question about the document. It returns a text that contains the answer to the question.",highlighted:"- document_qa: This is a tool that answers a question about a document (pdf). It takes an input named `document` which should be the document containing the information, as well as a `question` that is the question about the document. It returns a text that contains the answer to the question."}}),Ae=new ie({props:{$$slots:{default:[F_]},$$scope:{ctx:T}}}),yt=new y({props:{code:'Task: "Identify the oldest person in the `document` and create an image showcasing the result as a banner."\n\nI will use the following tools: `document_qa` to find the oldest person in the document, then `image_generator` to generate an image according to the answer.\n\nAnswer:\n```py\nanswer = document_qa(document, question="What is the oldest person?")\nprint(f"The answer is {answer}.")\nimage = image_generator("A banner showing " + answer)\n```\n',highlighted:"Task: &quot;Identify the oldest person in the `document` and create an image showcasing the result as a banner.&quot;\n\nI will use the following tools: `document_qa` to find the oldest person in the document, then `image_generator` to generate an image according to the answer.\n\nAnswer:\n```py\nanswer = document_qa(document, question=&quot;What is the oldest person?&quot;)\nprint(f&quot;The answer is {answer}.&quot;)\nimage = image_generator(&quot;A banner showing &quot; + answer)\n```\n"}}),Et=new y({props:{code:`Task: "Draw me a picture of rivers and lakes"

I will use the following`,highlighted:`Task: &quot;Draw me a picture of rivers and lakes&quot;

I will use the following`}}),qt=new y({props:{code:'agent.run("Draw me a picture of rivers and lakes")',highlighted:'agent.run(<span class="hljs-string">&quot;Draw me a picture of rivers and lakes&quot;</span>)'}}),xt=new y({props:{code:`[...]

=====

Human: Answer the question in the variable \`question\` about the image stored in the variable \`image\`.

Assistant: I will use the tool \`image_qa\` to answer the question on the input image.

\`\`\`py
answer = image_qa(text=question, image=image)
print(f"The answer is {answer}")
\`\`\`

Human: I tried this code, it worked but didn't give me a good result. The question is in French

Assistant: In this case, the question needs to be translated first. I will use the tool \`translator\` to do this.

\`\`\`py
translated_question = translator(question=question, src_lang="French", tgt_lang="English")
print(f"The translated question is {translated_question}.")
answer = image_qa(text=translated_question, image=image)
print(f"The answer is {answer}")
\`\`\`

=====

[...]`,highlighted:`[...]

=====

Human: Answer the question in the variable \`question\` about the image stored in the variable \`image\`.

Assistant: I will use the tool \`image_qa\` to answer the question on the input image.

\`\`\`py
answer = image_qa(text=question, image=image)
print(f&quot;The answer is {answer}&quot;)
\`\`\`

Human: I tried this code, it worked but didn&#x27;t give me a good result. The question is in French

Assistant: In this case, the question needs to be translated first. I will use the tool \`translator\` to do this.

\`\`\`py
translated_question = translator(question=question, src_lang=&quot;French&quot;, tgt_lang=&quot;English&quot;)
print(f&quot;The translated question is {translated_question}.&quot;)
answer = image_qa(text=translated_question, image=image)
print(f&quot;The answer is {answer}&quot;)
\`\`\`

=====

[...]`}}),Tt=new y({props:{code:"Human: <user-input>\\n\\nAssistant:",highlighted:"Human: &lt;user-input&gt;\\n\\nAssistant:"}}),At=new F({}),Pt=new y({props:{code:`from transformers import HfAgent

agent = HfAgent("https://api-inference.huggingface.co/models/bigcode/starcoder")

agent.run("Show me a tree", return_code=True)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> HfAgent

agent = HfAgent(<span class="hljs-string">&quot;https://api-inference.huggingface.co/models/bigcode/starcoder&quot;</span>)

agent.run(<span class="hljs-string">&quot;Show me a tree&quot;</span>, return_code=<span class="hljs-literal">True</span>)`}}),jt=new y({props:{code:`==Explanation from the agent==
I will use the following tool: \`image_segmenter\` to create a segmentation mask for the image.


==Code generated by the agent==
mask = image_segmenter(image, prompt="tree")`,highlighted:`==Explanation from the agent==
I will use the following tool: \`image_segmenter\` to create a segmentation mask for the image.


==Code generated by the agent==
mask = image_segmenter(image, prompt=&quot;tree&quot;)`}}),It=new y({props:{code:'agent.toolbox["image_generator"].description',highlighted:'agent.toolbox[<span class="hljs-string">&quot;image_generator&quot;</span>].description'}}),Ct=new y({props:{code:"'This is a tool that creates an image according to a prompt, which is a text description. It takes an input named `prompt` which contains the image description and outputs an image.",highlighted:"&#x27;This is a tool that creates an image according to a prompt, which is a text description. It takes an input named `prompt` which contains the image description and outputs an image."}}),Dt=new y({props:{code:'agent.run("Create an image of a tree", return_code=True)',highlighted:'agent.run(<span class="hljs-string">&quot;Create an image of a tree&quot;</span>, return_code=<span class="hljs-literal">True</span>)'}}),Ht=new y({props:{code:`==Explanation from the agent==
I will use the following tool \`image_generator\` to generate an image of a tree.


==Code generated by the agent==
image = image_generator(prompt="tree")`,highlighted:`==Explanation from the agent==
I will use the following tool \`image_generator\` to generate an image of a tree.


==Code generated by the agent==
image = image_generator(prompt=&quot;tree&quot;)`}}),Ot=new F({}),St=new y({props:{code:'agent.run("Make an image of a house and a car", return_code=True)',highlighted:'agent.run(<span class="hljs-string">&quot;Make an image of a house and a car&quot;</span>, return_code=<span class="hljs-literal">True</span>)'}}),Nt=new y({props:{code:`==Explanation from the agent== 
I will use the following tools \`image_generator\` to generate an image of a house and \`image_transformer\` to transform the image of a car into the image of a house.

==Code generated by the agent==
house_image = image_generator(prompt="A house")
car_image = image_generator(prompt="A car")
house_car_image = image_transformer(image=car_image, prompt="A house")`,highlighted:`==Explanation from the agent== 
I will use the following tools \`image_generator\` to generate an image of a house and \`image_transformer\` to transform the image of a car into the image of a house.

==Code generated by the agent==
house_image = image_generator(prompt=&quot;A house&quot;)
car_image = image_generator(prompt=&quot;A car&quot;)
house_car_image = image_transformer(image=car_image, prompt=&quot;A house&quot;)`}}),Wt=new y({props:{code:`agent.toolbox["modifier"] = agent.toolbox.pop("image_transformer")
agent.toolbox["modifier"].description = agent.toolbox["modifier"].description.replace(
    "transforms an image according to a prompt", "modifies an image"
)`,highlighted:`agent.toolbox[<span class="hljs-string">&quot;modifier&quot;</span>] = agent.toolbox.pop(<span class="hljs-string">&quot;image_transformer&quot;</span>)
agent.toolbox[<span class="hljs-string">&quot;modifier&quot;</span>].description = agent.toolbox[<span class="hljs-string">&quot;modifier&quot;</span>].description.replace(
    <span class="hljs-string">&quot;transforms an image according to a prompt&quot;</span>, <span class="hljs-string">&quot;modifies an image&quot;</span>
)`}}),zt=new y({props:{code:'agent.run("Make an image of a house and a car", return_code=True)',highlighted:'agent.run(<span class="hljs-string">&quot;Make an image of a house and a car&quot;</span>, return_code=<span class="hljs-literal">True</span>)'}}),Mt=new y({props:{code:`==Explanation from the agent==
I will use the following tools: \`image_generator\` to generate an image of a house, then \`image_generator\` to generate an image of a car.


==Code generated by the agent==
house_image = image_generator(prompt="A house")
car_image = image_generator(prompt="A car")`,highlighted:`==Explanation from the agent==
I will use the following tools: \`image_generator\` to generate an image of a house, then \`image_generator\` to generate an image of a car.


==Code generated by the agent==
house_image = image_generator(prompt=&quot;A house&quot;)
car_image = image_generator(prompt=&quot;A car&quot;)`}}),Ft=new y({props:{code:`agent.run("Create image: 'A house and car'", return_code=True)`,highlighted:'agent.run(<span class="hljs-string">&quot;Create image: &#x27;A house and car&#x27;&quot;</span>, return_code=<span class="hljs-literal">True</span>)'}}),Gt=new y({props:{code:`==Explanation from the agent==
I will use the following tool: \`image_generator\` to generate an image.


==Code generated by the agent==
image = image_generator(prompt="A house and car")`,highlighted:`==Explanation from the agent==
I will use the following tool: \`image_generator\` to generate an image.


==Code generated by the agent==
image = image_generator(prompt=&quot;A house and car&quot;)`}}),He=new ie({props:{warning:!0,$$slots:{default:[G_]},$$scope:{ctx:T}}}),Ut=new F({}),Bt=new y({props:{code:`template = """ [...] """

agent = HfAgent(your_endpoint, run_prompt_template=template)`,highlighted:`template = <span class="hljs-string">&quot;&quot;&quot; [...] &quot;&quot;&quot;</span>

agent = HfAgent(your_endpoint, run_prompt_template=template)`}}),Le=new ie({props:{warning:!0,$$slots:{default:[U_]},$$scope:{ctx:T}}}),Rt=new y({props:{code:`Human: <<task>>

Assistant:`,highlighted:`Human: &lt;&lt;task&gt;&gt;

Assistant:`}}),Yt=new y({props:{code:`template = """ [...] """

agent = HfAgent(url_endpoint=your_endpoint, chat_prompt_template=template)`,highlighted:`<span class="hljs-attr">template</span> = <span class="hljs-string">&quot;&quot;&quot; [...] &quot;&quot;&quot;</span>

<span class="hljs-attr">agent</span> = HfAgent(url_endpoint=your_endpoint, chat_prompt_template=template)`}}),Se=new ie({props:{warning:!0,$$slots:{default:[B_]},$$scope:{ctx:T}}}),Qt=new F({}),Zt=new y({props:{code:`from transformers import load_tool

controlnet_transformer = load_tool("diffusers/controlnet-canny-tool")
upscaler = load_tool("diffusers/latent-upscaler-tool")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> load_tool

controlnet_transformer = load_tool(<span class="hljs-string">&quot;diffusers/controlnet-canny-tool&quot;</span>)
upscaler = load_tool(<span class="hljs-string">&quot;diffusers/latent-upscaler-tool&quot;</span>)`}}),eo=new y({props:{code:`print(f"Description: '{controlnet_transformer.description}'")
print(f"Name: '{controlnet_transformer.name}'")`,highlighted:`<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Description: &#x27;<span class="hljs-subst">{controlnet_transformer.description}</span>&#x27;&quot;</span>)
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Name: &#x27;<span class="hljs-subst">{controlnet_transformer.name}</span>&#x27;&quot;</span>)`}}),to=new y({props:{code:"Description: 'This is a tool that transforms an image with ControlNet according to a prompt. \nIt takes two inputs: `image`, which should be the image to transform, and `prompt`, which should be the prompt to use to change it. It returns the modified image.'\nName: 'image_transformer'",highlighted:"Description: &#x27;This is a tool that transforms an image with ControlNet according to a prompt. \nIt takes two inputs: `image`, which should be the image to transform, and `prompt`, which should be the prompt to use to change it. It returns the modified image.&#x27;\nName: &#x27;image_transformer&#x27;"}}),oo=new y({props:{code:`tools = [controlnet_transformer, upscaler]
agent = HfAgent("https://api-inference.huggingface.co/models/bigcode/starcoder", additional_tools=tools)`,highlighted:`tools = [controlnet_transformer, upscaler]
agent = HfAgent(<span class="hljs-string">&quot;https://api-inference.huggingface.co/models/bigcode/starcoder&quot;</span>, additional_tools=tools)`}}),ao=new y({props:{code:"image_transformer has been replaced by <transformers_modules.diffusers.controlnet-canny-tool.bd76182c7777eba9612fc03c0\n8718a60c0aa6312.image_transformation.ControlNetTransformationTool object at 0x7f1d3bfa3a00> as provided in `additional_tools`",highlighted:"image_transformer has been replaced by &lt;transformers_modules.diffusers.controlnet-canny-tool.bd76182c7777eba9612fc03c0\n8718a60c0aa6312.image_transformation.ControlNetTransformationTool object at 0x7f1d3bfa3a00&gt; as provided in `additional_tools`"}}),Ge=new ie({props:{$$slots:{default:[R_]},$$scope:{ctx:T}}}),so=new y({props:{code:'print("\\n".join([f"- {a}" for a in agent.toolbox.keys()]))',highlighted:'<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;\\n&quot;</span>.join([<span class="hljs-string">f&quot;- <span class="hljs-subst">{a}</span>&quot;</span> <span class="hljs-keyword">for</span> a <span class="hljs-keyword">in</span> agent.toolbox.keys()]))'}}),no=new y({props:{code:`- document_qa
- image_captioner
- image_qa
- image_segmenter
- transcriber
- summarizer
- text_classifier
- text_qa
- text_reader
- translator
- image_transformer
- text_downloader
- image_generator
- video_generator
- image_upscaler`,highlighted:`- document_qa
- image_captioner
- image_qa
- image_segmenter
- transcriber
- summarizer
- text_classifier
- text_qa
- text_reader
- translator
- image_transformer
- text_downloader
- image_generator
- video_generator
- image_upscaler`}}),ro=new y({props:{code:`from diffusers.utils import load_image

image = load_image(
    "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/rivers_and_lakes.png"
)`,highlighted:`<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image

image = load_image(
    <span class="hljs-string">&quot;https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/rivers_and_lakes.png&quot;</span>
)`}}),lo=new y({props:{code:`image = agent.run("Transform the image: 'A frozen lake and snowy forest'", image=image)`,highlighted:'image = agent.run(<span class="hljs-string">&quot;Transform the image: &#x27;A frozen lake and snowy forest&#x27;&quot;</span>, image=image)'}}),po=new y({props:{code:`==Explanation from the agent==
I will use the following tool: \`image_transformer\` to transform the image.


==Code generated by the agent==
image = image_transformer(image, prompt="A frozen lake and snowy forest")`,highlighted:`==Explanation from the agent==
I will use the following tool: \`image_transformer\` to transform the image.


==Code generated by the agent==
image = image_transformer(image, prompt=&quot;A frozen lake and snowy forest&quot;)`}}),mo=new y({props:{code:'image = agent.run("Upscale the image", image)',highlighted:'image = agent.run(<span class="hljs-string">&quot;Upscale the image&quot;</span>, image)'}}),fo=new y({props:{code:`==Explanation from the agent==
I will use the following tool: \`image_upscaler\` to upscale the image.


==Code generated by the agent==
upscaled_image = image_upscaler(image)`,highlighted:`==Explanation from the agent==
I will use the following tool: \`image_upscaler\` to upscale the image.


==Code generated by the agent==
upscaled_image = image_upscaler(image)`}}),co=new F({}),go=new F({}),wo=new y({props:{code:`from huggingface_hub import list_models

task = "text-classification"

model = next(iter(list_models(filter=task, sort="downloads", direction=-1)))
print(model.id)`,highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> list_models

task = <span class="hljs-string">&quot;text-classification&quot;</span>

model = <span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(list_models(<span class="hljs-built_in">filter</span>=task, sort=<span class="hljs-string">&quot;downloads&quot;</span>, direction=-<span class="hljs-number">1</span>)))
<span class="hljs-built_in">print</span>(model.<span class="hljs-built_in">id</span>)`}}),_o=new y({props:{code:`from transformers import Tool


class HFModelDownloadsTool(Tool):
    pass`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Tool


<span class="hljs-keyword">class</span> <span class="hljs-title class_">HFModelDownloadsTool</span>(<span class="hljs-title class_ inherited__">Tool</span>):
    <span class="hljs-keyword">pass</span>`}}),bo=new y({props:{code:`from transformers import Tool
from huggingface_hub import list_models


class HFModelDownloadsTool(Tool):
    name = "model_download_counter"
    description = (
        "This is a tool that returns the most downloaded model of a given task on the Hugging Face Hub. "
        "It takes the name of the category (such as text-classification, depth-estimation, etc), and "
        "returns the name of the checkpoint."
    )

    inputs = ["text"]
    outputs = ["text"]

    def __call__(self, task: str):
        model = next(iter(list_models(filter=task, sort="downloads", direction=-1)))
        return model.id`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Tool
<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> list_models


<span class="hljs-keyword">class</span> <span class="hljs-title class_">HFModelDownloadsTool</span>(<span class="hljs-title class_ inherited__">Tool</span>):
    name = <span class="hljs-string">&quot;model_download_counter&quot;</span>
    description = (
        <span class="hljs-string">&quot;This is a tool that returns the most downloaded model of a given task on the Hugging Face Hub. &quot;</span>
        <span class="hljs-string">&quot;It takes the name of the category (such as text-classification, depth-estimation, etc), and &quot;</span>
        <span class="hljs-string">&quot;returns the name of the checkpoint.&quot;</span>
    )

    inputs = [<span class="hljs-string">&quot;text&quot;</span>]
    outputs = [<span class="hljs-string">&quot;text&quot;</span>]

    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__call__</span>(<span class="hljs-params">self, task: <span class="hljs-built_in">str</span></span>):
        model = <span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(list_models(<span class="hljs-built_in">filter</span>=task, sort=<span class="hljs-string">&quot;downloads&quot;</span>, direction=-<span class="hljs-number">1</span>)))
        <span class="hljs-keyword">return</span> model.<span class="hljs-built_in">id</span>`}}),yo=new y({props:{code:`from model_downloads import HFModelDownloadsTool

tool = HFModelDownloadsTool()`,highlighted:`<span class="hljs-keyword">from</span> model_downloads <span class="hljs-keyword">import</span> HFModelDownloadsTool

tool = HFModelDownloadsTool()`}}),ko=new y({props:{code:'tool.push_to_hub("hf-model-downloads")',highlighted:'tool.push_to_hub(<span class="hljs-string">&quot;hf-model-downloads&quot;</span>)'}}),Eo=new F({}),qo=new y({props:{code:`from transformers import load_tool

tool = load_tool("lysandre/hf-model-downloads")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> load_tool

tool = load_tool(<span class="hljs-string">&quot;lysandre/hf-model-downloads&quot;</span>)`}}),xo=new y({props:{code:`from transformers import HfAgent

agent = HfAgent("https://api-inference.huggingface.co/models/bigcode/starcoder", additional_tools=[tool])

agent.run(
    "Can you read out loud the name of the model that has the most downloads in the 'text-to-video' task on the Hugging Face Hub?"
)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> HfAgent

agent = HfAgent(<span class="hljs-string">&quot;https://api-inference.huggingface.co/models/bigcode/starcoder&quot;</span>, additional_tools=[tool])

agent.run(
    <span class="hljs-string">&quot;Can you read out loud the name of the model that has the most downloads in the &#x27;text-to-video&#x27; task on the Hugging Face Hub?&quot;</span>
)`}}),To=new y({props:{code:`==Code generated by the agent==
model = model_download_counter(task="text-to-video")
print(f"The model with the most downloads is {model}.")
audio_model = text_reader(model)


==Result==
The model with the most downloads is damo-vilab/text-to-video-ms-1.7b.`,highlighted:`==Code generated by the agent==
model = model_download_counter(task=&quot;text-to-video&quot;)
print(f&quot;The model with the most downloads is {model}.&quot;)
audio_model = text_reader(model)


==Result==
The model with the most downloads is damo-vilab/text-to-video-ms-1.7b.`}}),Ze=new ie({props:{$$slots:{default:[Y_]},$$scope:{ctx:T}}}),Ao=new F({}),Po=new y({props:{code:`from transformers import HfAgent, load_tool

agent = HfAgent("https://api-inference.huggingface.co/models/bigcode/starcoder")
agent.toolbox["image-transformation"] = load_tool("diffusers/controlnet-canny-tool")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> HfAgent, load_tool

agent = HfAgent(<span class="hljs-string">&quot;https://api-inference.huggingface.co/models/bigcode/starcoder&quot;</span>)
agent.toolbox[<span class="hljs-string">&quot;image-transformation&quot;</span>] = load_tool(<span class="hljs-string">&quot;diffusers/controlnet-canny-tool&quot;</span>)`}}),tt=new ie({props:{$$slots:{default:[Q_]},$$scope:{ctx:T}}}),jo=new F({}),Do=new y({props:{code:`from gradio_tools import StableDiffusionPromptGeneratorTool

gradio_tool = StableDiffusionPromptGeneratorTool()`,highlighted:`<span class="hljs-keyword">from</span> gradio_tools <span class="hljs-keyword">import</span> StableDiffusionPromptGeneratorTool

gradio_tool = StableDiffusionPromptGeneratorTool()`}}),Ho=new y({props:{code:`from transformers import Tool

tool = Tool.from_gradio(gradio_tool)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Tool

tool = Tool.from_gradio(gradio_tool)`}}),Oo=new y({props:{code:`from transformers import HfAgent

agent = HfAgent("https://api-inference.huggingface.co/models/bigcode/starcoder", additional_tools=[tool])

agent.run("Generate an image of the \`prompt\` after improving it.", prompt="A rabbit wearing a space suit")`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> HfAgent

agent = HfAgent(<span class="hljs-string">&quot;https://api-inference.huggingface.co/models/bigcode/starcoder&quot;</span>, additional_tools=[tool])

agent.run(<span class="hljs-string">&quot;Generate an image of the \`prompt\` after improving it.&quot;</span>, prompt=<span class="hljs-string">&quot;A rabbit wearing a space suit&quot;</span>)`}}),Lo=new y({props:{code:`==Explanation from the agent==
I will use the following  tools: \`StableDiffusionPromptGenerator\` to improve the prompt, then \`image_generator\` to generate an image according to the improved prompt.


==Code generated by the agent==
improved_prompt = StableDiffusionPromptGenerator(prompt)
print(f"The improved prompt is {improved_prompt}.")
image = image_generator(improved_prompt)`,highlighted:`==Explanation from the agent==
I will use the following  tools: \`StableDiffusionPromptGenerator\` to improve the prompt, then \`image_generator\` to generate an image according to the improved prompt.


==Code generated by the agent==
improved_prompt = StableDiffusionPromptGenerator(prompt)
print(f&quot;The improved prompt is {improved_prompt}.&quot;)
image = image_generator(improved_prompt)`}}),rt=new ie({props:{warning:!0,$$slots:{default:[J_]},$$scope:{ctx:T}}}),So=new F({}),{c(){f=i("meta"),k=h(),$=i("h1"),b=i("a"),x=i("span"),d(E.$$.fragment),q=h(),A=i("span"),H=s("Custom Tools and Prompts"),D=h(),d(O.$$.fragment),M=h(),d(j.$$.fragment),dt=h(),le=i("p"),Mo=s(`Creating and using custom tools and prompts is paramount to empowering the agent and having it perform new tasks.
In this guide we\u2019ll take a look at:`),ur=h(),Q=i("ul"),es=i("li"),Up=s("How to customize the prompt"),Bp=h(),ts=i("li"),Rp=s("How to use custom tools"),Yp=h(),os=i("li"),Qp=s("How to create custom tools"),dr=h(),pe=i("h2"),Ee=i("a"),as=i("span"),d(ct.$$.fragment),Jp=h(),ss=i("span"),Kp=s("Customizing the prompt"),cr=h(),I=i("p"),Vp=s("As explained in "),Fo=i("a"),Xp=s("Transformers Agents"),Zp=s(" agents can run in "),Go=i("a"),eh=s("run()"),th=s(" and "),Uo=i("a"),oh=s("chat()"),ah=s(` mode.
Both the `),ns=i("code"),sh=s("run"),nh=s(" and "),rs=i("code"),rh=s("chat"),ih=s(` modes underlie the same logic. The language model powering the agent is conditioned on a long
prompt and completes the prompt by generating the next tokens until the stop token is reached.
The only difference between the two modes is that during the `),is=i("code"),lh=s("chat"),ph=s(` mode the prompt is extended with
previous user inputs and model generations. This allows the agent to have access to past interactions,
seemingly giving the agent some kind of memory.`),gr=h(),he=i("h3"),qe=i("a"),ls=i("span"),d(gt.$$.fragment),hh=h(),ps=i("span"),mh=s("Structure of the prompt"),wr=h(),Bo=i("p"),fh=s(`Let\u2019s take a closer look at how the prompt is structured to understand how it can be best customized.
The prompt is structured broadly into four parts.`),_r=h(),G=i("ul"),hs=i("li"),ms=i("ol"),fs=i("li"),uh=s("Introduction: how the agent should behave, explanation of the concept of tools."),dh=h(),us=i("li"),Ro=i("ol"),wt=i("li"),ch=s("Description of all the tools. This is defined by a "),ds=i("code"),gh=s("<<all_tools>>"),wh=s(" token that is dynamically replaced at runtime with the tools defined/chosen by the user."),_h=h(),cs=i("li"),Yo=i("ol"),gs=i("li"),vh=s("A set of examples of tasks and their solution"),$h=h(),ws=i("li"),Qo=i("ol"),_s=i("li"),bh=s("Current example, and request for solution."),vr=h(),xe=i("p"),yh=s("To better understand each part, let\u2019s look at a shortened version of how the "),vs=i("code"),kh=s("run"),Eh=s(" prompt can look like:"),$r=h(),d(_t.$$.fragment),br=h(),Te=i("p"),qh=s("The introduction (the text before "),$s=i("em"),xh=s("\u201CTools:\u201D"),Th=s(`) explains precisely how the model shall behave and what it should do.
This part most likely does not need to be customized as the agent shall always behave the same way.`),yr=h(),L=i("p"),Ah=s("The second part (the bullet points below "),bs=i("em"),Ph=s("\u201CTools\u201D"),jh=s(") is dynamically added upon calling "),ys=i("code"),Ih=s("run"),Ch=s(" or "),ks=i("code"),Dh=s("chat"),Hh=s(`. There are
exactly as many bullet points as there are tools in `),Es=i("code"),Oh=s("agent.toolbox"),Lh=s(` and each bullet point consists of the name
and description of the tool:`),kr=h(),d(vt.$$.fragment),Er=h(),Jo=i("p"),Sh=s("Let\u2019s verify this quickly by loading the document_qa tool and printing out the name and description."),qr=h(),d($t.$$.fragment),xr=h(),Ko=i("p"),Nh=s("which gives:"),Tr=h(),d(bt.$$.fragment),Ar=h(),Vo=i("p"),Wh=s(`We can see that the tool name is short and precise. The description includes two parts, the first explaining
what the tool does and the second states what input arguments and return values are expected.`),Pr=h(),Xo=i("p"),zh=s(`A good tool name and tool description are very important for the agent to correctly use it. Note that the only
information the agent has about the tool is its name and description, so one should make sure that both
are precisely written and match the style of the existing tools in the toolbox. In particular make sure the description
mentions all the arguments expected by name in code-style, along with the expected type and a description of what they
are.`),jr=h(),d(Ae.$$.fragment),Ir=h(),Zo=i("p"),Mh=s(`The third part includes a set of curated examples that show the agent exactly what code it should produce
for what kind of user request. The large language models empowering the agent are extremely good at
recognizing patterns in a prompt and repeating the pattern with new data. Therefore, it is very important
that the examples are written in a way that maximizes the likelihood of the agent to generating correct,
executable code in practice.`),Cr=h(),ea=i("p"),Fh=s("Let\u2019s have a look at one example:"),Dr=h(),d(yt.$$.fragment),Hr=h(),ta=i("p"),Gh=s(`The pattern the model is prompted to repeat has three parts: The task statement, the agent\u2019s explanation of
what it intends to do, and finally the generated code. Every example that is part of the prompt has this exact
pattern, thus making sure that the agent will reproduce exactly the same pattern when generating new tokens.`),Or=h(),Pe=i("p"),Uh=s(`The prompt examples are curated by the Transformers team and rigorously evaluated on a set of
`),kt=i("a"),Bh=s("problem statements"),Rh=s(`
to ensure that the agent\u2019s prompt is as good as possible to solve real use cases of the agent.`),Lr=h(),oa=i("p"),Yh=s("The final part of the prompt corresponds to:"),Sr=h(),d(Et.$$.fragment),Nr=h(),aa=i("p"),Qh=s(`is a final and unfinished example that the agent is tasked to complete. The unfinished example
is dynamically created based on the actual user input. For the above example, the user ran:`),Wr=h(),d(qt.$$.fragment),zr=h(),J=i("p"),Jh=s("The user input - "),qs=i("em"),Kh=s("a.k.a"),Vh=s(" the task: "),xs=i("em"),Xh=s("\u201CDraw me a picture of rivers and lakes\u201D"),Zh=s(` is cast into the
prompt template: \u201CTask: <task> \\n\\n I will use the following\u201D. This sentence makes up the final lines of the
prompt the agent is conditioned on, therefore strongly influencing the agent to finish the example
exactly in the same way it was previously done in the examples.`),Mr=h(),je=i("p"),em=s(`Without going into too much detail, the chat template has the same prompt structure with the
examples having a slightly different style, `),Ts=i("em"),tm=s("e.g."),om=s(":"),Fr=h(),d(xt.$$.fragment),Gr=h(),P=i("p"),am=s("Contrary, to the examples of the "),As=i("code"),sm=s("run"),nm=s(" prompt, each "),Ps=i("code"),rm=s("chat"),im=s(` prompt example has one or more exchanges between the
`),js=i("em"),lm=s("Human"),pm=s(" and the "),Is=i("em"),hm=s("Assistant"),mm=s(". Every exchange is structured similarly to the example of the "),Cs=i("code"),fm=s("run"),um=s(` prompt.
The user\u2019s input is appended to behind `),Ds=i("em"),dm=s("Human:"),cm=s(` and the agent is prompted to first generate what needs to be done
before generating code. An exchange can be based on previous exchanges, therefore allowing the user to refer
to past exchanges as is done `),Hs=i("em"),gm=s("e.g."),wm=s(" above by the user\u2019s input of \u201CI tried "),Os=i("strong"),_m=s("this"),vm=s(` code\u201D refers to the
previously generated code of the agent.`),Ur=h(),K=i("p"),$m=s("Upon running "),Ls=i("code"),bm=s(".chat"),ym=s(", the user\u2019s input or "),Ss=i("em"),km=s("task"),Em=s(" is cast into an unfinished example of the form:"),Br=h(),d(Tt.$$.fragment),Rr=h(),U=i("p"),qm=s("which the agent completes. Contrary to the "),Ns=i("code"),xm=s("run"),Tm=s(" command, the "),Ws=i("code"),Am=s("chat"),Pm=s(` command then appends the completed example
to the prompt, thus giving the agent more context for the next `),zs=i("code"),jm=s("chat"),Im=s(" turn."),Yr=h(),sa=i("p"),Cm=s("Great now that we know how the prompt is structured, let\u2019s see how we can customize it!"),Qr=h(),me=i("h3"),Ie=i("a"),Ms=i("span"),d(At.$$.fragment),Dm=h(),Fs=i("span"),Hm=s("Writing good user inputs"),Jr=h(),na=i("p"),Om=s(`While large language models are getting better and better at understanding users\u2019 intentions, it helps
enormously to be as precise as possible to help the agent pick the correct task. What does it mean to be
as precise as possible?`),Kr=h(),ra=i("p"),Lm=s(`The agent sees a list of tool names and their description in its prompt. The more tools are added the
more difficult it becomes for the agent to choose the correct tool and it\u2019s even more difficult to choose
the correct sequences of tools to run. Let\u2019s look at a common failure case, here we will only return
the code to analyze it.`),Vr=h(),d(Pt.$$.fragment),Xr=h(),ia=i("p"),Sm=s("gives:"),Zr=h(),d(jt.$$.fragment),ei=h(),la=i("p"),Nm=s(`which is probably not what we wanted. Instead, it is more likely that we want an image of a tree to be generated.
To steer the agent more towards using a specific tool it can therefore be very helpful to use important keywords that
are present in the tool\u2019s name and description. Let\u2019s have a look.`),ti=h(),d(It.$$.fragment),oi=h(),d(Ct.$$.fragment),ai=h(),pa=i("p"),Wm=s("The name and description make use of the keywords \u201Cimage\u201D, \u201Cprompt\u201D, \u201Ccreate\u201D and \u201Cgenerate\u201D. Using these words will most likely work better here. Let\u2019s refine our prompt a bit."),si=h(),d(Dt.$$.fragment),ni=h(),ha=i("p"),zm=s("gives:"),ri=h(),d(Ht.$$.fragment),ii=h(),ma=i("p"),Mm=s(`Much better! That looks more like what we want. In short, when you notice that the agent struggles to
correctly map your task to the correct tools, try looking up the most pertinent keywords of the tool\u2019s name
and description and try refining your task request with it.`),li=h(),fe=i("h3"),Ce=i("a"),Gs=i("span"),d(Ot.$$.fragment),Fm=h(),Us=i("span"),Gm=s("Customizing the tool descriptions"),pi=h(),De=i("p"),Um=s(`As we\u2019ve seen before the agent has access to each of the tools\u2019 names and descriptions. The base tools
should have very precise names and descriptions, however, you might find that it could help to change the
the description or name of a tool for your specific use case. This might become especially important
when you\u2019ve added multiple tools that are very similar or if you want to use your agent only for a certain
domain, `),Bs=i("em"),Bm=s("e.g."),Rm=s(" image generation and transformations."),hi=h(),Lt=i("p"),Ym=s(`A common problem is that the agent confuses image generation with image transformation/modification when
used a lot for image generation tasks, `),Rs=i("em"),Qm=s("e.g."),mi=h(),d(St.$$.fragment),fi=h(),fa=i("p"),Jm=s("returns"),ui=h(),d(Nt.$$.fragment),di=h(),V=i("p"),Km=s(`which is probably not exactly what we want here. It seems like the agent has a difficult time
to understand the difference between `),Ys=i("code"),Vm=s("image_generator"),Xm=s(" and "),Qs=i("code"),Zm=s("image_transformer"),ef=s(" and often uses the two together."),ci=h(),X=i("p"),tf=s("We can help the agent here by changing the tool name and description of "),Js=i("code"),of=s("image_transformer"),af=s(". Let\u2019s instead call it "),Ks=i("code"),sf=s("modifier"),nf=s(`
to disassociate it a bit from \u201Cimage\u201D and \u201Cprompt\u201D:`),gi=h(),d(Wt.$$.fragment),wi=h(),ua=i("p"),rf=s("Now \u201Cmodify\u201D is a strong cue to use the new image processor which should help with the above prompt. Let\u2019s run it again."),_i=h(),d(zt.$$.fragment),vi=h(),da=i("p"),lf=s("Now we\u2019re getting:"),$i=h(),d(Mt.$$.fragment),bi=h(),ca=i("p"),pf=s("which is definitely closer to what we had in mind! However, we want to have both the house and car in the same image. Steering the task more toward single image generation should help:"),yi=h(),d(Ft.$$.fragment),ki=h(),d(Gt.$$.fragment),Ei=h(),d(He.$$.fragment),qi=h(),ue=i("h3"),Oe=i("a"),Vs=i("span"),d(Ut.$$.fragment),hf=h(),Xs=i("span"),mf=s("Customizing the whole prompt"),xi=h(),Z=i("p"),ff=s("To give the user maximum flexibility, the whole prompt template as explained in "),ga=i("a"),uf=s("above"),df=s(`
can be overwritten by the user. In this case make sure that your custom prompt includes an introduction section,
a tool section, an example section, and an unfinished example section. If you want to overwrite the `),Zs=i("code"),cf=s("run"),gf=s(` prompt template,
you can do as follows:`),Ti=h(),d(Bt.$$.fragment),Ai=h(),d(Le.$$.fragment),Pi=h(),ee=i("p"),wf=s("Similarly, one can overwrite the "),en=i("code"),_f=s("chat"),vf=s(" prompt template. Note that the "),tn=i("code"),$f=s("chat"),bf=s(" mode always uses the following format for the exchanges:"),ji=h(),d(Rt.$$.fragment),Ii=h(),te=i("p"),yf=s("Therefore it is important that the examples of the custom "),on=i("code"),kf=s("chat"),Ef=s(` prompt template also make use of this format.
You can overwrite the `),an=i("code"),qf=s("chat"),xf=s(" template at instantiation as follows."),Ci=h(),d(Yt.$$.fragment),Di=h(),d(Se.$$.fragment),Hi=h(),de=i("h2"),Ne=i("a"),sn=i("span"),d(Qt.$$.fragment),Tf=h(),nn=i("span"),Af=s("Using custom tools"),Oi=h(),wa=i("p"),Pf=s("In this section, we\u2019ll be leveraging two existing custom tools that are specific to image generation:"),Li=h(),We=i("ul"),ce=i("li"),jf=s("We replace "),Jt=i("a"),If=s("huggingface-tools/image-transformation"),Cf=s(`,
with `),Kt=i("a"),Df=s("diffusers/controlnet-canny-tool"),Hf=s(`
to allow for more image modifications.`),Of=h(),Vt=i("li"),Lf=s(`We add a new tool for image upscaling to the default toolbox:
`),Xt=i("a"),Sf=s("diffusers/latent-upscaler-tool"),Nf=s(" replace the existing image-transformation tool."),Si=h(),ze=i("p"),Wf=s("We\u2019ll start by loading the custom tools with the convenient "),_a=i("a"),zf=s("load_tool()"),Mf=s(" function:"),Ni=h(),d(Zt.$$.fragment),Wi=h(),Me=i("p"),Ff=s(`Upon adding custom tools to an agent, the tools\u2019 descriptions and names are automatically
included in the agents\u2019 prompts. Thus, it is imperative that custom tools have
a well-written description and name in order for the agent to understand how to use them.
Let\u2019s take a look at the description and name of `),rn=i("code"),Gf=s("controlnet_transformer"),Uf=s(":"),zi=h(),d(eo.$$.fragment),Mi=h(),va=i("p"),Bf=s("gives"),Fi=h(),d(to.$$.fragment),Gi=h(),B=i("p"),Rf=s("The name and description are accurate and fit the style of the "),$a=i("a"),Yf=s("curated set of tools"),Qf=s(`.
Next, let\u2019s instantiate an agent with `),ln=i("code"),Jf=s("controlnet_transformer"),Kf=s(" and "),pn=i("code"),Vf=s("upscaler"),Xf=s(":"),Ui=h(),d(oo.$$.fragment),Bi=h(),ba=i("p"),Zf=s("This command should give you the following info:"),Ri=h(),d(ao.$$.fragment),Yi=h(),Fe=i("p"),eu=s("The set of curated tools already has an "),hn=i("code"),tu=s("image_transformer"),ou=s(" tool which is hereby replaced with our custom tool."),Qi=h(),d(Ge.$$.fragment),Ji=h(),oe=i("p"),au=s("The upscaler tool was given the name "),mn=i("code"),su=s("image_upscaler"),nu=s(` which is not yet present in the default toolbox and is therefore simply added to the list of tools.
You can always have a look at the toolbox that is currently available to the agent via the `),fn=i("code"),ru=s("agent.toolbox"),iu=s(" attribute:"),Ki=h(),d(so.$$.fragment),Vi=h(),d(no.$$.fragment),Xi=h(),Ue=i("p"),lu=s("Note how "),un=i("code"),pu=s("image_upscaler"),hu=s(" is now part of the agents\u2019 toolbox."),Zi=h(),Be=i("p"),mu=s("Let\u2019s now try out the new tools! We will re-use the image we generated in "),ya=i("a"),fu=s("Transformers Agents Quickstart"),uu=s("."),el=h(),d(ro.$$.fragment),tl=h(),io=i("img"),ol=h(),ka=i("p"),du=s("Let\u2019s transform the image into a beautiful winter landscape:"),al=h(),d(lo.$$.fragment),sl=h(),d(po.$$.fragment),nl=h(),ho=i("img"),rl=h(),Ea=i("p"),cu=s(`The new image processing tool is based on ControlNet which can make very strong modifications to the image.
By default the image processing tool returns an image of size 512x512 pixels. Let\u2019s see if we can upscale it.`),il=h(),d(mo.$$.fragment),ll=h(),d(fo.$$.fragment),pl=h(),uo=i("img"),hl=h(),qa=i("p"),gu=s(`The agent automatically mapped our prompt \u201CUpscale the image\u201D to the just added upscaler tool purely based on the description and name of the upscaler tool
and was able to correctly run it.`),ml=h(),xa=i("p"),wu=s("Next, let\u2019s have a look at how you can create a new custom tool."),fl=h(),ge=i("h3"),Re=i("a"),dn=i("span"),d(co.$$.fragment),_u=h(),cn=i("span"),vu=s("Adding new tools"),ul=h(),Ta=i("p"),$u=s("In this section, we show how to create a new tool that can be added to the agent."),dl=h(),we=i("h4"),Ye=i("a"),gn=i("span"),d(go.$$.fragment),bu=h(),wn=i("span"),yu=s("Creating a new tool"),cl=h(),Aa=i("p"),ku=s(`We\u2019ll first start by creating a tool. We\u2019ll add the not-so-useful yet fun task of fetching the model on the Hugging Face
Hub with the most downloads for a given task.`),gl=h(),Pa=i("p"),Eu=s("We can do that with the following code:"),wl=h(),d(wo.$$.fragment),_l=h(),S=i("p"),qu=s("For the task "),_n=i("code"),xu=s("text-classification"),Tu=s(", this returns "),vn=i("code"),Au=s("'facebook/bart-large-mnli'"),Pu=s(", for "),$n=i("code"),ju=s("translation"),Iu=s(" it returns "),bn=i("code"),Cu=s("'t5-base"),Du=s("."),vl=h(),Qe=i("p"),Hu=s("How do we convert this to a tool that the agent can leverage? All tools depend on the superclass "),yn=i("code"),Ou=s("Tool"),Lu=s(` that holds the
main attributes necessary. We\u2019ll create a class that inherits from it:`),$l=h(),d(_o.$$.fragment),bl=h(),ja=i("p"),Su=s("This class has a few needs:"),yl=h(),R=i("ul"),_e=i("li"),Nu=s("An attribute "),kn=i("code"),Wu=s("name"),zu=s(`, which corresponds to the name of the tool itself. To be in tune with other tools which have a
performative name, we\u2019ll name it `),En=i("code"),Mu=s("model_download_counter"),Fu=s("."),Gu=h(),vo=i("li"),Uu=s("An attribute "),qn=i("code"),Bu=s("description"),Ru=s(", which will be used to populate the prompt of the agent."),Yu=h(),N=i("li"),xn=i("code"),Qu=s("inputs"),Ju=s(" and "),Tn=i("code"),Ku=s("outputs"),Vu=s(` attributes. Defining this will help the python interpreter make educated choices about types,
and will allow for a gradio-demo to be spawned when we push our tool to the Hub. They\u2019re both a list of expected
values, which can be `),An=i("code"),Xu=s("text"),Zu=s(", "),Pn=i("code"),ed=s("image"),td=s(", or "),jn=i("code"),od=s("audio"),ad=s("."),sd=h(),$o=i("li"),nd=s("A "),In=i("code"),rd=s("__call__"),id=s(" method which contains the inference code. This is the code we\u2019ve played with above!"),kl=h(),Ia=i("p"),ld=s("Here\u2019s what our class looks like now:"),El=h(),d(bo.$$.fragment),ql=h(),Je=i("p"),pd=s(`We now have our tool handy. Save it in a file and import it from your main script. Let\u2019s name this file
`),Cn=i("code"),hd=s("model_downloads.py"),md=s(", so the resulting import code looks like this:"),xl=h(),d(yo.$$.fragment),Tl=h(),ae=i("p"),fd=s(`In order to let others benefit from it and for simpler initialization, we recommend pushing it to the Hub under your
namespace. To do so, just call `),Dn=i("code"),ud=s("push_to_hub"),dd=s(" on the "),Hn=i("code"),cd=s("tool"),gd=s(" variable:"),Al=h(),d(ko.$$.fragment),Pl=h(),Ca=i("p"),wd=s("You now have your code on the Hub! Let\u2019s take a look at the final step, which is to have the agent use it."),jl=h(),ve=i("h4"),Ke=i("a"),On=i("span"),d(Eo.$$.fragment),_d=h(),Ln=i("span"),vd=s("Having the agent use the tool"),Il=h(),Da=i("p"),$d=s("We now have our tool that lives on the Hub which can be instantiated as such (change the user name for your tool):"),Cl=h(),d(qo.$$.fragment),Dl=h(),Ve=i("p"),bd=s("In order to use it in the agent, simply pass it in the "),Sn=i("code"),yd=s("additional_tools"),kd=s(" parameter of the agent initialization method:"),Hl=h(),d(xo.$$.fragment),Ol=h(),Ha=i("p"),Ed=s("which outputs the following:"),Ll=h(),d(To.$$.fragment),Sl=h(),Oa=i("p"),qd=s("and generates the following audio."),Nl=h(),Xe=i("table"),Nn=i("thead"),Wn=i("tr"),zn=i("th"),Mn=i("strong"),xd=s("Audio"),Td=h(),Fn=i("tbody"),Gn=i("tr"),Un=i("td"),La=i("audio"),Sa=i("source"),Wl=h(),d(Ze.$$.fragment),zl=h(),$e=i("h3"),et=i("a"),Bn=i("span"),d(Ao.$$.fragment),Ad=h(),Rn=i("span"),Pd=s("Replacing existing tools"),Ml=h(),Na=i("p"),jd=s("Replacing existing tools can be done simply by assigning a new item to the agent\u2019s toolbox. Here\u2019s how one would do so:"),Fl=h(),d(Po.$$.fragment),Gl=h(),d(tt.$$.fragment),Ul=h(),be=i("h2"),ot=i("a"),Yn=i("span"),d(jo.$$.fragment),Id=h(),Qn=i("span"),Cd=s("Leveraging gradio-tools"),Bl=h(),Io=i("p"),Co=i("a"),Dd=s("gradio-tools"),Hd=s(` is a powerful library that allows using Hugging
Face Spaces as tools. It supports many existing Spaces as well as custom Spaces to be designed with it.`),Rl=h(),W=i("p"),Od=s("We offer support for "),Jn=i("code"),Ld=s("gradio_tools"),Sd=s(" by using the "),Kn=i("code"),Nd=s("Tool.from_gradio"),Wd=s(` method. For example, we want to take
advantage of the `),Vn=i("code"),zd=s("StableDiffusionPromptGeneratorTool"),Md=s(" tool offered in the "),Xn=i("code"),Fd=s("gradio-tools"),Gd=s(` toolkit so as to
improve our prompts and generate better images.`),Yl=h(),at=i("p"),Ud=s("We first import the tool from "),Zn=i("code"),Bd=s("gradio_tools"),Rd=s(" and instantiate it:"),Ql=h(),d(Do.$$.fragment),Jl=h(),st=i("p"),Yd=s("We pass that instance to the "),er=i("code"),Qd=s("Tool.from_gradio"),Jd=s(" method:"),Kl=h(),d(Ho.$$.fragment),Vl=h(),nt=i("p"),Kd=s(`Now we can manage it exactly as we would a usual custom tool. We leverage it to improve our prompt
`),tr=i("code"),Vd=s("a rabbit wearing a space suit"),Xd=s(":"),Xl=h(),d(Oo.$$.fragment),Zl=h(),Wa=i("p"),Zd=s("The model adequately leverages the tool:"),ep=h(),d(Lo.$$.fragment),tp=h(),za=i("p"),ec=s("Before finally generating the image:"),op=h(),Ma=i("img"),ap=h(),d(rt.$$.fragment),sp=h(),ye=i("h2"),it=i("a"),or=i("span"),d(So.$$.fragment),tc=h(),ar=i("span"),oc=s("Future compatibility with Langchain"),np=h(),lt=i("p"),ac=s(`We love Langchain and think it has a very compelling suite of tools. In order to handle these tools,
Langchain requires `),sr=i("em"),sc=s("textual"),nc=s(` inputs and outputs, even when working with different modalities.
This is often the serialized version (i.e., saved to disk) of the objects.`),rp=h(),Fa=i("p"),rc=s(`This difference means that multi-modality isn\u2019t handled between transformers-agents and langchain.
We aim for this limitation to be resolved in future versions, and welcome any help from avid langchain
users to help us achieve this compatibility.`),ip=h(),pt=i("p"),ic=s(`We would love to have better support. If you would like to help, please
`),No=i("a"),lc=s("open an issue"),pc=s(" and share what you have in mind."),this.h()},l(e){const a=N_('[data-svelte="svelte-1phssyn"]',document.head);f=l(a,"META",{name:!0,content:!0}),a.forEach(t),k=m(e),$=l(e,"H1",{class:!0});var Wo=p($);b=l(Wo,"A",{id:!0,class:!0,href:!0});var nr=p(b);x=l(nr,"SPAN",{});var rr=p(x);c(E.$$.fragment,rr),rr.forEach(t),nr.forEach(t),q=m(Wo),A=l(Wo,"SPAN",{});var ir=p(A);H=n(ir,"Custom Tools and Prompts"),ir.forEach(t),Wo.forEach(t),D=m(e),c(O.$$.fragment,e),M=m(e),c(j.$$.fragment,e),dt=m(e),le=l(e,"P",{});var lr=p(le);Mo=n(lr,`Creating and using custom tools and prompts is paramount to empowering the agent and having it perform new tasks.
In this guide we\u2019ll take a look at:`),lr.forEach(t),ur=m(e),Q=l(e,"UL",{});var ke=p(Q);es=l(ke,"LI",{});var pr=p(es);Up=n(pr,"How to customize the prompt"),pr.forEach(t),Bp=m(ke),ts=l(ke,"LI",{});var hr=p(ts);Rp=n(hr,"How to use custom tools"),hr.forEach(t),Yp=m(ke),os=l(ke,"LI",{});var mr=p(os);Qp=n(mr,"How to create custom tools"),mr.forEach(t),ke.forEach(t),dr=m(e),pe=l(e,"H2",{class:!0});var zo=p(pe);Ee=l(zo,"A",{id:!0,class:!0,href:!0});var wc=p(Ee);as=l(wc,"SPAN",{});var _c=p(as);c(ct.$$.fragment,_c),_c.forEach(t),wc.forEach(t),Jp=m(zo),ss=l(zo,"SPAN",{});var vc=p(ss);Kp=n(vc,"Customizing the prompt"),vc.forEach(t),zo.forEach(t),cr=m(e),I=l(e,"P",{});var z=p(I);Vp=n(z,"As explained in "),Fo=l(z,"A",{href:!0});var $c=p(Fo);Xp=n($c,"Transformers Agents"),$c.forEach(t),Zp=n(z," agents can run in "),Go=l(z,"A",{href:!0});var bc=p(Go);eh=n(bc,"run()"),bc.forEach(t),th=n(z," and "),Uo=l(z,"A",{href:!0});var yc=p(Uo);oh=n(yc,"chat()"),yc.forEach(t),ah=n(z,` mode.
Both the `),ns=l(z,"CODE",{});var kc=p(ns);sh=n(kc,"run"),kc.forEach(t),nh=n(z," and "),rs=l(z,"CODE",{});var Ec=p(rs);rh=n(Ec,"chat"),Ec.forEach(t),ih=n(z,` modes underlie the same logic. The language model powering the agent is conditioned on a long
prompt and completes the prompt by generating the next tokens until the stop token is reached.
The only difference between the two modes is that during the `),is=l(z,"CODE",{});var qc=p(is);lh=n(qc,"chat"),qc.forEach(t),ph=n(z,` mode the prompt is extended with
previous user inputs and model generations. This allows the agent to have access to past interactions,
seemingly giving the agent some kind of memory.`),z.forEach(t),gr=m(e),he=l(e,"H3",{class:!0});var pp=p(he);qe=l(pp,"A",{id:!0,class:!0,href:!0});var xc=p(qe);ls=l(xc,"SPAN",{});var Tc=p(ls);c(gt.$$.fragment,Tc),Tc.forEach(t),xc.forEach(t),hh=m(pp),ps=l(pp,"SPAN",{});var Ac=p(ps);mh=n(Ac,"Structure of the prompt"),Ac.forEach(t),pp.forEach(t),wr=m(e),Bo=l(e,"P",{});var Pc=p(Bo);fh=n(Pc,`Let\u2019s take a closer look at how the prompt is structured to understand how it can be best customized.
The prompt is structured broadly into four parts.`),Pc.forEach(t),_r=m(e),G=l(e,"UL",{});var ht=p(G);hs=l(ht,"LI",{});var jc=p(hs);ms=l(jc,"OL",{});var Ic=p(ms);fs=l(Ic,"LI",{});var Cc=p(fs);uh=n(Cc,"Introduction: how the agent should behave, explanation of the concept of tools."),Cc.forEach(t),Ic.forEach(t),jc.forEach(t),dh=m(ht),us=l(ht,"LI",{});var Dc=p(us);Ro=l(Dc,"OL",{start:!0});var Hc=p(Ro);wt=l(Hc,"LI",{});var hp=p(wt);ch=n(hp,"Description of all the tools. This is defined by a "),ds=l(hp,"CODE",{});var Oc=p(ds);gh=n(Oc,"<<all_tools>>"),Oc.forEach(t),wh=n(hp," token that is dynamically replaced at runtime with the tools defined/chosen by the user."),hp.forEach(t),Hc.forEach(t),Dc.forEach(t),_h=m(ht),cs=l(ht,"LI",{});var Lc=p(cs);Yo=l(Lc,"OL",{start:!0});var Sc=p(Yo);gs=l(Sc,"LI",{});var Nc=p(gs);vh=n(Nc,"A set of examples of tasks and their solution"),Nc.forEach(t),Sc.forEach(t),Lc.forEach(t),$h=m(ht),ws=l(ht,"LI",{});var Wc=p(ws);Qo=l(Wc,"OL",{start:!0});var zc=p(Qo);_s=l(zc,"LI",{});var Mc=p(_s);bh=n(Mc,"Current example, and request for solution."),Mc.forEach(t),zc.forEach(t),Wc.forEach(t),ht.forEach(t),vr=m(e),xe=l(e,"P",{});var mp=p(xe);yh=n(mp,"To better understand each part, let\u2019s look at a shortened version of how the "),vs=l(mp,"CODE",{});var Fc=p(vs);kh=n(Fc,"run"),Fc.forEach(t),Eh=n(mp," prompt can look like:"),mp.forEach(t),$r=m(e),c(_t.$$.fragment,e),br=m(e),Te=l(e,"P",{});var fp=p(Te);qh=n(fp,"The introduction (the text before "),$s=l(fp,"EM",{});var Gc=p($s);xh=n(Gc,"\u201CTools:\u201D"),Gc.forEach(t),Th=n(fp,`) explains precisely how the model shall behave and what it should do.
This part most likely does not need to be customized as the agent shall always behave the same way.`),fp.forEach(t),yr=m(e),L=l(e,"P",{});var se=p(L);Ah=n(se,"The second part (the bullet points below "),bs=l(se,"EM",{});var Uc=p(bs);Ph=n(Uc,"\u201CTools\u201D"),Uc.forEach(t),jh=n(se,") is dynamically added upon calling "),ys=l(se,"CODE",{});var Bc=p(ys);Ih=n(Bc,"run"),Bc.forEach(t),Ch=n(se," or "),ks=l(se,"CODE",{});var Rc=p(ks);Dh=n(Rc,"chat"),Rc.forEach(t),Hh=n(se,`. There are
exactly as many bullet points as there are tools in `),Es=l(se,"CODE",{});var Yc=p(Es);Oh=n(Yc,"agent.toolbox"),Yc.forEach(t),Lh=n(se,` and each bullet point consists of the name
and description of the tool:`),se.forEach(t),kr=m(e),c(vt.$$.fragment,e),Er=m(e),Jo=l(e,"P",{});var Qc=p(Jo);Sh=n(Qc,"Let\u2019s verify this quickly by loading the document_qa tool and printing out the name and description."),Qc.forEach(t),qr=m(e),c($t.$$.fragment,e),xr=m(e),Ko=l(e,"P",{});var Jc=p(Ko);Nh=n(Jc,"which gives:"),Jc.forEach(t),Tr=m(e),c(bt.$$.fragment,e),Ar=m(e),Vo=l(e,"P",{});var Kc=p(Vo);Wh=n(Kc,`We can see that the tool name is short and precise. The description includes two parts, the first explaining
what the tool does and the second states what input arguments and return values are expected.`),Kc.forEach(t),Pr=m(e),Xo=l(e,"P",{});var Vc=p(Xo);zh=n(Vc,`A good tool name and tool description are very important for the agent to correctly use it. Note that the only
information the agent has about the tool is its name and description, so one should make sure that both
are precisely written and match the style of the existing tools in the toolbox. In particular make sure the description
mentions all the arguments expected by name in code-style, along with the expected type and a description of what they
are.`),Vc.forEach(t),jr=m(e),c(Ae.$$.fragment,e),Ir=m(e),Zo=l(e,"P",{});var Xc=p(Zo);Mh=n(Xc,`The third part includes a set of curated examples that show the agent exactly what code it should produce
for what kind of user request. The large language models empowering the agent are extremely good at
recognizing patterns in a prompt and repeating the pattern with new data. Therefore, it is very important
that the examples are written in a way that maximizes the likelihood of the agent to generating correct,
executable code in practice.`),Xc.forEach(t),Cr=m(e),ea=l(e,"P",{});var Zc=p(ea);Fh=n(Zc,"Let\u2019s have a look at one example:"),Zc.forEach(t),Dr=m(e),c(yt.$$.fragment,e),Hr=m(e),ta=l(e,"P",{});var eg=p(ta);Gh=n(eg,`The pattern the model is prompted to repeat has three parts: The task statement, the agent\u2019s explanation of
what it intends to do, and finally the generated code. Every example that is part of the prompt has this exact
pattern, thus making sure that the agent will reproduce exactly the same pattern when generating new tokens.`),eg.forEach(t),Or=m(e),Pe=l(e,"P",{});var up=p(Pe);Uh=n(up,`The prompt examples are curated by the Transformers team and rigorously evaluated on a set of
`),kt=l(up,"A",{href:!0,rel:!0});var tg=p(kt);Bh=n(tg,"problem statements"),tg.forEach(t),Rh=n(up,`
to ensure that the agent\u2019s prompt is as good as possible to solve real use cases of the agent.`),up.forEach(t),Lr=m(e),oa=l(e,"P",{});var og=p(oa);Yh=n(og,"The final part of the prompt corresponds to:"),og.forEach(t),Sr=m(e),c(Et.$$.fragment,e),Nr=m(e),aa=l(e,"P",{});var ag=p(aa);Qh=n(ag,`is a final and unfinished example that the agent is tasked to complete. The unfinished example
is dynamically created based on the actual user input. For the above example, the user ran:`),ag.forEach(t),Wr=m(e),c(qt.$$.fragment,e),zr=m(e),J=l(e,"P",{});var Ga=p(J);Jh=n(Ga,"The user input - "),qs=l(Ga,"EM",{});var sg=p(qs);Kh=n(sg,"a.k.a"),sg.forEach(t),Vh=n(Ga," the task: "),xs=l(Ga,"EM",{});var ng=p(xs);Xh=n(ng,"\u201CDraw me a picture of rivers and lakes\u201D"),ng.forEach(t),Zh=n(Ga,` is cast into the
prompt template: \u201CTask: <task> \\n\\n I will use the following\u201D. This sentence makes up the final lines of the
prompt the agent is conditioned on, therefore strongly influencing the agent to finish the example
exactly in the same way it was previously done in the examples.`),Ga.forEach(t),Mr=m(e),je=l(e,"P",{});var dp=p(je);em=n(dp,`Without going into too much detail, the chat template has the same prompt structure with the
examples having a slightly different style, `),Ts=l(dp,"EM",{});var rg=p(Ts);tm=n(rg,"e.g."),rg.forEach(t),om=n(dp,":"),dp.forEach(t),Fr=m(e),c(xt.$$.fragment,e),Gr=m(e),P=l(e,"P",{});var C=p(P);am=n(C,"Contrary, to the examples of the "),As=l(C,"CODE",{});var ig=p(As);sm=n(ig,"run"),ig.forEach(t),nm=n(C," prompt, each "),Ps=l(C,"CODE",{});var lg=p(Ps);rm=n(lg,"chat"),lg.forEach(t),im=n(C,` prompt example has one or more exchanges between the
`),js=l(C,"EM",{});var pg=p(js);lm=n(pg,"Human"),pg.forEach(t),pm=n(C," and the "),Is=l(C,"EM",{});var hg=p(Is);hm=n(hg,"Assistant"),hg.forEach(t),mm=n(C,". Every exchange is structured similarly to the example of the "),Cs=l(C,"CODE",{});var mg=p(Cs);fm=n(mg,"run"),mg.forEach(t),um=n(C,` prompt.
The user\u2019s input is appended to behind `),Ds=l(C,"EM",{});var fg=p(Ds);dm=n(fg,"Human:"),fg.forEach(t),cm=n(C,` and the agent is prompted to first generate what needs to be done
before generating code. An exchange can be based on previous exchanges, therefore allowing the user to refer
to past exchanges as is done `),Hs=l(C,"EM",{});var ug=p(Hs);gm=n(ug,"e.g."),ug.forEach(t),wm=n(C," above by the user\u2019s input of \u201CI tried "),Os=l(C,"STRONG",{});var dg=p(Os);_m=n(dg,"this"),dg.forEach(t),vm=n(C,` code\u201D refers to the
previously generated code of the agent.`),C.forEach(t),Ur=m(e),K=l(e,"P",{});var Ua=p(K);$m=n(Ua,"Upon running "),Ls=l(Ua,"CODE",{});var cg=p(Ls);bm=n(cg,".chat"),cg.forEach(t),ym=n(Ua,", the user\u2019s input or "),Ss=l(Ua,"EM",{});var gg=p(Ss);km=n(gg,"task"),gg.forEach(t),Em=n(Ua," is cast into an unfinished example of the form:"),Ua.forEach(t),Br=m(e),c(Tt.$$.fragment,e),Rr=m(e),U=l(e,"P",{});var mt=p(U);qm=n(mt,"which the agent completes. Contrary to the "),Ns=l(mt,"CODE",{});var wg=p(Ns);xm=n(wg,"run"),wg.forEach(t),Tm=n(mt," command, the "),Ws=l(mt,"CODE",{});var _g=p(Ws);Am=n(_g,"chat"),_g.forEach(t),Pm=n(mt,` command then appends the completed example
to the prompt, thus giving the agent more context for the next `),zs=l(mt,"CODE",{});var vg=p(zs);jm=n(vg,"chat"),vg.forEach(t),Im=n(mt," turn."),mt.forEach(t),Yr=m(e),sa=l(e,"P",{});var $g=p(sa);Cm=n($g,"Great now that we know how the prompt is structured, let\u2019s see how we can customize it!"),$g.forEach(t),Qr=m(e),me=l(e,"H3",{class:!0});var cp=p(me);Ie=l(cp,"A",{id:!0,class:!0,href:!0});var bg=p(Ie);Ms=l(bg,"SPAN",{});var yg=p(Ms);c(At.$$.fragment,yg),yg.forEach(t),bg.forEach(t),Dm=m(cp),Fs=l(cp,"SPAN",{});var kg=p(Fs);Hm=n(kg,"Writing good user inputs"),kg.forEach(t),cp.forEach(t),Jr=m(e),na=l(e,"P",{});var Eg=p(na);Om=n(Eg,`While large language models are getting better and better at understanding users\u2019 intentions, it helps
enormously to be as precise as possible to help the agent pick the correct task. What does it mean to be
as precise as possible?`),Eg.forEach(t),Kr=m(e),ra=l(e,"P",{});var qg=p(ra);Lm=n(qg,`The agent sees a list of tool names and their description in its prompt. The more tools are added the
more difficult it becomes for the agent to choose the correct tool and it\u2019s even more difficult to choose
the correct sequences of tools to run. Let\u2019s look at a common failure case, here we will only return
the code to analyze it.`),qg.forEach(t),Vr=m(e),c(Pt.$$.fragment,e),Xr=m(e),ia=l(e,"P",{});var xg=p(ia);Sm=n(xg,"gives:"),xg.forEach(t),Zr=m(e),c(jt.$$.fragment,e),ei=m(e),la=l(e,"P",{});var Tg=p(la);Nm=n(Tg,`which is probably not what we wanted. Instead, it is more likely that we want an image of a tree to be generated.
To steer the agent more towards using a specific tool it can therefore be very helpful to use important keywords that
are present in the tool\u2019s name and description. Let\u2019s have a look.`),Tg.forEach(t),ti=m(e),c(It.$$.fragment,e),oi=m(e),c(Ct.$$.fragment,e),ai=m(e),pa=l(e,"P",{});var Ag=p(pa);Wm=n(Ag,"The name and description make use of the keywords \u201Cimage\u201D, \u201Cprompt\u201D, \u201Ccreate\u201D and \u201Cgenerate\u201D. Using these words will most likely work better here. Let\u2019s refine our prompt a bit."),Ag.forEach(t),si=m(e),c(Dt.$$.fragment,e),ni=m(e),ha=l(e,"P",{});var Pg=p(ha);zm=n(Pg,"gives:"),Pg.forEach(t),ri=m(e),c(Ht.$$.fragment,e),ii=m(e),ma=l(e,"P",{});var jg=p(ma);Mm=n(jg,`Much better! That looks more like what we want. In short, when you notice that the agent struggles to
correctly map your task to the correct tools, try looking up the most pertinent keywords of the tool\u2019s name
and description and try refining your task request with it.`),jg.forEach(t),li=m(e),fe=l(e,"H3",{class:!0});var gp=p(fe);Ce=l(gp,"A",{id:!0,class:!0,href:!0});var Ig=p(Ce);Gs=l(Ig,"SPAN",{});var Cg=p(Gs);c(Ot.$$.fragment,Cg),Cg.forEach(t),Ig.forEach(t),Fm=m(gp),Us=l(gp,"SPAN",{});var Dg=p(Us);Gm=n(Dg,"Customizing the tool descriptions"),Dg.forEach(t),gp.forEach(t),pi=m(e),De=l(e,"P",{});var wp=p(De);Um=n(wp,`As we\u2019ve seen before the agent has access to each of the tools\u2019 names and descriptions. The base tools
should have very precise names and descriptions, however, you might find that it could help to change the
the description or name of a tool for your specific use case. This might become especially important
when you\u2019ve added multiple tools that are very similar or if you want to use your agent only for a certain
domain, `),Bs=l(wp,"EM",{});var Hg=p(Bs);Bm=n(Hg,"e.g."),Hg.forEach(t),Rm=n(wp," image generation and transformations."),wp.forEach(t),hi=m(e),Lt=l(e,"P",{});var hc=p(Lt);Ym=n(hc,`A common problem is that the agent confuses image generation with image transformation/modification when
used a lot for image generation tasks, `),Rs=l(hc,"EM",{});var Og=p(Rs);Qm=n(Og,"e.g."),Og.forEach(t),hc.forEach(t),mi=m(e),c(St.$$.fragment,e),fi=m(e),fa=l(e,"P",{});var Lg=p(fa);Jm=n(Lg,"returns"),Lg.forEach(t),ui=m(e),c(Nt.$$.fragment,e),di=m(e),V=l(e,"P",{});var Ba=p(V);Km=n(Ba,`which is probably not exactly what we want here. It seems like the agent has a difficult time
to understand the difference between `),Ys=l(Ba,"CODE",{});var Sg=p(Ys);Vm=n(Sg,"image_generator"),Sg.forEach(t),Xm=n(Ba," and "),Qs=l(Ba,"CODE",{});var Ng=p(Qs);Zm=n(Ng,"image_transformer"),Ng.forEach(t),ef=n(Ba," and often uses the two together."),Ba.forEach(t),ci=m(e),X=l(e,"P",{});var Ra=p(X);tf=n(Ra,"We can help the agent here by changing the tool name and description of "),Js=l(Ra,"CODE",{});var Wg=p(Js);of=n(Wg,"image_transformer"),Wg.forEach(t),af=n(Ra,". Let\u2019s instead call it "),Ks=l(Ra,"CODE",{});var zg=p(Ks);sf=n(zg,"modifier"),zg.forEach(t),nf=n(Ra,`
to disassociate it a bit from \u201Cimage\u201D and \u201Cprompt\u201D:`),Ra.forEach(t),gi=m(e),c(Wt.$$.fragment,e),wi=m(e),ua=l(e,"P",{});var Mg=p(ua);rf=n(Mg,"Now \u201Cmodify\u201D is a strong cue to use the new image processor which should help with the above prompt. Let\u2019s run it again."),Mg.forEach(t),_i=m(e),c(zt.$$.fragment,e),vi=m(e),da=l(e,"P",{});var Fg=p(da);lf=n(Fg,"Now we\u2019re getting:"),Fg.forEach(t),$i=m(e),c(Mt.$$.fragment,e),bi=m(e),ca=l(e,"P",{});var Gg=p(ca);pf=n(Gg,"which is definitely closer to what we had in mind! However, we want to have both the house and car in the same image. Steering the task more toward single image generation should help:"),Gg.forEach(t),yi=m(e),c(Ft.$$.fragment,e),ki=m(e),c(Gt.$$.fragment,e),Ei=m(e),c(He.$$.fragment,e),qi=m(e),ue=l(e,"H3",{class:!0});var _p=p(ue);Oe=l(_p,"A",{id:!0,class:!0,href:!0});var Ug=p(Oe);Vs=l(Ug,"SPAN",{});var Bg=p(Vs);c(Ut.$$.fragment,Bg),Bg.forEach(t),Ug.forEach(t),hf=m(_p),Xs=l(_p,"SPAN",{});var Rg=p(Xs);mf=n(Rg,"Customizing the whole prompt"),Rg.forEach(t),_p.forEach(t),xi=m(e),Z=l(e,"P",{});var Ya=p(Z);ff=n(Ya,"To give the user maximum flexibility, the whole prompt template as explained in "),ga=l(Ya,"A",{href:!0});var Yg=p(ga);uf=n(Yg,"above"),Yg.forEach(t),df=n(Ya,`
can be overwritten by the user. In this case make sure that your custom prompt includes an introduction section,
a tool section, an example section, and an unfinished example section. If you want to overwrite the `),Zs=l(Ya,"CODE",{});var Qg=p(Zs);cf=n(Qg,"run"),Qg.forEach(t),gf=n(Ya,` prompt template,
you can do as follows:`),Ya.forEach(t),Ti=m(e),c(Bt.$$.fragment,e),Ai=m(e),c(Le.$$.fragment,e),Pi=m(e),ee=l(e,"P",{});var Qa=p(ee);wf=n(Qa,"Similarly, one can overwrite the "),en=l(Qa,"CODE",{});var Jg=p(en);_f=n(Jg,"chat"),Jg.forEach(t),vf=n(Qa," prompt template. Note that the "),tn=l(Qa,"CODE",{});var Kg=p(tn);$f=n(Kg,"chat"),Kg.forEach(t),bf=n(Qa," mode always uses the following format for the exchanges:"),Qa.forEach(t),ji=m(e),c(Rt.$$.fragment,e),Ii=m(e),te=l(e,"P",{});var Ja=p(te);yf=n(Ja,"Therefore it is important that the examples of the custom "),on=l(Ja,"CODE",{});var Vg=p(on);kf=n(Vg,"chat"),Vg.forEach(t),Ef=n(Ja,` prompt template also make use of this format.
You can overwrite the `),an=l(Ja,"CODE",{});var Xg=p(an);qf=n(Xg,"chat"),Xg.forEach(t),xf=n(Ja," template at instantiation as follows."),Ja.forEach(t),Ci=m(e),c(Yt.$$.fragment,e),Di=m(e),c(Se.$$.fragment,e),Hi=m(e),de=l(e,"H2",{class:!0});var vp=p(de);Ne=l(vp,"A",{id:!0,class:!0,href:!0});var Zg=p(Ne);sn=l(Zg,"SPAN",{});var ew=p(sn);c(Qt.$$.fragment,ew),ew.forEach(t),Zg.forEach(t),Tf=m(vp),nn=l(vp,"SPAN",{});var tw=p(nn);Af=n(tw,"Using custom tools"),tw.forEach(t),vp.forEach(t),Oi=m(e),wa=l(e,"P",{});var ow=p(wa);Pf=n(ow,"In this section, we\u2019ll be leveraging two existing custom tools that are specific to image generation:"),ow.forEach(t),Li=m(e),We=l(e,"UL",{});var $p=p(We);ce=l($p,"LI",{});var Ka=p(ce);jf=n(Ka,"We replace "),Jt=l(Ka,"A",{href:!0,rel:!0});var aw=p(Jt);If=n(aw,"huggingface-tools/image-transformation"),aw.forEach(t),Cf=n(Ka,`,
with `),Kt=l(Ka,"A",{href:!0,rel:!0});var sw=p(Kt);Df=n(sw,"diffusers/controlnet-canny-tool"),sw.forEach(t),Hf=n(Ka,`
to allow for more image modifications.`),Ka.forEach(t),Of=m($p),Vt=l($p,"LI",{});var bp=p(Vt);Lf=n(bp,`We add a new tool for image upscaling to the default toolbox:
`),Xt=l(bp,"A",{href:!0,rel:!0});var nw=p(Xt);Sf=n(nw,"diffusers/latent-upscaler-tool"),nw.forEach(t),Nf=n(bp," replace the existing image-transformation tool."),bp.forEach(t),$p.forEach(t),Si=m(e),ze=l(e,"P",{});var yp=p(ze);Wf=n(yp,"We\u2019ll start by loading the custom tools with the convenient "),_a=l(yp,"A",{href:!0});var rw=p(_a);zf=n(rw,"load_tool()"),rw.forEach(t),Mf=n(yp," function:"),yp.forEach(t),Ni=m(e),c(Zt.$$.fragment,e),Wi=m(e),Me=l(e,"P",{});var kp=p(Me);Ff=n(kp,`Upon adding custom tools to an agent, the tools\u2019 descriptions and names are automatically
included in the agents\u2019 prompts. Thus, it is imperative that custom tools have
a well-written description and name in order for the agent to understand how to use them.
Let\u2019s take a look at the description and name of `),rn=l(kp,"CODE",{});var iw=p(rn);Gf=n(iw,"controlnet_transformer"),iw.forEach(t),Uf=n(kp,":"),kp.forEach(t),zi=m(e),c(eo.$$.fragment,e),Mi=m(e),va=l(e,"P",{});var lw=p(va);Bf=n(lw,"gives"),lw.forEach(t),Fi=m(e),c(to.$$.fragment,e),Gi=m(e),B=l(e,"P",{});var ft=p(B);Rf=n(ft,"The name and description are accurate and fit the style of the "),$a=l(ft,"A",{href:!0});var pw=p($a);Yf=n(pw,"curated set of tools"),pw.forEach(t),Qf=n(ft,`.
Next, let\u2019s instantiate an agent with `),ln=l(ft,"CODE",{});var hw=p(ln);Jf=n(hw,"controlnet_transformer"),hw.forEach(t),Kf=n(ft," and "),pn=l(ft,"CODE",{});var mw=p(pn);Vf=n(mw,"upscaler"),mw.forEach(t),Xf=n(ft,":"),ft.forEach(t),Ui=m(e),c(oo.$$.fragment,e),Bi=m(e),ba=l(e,"P",{});var fw=p(ba);Zf=n(fw,"This command should give you the following info:"),fw.forEach(t),Ri=m(e),c(ao.$$.fragment,e),Yi=m(e),Fe=l(e,"P",{});var Ep=p(Fe);eu=n(Ep,"The set of curated tools already has an "),hn=l(Ep,"CODE",{});var uw=p(hn);tu=n(uw,"image_transformer"),uw.forEach(t),ou=n(Ep," tool which is hereby replaced with our custom tool."),Ep.forEach(t),Qi=m(e),c(Ge.$$.fragment,e),Ji=m(e),oe=l(e,"P",{});var Va=p(oe);au=n(Va,"The upscaler tool was given the name "),mn=l(Va,"CODE",{});var dw=p(mn);su=n(dw,"image_upscaler"),dw.forEach(t),nu=n(Va,` which is not yet present in the default toolbox and is therefore simply added to the list of tools.
You can always have a look at the toolbox that is currently available to the agent via the `),fn=l(Va,"CODE",{});var cw=p(fn);ru=n(cw,"agent.toolbox"),cw.forEach(t),iu=n(Va," attribute:"),Va.forEach(t),Ki=m(e),c(so.$$.fragment,e),Vi=m(e),c(no.$$.fragment,e),Xi=m(e),Ue=l(e,"P",{});var qp=p(Ue);lu=n(qp,"Note how "),un=l(qp,"CODE",{});var gw=p(un);pu=n(gw,"image_upscaler"),gw.forEach(t),hu=n(qp," is now part of the agents\u2019 toolbox."),qp.forEach(t),Zi=m(e),Be=l(e,"P",{});var xp=p(Be);mu=n(xp,"Let\u2019s now try out the new tools! We will re-use the image we generated in "),ya=l(xp,"A",{href:!0});var ww=p(ya);fu=n(ww,"Transformers Agents Quickstart"),ww.forEach(t),uu=n(xp,"."),xp.forEach(t),el=m(e),c(ro.$$.fragment,e),tl=m(e),io=l(e,"IMG",{src:!0,width:!0}),ol=m(e),ka=l(e,"P",{});var _w=p(ka);du=n(_w,"Let\u2019s transform the image into a beautiful winter landscape:"),_w.forEach(t),al=m(e),c(lo.$$.fragment,e),sl=m(e),c(po.$$.fragment,e),nl=m(e),ho=l(e,"IMG",{src:!0,width:!0}),rl=m(e),Ea=l(e,"P",{});var vw=p(Ea);cu=n(vw,`The new image processing tool is based on ControlNet which can make very strong modifications to the image.
By default the image processing tool returns an image of size 512x512 pixels. Let\u2019s see if we can upscale it.`),vw.forEach(t),il=m(e),c(mo.$$.fragment,e),ll=m(e),c(fo.$$.fragment,e),pl=m(e),uo=l(e,"IMG",{src:!0,width:!0}),hl=m(e),qa=l(e,"P",{});var $w=p(qa);gu=n($w,`The agent automatically mapped our prompt \u201CUpscale the image\u201D to the just added upscaler tool purely based on the description and name of the upscaler tool
and was able to correctly run it.`),$w.forEach(t),ml=m(e),xa=l(e,"P",{});var bw=p(xa);wu=n(bw,"Next, let\u2019s have a look at how you can create a new custom tool."),bw.forEach(t),fl=m(e),ge=l(e,"H3",{class:!0});var Tp=p(ge);Re=l(Tp,"A",{id:!0,class:!0,href:!0});var yw=p(Re);dn=l(yw,"SPAN",{});var kw=p(dn);c(co.$$.fragment,kw),kw.forEach(t),yw.forEach(t),_u=m(Tp),cn=l(Tp,"SPAN",{});var Ew=p(cn);vu=n(Ew,"Adding new tools"),Ew.forEach(t),Tp.forEach(t),ul=m(e),Ta=l(e,"P",{});var qw=p(Ta);$u=n(qw,"In this section, we show how to create a new tool that can be added to the agent."),qw.forEach(t),dl=m(e),we=l(e,"H4",{class:!0});var Ap=p(we);Ye=l(Ap,"A",{id:!0,class:!0,href:!0});var xw=p(Ye);gn=l(xw,"SPAN",{});var Tw=p(gn);c(go.$$.fragment,Tw),Tw.forEach(t),xw.forEach(t),bu=m(Ap),wn=l(Ap,"SPAN",{});var Aw=p(wn);yu=n(Aw,"Creating a new tool"),Aw.forEach(t),Ap.forEach(t),cl=m(e),Aa=l(e,"P",{});var Pw=p(Aa);ku=n(Pw,`We\u2019ll first start by creating a tool. We\u2019ll add the not-so-useful yet fun task of fetching the model on the Hugging Face
Hub with the most downloads for a given task.`),Pw.forEach(t),gl=m(e),Pa=l(e,"P",{});var jw=p(Pa);Eu=n(jw,"We can do that with the following code:"),jw.forEach(t),wl=m(e),c(wo.$$.fragment,e),_l=m(e),S=l(e,"P",{});var ne=p(S);qu=n(ne,"For the task "),_n=l(ne,"CODE",{});var Iw=p(_n);xu=n(Iw,"text-classification"),Iw.forEach(t),Tu=n(ne,", this returns "),vn=l(ne,"CODE",{});var Cw=p(vn);Au=n(Cw,"'facebook/bart-large-mnli'"),Cw.forEach(t),Pu=n(ne,", for "),$n=l(ne,"CODE",{});var Dw=p($n);ju=n(Dw,"translation"),Dw.forEach(t),Iu=n(ne," it returns "),bn=l(ne,"CODE",{});var Hw=p(bn);Cu=n(Hw,"'t5-base"),Hw.forEach(t),Du=n(ne,"."),ne.forEach(t),vl=m(e),Qe=l(e,"P",{});var Pp=p(Qe);Hu=n(Pp,"How do we convert this to a tool that the agent can leverage? All tools depend on the superclass "),yn=l(Pp,"CODE",{});var Ow=p(yn);Ou=n(Ow,"Tool"),Ow.forEach(t),Lu=n(Pp,` that holds the
main attributes necessary. We\u2019ll create a class that inherits from it:`),Pp.forEach(t),$l=m(e),c(_o.$$.fragment,e),bl=m(e),ja=l(e,"P",{});var Lw=p(ja);Su=n(Lw,"This class has a few needs:"),Lw.forEach(t),yl=m(e),R=l(e,"UL",{});var ut=p(R);_e=l(ut,"LI",{});var Xa=p(_e);Nu=n(Xa,"An attribute "),kn=l(Xa,"CODE",{});var Sw=p(kn);Wu=n(Sw,"name"),Sw.forEach(t),zu=n(Xa,`, which corresponds to the name of the tool itself. To be in tune with other tools which have a
performative name, we\u2019ll name it `),En=l(Xa,"CODE",{});var Nw=p(En);Mu=n(Nw,"model_download_counter"),Nw.forEach(t),Fu=n(Xa,"."),Xa.forEach(t),Gu=m(ut),vo=l(ut,"LI",{});var jp=p(vo);Uu=n(jp,"An attribute "),qn=l(jp,"CODE",{});var Ww=p(qn);Bu=n(Ww,"description"),Ww.forEach(t),Ru=n(jp,", which will be used to populate the prompt of the agent."),jp.forEach(t),Yu=m(ut),N=l(ut,"LI",{});var Y=p(N);xn=l(Y,"CODE",{});var zw=p(xn);Qu=n(zw,"inputs"),zw.forEach(t),Ju=n(Y," and "),Tn=l(Y,"CODE",{});var Mw=p(Tn);Ku=n(Mw,"outputs"),Mw.forEach(t),Vu=n(Y,` attributes. Defining this will help the python interpreter make educated choices about types,
and will allow for a gradio-demo to be spawned when we push our tool to the Hub. They\u2019re both a list of expected
values, which can be `),An=l(Y,"CODE",{});var Fw=p(An);Xu=n(Fw,"text"),Fw.forEach(t),Zu=n(Y,", "),Pn=l(Y,"CODE",{});var Gw=p(Pn);ed=n(Gw,"image"),Gw.forEach(t),td=n(Y,", or "),jn=l(Y,"CODE",{});var Uw=p(jn);od=n(Uw,"audio"),Uw.forEach(t),ad=n(Y,"."),Y.forEach(t),sd=m(ut),$o=l(ut,"LI",{});var Ip=p($o);nd=n(Ip,"A "),In=l(Ip,"CODE",{});var Bw=p(In);rd=n(Bw,"__call__"),Bw.forEach(t),id=n(Ip," method which contains the inference code. This is the code we\u2019ve played with above!"),Ip.forEach(t),ut.forEach(t),kl=m(e),Ia=l(e,"P",{});var Rw=p(Ia);ld=n(Rw,"Here\u2019s what our class looks like now:"),Rw.forEach(t),El=m(e),c(bo.$$.fragment,e),ql=m(e),Je=l(e,"P",{});var Cp=p(Je);pd=n(Cp,`We now have our tool handy. Save it in a file and import it from your main script. Let\u2019s name this file
`),Cn=l(Cp,"CODE",{});var Yw=p(Cn);hd=n(Yw,"model_downloads.py"),Yw.forEach(t),md=n(Cp,", so the resulting import code looks like this:"),Cp.forEach(t),xl=m(e),c(yo.$$.fragment,e),Tl=m(e),ae=l(e,"P",{});var Za=p(ae);fd=n(Za,`In order to let others benefit from it and for simpler initialization, we recommend pushing it to the Hub under your
namespace. To do so, just call `),Dn=l(Za,"CODE",{});var Qw=p(Dn);ud=n(Qw,"push_to_hub"),Qw.forEach(t),dd=n(Za," on the "),Hn=l(Za,"CODE",{});var Jw=p(Hn);cd=n(Jw,"tool"),Jw.forEach(t),gd=n(Za," variable:"),Za.forEach(t),Al=m(e),c(ko.$$.fragment,e),Pl=m(e),Ca=l(e,"P",{});var Kw=p(Ca);wd=n(Kw,"You now have your code on the Hub! Let\u2019s take a look at the final step, which is to have the agent use it."),Kw.forEach(t),jl=m(e),ve=l(e,"H4",{class:!0});var Dp=p(ve);Ke=l(Dp,"A",{id:!0,class:!0,href:!0});var Vw=p(Ke);On=l(Vw,"SPAN",{});var Xw=p(On);c(Eo.$$.fragment,Xw),Xw.forEach(t),Vw.forEach(t),_d=m(Dp),Ln=l(Dp,"SPAN",{});var Zw=p(Ln);vd=n(Zw,"Having the agent use the tool"),Zw.forEach(t),Dp.forEach(t),Il=m(e),Da=l(e,"P",{});var e_=p(Da);$d=n(e_,"We now have our tool that lives on the Hub which can be instantiated as such (change the user name for your tool):"),e_.forEach(t),Cl=m(e),c(qo.$$.fragment,e),Dl=m(e),Ve=l(e,"P",{});var Hp=p(Ve);bd=n(Hp,"In order to use it in the agent, simply pass it in the "),Sn=l(Hp,"CODE",{});var t_=p(Sn);yd=n(t_,"additional_tools"),t_.forEach(t),kd=n(Hp," parameter of the agent initialization method:"),Hp.forEach(t),Hl=m(e),c(xo.$$.fragment,e),Ol=m(e),Ha=l(e,"P",{});var o_=p(Ha);Ed=n(o_,"which outputs the following:"),o_.forEach(t),Ll=m(e),c(To.$$.fragment,e),Sl=m(e),Oa=l(e,"P",{});var a_=p(Oa);qd=n(a_,"and generates the following audio."),a_.forEach(t),Nl=m(e),Xe=l(e,"TABLE",{});var Op=p(Xe);Nn=l(Op,"THEAD",{});var s_=p(Nn);Wn=l(s_,"TR",{});var n_=p(Wn);zn=l(n_,"TH",{});var r_=p(zn);Mn=l(r_,"STRONG",{});var i_=p(Mn);xd=n(i_,"Audio"),i_.forEach(t),r_.forEach(t),n_.forEach(t),s_.forEach(t),Td=m(Op),Fn=l(Op,"TBODY",{});var l_=p(Fn);Gn=l(l_,"TR",{});var p_=p(Gn);Un=l(p_,"TD",{});var h_=p(Un);La=l(h_,"AUDIO",{});var m_=p(La);Sa=l(m_,"SOURCE",{src:!0,type:!0}),m_.forEach(t),h_.forEach(t),p_.forEach(t),l_.forEach(t),Op.forEach(t),Wl=m(e),c(Ze.$$.fragment,e),zl=m(e),$e=l(e,"H3",{class:!0});var Lp=p($e);et=l(Lp,"A",{id:!0,class:!0,href:!0});var f_=p(et);Bn=l(f_,"SPAN",{});var u_=p(Bn);c(Ao.$$.fragment,u_),u_.forEach(t),f_.forEach(t),Ad=m(Lp),Rn=l(Lp,"SPAN",{});var d_=p(Rn);Pd=n(d_,"Replacing existing tools"),d_.forEach(t),Lp.forEach(t),Ml=m(e),Na=l(e,"P",{});var c_=p(Na);jd=n(c_,"Replacing existing tools can be done simply by assigning a new item to the agent\u2019s toolbox. Here\u2019s how one would do so:"),c_.forEach(t),Fl=m(e),c(Po.$$.fragment,e),Gl=m(e),c(tt.$$.fragment,e),Ul=m(e),be=l(e,"H2",{class:!0});var Sp=p(be);ot=l(Sp,"A",{id:!0,class:!0,href:!0});var g_=p(ot);Yn=l(g_,"SPAN",{});var w_=p(Yn);c(jo.$$.fragment,w_),w_.forEach(t),g_.forEach(t),Id=m(Sp),Qn=l(Sp,"SPAN",{});var __=p(Qn);Cd=n(__,"Leveraging gradio-tools"),__.forEach(t),Sp.forEach(t),Bl=m(e),Io=l(e,"P",{});var mc=p(Io);Co=l(mc,"A",{href:!0,rel:!0});var v_=p(Co);Dd=n(v_,"gradio-tools"),v_.forEach(t),Hd=n(mc,` is a powerful library that allows using Hugging
Face Spaces as tools. It supports many existing Spaces as well as custom Spaces to be designed with it.`),mc.forEach(t),Rl=m(e),W=l(e,"P",{});var re=p(W);Od=n(re,"We offer support for "),Jn=l(re,"CODE",{});var $_=p(Jn);Ld=n($_,"gradio_tools"),$_.forEach(t),Sd=n(re," by using the "),Kn=l(re,"CODE",{});var b_=p(Kn);Nd=n(b_,"Tool.from_gradio"),b_.forEach(t),Wd=n(re,` method. For example, we want to take
advantage of the `),Vn=l(re,"CODE",{});var y_=p(Vn);zd=n(y_,"StableDiffusionPromptGeneratorTool"),y_.forEach(t),Md=n(re," tool offered in the "),Xn=l(re,"CODE",{});var k_=p(Xn);Fd=n(k_,"gradio-tools"),k_.forEach(t),Gd=n(re,` toolkit so as to
improve our prompts and generate better images.`),re.forEach(t),Yl=m(e),at=l(e,"P",{});var Np=p(at);Ud=n(Np,"We first import the tool from "),Zn=l(Np,"CODE",{});var E_=p(Zn);Bd=n(E_,"gradio_tools"),E_.forEach(t),Rd=n(Np," and instantiate it:"),Np.forEach(t),Ql=m(e),c(Do.$$.fragment,e),Jl=m(e),st=l(e,"P",{});var Wp=p(st);Yd=n(Wp,"We pass that instance to the "),er=l(Wp,"CODE",{});var q_=p(er);Qd=n(q_,"Tool.from_gradio"),q_.forEach(t),Jd=n(Wp," method:"),Wp.forEach(t),Kl=m(e),c(Ho.$$.fragment,e),Vl=m(e),nt=l(e,"P",{});var zp=p(nt);Kd=n(zp,`Now we can manage it exactly as we would a usual custom tool. We leverage it to improve our prompt
`),tr=l(zp,"CODE",{});var x_=p(tr);Vd=n(x_,"a rabbit wearing a space suit"),x_.forEach(t),Xd=n(zp,":"),zp.forEach(t),Xl=m(e),c(Oo.$$.fragment,e),Zl=m(e),Wa=l(e,"P",{});var T_=p(Wa);Zd=n(T_,"The model adequately leverages the tool:"),T_.forEach(t),ep=m(e),c(Lo.$$.fragment,e),tp=m(e),za=l(e,"P",{});var A_=p(za);ec=n(A_,"Before finally generating the image:"),A_.forEach(t),op=m(e),Ma=l(e,"IMG",{src:!0}),ap=m(e),c(rt.$$.fragment,e),sp=m(e),ye=l(e,"H2",{class:!0});var Mp=p(ye);it=l(Mp,"A",{id:!0,class:!0,href:!0});var P_=p(it);or=l(P_,"SPAN",{});var j_=p(or);c(So.$$.fragment,j_),j_.forEach(t),P_.forEach(t),tc=m(Mp),ar=l(Mp,"SPAN",{});var I_=p(ar);oc=n(I_,"Future compatibility with Langchain"),I_.forEach(t),Mp.forEach(t),np=m(e),lt=l(e,"P",{});var Fp=p(lt);ac=n(Fp,`We love Langchain and think it has a very compelling suite of tools. In order to handle these tools,
Langchain requires `),sr=l(Fp,"EM",{});var C_=p(sr);sc=n(C_,"textual"),C_.forEach(t),nc=n(Fp,` inputs and outputs, even when working with different modalities.
This is often the serialized version (i.e., saved to disk) of the objects.`),Fp.forEach(t),rp=m(e),Fa=l(e,"P",{});var D_=p(Fa);rc=n(D_,`This difference means that multi-modality isn\u2019t handled between transformers-agents and langchain.
We aim for this limitation to be resolved in future versions, and welcome any help from avid langchain
users to help us achieve this compatibility.`),D_.forEach(t),ip=m(e),pt=l(e,"P",{});var Gp=p(pt);ic=n(Gp,`We would love to have better support. If you would like to help, please
`),No=l(Gp,"A",{href:!0,rel:!0});var H_=p(No);lc=n(H_,"open an issue"),H_.forEach(t),pc=n(Gp," and share what you have in mind."),Gp.forEach(t),this.h()},h(){u(f,"name","hf:doc:metadata"),u(f,"content",JSON.stringify(V_)),u(b,"id","custom-tools-and-prompts"),u(b,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(b,"href","#custom-tools-and-prompts"),u($,"class","relative group"),u(Ee,"id","customizing-the-prompt"),u(Ee,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Ee,"href","#customizing-the-prompt"),u(pe,"class","relative group"),u(Fo,"href","transformers_agents"),u(Go,"href","/docs/transformers/v4.29.0/en/main_classes/agent#transformers.Agent.run"),u(Uo,"href","/docs/transformers/v4.29.0/en/main_classes/agent#transformers.Agent.chat"),u(qe,"id","structure-of-the-prompt"),u(qe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(qe,"href","#structure-of-the-prompt"),u(he,"class","relative group"),u(Ro,"start","2"),u(Yo,"start","3"),u(Qo,"start","4"),u(kt,"href","https://github.com/huggingface/transformers/blob/main/src/transformers/tools/evaluate_agent.py"),u(kt,"rel","nofollow"),u(Ie,"id","writing-good-user-inputs"),u(Ie,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Ie,"href","#writing-good-user-inputs"),u(me,"class","relative group"),u(Ce,"id","customizing-the-tool-descriptions"),u(Ce,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Ce,"href","#customizing-the-tool-descriptions"),u(fe,"class","relative group"),u(Oe,"id","customizing-the-whole-prompt"),u(Oe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Oe,"href","#customizing-the-whole-prompt"),u(ue,"class","relative group"),u(ga,"href","#structure-of-the-prompt"),u(Ne,"id","using-custom-tools"),u(Ne,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Ne,"href","#using-custom-tools"),u(de,"class","relative group"),u(Jt,"href","https://huggingface.co/spaces/huggingface-tools/image-transformation"),u(Jt,"rel","nofollow"),u(Kt,"href","https://huggingface.co/spaces/diffusers/controlnet-canny-tool"),u(Kt,"rel","nofollow"),u(Xt,"href","https://huggingface.co/spaces/diffusers/latent-upscaler-tool"),u(Xt,"rel","nofollow"),u(_a,"href","/docs/transformers/v4.29.0/en/main_classes/agent#transformers.load_tool"),u($a,"href","./transformers_agents#a-curated-set-of-tools"),u(ya,"href","./transformers_agents#single-execution-run"),fr(io.src,fc="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/rivers_and_lakes.png")||u(io,"src",fc),u(io,"width","200"),fr(ho.src,uc="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/rivers_and_lakes_winter.png")||u(ho,"src",uc),u(ho,"width","200"),fr(uo.src,dc="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/rivers_and_lakes_winter_upscale.png")||u(uo,"src",dc),u(uo,"width","400"),u(Re,"id","adding-new-tools"),u(Re,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Re,"href","#adding-new-tools"),u(ge,"class","relative group"),u(Ye,"id","creating-a-new-tool"),u(Ye,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Ye,"href","#creating-a-new-tool"),u(we,"class","relative group"),u(Ke,"id","having-the-agent-use-the-tool"),u(Ke,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Ke,"href","#having-the-agent-use-the-tool"),u(ve,"class","relative group"),fr(Sa.src,cc="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/damo.wav")||u(Sa,"src",cc),u(Sa,"type","audio/wav"),La.controls=!0,u(et,"id","replacing-existing-tools"),u(et,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(et,"href","#replacing-existing-tools"),u($e,"class","relative group"),u(ot,"id","leveraging-gradiotools"),u(ot,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(ot,"href","#leveraging-gradiotools"),u(be,"class","relative group"),u(Co,"href","https://github.com/freddyaboulton/gradio-tools"),u(Co,"rel","nofollow"),fr(Ma.src,gc="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/rabbit.png")||u(Ma,"src",gc),u(it,"id","future-compatibility-with-langchain"),u(it,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(it,"href","#future-compatibility-with-langchain"),u(ye,"class","relative group"),u(No,"href","https://github.com/huggingface/transformers/issues/new"),u(No,"rel","nofollow")},m(e,a){o(document.head,f),r(e,k,a),r(e,$,a),o($,b),o(b,x),g(E,x,null),o($,q),o($,A),o(A,H),r(e,D,a),g(O,e,a),r(e,M,a),g(j,e,a),r(e,dt,a),r(e,le,a),o(le,Mo),r(e,ur,a),r(e,Q,a),o(Q,es),o(es,Up),o(Q,Bp),o(Q,ts),o(ts,Rp),o(Q,Yp),o(Q,os),o(os,Qp),r(e,dr,a),r(e,pe,a),o(pe,Ee),o(Ee,as),g(ct,as,null),o(pe,Jp),o(pe,ss),o(ss,Kp),r(e,cr,a),r(e,I,a),o(I,Vp),o(I,Fo),o(Fo,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,ec),r(e,op,a),r(e,Ma,a),r(e,ap,a),g(rt,e,a),r(e,sp,a),r(e,ye,a),o(ye,it),o(it,or),g(So,or,null),o(ye,tc),o(ye,ar),o(ar,oc),r(e,np,a),r(e,lt,a),o(lt,ac),o(lt,sr),o(sr,sc),o(lt,nc),r(e,rp,a),r(e,Fa,a),o(Fa,rc),r(e,ip,a),r(e,pt,a),o(pt,ic),o(pt,No),o(No,lc),o(pt,pc),lp=!0},p(e,[a]){const Wo={};a&2&&(Wo.$$scope={dirty:a,ctx:e}),O.$set(Wo);const nr={};a&2&&(nr.$$scope={dirty:a,ctx:e}),j.$set(nr);const rr={};a&2&&(rr.$$scope={dirty:a,ctx:e}),Ae.$set(rr);const ir={};a&2&&(ir.$$scope={dirty:a,ctx:e}),He.$set(ir);const lr={};a&2&&(lr.$$scope={dirty:a,ctx:e}),Le.$set(lr);const ke={};a&2&&(ke.$$scope={dirty:a,ctx:e}),Se.$set(ke);const pr={};a&2&&(pr.$$scope={dirty:a,ctx:e}),Ge.$set(pr);const hr={};a&2&&(hr.$$scope={dirty:a,ctx:e}),Ze.$set(hr);const mr={};a&2&&(mr.$$scope={dirty:a,ctx:e}),tt.$set(mr);const zo={};a&2&&(zo.$$scope={dirty:a,ctx:e}),rt.$set(zo)},i(e){lp||(w(E.$$.fragment,e),w(O.$$.fragment,e),w(j.$$.fragment,e),w(ct.$$.fragment,e),w(gt.$$.fragment,e),w(_t.$$.fragment,e),w(vt.$$.fragment,e),w($t.$$.fragment,e),w(bt.$$.fragment,e),w(Ae.$$.fragment,e),w(yt.$$.fragment,e),w(Et.$$.fragment,e),w(qt.$$.fragment,e),w(xt.$$.fragment,e),w(Tt.$$.fragment,e),w(At.$$.fragment,e),w(Pt.$$.fragment,e),w(jt.$$.fragment,e),w(It.$$.fragment,e),w(Ct.$$.fragment,e),w(Dt.$$.fragment,e),w(Ht.$$.fragment,e),w(Ot.$$.fragment,e),w(St.$$.fragment,e),w(Nt.$$.fragment,e),w(Wt.$$.fragment,e),w(zt.$$.fragment,e),w(Mt.$$.fragment,e),w(Ft.$$.fragment,e),w(Gt.$$.fragment,e),w(He.$$.fragment,e),w(Ut.$$.fragment,e),w(Bt.$$.fragment,e),w(Le.$$.fragment,e),w(Rt.$$.fragment,e),w(Yt.$$.fragment,e),w(Se.$$.fragment,e),w(Qt.$$.fragment,e),w(Zt.$$.fragment,e),w(eo.$$.fragment,e),w(to.$$.fragment,e),w(oo.$$.fragment,e),w(ao.$$.fragment,e),w(Ge.$$.fragment,e),w(so.$$.fragment,e),w(no.$$.fragment,e),w(ro.$$.fragment,e),w(lo.$$.fragment,e),w(po.$$.fragment,e),w(mo.$$.fragment,e),w(fo.$$.fragment,e),w(co.$$.fragment,e),w(go.$$.fragment,e),w(wo.$$.fragment,e),w(_o.$$.fragment,e),w(bo.$$.fragment,e),w(yo.$$.fragment,e),w(ko.$$.fragment,e),w(Eo.$$.fragment,e),w(qo.$$.fragment,e),w(xo.$$.fragment,e),w(To.$$.fragment,e),w(Ze.$$.fragment,e),w(Ao.$$.fragment,e),w(Po.$$.fragment,e),w(tt.$$.fragment,e),w(jo.$$.fragment,e),w(Do.$$.fragment,e),w(Ho.$$.fragment,e),w(Oo.$$.fragment,e),w(Lo.$$.fragment,e),w(rt.$$.fragment,e),w(So.$$.fragment,e),lp=!0)},o(e){_(E.$$.fragment,e),_(O.$$.fragment,e),_(j.$$.fragment,e),_(ct.$$.fragment,e),_(gt.$$.fragment,e),_(_t.$$.fragment,e),_(vt.$$.fragment,e),_($t.$$.fragment,e),_(bt.$$.fragment,e),_(Ae.$$.fragment,e),_(yt.$$.fragment,e),_(Et.$$.fragment,e),_(qt.$$.fragment,e),_(xt.$$.fragment,e),_(Tt.$$.fragment,e),_(At.$$.fragment,e),_(Pt.$$.fragment,e),_(jt.$$.fragment,e),_(It.$$.fragment,e),_(Ct.$$.fragment,e),_(Dt.$$.fragment,e),_(Ht.$$.fragment,e),_(Ot.$$.fragment,e),_(St.$$.fragment,e),_(Nt.$$.fragment,e),_(Wt.$$.fragment,e),_(zt.$$.fragment,e),_(Mt.$$.fragment,e),_(Ft.$$.fragment,e),_(Gt.$$.fragment,e),_(He.$$.fragment,e),_(Ut.$$.fragment,e),_(Bt.$$.fragment,e),_(Le.$$.fragment,e),_(Rt.$$.fragment,e),_(Yt.$$.fragment,e),_(Se.$$.fragment,e),_(Qt.$$.fragment,e),_(Zt.$$.fragment,e),_(eo.$$.fragment,e),_(to.$$.fragment,e),_(oo.$$.fragment,e),_(ao.$$.fragment,e),_(Ge.$$.fragment,e),_(so.$$.fragment,e),_(no.$$.fragment,e),_(ro.$$.fragment,e),_(lo.$$.fragment,e),_(po.$$.fragment,e),_(mo.$$.fragment,e),_(fo.$$.fragment,e),_(co.$$.fragment,e),_(go.$$.fragment,e),_(wo.$$.fragment,e),_(_o.$$.fragment,e),_(bo.$$.fragment,e),_(yo.$$.fragment,e),_(ko.$$.fragment,e),_(Eo.$$.fragment,e),_(qo.$$.fragment,e),_(xo.$$.fragment,e),_(To.$$.fragment,e),_(Ze.$$.fragment,e),_(Ao.$$.fragment,e),_(Po.$$.fragment,e),_(tt.$$.fragment,e),_(jo.$$.fragment,e),_(Do.$$.fragment,e),_(Ho.$$.fragment,e),_(Oo.$$.fragment,e),_(Lo.$$.fragment,e),_(rt.$$.fragment,e),_(So.$$.fragment,e),lp=!1},d(e){t(f),e&&t(k),e&&t($),v(E),e&&t(D),v(O,e),e&&t(M),v(j,e),e&&t(dt),e&&t(le),e&&t(ur),e&&t(Q),e&&t(dr),e&&t(pe),v(ct),e&&t(cr),e&&t(I),e&&t(gr),e&&t(he),v(gt),e&&t(wr),e&&t(Bo),e&&t(_r),e&&t(G),e&&t(vr),e&&t(xe),e&&t($r),v(_t,e),e&&t(br),e&&t(Te),e&&t(yr),e&&t(L),e&&t(kr),v(vt,e),e&&t(Er),e&&t(Jo),e&&t(qr),v($t,e),e&&t(xr),e&&t(Ko),e&&t(Tr),v(bt,e),e&&t(Ar),e&&t(Vo),e&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),e&&t(Rl),e&&t(W),e&&t(Yl),e&&t(at),e&&t(Ql),v(Do,e),e&&t(Jl),e&&t(st),e&&t(Kl),v(Ho,e),e&&t(Vl),e&&t(nt),e&&t(Xl),v(Oo,e),e&&t(Zl),e&&t(Wa),e&&t(ep),v(Lo,e),e&&t(tp),e&&t(za),e&&t(op),e&&t(Ma),e&&t(ap),v(rt,e),e&&t(sp),e&&t(ye),v(So),e&&t(np),e&&t(lt),e&&t(rp),e&&t(Fa),e&&t(ip),e&&t(pt)}}}const V_={local:"custom-tools-and-prompts",sections:[{local:"customizing-the-prompt",sections:[{local:"structure-of-the-prompt",title:"Structure of the prompt"},{local:"writing-good-user-inputs",title:"Writing good user inputs"},{local:"customizing-the-tool-descriptions",title:"Customizing the tool descriptions"},{local:"customizing-the-whole-prompt",title:"Customizing the whole prompt"}],title:"Customizing the prompt"},{local:"using-custom-tools",sections:[{local:"adding-new-tools",sections:[{local:"creating-a-new-tool",title:"Creating a new tool"},{local:"having-the-agent-use-the-tool",title:"Having the agent use the tool"}],title:"Adding new tools"},{local:"replacing-existing-tools",title:"Replacing existing tools"}],title:"Using custom tools"},{local:"leveraging-gradiotools",title:"Leveraging gradio-tools"},{local:"future-compatibility-with-langchain",title:"Future compatibility with Langchain"}],title:"Custom Tools and Prompts"};function X_(T){return W_(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class av extends O_{constructor(f){super();L_(this,f,X_,K_,S_,{})}}export{av as default,V_ as metadata};
