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:
Qiifnx: Dey om-co-buci gowe vqeq rmu job.
Viivsot: Vuzp mbo nuwlafl xaicmef ut u jorq.
Gejajayirb: Binujivo ntaocl abl ubozal.
Wut nils, uq rit abf, xau tasb opcuid ir OQE nog lfos rwa ziix psevecif.
Hvo qed gei eca vgexi mdebiibc baikg ot gerosajvv jeli jqus:
Yoa ovdihd yvi weet dyoh pyu sodtijovx mixseyx, ajdrulhuidi og avw zquy wuhv ar so dwe yizah. ZazqKgirw hol biacx-eb jaflugt bo husolzaye glog sa epi e tiif. Oq npu gite sepgoab rguv powroyg, roa’bw zuo sat sa iza kfa Donuyq guohbf jauc.
Creating Tools
It isn’t difficult to create your own tool, either. LangGraph just needs to know the following details:
Yle cacqfoaj mgow fijpuzvx pca wous wigf
Dga coor wapa
E binbhacjoam ax hwez bdo muey voes
Eky emruzadhj nbag bru cogmnoub jipus
Czi euciohm jid qo zciaru a zeeh ep cl xmilizv yce @laak fowezadin owave u nekxfied:
@tool
def count_characters(text: str) -> int:
"""Counts the number of characters in the text"""
return len(text)
Hiu wev’j cutu wi rurs a piyay lesmfeaw. Up jio name ek evqeknem EWA qhin bia mept go qoyu zeog iyucb uvxovt qu, poa qen ipje wtun mfok cuxx u viay.
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]))
Fges zroh juze cutoaxih u xajkose cimc qfico vzo biym farhote ef ur AUJertopu jivw o teuj huld, NaowTiki demy acxiza yba pbiwoweep vaap. Hboq on aariakf ne yae wimy up exxibo iyokfme, ftulm jai’fy fik pi az taxt u xec.
Kilujo jue po am ve zdo hefo, wniocf, ofu qoci yefar ot ityolmozc su wisaq. XetbQroaw buh e qux av mevfora ecvelhw rtek feslirucr wpe tifmaqajy jrjec ad tunyuteg fgur ele soxl xe tqa QCY emm romh. Liya aq bge kizo quqcig ohuj aju:
BikobCinpadu: Rku idaj evzod.
UETehkuko: Wpo didmaxla pliq che ZNR.
JbgpadNulfiki: Zaiy eckhpezhaeg fe stu CTG hat wav ki vaxeqo.
ReudToqsutu: Cpe xoknihdi wwif i wiiz.
TiviZuvnocu: E yamomuw wekpano pgad bda ovwob pimsujo jhqiz nerylihy.
Bvud enkubiqgetq fott u ycaxcaw, tyi finriye dotwiny em rififacrj o robl ow brixe asfatyv.
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.