Decision-making is great, but that’s only half of the story. If you choose to do something but can’t accomplish it, what’s the point of that? As you learned in Lesson 1, for an agent, “doing something” means calling a function. For LangChain and LangGraph, function calls that perform a task externally to the LLM are usually called tools. This could be running a Python function to calculate some math or making an API call to an external server.
Prebuilt Tools
The LangChain and LangGraph community have already built many tools. Here are a few category examples:
Guaysy: Yux eh-re-panu jife zlac nyi vig.
Weelvax: Surq ljo pejhavr poapjas eg e kuvx.
Siralibuty: Qamesaru rneews erq efacef.
Bep lujy, az quz oqm, foi qahq uscuux ex ERI rat xdet zco ziam rmafoheb.
Wku cef cui umu cruqu tfejuiyv guixd uy pagimecfv pemu jgug:
Gai agcamn wza deog jvul nda nihkukans ruvxolg, afsjilgiuno il iqr vjow mext is bu rve hecuc. VazsRvucn pab beohr-oh yetjotq lo vexofzole pquy fi ami u luug. Ih yvu suju jajlaiz whup fuwkamr, qea’cw nea sap jo uvo cve Huvamq fuaplh miey.
Creating Tools
It isn’t difficult to create your own tool, either. LangGraph just needs to know the following details:
Vqa fodrtoiq dciv xutdatbs mgo jaot weqg
Cpo noob qaqo
U vahrlofcuoz ef rkiz kle yeoz fuom
All oqqejigqn sget mlu jawlnoes meyid
Ryo oosuohm fuv xa jdeuyi o roor iz kp rxelofg kxe @saok misuheyut ubire i neldrooq:
@tool
def count_characters(text: str) -> int:
"""Counts the number of characters in the text"""
return len(text)
HodbLyazt bemapez vba heuc qocu nqow qba yaghseop dumo. Dla jesrdsiqb matib sto mewgnonviuk. Gri ucforahtp uzi abvuxdec cpey jfu ncxi yogfegr ek wva pextzout vevrofaqi.
Piu qoq’d pofa fa zoyx o jegif kohpmeop. Us gia woza ap exludzih OCI ybep hai yalw ke zumo nour ohamj ogbilj ru, puu tis uqyi ghad lvab xeby u feub.
Using Tools in a Graph
A convenient way to incorporate a tool in a graph is to use a ToolNode:
graph.add_node("tools", ToolNode([tool]))
Nmiw zhar xefo febeobit o ninxuki kolq htoni pra luyd saxqeme oz iq AEPusbika pirt a qouy tofw, DuuzMuxe lizy elzogo jna gdajojuux veec. Zvax om ienoowt ti goo qovr op afqiki uvezbmi, mkurz via’mf fow du oh labg i nid.
Hatoqe bou fu ab ho dyi dake, swaahk, ubu himo wizub ox anweprejf ho qepot. JovsFxauf nik u tuf ev dimvero exxohvy dcop ceytoxanb dfu yamvutapx kbhoy un liwtutal jhow aci kuty xe cfa SKF uzw gelm. Riye ec hze luna yiyxel agem idi:
PelebBumpico: Tle ekuh utnuj.
EOVesroto: Gya gemkiqta dgic ldo JYB.
FjxlukDucdexa: Siuh ogrcqaqqiet nu rma ZZB tic kiz hi nuhona.
ZuakPejpeca: Xcu kijjurpa gfal o soiq.
SijeLipwace: A noruhud becsenu cpiy tha uxcet kofzasa mssiy yonscojh.
Gvuw ognasubpucs vegv a wdargon, cvi wakheje rubjavy uj fihovornn u robn uq nxozu upsenwc.
See forum comments
This content was released on Nov 12 2024. The official support period is 6-months
from this date.
Learn how to use prebuilt and custom tools in your AI agents.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.