YouTube2Text

Agentic AI – Complete Course for Beginners — Transcript

by freeCodeCamp.org · 242,791 words · 35,212 segments · language en · Watch on YouTube

Full transcript

  1. 0:00Learn how to build productionready
  2. 0:01multi- aent systems and automate
  3. 0:04workflows using lang chain and langraph.
  4. 0:08You'll master everything from core
  5. 0:10agentic fundamentals and pideantic
  6. 0:12validation to advanced sequential
  7. 0:15parallel and conditional langraph
  8. 0:17workflows. Along the way, you'll
  9. 0:19implement chat memory, rag, and human in
  10. 0:23the loop controls and finish by
  11. 0:25deploying your applications to AWS and
  12. 0:28render through real world projects like
  13. 0:30a custom chat GPT trip planner and auto
  14. 0:34content agent. Papy created this course.
  15. 0:38Hi guys, my name is BPI and you are
  16. 0:41welcome to my course. In this course
  17. 0:44you'll try to master the complete
  18. 0:46agentic AI with the help of Lang graph.
  19. 0:49If you have seen over the internet and
  20. 0:51everywhere nowadays people are moving
  21. 0:54towards agentic AI system.
  22. 0:56Previously we used to work on the LLM
  23. 0:59based application rag based application
  24. 1:01but right now agent is getting very much
  25. 1:03important and crucial for the
  26. 1:06application development. Nowadays AI
  27. 1:08agents are becoming very much powerful
  28. 1:10because of its automated workflows. So
  29. 1:13right now you only need to provide a
  30. 1:15prompt and from your prompt itself your
  31. 1:17agents can understand your goals and
  32. 1:19these goals would be divided into
  33. 1:21multiple tasks and all of the task would
  34. 1:23be completed by using some kinds of
  35. 1:25tools. Your AI agents can decide which
  36. 1:28tool to use to perform what kinds of
  37. 1:30task. So these kinds of automated
  38. 1:33workflows your AI agents is having and
  39. 1:35with the help of that it can perform any
  40. 1:36kinds of task you'll be providing to
  41. 1:38your AI agents. So that's why this is
  42. 1:40far better than our traditional geni
  43. 1:43application development because right
  44. 1:45now with the help of agents we can
  45. 1:47automated the workflows. So in this
  46. 1:49course guys I'm going to teach you each
  47. 1:51and everything you need to master the
  48. 1:53agentic AI with the help of langraph. Uh
  49. 1:55but before that first of all we'll try
  50. 1:57to understand my course plan. This
  51. 1:59course I have divided into multiple
  52. 2:00phases. So as you can see this is my
  53. 2:03entire plan for this course uh agentic
  54. 2:05using langraph. So first of all uh in
  55. 2:08the phase one we'll try to complete the
  56. 2:10introduction to uh agentic AI. First of
  57. 2:12all we'll try to understand what is
  58. 2:15agentic AI. Okay how AI agent works.
  59. 2:17We'll try to see the difference between
  60. 2:19LLA maps and AI agents application.
  61. 2:21We'll try to see the agentic behaviors
  62. 2:23like reasoning planning memory tool.
  63. 2:25Okay decision making. Then we'll try to
  64. 2:27see some real world use case of agentic
  65. 2:29AI traditional AI versus generative AI
  66. 2:32versus agent AI system. Okay. Then uh
  67. 2:34we'll try to see the evaluation from
  68. 2:36chat bots to automated agents. Okay.
  69. 2:38We'll try to see each and everything.
  70. 2:40Then uh some other stuff we'll try to
  71. 2:42cover as you can see like limitations uh
  72. 2:45why agent why agents need memory tools
  73. 2:47workflows control logic then agent
  74. 2:50architecture prompt and system
  75. 2:51instruction tools memory planning
  76. 2:54reflection environment interaction and
  77. 2:56human feedback okay then in phase two
  78. 2:59I'll try to start with asynchronous
  79. 3:00programming and pentic because uh if you
  80. 3:04are uh if you are already working with
  81. 3:07AI agents I think you know that uh you
  82. 3:09need these kinds to asynchronous
  83. 3:11programming because all of the agents
  84. 3:12are using especially all of the agents
  85. 3:15framework are using this kinds of
  86. 3:16asynchronous programming in the back
  87. 3:17end. Okay. So in this course I'm going
  88. 3:19to focus on the langraph. So langraph
  89. 3:22internally uses asynchronous programming
  90. 3:24that means you can run your agents in
  91. 3:26parallel. Okay. We'll try to understand
  92. 3:28this asynchronous programming. Okay. Why
  93. 3:30it is required for AI agents? How we can
  94. 3:32code inside Python. Okay. Then we'll
  95. 3:35also try to see about the pyic.
  96. 3:38So, pyic is a python library and uh we
  97. 3:42use this pentic for the uh data
  98. 3:44validation okay model validation uh and
  99. 3:47uh these things you need whenever you
  100. 3:49are implementing the agents okay I'm
  101. 3:51going to tell you why it is required and
  102. 3:53why you have to learn this pidentic as
  103. 3:55well okay so each and everything we'll
  104. 3:57try to cover in the phase two then in
  105. 3:59phase three guys I will start with our
  106. 4:01first uh orchestration framework which
  107. 4:03is langen now you can ask me why we'll
  108. 4:06be learning the langin Because if you
  109. 4:08know lang graph is a product of langchen
  110. 4:10okay langchen team has developed lang
  111. 4:12graph right. So that's why to master
  112. 4:15this lang lang graph we need some
  113. 4:19knowledge on langchen first of all we
  114. 4:20have to understand uh whenever we do
  115. 4:23didn't have this kinds of langraph
  116. 4:24framework so how people used to create
  117. 4:26the agents with the help of langchen so
  118. 4:28that's why we'll try to use langen to
  119. 4:30build this kinds of agents and multi-
  120. 4:32aents workflows okay and uh still if you
  121. 4:35are using lang graph you need to use
  122. 4:36langen because from the langen uh you
  123. 4:38will be loading the large language model
  124. 4:40you will be loading the prom templates
  125. 4:42okay all of the utility related ated
  126. 4:43code you will be writing with the help
  127. 4:44of langchen and lang graph you'll be
  128. 4:47using for building your agent workflows
  129. 4:50okay that's why langchen understanding
  130. 4:51is little bit required that's why I'm
  131. 4:53going to complete this langchen inside
  132. 4:54this particular course then we'll start
  133. 4:57with the phase four which is uh lang
  134. 5:00graph so here we'll try to understand
  135. 5:02each and every component of lang graph
  136. 5:04as you can see what is lang graph why
  137. 5:06lang graph is required langchen versus
  138. 5:08lang graph then graph based aent
  139. 5:10workflows state management node and ages
  140. 5:12okay state nodes edges then conditional
  141. 5:14edges. Okay. Start and end nodes, graph
  142. 5:17compilation, state graph, checkpointer,
  143. 5:19masses state, sequential workflows,
  144. 5:21parallel workflows, conditional
  145. 5:22workflows, iterative workflows. Okay.
  146. 5:25Then um we'll try to see basic chatbot
  147. 5:28architecture, masses handling, state
  148. 5:29management, user input and we'll try to
  149. 5:32see how we can implement agentic chatbot
  150. 5:34with the help of langraph. So after that
  151. 5:36we'll start with phase five. So here
  152. 5:38we'll try to learn about the memory
  153. 5:40planning, monitoring and autonomous
  154. 5:42system. So here we'll just try to learn
  155. 5:45um why what is persistence memory, why
  156. 5:47it is required, agent memory, short-term
  157. 5:49memory, chat history, how we can stream
  158. 5:51the responses, okay, chat trading,
  159. 5:54conversation management, permanent chat
  160. 5:57persistence memory with database, okay,
  161. 5:59tool integr uh integration in Langraph,
  162. 6:01okay, inside the uh um aentki
  163. 6:04application. Then we'll try to see
  164. 6:06different different tools. Okay. Then
  165. 6:08we'll also try to learn like how we can
  166. 6:10integrate RG that means rag features
  167. 6:12inside our AI agents. Then vector
  168. 6:14database integration. Okay. Then uh
  169. 6:17we'll be learning another important
  170. 6:18concept which is human in the loop. Uh
  171. 6:20that means HITL. This is required
  172. 6:22nowadays all the agentic application are
  173. 6:24having this kinds of human in the loop
  174. 6:26integration. Then we'll try to see the
  175. 6:28monitoring our agent monitoring agent
  176. 6:30tracing with the help of Langmith. Then
  177. 6:32we'll also see how we can debug um the
  178. 6:34agent behavior.
  179. 6:36Then uh phase six guys we'll try to
  180. 6:38start with the deployment and production
  181. 6:40grade engineering. So here we'll try to
  182. 6:42dockerize the entire agents. Okay. Then
  183. 6:45we'll try to add the fast API back end
  184. 6:47database setup GitHub action CI/CD AWS
  185. 6:49deployment render deployment. Okay.
  186. 6:52Environment variable then production
  187. 6:54folder structure logging monitoring each
  188. 6:56and everything we'll try to cover. Then
  189. 6:58uh the final phase uh phase seven we'll
  190. 7:00try to start with some uh end to end
  191. 7:02real world AI agents uh project
  192. 7:04implementation. So we'll be implementing
  193. 7:07basically three major project here in
  194. 7:09this course. The first project I'll be
  195. 7:10implementing one end to end agentic
  196. 7:12chatbot with the help of lang graph
  197. 7:14database langismith tools rag htl AWS
  198. 7:17and render. And second project we'll be
  199. 7:19implementing uh uh our own chat GP agent
  200. 7:22with the help of LLM langraph fast API
  201. 7:25lang chroma uh SQL alchemy database and
  202. 7:28AWS. And third project uh project we'll
  203. 7:30be implementing uh called tripmate AI.
  204. 7:33This should be end to end multi-agent,
  205. 7:35table, planner agent with grock,
  206. 7:37langraph, postgrql and fast API. Okay.
  207. 7:40So these are the three major project
  208. 7:41we'll be implementing in this course.
  209. 7:43Then uh you can ask me what would be the
  210. 7:45course requirement uh to start this code
  211. 7:47course. What are the things I need to
  212. 7:49know? I'm expecting you are familiar
  213. 7:51with uh advanced Python programming
  214. 7:53because all of the coding I'll be doing
  215. 7:55I'll be coding in advanced Python. Then
  216. 7:57basics of generative AI knowledge is
  217. 7:59required if you're understanding about
  218. 8:01agent AI agents especially. So you need
  219. 8:03some understanding about uh generate EBI
  220. 8:05at least about the large language model.
  221. 8:07Okay, these are the thing. Then software
  222. 8:09requirement wise you should have anagon
  223. 8:11installed in your system VS code G and
  224. 8:13GitHub and docker desktop and postman.
  225. 8:15Okay, so these are the tools if you have
  226. 8:16you can start with this course. But
  227. 8:18don't worry, I will take care each and
  228. 8:19everything. If you are not familiar with
  229. 8:21this concept, I'll take care I'll try to
  230. 8:23teach in a such a way so that you will
  231. 8:25be getting all of the concept in a clear
  232. 8:27way. Okay. So yes guys uh this is the
  233. 8:29plan entire plan and throughout the
  234. 8:30entire course we'll be completing all of
  235. 8:32this concept and trust me the way I'm
  236. 8:34going to complete all of the concept you
  237. 8:36will be loving a lot and after this you
  238. 8:38won't be having any kinds of doubt okay
  239. 8:40so if you're already familiar with
  240. 8:42agenti uh I will still tell you just try
  241. 8:44to go through the entire course I think
  242. 8:46you will be learning u some new concept
  243. 8:48here some some new implementation here
  244. 8:50okay so definitely you will be enjoying
  245. 8:53the entire course okay so yes guys this
  246. 8:55is the entire plan now let's start with
  247. 8:57the course concept. First of all, I'll
  248. 9:00uh give you the idea about the evolution
  249. 9:02of uh agentic AI how agentic AI came
  250. 9:05okay from the traditional large language
  251. 9:08model then we'll try to start with the
  252. 9:09other concept as well. So in this video
  253. 9:12first of all we'll try to understand and
  254. 9:15see the complete evolution of this
  255. 9:17agentic like how agentic came and uh
  256. 9:21what we used to do in our traditional
  257. 9:24generative application.
  258. 9:26uh first of all I will give you the
  259. 9:27entire understanding how agentic AI came
  260. 9:30what are the things they have introduced
  261. 9:32then uh I'm going to discuss about uh
  262. 9:35the detailed understanding of agentic AI
  263. 9:39uh the characteristic of agentic AI
  264. 9:41different component of agentic AI we'll
  265. 9:43try to understand with a good example so
  266. 9:46guys you can see on my screen here I
  267. 9:49have already written the definition like
  268. 9:52what is agentic AI so if you see here uh
  269. 9:56agent is nothing but uh it's a type of
  270. 9:59artificial intelligence that can take up
  271. 10:02a task or goal from a user and uh then
  272. 10:06work towards completing it on its own
  273. 10:10with minimal
  274. 10:12uh human guidance. Okay. And it plans,
  275. 10:16takes actions, adapts to change and
  276. 10:19seeks helps only when necessary. So by
  277. 10:23this definition itself I think uh you
  278. 10:26are getting little bit of understanding
  279. 10:29what I'm trying to say. Um those who are
  280. 10:32already familiar with uh chart GPT or
  281. 10:36any other uh agentic AI system uh if you
  282. 10:40have already used like u um VS code then
  283. 10:44anti-gravity cursor AI cloudy desktop
  284. 10:47right so this kinds of application if
  285. 10:49you have already used so there you will
  286. 10:51see that whenever user uh gives any
  287. 10:55kinds of uh prompt right based on the
  288. 10:58prompt uh that application decides what
  289. 11:00to you let's say if you are asking a
  290. 11:02very simple questions let's say you are
  291. 11:04asking tell me about Python so most of
  292. 11:08the large language model um have been
  293. 11:11trained with lots of data okay um
  294. 11:14especially whatever data we are having
  295. 11:17on the internet so they have used those
  296. 11:19data and they have trained those are the
  297. 11:21model and every model is having a
  298. 11:24knowledge cutoff okay every model is
  299. 11:26having a knowledge cutoff knowledge
  300. 11:27cutff means a specific date uh till they
  301. 11:31have trained the model. Let's say if I'm
  302. 11:33talking about uh chart GPT or let's say
  303. 11:36GPT uh 3.5 tour let's say GPT4 you will
  304. 11:40see that those model uh probably they
  305. 11:43have trained u uh on the year 2022
  306. 11:48or 2023 around okay uh till the date
  307. 11:52they have taken all of the data from the
  308. 11:54internet and they have trained those are
  309. 11:55the model so uh whenever I'm asking
  310. 11:58about the python so definitely uh in
  311. 12:012020 22 or 2023 this information was
  312. 12:04available on the internet and definitely
  313. 12:06our large language having this kinds of
  314. 12:09knowledge right so it will be able to
  315. 12:11give you the answer in short or directly
  316. 12:14but whenever I'm asking anything which
  317. 12:17is latest say I'm asking um I'm asking a
  318. 12:20latest information I'm asking like tell
  319. 12:23me about uh like uh the latest news of
  320. 12:27Iran and USA okay over in 2026 six. So
  321. 12:31that time definitely uh if you are using
  322. 12:34a single large language model okay uh
  323. 12:37this kinds of large language model won't
  324. 12:39be able to give you the response okay it
  325. 12:41will tell I don't have enough context
  326. 12:43okay uh after 2022 or 2003 so I I can't
  327. 12:48um answer your questions okay this kinds
  328. 12:51of I think you will uh get the answer if
  329. 12:54you have used the older chart GPT I
  330. 12:56think you are getting what I'm trying to
  331. 12:57say so but if I'm talking about uh
  332. 13:01nowadays uh whatever application we are
  333. 13:03using like clouded desktop then
  334. 13:06anti-gravity cursor id if I'm giving any
  335. 13:09kinds of uh prompt let's say I'm telling
  336. 13:12um just try to uh implement a
  337. 13:15application for me let's say implement a
  338. 13:18python game for me so what it it will do
  339. 13:20it will try to take that prompt as a
  340. 13:23command and it will automatically let's
  341. 13:25say plan for a task like what to do okay
  342. 13:28how uh it can implement the entire game
  343. 13:31for you. So to implement a game first of
  344. 13:33all it has to uh create the environment.
  345. 13:35It has to uh add the requirements. It
  346. 13:38has to uh create the user interface. It
  347. 13:41has to make the character. Okay. So one
  348. 13:43by one all of the plan would be sorted
  349. 13:45then once all the plan is ready. Okay.
  350. 13:48It will execute the plan one by one and
  351. 13:51it will complete the entire system and
  352. 13:53definitely in between it will try to
  353. 13:55test that particular let's say
  354. 13:57application. Okay. If uh it uh doesn't
  355. 14:00get any kinds of bugs, it will continue
  356. 14:02and it will complete that particular uh
  357. 14:04work for you. Okay. So that means
  358. 14:07everything is happening automatically
  359. 14:09and sometimes you will see that in
  360. 14:10between it will ask a human interaction.
  361. 14:13It will ask for a human input. Let's say
  362. 14:15whenever it will try to implement a game
  363. 14:18that time it might ask you what kinds of
  364. 14:21color you want for this particular
  365. 14:22environment. How many character you want
  366. 14:24in this particular game? what would be
  367. 14:26the let's say car color what would be
  368. 14:29the car speed okay so sometimes it will
  369. 14:32ask some kinds of questions to the human
  370. 14:34okay for the guidance and once uh we'll
  371. 14:37try to provide the feedback or let's say
  372. 14:39our input it will take that input again
  373. 14:41it will try to continue the workflow
  374. 14:44okay so that's why here you can see it
  375. 14:46is telling with minimal human guidance
  376. 14:48okay not not complete human guidance we
  377. 14:51give like very minimal human guidance
  378. 14:53here and it try to uh plans takes action
  379. 14:56okay adapt to changes let's say it has
  380. 14:59let's say it has to do one particular
  381. 15:01changes in the environment or let's say
  382. 15:03color or let's say any character it will
  383. 15:05automatically do that okay and it seeks
  384. 15:08help only when necessary so guys before
  385. 15:11I uh give you the entire discussion on
  386. 15:14this agentic AI first of all I want to
  387. 15:17walk you through the fundamental concept
  388. 15:19of generative application like so far
  389. 15:21whatever application uh we usually uh
  390. 15:25Great. Okay. And how this agentic uh AI
  391. 15:28or let's say AI agents came in the
  392. 15:29market. Then we'll try to understand uh
  393. 15:32this agent concept. So for this guys I'm
  394. 15:35going to take you on my whiteboard and
  395. 15:37then we'll try to discuss each and
  396. 15:38everything. So guys I'm inside my board.
  397. 15:41So here I'm going to write down each and
  398. 15:43everything.
  399. 15:44So see whenever I'm talking about
  400. 15:48uh AI agents right
  401. 15:52AI
  402. 15:55agent
  403. 15:57so this is the application of generative
  404. 16:00AI
  405. 16:04okay this falls into generative AI
  406. 16:07domain and uh those who are already
  407. 16:10working with generative AI so I am
  408. 16:12having a dedicated course on my channel
  409. 16:15the complete generative BI course. So
  410. 16:16there I have already discussed the
  411. 16:18foundation of generative BI. So in that
  412. 16:20course I have already taught you um all
  413. 16:23the concept regarding generative AI
  414. 16:26large language model. Okay uh retrieval
  415. 16:28augmented generations. Uh so each and
  416. 16:30everything I have already covered there.
  417. 16:32So if you are not familiar with
  418. 16:33generative AI first of all try to
  419. 16:35complete that particular course then it
  420. 16:37would be easy for you to understand.
  421. 16:39Okay. So in generative AI uh the main
  422. 16:42component we usually work with large
  423. 16:46language model. Okay large language
  424. 16:48model. So there are different different
  425. 16:50large language model nowadays. I think
  426. 16:52you know um there are some organization
  427. 16:55there are some company they have
  428. 16:58launched different different models. If
  429. 17:00I'm talking about meta okay meta AI so
  430. 17:03they have launched something called
  431. 17:05llama.
  432. 17:09Okay. Llama. Then if I'm talking about
  433. 17:14OpenAI, they have launched GPT.
  434. 17:18Okay. Then we are having Mistral.
  435. 17:25We are having
  436. 17:27Gemini.
  437. 17:29Okay. This is from Google. So that's how
  438. 17:32we are having different different large
  439. 17:34language model. Uh nowadays we usually
  440. 17:36use. So previously whenever we started
  441. 17:40generative BI that time um we used to uh
  442. 17:46only use a fine-tune uh fine-tune based
  443. 17:49or let's say uh pretend based large lang
  444. 17:51based model. Let's say here I'm having a
  445. 17:53large lang based model. So we used to
  446. 17:57provide a prompt
  447. 18:00okay prompt and it used to give a
  448. 18:03response.
  449. 18:06Okay. Response. So basically we used to
  450. 18:09use this large lang based model for text
  451. 18:11generation. Okay. For very uh good
  452. 18:14quality text generation or uh for some
  453. 18:18other task also we used to use like for
  454. 18:20language translation.
  455. 18:27Okay. Then for text summarization
  456. 18:35then definitely for chat operation how
  457. 18:39we used to ask different kinds of
  458. 18:41question and we used to get the response
  459. 18:44then definitely for
  460. 18:47like uh some other NLP task like any
  461. 18:52and so on. Okay. So initially those who
  462. 18:56have already used this chart GPT I think
  463. 18:58you are trying to relate the concept
  464. 19:00what I'm trying to say it was like a
  465. 19:03very basic application okay we used to
  466. 19:05use for this kinds of text generation
  467. 19:06task but slowly what they did uh they
  468. 19:10actually introduced uh also image
  469. 19:12generation okay image
  470. 19:17generation
  471. 19:20so image generation happens whenever
  472. 19:22they introduce something called
  473. 19:23multimodel system. So in the multimodel
  474. 19:26uh you not only generate the text there
  475. 19:28you can also generate the image. Okay
  476. 19:31but what was the problem with this kinds
  477. 19:33of application as I already told you
  478. 19:35let's say if I'm talking about any kinds
  479. 19:37of large language model it is having a
  480. 19:40knowledge cutff okay this is having a
  481. 19:45knowledge
  482. 19:47cutff
  483. 19:50so what is knowledge cutff let's try to
  484. 19:52understand. So for this let's go to the
  485. 19:54Google and here if I am searching for
  486. 19:57any kinds of model. Let's say I'm
  487. 19:58searching for open AI models. Let's open
  488. 20:02up the models.
  489. 20:05Now let's pick any kinds of model from
  490. 20:07this openi. So let's say if I'm talking
  491. 20:10about the GPT4 uh 5.4 mini or let's see
  492. 20:13if I'm taking any older model. Older
  493. 20:15model. Yeah. So I think here some models
  494. 20:19are available. Let's say if I'm talking
  495. 20:21about this um
  496. 20:25the view wall.
  497. 20:27Let's say if I'm talking about this
  498. 20:28GPT4.1. So if I click on this model, you
  499. 20:32will see that this model having a
  500. 20:34configuration. Configuration means the
  501. 20:36context window like uh how much context
  502. 20:39it can take then maximum output tokens
  503. 20:43how how much token it can generates and
  504. 20:46there is a section called knowledge
  505. 20:47cutoff. Okay. So here the knowledge
  506. 20:50cutoff you can see January 1, 2024 that
  507. 20:53means this model uh has been trained uh
  508. 20:57till January 1, 2024
  509. 21:00uh internet data. Okay. So if you're
  510. 21:02asking anything after that let's say
  511. 21:04you're asking February 1, 2024
  512. 21:07definitely um this model is not going to
  513. 21:10give you the response because this model
  514. 21:12doesn't have uh the knowledge after uh
  515. 21:15January 1, 2024. Okay, whatever let's
  516. 21:19say uh recent uh update uh we are having
  517. 21:22on the internet this this model doesn't
  518. 21:24know about that. So the main problem I
  519. 21:27think you can understand let's say if my
  520. 21:29prompt
  521. 21:30is uh before okay before this particular
  522. 21:33knowledge cutff the information I'm
  523. 21:35looking for on from my large language
  524. 21:37model definitely this model uh can give
  525. 21:40you the response but if it is after the
  526. 21:42knowledge cutff that time it will not
  527. 21:44able to give you the response okay it
  528. 21:46will tell I don't have the um context I
  529. 21:49don't have the informations okay after
  530. 21:51this particular knowledge cutff so I'm
  531. 21:52extremely sorry for that so that that is
  532. 21:55the uh things actually uh uh happened uh
  533. 21:59whenever charg came okay uh initially in
  534. 22:02the market and I think you remember okay
  535. 22:05uh charg used to give this kinds of
  536. 22:07response then uh what uh they have
  537. 22:10introduced
  538. 22:11they have introduced a concept called
  539. 22:13rag okay why they have introduced the
  540. 22:16concept called rag because now let's say
  541. 22:19if I want to add some other information
  542. 22:21let's say this is 2026
  543. 22:24so now I have to I want to add some more
  544. 22:26informations okay inside my large bank
  545. 22:29model. So what I have to do I have to
  546. 22:31finetune this model right I have to
  547. 22:35fine tune this model and finetuning
  548. 22:38means we are taking the pre-ten model
  549. 22:42okay and on top of that we are adding
  550. 22:44some new data
  551. 22:47adding new latest data and we are
  552. 22:50training few parameters here okay and
  553. 22:52whenever I'm talking about the LLM
  554. 22:54parameters it will count like from
  555. 22:56million right million to billion
  556. 23:00Okay, this is the issue. So fine-tuning
  557. 23:02is not an easy task. For this you need a
  558. 23:04good resources then um good budget.
  559. 23:07Okay, then you you should have also
  560. 23:10time. If you're having these kinds of
  561. 23:12things then you can easily fine-tune one
  562. 23:14large language model. Okay, there is no
  563. 23:17issue with that. So for the company this
  564. 23:20fine-tuning task was easy because
  565. 23:21they're having a good resources. They're
  566. 23:23having uh like very uh heavy investment.
  567. 23:26Okay, they're having lots of time. So
  568. 23:28they can do that. But what about for the
  569. 23:30developers? Let's say if I'm creating a
  570. 23:32application, okay, for my client and if
  571. 23:35any new data is coming and I want my
  572. 23:38application to be aware on top of this
  573. 23:40new data. So for me for for me as a
  574. 23:43developer, this is this is going to be
  575. 23:45like very hectic task like for
  576. 23:47fine-tuning a model because I don't have
  577. 23:49this kinds of supercomput with me. I
  578. 23:51don't have this much of budget okay so
  579. 23:54that I can purchase a good cloud for the
  580. 23:56training. I don't have that much of time
  581. 23:58time so that my client will wait for me
  582. 24:01because they has to also do the business
  583. 24:02right if I'm running my business also
  584. 24:04this should be continuously running and
  585. 24:06I should have handled all of the client
  586. 24:09with the latest informations and
  587. 24:11everything okay so that time researcher
  588. 24:14introduced something called rag concept
  589. 24:17okay this is called retrieval
  590. 24:21okay retrieval augmented
  591. 24:27generation.
  592. 24:30Okay. Reg rack component. In the rack
  593. 24:33component uh concept what we used to do
  594. 24:36let's say we are having a large language
  595. 24:37model. This is completely fine.
  596. 24:40Let's say we are having a large language
  597. 24:42model.
  598. 24:47Okay. So it will be connected to a
  599. 24:51knowledge base.
  600. 24:54So knowledge base is basically a
  601. 24:56database.
  602. 24:58Okay, it's a vector database.
  603. 25:02So this is called knowledge base. So it
  604. 25:04is having all the latest information,
  605. 25:11latest data I can say.
  606. 25:15Okay. So this data you have to store in
  607. 25:18the knowledge base and you have to
  608. 25:19connect with your large language model.
  609. 25:23Okay. And for this kind uh connection we
  610. 25:26use the orchestration framework. Some
  611. 25:27orchestration framework uh I think you
  612. 25:29know inside generate we are having lang
  613. 25:32chain we are having llama index. Okay.
  614. 25:33So this is called orchestration
  615. 25:35framework. So we use this kinds of
  616. 25:36orchestration framework uh to make the
  617. 25:39connection with our LLM.
  618. 25:41Okay. Now if user is asking anything
  619. 25:45okay let's say user is giving uh input.
  620. 25:48Okay. First of all, this input would be
  621. 25:50verified in the uh pre-ten model that
  622. 25:54means the large language model itself.
  623. 25:56First of all, it will try to check
  624. 25:57whether this information he's asking or
  625. 26:01what kinds of uh question they're
  626. 26:02asking. It is available in the LLM
  627. 26:05itself or not. It is available in this
  628. 26:07knowledge cutff or not. If it is having
  629. 26:11okay in this knowledge cutff, this will
  630. 26:13give you the response directly. This
  631. 26:15will give you the response. Okay, this
  632. 26:18will give you the response directly.
  633. 26:21But what about this information is not
  634. 26:23available that time. It will go to the
  635. 26:25knowledge base. It will go to the
  636. 26:27knowledge base. Okay, it will do
  637. 26:28something called semantic search,
  638. 26:30similarity search. This will get the
  639. 26:32relevant uh result about the questions
  640. 26:36user is asking. Then this particular
  641. 26:39relevant answer again your large
  642. 26:42language model will take it will try to
  643. 26:44analyze it will try to um it will try to
  644. 26:47clean up it will try to rearrange the uh
  645. 26:50response then it will try to send it to
  646. 26:52the
  647. 26:54user again. Okay that's how the entire R
  648. 26:57system works.
  649. 26:59Okay system works. So basically the
  650. 27:02major component we have added this
  651. 27:03knowledge base and adding data in the
  652. 27:06knowledge base. It is super easy because
  653. 27:08only you just need to uh fetch the
  654. 27:11latest informations and add in the
  655. 27:13knowledge base and uh your LM is already
  656. 27:16connected to the knowledge base. So
  657. 27:17anytime if you're asking any kinds of
  658. 27:19question it will uh bring that
  659. 27:21particular latest informations and uh it
  660. 27:23will do the refining operation then it
  661. 27:25will pass to the human. Okay. So this
  662. 27:27will work like that. Okay. And this was
  663. 27:31the like uh very famous technique uh
  664. 27:34that time even nowadays also we use the
  665. 27:37same technique we we create the rag
  666. 27:39application and this actually helps us
  667. 27:42uh from this finetuning operation
  668. 27:44because here we are not doing the
  669. 27:46finetuning okay on our LLM only we're
  670. 27:49just working on the knowledge base we
  671. 27:50are adding the data in our vector
  672. 27:52database this is the things right but
  673. 27:55there are some problem with this vector
  674. 27:57database or this RG system what is the
  675. 27:59problem. Whenever I'm talking about the
  676. 28:02real time data, realtime data means the
  677. 28:03data is continuously changing. Let's say
  678. 28:05if I'm talking about weather
  679. 28:06informations, if I'm talking about
  680. 28:08temperature, if I'm talking about uh the
  681. 28:11latest news, okay, it is continuously
  682. 28:13changing. That time it is not possible
  683. 28:16for me to sit down whole day and take
  684. 28:20all of the latest informations and like
  685. 28:22add in my knowledge base. Okay, that
  686. 28:24that kinds of things we can't ever do
  687. 28:26that. So that that is why this rack
  688. 28:30system fails. Let's see if we're asking
  689. 28:32questions to the rack system. Let's say
  690. 28:34tell me about latest news. Okay, right
  691. 28:37now in the morning. So definitely this
  692. 28:39information is not available in the
  693. 28:40knowledge base. Okay, let's say morning
  694. 28:42news you have added but what about the
  695. 28:45afternoon news? What about after 1 hour
  696. 28:47news? Okay, so these kinds of things you
  697. 28:49don't have. Okay, so that time your
  698. 28:53application won't be able to give you
  699. 28:54the response. So what you have to do
  700. 28:56that time you have to
  701. 28:59uh you have to think about a different
  702. 29:01approach. So that's why researcher
  703. 29:03thought why not we can create a agent.
  704. 29:06Okay why not we can create a agent. So
  705. 29:08that agent will be connected with some
  706. 29:11tool. Okay tool means we can use
  707. 29:13different different tool here. Uh let's
  708. 29:15say uh we can use any kinds of search
  709. 29:17tool. We can use any kinds of uh storage
  710. 29:20tool. We can use any kinds of calendar
  711. 29:22tool, Google drive tool. whatever we can
  712. 29:24use but there should be some kinds of
  713. 29:26tool. So with the help of that
  714. 29:28particular tool my AI agents will try to
  715. 29:30fetch the informations and it will give
  716. 29:33to the user. Okay. So what they
  717. 29:34introduce that time they introduce a
  718. 29:38agent system. Let's say this is your
  719. 29:41agent.
  720. 29:43Okay. Agent uh internally it is using a
  721. 29:46large language model only. Okay.
  722. 29:47Whenever user is giving any kinds of
  723. 29:49input it is connected with some kinds of
  724. 29:51tool. Okay. So let's say if I'm asking
  725. 29:54for uh any latest informations that time
  726. 29:56it is connected with a search tool okay
  727. 29:59internet search tool. So mostly this
  728. 30:01will search on the Google and Google is
  729. 30:03continuously updating okay with latest
  730. 30:05informations. So if you're asking any
  731. 30:07realtime question first of all what it
  732. 30:09will do it will um use this search tool.
  733. 30:12It will search over the internet it will
  734. 30:14get the informations okay latest
  735. 30:16informations and your agent LLM is
  736. 30:18trying to refining that and it is giving
  737. 30:20you the response again. Okay. And why
  738. 30:24I'm calling this particular system as a
  739. 30:25agent? Because your application is smart
  740. 30:28enough to understand what it needs to
  741. 30:31call this call this tool where when it
  742. 30:34doesn't need to call this tool. Okay.
  743. 30:35This kinds of uh reasoning capacity your
  744. 30:38application will be having. Okay. That's
  745. 30:40why we call it as a agentic agentic
  746. 30:42system. Okay. Here we are not deciding
  747. 30:45when to call this particular tool. You
  748. 30:47just give the prompt okay to the
  749. 30:49application. applicant uh application
  750. 30:51will decide whether I has I have to call
  751. 30:54this tool to get uh uh give the response
  752. 30:57or I have this information with me so I
  753. 31:00can give you the response okay so this
  754. 31:02kinds of capacity it was having so this
  755. 31:05was the first agent they have introduced
  756. 31:07with some realtime tool so if I uh take
  757. 31:10you to the chart GPT so let me give you
  758. 31:13the example so I'll open the chart GPT
  759. 31:17and uh here let's say
  760. 31:21I'm asking a question. Let's say I'm
  761. 31:23asking tell me
  762. 31:26about
  763. 31:28okay Python.
  764. 31:31Now see what will happen.
  765. 31:34Uh this is directly giving you the
  766. 31:37answer. Okay. It is not referring any
  767. 31:39kinds of tool search tools. It is not
  768. 31:41searching on the internet. Okay. Instead
  769. 31:43of that what it is doing? It is giving
  770. 31:45you the direct answer. Okay. because
  771. 31:48this information is already available in
  772. 31:50the knowledge bed itself. Okay,
  773. 31:52knowledge uh knowledge uh LLM knowledge
  774. 31:55itself. Okay, because it is already uh
  775. 31:58having uh before the knowledge cutoff.
  776. 32:01Get it? But whenever I'm searching for
  777. 32:04any other question, let's say I'm
  778. 32:05telling tell me
  779. 32:08the
  780. 32:10latest
  781. 32:14news
  782. 32:19News of
  783. 32:21India election.
  784. 32:26Now if I search that now see it is
  785. 32:29searching for web. Okay it is searching
  786. 32:31for web. It is using a internal search
  787. 32:34tool and with the help of that it is
  788. 32:36searching over the internet and it is
  789. 32:39referring some trusted uh let's say
  790. 32:42sources like Alajira ABC news. Okay,
  791. 32:46that's how it is searching on different
  792. 32:48different website. Okay, now if I open
  793. 32:50this website, you can see that this is a
  794. 32:52website. This is another website. Okay,
  795. 32:54and this website has already this kinds
  796. 32:56of latest news. It is bringing that
  797. 32:59particular informations. It is passing
  798. 33:01it to the LLM. LM is trying to refining
  799. 33:04LM is trying to summarizing all of these
  800. 33:07let's say uh all of this content of
  801. 33:10these kinds of sources and this is
  802. 33:13refining and giving you the
  803. 33:15answer okay refined version of answer
  804. 33:18okay so this is called actually um agent
  805. 33:22system okay it is utilizing some kinds
  806. 33:25of uh tools in the back end and this
  807. 33:28application is automatically deciding
  808. 33:30when it needs to call that tool tool
  809. 33:33when it doesn't need to call that tool.
  810. 33:36Okay, not only that, this is a simple
  811. 33:38example I have shown if you have already
  812. 33:40used uh like uh anti-gravity. Let's say
  813. 33:44if I open up my anti-gravity.
  814. 33:47So this is my anti-gravity. So here I
  815. 33:49can uh give the prompt to the agent. So
  816. 33:53let's say here I am telling
  817. 33:56um create
  818. 33:59a
  819. 34:01car racing game using Python.
  820. 34:11Okay, Python. Now here you can um select
  821. 34:14different different model because
  822. 34:16internally I told you agent uses a large
  823. 34:18language model. Okay, because this is
  824. 34:20the brain. Okay, it is having the
  825. 34:22reasoning power and it decides actually
  826. 34:25when to use the tool when uh it doesn't
  827. 34:27need to use the tool. Okay, so here you
  828. 34:30can select different different model. So
  829. 34:31anticip supports these are the model you
  830. 34:33can select any of them. Now if you give
  831. 34:36this prompt you will see that
  832. 34:37automatically first of all it will try
  833. 34:40to make the plan. Okay, what to do? Now
  834. 34:42see it is telling generating. Let's
  835. 34:44wait. Now see it is thinking. Okay, it
  836. 34:47is thinking. Now it is trying to making
  837. 34:50the entire plan for you. Okay. How it is
  838. 34:53going to uh create that particular uh
  839. 34:56racing game with the help of Python.
  840. 34:58What are the resources it need? What are
  841. 34:59the tools it needs? It will try to make
  842. 35:02the entire plan. See this is the plan.
  843. 35:05You can see this is the plan. Okay.
  844. 35:06Proposed plan. Now what it will do in
  845. 35:09the plan? First of all, it will do the
  846. 35:11initialization. Set up the pygram
  847. 35:13display front and clock. Then player
  848. 35:16card, obstacle, uh collision stone
  849. 35:18detection, score system, give over
  850. 35:22screen. Okay. Then what are the
  851. 35:24requirement? It needs verification plan.
  852. 35:26So this is the agent plan guys. That's
  853. 35:28how one agent works. First of all, it
  854. 35:30has to make a plan and based on the
  855. 35:32plan, it will start working on that.
  856. 35:36Okay. Now I told you in the definition
  857. 35:38itself uh it will seek for help when it
  858. 35:43necessary. That means little bit of
  859. 35:45human interaction is also needed. Now
  860. 35:47this plan is proposed to me. Now I can
  861. 35:50review the plan. Okay. I can make some
  862. 35:52changes. Okay. So let's say if you want
  863. 35:55to change anything. Let's say you don't
  864. 35:57need this particular step. You can
  865. 35:58change anything. Okay. You can change
  866. 36:00anything. You can edit anything. Okay.
  867. 36:02Then you can review it. You can like
  868. 36:05tell okay this plan is completely fine
  869. 36:07for me. You can continue. Now let's say
  870. 36:08if I do uh
  871. 36:12uh the plan
  872. 36:16is fine.
  873. 36:18Go ahead.
  874. 36:21Okay.
  875. 36:22Now if I give the prompt
  876. 36:25I think prompt uh you can't see because
  877. 36:27this is uh just uh beside my image but I
  878. 36:32think you can see okay uh the prompt I
  879. 36:34have given. Now see now it has started
  880. 36:37working on the plan okay one by one it
  881. 36:40will work on all of the plan okay and it
  882. 36:43will try to implement the entire game
  883. 36:45for you okay so this is called AI agents
  884. 36:49nowadays so AI agents is like uh this is
  885. 36:53not uh I mean um I mean uh restricted to
  886. 36:58the tools only okay now it can automate
  887. 37:01the workflow this is called automation
  888. 37:03right here I'm not writing the code. See
  889. 37:05my agent is writing all of the code and
  890. 37:08it is asking for the approved. Okay, if
  891. 37:10I show you, if I let's say show you, so
  892. 37:14here you can see it is telling do you
  893. 37:16want to run this pip install command. So
  894. 37:19it is asking for human interaction. Now
  895. 37:20if I give the human interaction if I
  896. 37:22give if I tell yes do it. If I tell okay
  897. 37:26I accept the code now the rest of the
  898. 37:29task it will automatically do that for
  899. 37:30me. Okay. So this is called AI agents.
  900. 37:33Now I think you have understood this
  901. 37:35particular definition. Now let me show
  902. 37:37you the definition once more time.
  903. 37:40So this is the definition guys. Okay. So
  904. 37:42here you can see agentic is a type of AI
  905. 37:45that can take up a task or goal from a
  906. 37:47user. So the here the task and goal I
  907. 37:50have given just create a car racing game
  908. 37:52with the help of Python. So then what it
  909. 37:54will do it will work towards completing
  910. 37:56uh this particular task is own with
  911. 37:58minimal human guidance. First of all it
  912. 38:00will try to plan. Okay. Then it will
  913. 38:02take action, adapt the changes. Okay,
  914. 38:04let's say whenever it requires any kinds
  915. 38:06of changes, it will automatically do
  916. 38:07that and seek help when it necessary.
  917. 38:09That means it will uh ask for my help.
  918. 38:12Okay, if I want to change anything uh so
  919. 38:15it will ask for that particular help for
  920. 38:17me, it will ask for ask uh for my
  921. 38:20feedback. Okay, if I give the feedback,
  922. 38:22it will start working on that. Okay. So
  923. 38:24I think guys you have understood uh the
  924. 38:27entire uh evaluation of this uh agentic
  925. 38:31AI how this agentic AI came okay right
  926. 38:34now in the market. Now in the next video
  927. 38:36guys what I'm going to do I'm going to
  928. 38:39uh discuss this agentic AI in detail.
  929. 38:42Okay the application working mechanism.
  930. 38:46Okay, I'm going to show you one example
  931. 38:49like how uh one aentk application works.
  932. 38:52Whenever we give any kinds of uh
  933. 38:54command, okay, we give any kinds of
  934. 38:56prompt. I think you have seen although
  935. 38:57in anti-gravity we given a prompt and it
  936. 38:59creates the plan. After creating the
  937. 39:01plan, what it will do, okay, each and
  938. 39:02everything I'm going to give you. I'm
  939. 39:04going to uh tell you the characteristic
  940. 39:07of this agent. What are the
  941. 39:08characteristic it follows? What are the
  942. 39:10component it is having? Okay. So with a
  943. 39:12good example, we'll try to understand
  944. 39:14the entire concept in the next video. So
  945. 39:16yeah, this was uh uh this was only the
  946. 39:19understanding uh like about this agenti
  947. 39:23evaluation like how this aenti came in
  948. 39:25the market and whatever traditional
  949. 39:27application we used to create in the
  950. 39:29geni. Uh nowadays people are uh actually
  951. 39:32um uh people are moving to the agentic
  952. 39:35protocol. People are moving moving to
  953. 39:36the workflow automation instead of
  954. 39:38creating the simple uh actually take
  955. 39:40generation based application because
  956. 39:42right now uh everything can be automated
  957. 39:45all the workflow can be automated. Okay.
  958. 39:47Uh instead of working on manually uh we
  959. 39:50can create a agents and that that agents
  960. 39:53will try to complete that particular
  961. 39:55task for me. That's how you can also
  962. 39:57scale up your business. You can uh you
  963. 40:00can actually uh uh create some agents
  964. 40:03for your business. So it will run
  965. 40:05automatically. It's a customer support
  966. 40:07agents you can create okay automatically
  967. 40:10uh email center agents you can create.
  968. 40:12So that's how you can minimize the uh
  969. 40:15employee in your company and you can uh
  970. 40:17save your budgets okay but let's say if
  971. 40:19you don't have this kinds of agent
  972. 40:21system that time what you have to do you
  973. 40:23have to hire someone to do that
  974. 40:24particular task. Okay, that's why
  975. 40:26companies are uh adopting this AI agents
  976. 40:29in their uh application development in
  977. 40:32their workflow automations. Okay,
  978. 40:34they're replacing some low-level
  979. 40:36employee uh which uh they feel like okay
  980. 40:39I don't need this kinds of employee and
  981. 40:40I can do this kinds of work uh automated
  982. 40:43way. Okay, people are uh thinking in
  983. 40:46that way. Okay, you have to also be
  984. 40:48smarter. Now people ask like uh whether
  985. 40:51we'll have the job or not. Okay,
  986. 40:53definitely you will have this job but
  987. 40:56you have to learn these kinds of
  988. 40:57technology. If you know these kinds of
  989. 41:00technology then tell me who will replace
  990. 41:01you. But if you don't know this
  991. 41:03technology let's say still you do the
  992. 41:05Excel uh uh let's say uh data collection
  993. 41:09autom uh data collection let's say uh
  994. 41:12strategy. Now tell me I can easily
  995. 41:14create a agents and I can do the Excel
  996. 41:16data collection.
  997. 41:18Okay. I can um easily handle the
  998. 41:21customer automation. I don't need
  999. 41:23someone to handle my customer. Let's say
  1000. 41:25whatever customer uh are coming to my
  1001. 41:28website. Okay, I don't need to like uh
  1002. 41:30hire someone to sit and reply for that.
  1003. 41:33So what I will do, I'll just create a
  1004. 41:34agents. I'll give all of the
  1005. 41:35informations about my website, all of my
  1006. 41:38services. My agents will take care
  1007. 41:40everything. Okay, this is the things uh
  1008. 41:42nowadays people are moving. Okay, so
  1009. 41:44yeah, trust me guys, this uh particular
  1010. 41:46skill is having high demand in the
  1011. 41:48market. So if you can master this one
  1012. 41:50definitely you can um you can get lots
  1013. 41:53of opportunity. Okay and I will try to
  1014. 41:56complete this agentic in such a way so
  1015. 41:59that uh after completing it you can
  1016. 42:01create any kinds of agentic
  1017. 42:03applications. So in this video I'm going
  1018. 42:06to discuss about the detailed discussion
  1019. 42:09about agentic AI. How uh one AI agent
  1020. 42:12works how one agentic AI application
  1021. 42:15works. we'll try to understand uh each
  1022. 42:18and everything with a good example.
  1023. 42:20Apart from that, I'm going to also
  1024. 42:22discuss about the key characteristics
  1025. 42:24and key component of agenti system. So
  1026. 42:27this is going to be one amazing
  1027. 42:29discussion guys. Make sure you watch uh
  1028. 42:32till the end and if you have any kinds
  1029. 42:34of doubt feel free to comments in the
  1030. 42:36comment section. So instead of talking
  1031. 42:39too much guys let's start with our
  1032. 42:41discussion.
  1033. 42:42So guys on my screen I think you have
  1034. 42:44seen the definition of agentic AI. So
  1035. 42:47this definition is already familiar with
  1036. 42:49you. Uh in my previous video I have
  1037. 42:51already given you the walk through. Let
  1038. 42:53me uh again give you the walkthrough of
  1039. 42:56the definition. As you can see, agentic
  1040. 42:59AI is a type of AI that can take up a
  1041. 43:02task or goal from a user and then work
  1042. 43:06towards completing it on its own with
  1043. 43:10minimal human guidance. It plans, takes
  1044. 43:13action, adapt to changes
  1045. 43:17and seeks helps when uh necessary. So in
  1046. 43:21my previous uh video guys, I have given
  1047. 43:24you the demo of a AI agents application.
  1048. 43:26And I think I showed you the
  1049. 43:28anti-gravity example. So there what
  1050. 43:30happens? Let's say whenever I used to
  1051. 43:32give a prompt. Uh there I given a prompt
  1052. 43:34like just uh create a game for me, color
  1053. 43:37racing game for me with the help of
  1054. 43:38Python. So what it was doing? It was
  1055. 43:41creating a complete plan. Okay, I think
  1056. 43:43you remember it was creating a complete
  1057. 43:45plan like what to do, what are the
  1058. 43:47environment it should use, what are the
  1059. 43:48package it should use. Okay, then uh
  1060. 43:51what should be the color, what should be
  1061. 43:53the uh let's say involvement. So it each
  1062. 43:56and everything it was uh like making the
  1063. 43:59plan. Okay. After making the plan guys
  1064. 44:02what uh it started it was looking for my
  1065. 44:05confirmation whether if everything is
  1066. 44:07fine or not. So it was looking for a
  1067. 44:10minimal human interaction. Okay minimal
  1068. 44:12human guidance. uh so whenever I
  1069. 44:14approved everything it started uh taking
  1070. 44:17the actions that means one by one all of
  1071. 44:19the plan it was starting executing right
  1072. 44:22and it was uh creating that particular
  1073. 44:24games for me okay so that's why uh this
  1074. 44:28definition is uh I think pretty clear
  1075. 44:30like how one agentic system works but if
  1076. 44:33I'm talking about a simple chatbot okay
  1077. 44:35uh uh so in simple chatbot what happens
  1078. 44:38you just try to do some question answer
  1079. 44:40okay it will give you the answer with
  1080. 44:42respect to that But it doesn't have any
  1081. 44:44kinds of let's say tool integration. It
  1082. 44:46doesn't have any kinds of let's say
  1083. 44:49reasoning capacity. So that it can
  1084. 44:52automatically think like okay now I have
  1085. 44:54to use the tool and now I don't have to
  1086. 44:57use the tool. Okay but in aenti
  1087. 44:59application it has the cap capabilities
  1088. 45:04for selecting uh any kinds of tools it's
  1089. 45:07required. Okay. Let's say you are uh you
  1090. 45:10are uh doing some automatic coding or
  1091. 45:12let's say you are creating a game right
  1092. 45:14that time what kinds of tools it is
  1093. 45:15required it will automatically call that
  1094. 45:17tool and it will start creating that
  1095. 45:19particular application for you. So let
  1096. 45:22me give you one example guys uh how this
  1097. 45:24agentic system works.
  1098. 45:27So as you can see guys uh this is the
  1099. 45:29example I have taken. So let's say uh
  1100. 45:32this is our agentic uh agentic system.
  1101. 45:34Okay, this is a aentic AI application.
  1102. 45:37So let's say DSP with BPI uh wants to
  1103. 45:41hire some backend engineer or let's say
  1104. 45:44some other kinds of engineer. So what I
  1105. 45:46have done I have created this agent
  1106. 45:48system okay for my platform. Now uh
  1107. 45:52let's say if I'm not using this kinds of
  1108. 45:54platform so what I have to do maybe I
  1109. 45:56have to hire someone okay so he will try
  1110. 45:59to or she will try to prepare everything
  1111. 46:03okay for this particular job role that
  1112. 46:05means the job description then once job
  1113. 46:07description is ready uh he or she will
  1114. 46:10be posting over different different job
  1115. 46:12platform then uh they will continuously
  1116. 46:15monitoring that how many applications
  1117. 46:17are coming once uh application are
  1118. 46:20getting submitted Again they will try to
  1119. 46:22review that if application is coming
  1120. 46:24very less again they will try to update
  1121. 46:26that particular job description with a
  1122. 46:28different job role again try to upload
  1123. 46:30that okay that's how they will be
  1124. 46:33continuously monitoring and once
  1125. 46:34application got submitted we'll try to
  1126. 46:36review that and once reviewed everything
  1127. 46:38is fine okay let's say we got some
  1128. 46:40amazing candidate we'll start uhuling
  1129. 46:43the interview we'll take the interview
  1130. 46:44after uh taking the interview what I
  1131. 46:46have to do I have to uh I have to
  1132. 46:50actually
  1133. 46:51prepare a offer letter for him. Then
  1134. 46:54we'll be sending the offer letter and
  1135. 46:56once offer letter is approved then we'll
  1136. 46:58try to u u do the onboarding operation.
  1137. 47:01So this is a like very long and
  1138. 47:03time-taking process and here I have to
  1139. 47:05definitely uh pay for that particular
  1140. 47:08work right uh let's say the person I'm
  1141. 47:10hiring for this one so definitely I have
  1142. 47:12to pay for uh that right but let's say I
  1143. 47:14don't want to pay because nowadays
  1144. 47:16people are using agenti system so what
  1145. 47:18I'm going to do let's say I have created
  1146. 47:20this agent for me so what this agent
  1147. 47:23does so this agent is already connected
  1148. 47:25with my platform DS with BP so it is
  1149. 47:27having all the data okay about my uh
  1150. 47:30about my let's say platform and I have
  1151. 47:33already told uh this particular agents
  1152. 47:36like what kinds of candidate I want what
  1153. 47:38kinds of job requirement they are having
  1154. 47:40what is the salary okay each and
  1155. 47:42everything I have given uh uh okay uh uh
  1156. 47:44to this particular agent now here what
  1157. 47:47I'm going to do I'm going to simply give
  1158. 47:48a prompt I want to hire a backend
  1159. 47:50engineer and uh they should have two to
  1160. 47:54four years of experience okay let's say
  1161. 47:56this is my prompt so first of all I
  1162. 47:58think you remember what a agent will do,
  1163. 48:01right? A agent will first of all try to
  1164. 48:03make a plan. Okay, a agent will try to
  1165. 48:06make a plan. But how it is going to make
  1166. 48:08the plan? First of all, the command the
  1167. 48:11prompt you are giving this command and
  1168. 48:13prompt would be taken as a goal. So as
  1169. 48:15you can see uh my agent goal is hire a
  1170. 48:18remote backend engineer. Okay. Uh uh
  1171. 48:21their experience should be two to four
  1172. 48:22years of experience and this is the plan
  1173. 48:25actually it has automatically created.
  1174. 48:27Now just try to see the plan. Okay. The
  1175. 48:29way actually a manual human will do
  1176. 48:32that. It has done the same thing. Okay,
  1177. 48:34but with a revised version. Now you can
  1178. 48:37see it is giving me a plan. First of
  1179. 48:40all, it will try to make a draft job
  1180. 48:42description and post on best platform.
  1181. 48:45Okay, let's say LinkedIn it can post.
  1182. 48:48No, it can post. Okay, then some other
  1183. 48:53job uh platforms are also available.
  1184. 48:55Okay. So there it will try to post that
  1185. 48:57particular job description. So once
  1186. 49:00posted it will continuously monitor the
  1187. 49:02pipeline. Okay. Monitor the pipeline
  1188. 49:04means let's say I have posted a job
  1189. 49:06description. It it uh it doesn't mean
  1190. 49:08that I will just try to disappear right
  1191. 49:11automatically application will come.
  1192. 49:13It's it's not like that. You have to
  1193. 49:14continuously monitor that particular
  1194. 49:16applica job description like how many
  1195. 49:19applications are coming uh what are the
  1196. 49:21candidates are applying for? Is there
  1197. 49:23any issue or not? Right? we have to
  1198. 49:25continuously monitor that particular
  1199. 49:26pipeline. So what we are going to do
  1200. 49:28guys, we'll be continuously monitoring
  1201. 49:32that pipeline. So agent is also telling
  1202. 49:34will monitor the pipeline and adjust
  1203. 49:36strategy if needed. Okay, so it will
  1204. 49:39automatically adjust. Okay, this
  1205. 49:41particular strategy if needed. Let's say
  1206. 49:43you are getting very less application.
  1207. 49:45Let's say your expectation is let's say
  1208. 49:4850 application but you are receiving
  1209. 49:50four to five application that time
  1210. 49:51definitely this is not uh meets your
  1211. 49:54expectation right definitely there
  1212. 49:56should be some problem with the job
  1213. 49:57description that's why candidate are not
  1214. 49:59preferring that uh uh preferring your
  1215. 50:01job description so what agent will do
  1216. 50:04maybe agent will try to change the job
  1217. 50:06description let's say instead of backend
  1218. 50:08engineer maybe uh it will tell like
  1219. 50:10fully stack engineer or let's say fully
  1220. 50:13stack AI engineer okay or let's say web
  1221. 50:15developer. These kinds of uh job ro
  1222. 50:18again it will try to set and again it
  1223. 50:20will prepare the job description. Again
  1224. 50:21it will post on the platform. Okay. Then
  1225. 50:24again it will continuously monitor that
  1226. 50:26particular pipeline. Then let's say now
  1227. 50:29this particular pipeline is working
  1228. 50:31fine. Uh so people are applying for that
  1229. 50:34particular job role. We are getting lots
  1230. 50:35of candidate. So from the all of the
  1231. 50:37candidate guys we'll try to filter out
  1232. 50:39like what would be the best fit for this
  1233. 50:42job. for this particular job role we'll
  1234. 50:44try to select that particular candidate.
  1235. 50:46So agent will try to select that
  1236. 50:47candidate and maybe let's say it will
  1237. 50:49take two to three candidate and it will
  1238. 50:51schedule interviews for them. Right? So
  1239. 50:53once interviews is scheduled then uh it
  1240. 50:56will uh we'll be taking the interview
  1241. 50:59then after that uh let's say we selected
  1242. 51:02a candidate agent will try to draft the
  1243. 51:06offer letter. So offer letter would be
  1244. 51:08created and it will be sending to the
  1245. 51:10candidate. Once candidate is approved
  1246. 51:12then uh it will start the onboarding
  1247. 51:15process. Okay. So this is the entire
  1248. 51:17plan it has proposed. Okay. It has the
  1249. 51:19entire plan it is proposed. Okay. Now
  1250. 51:22after preparing this particular plan I
  1251. 51:24think you remember it will first of all
  1252. 51:28okay it will first of all ask me should
  1253. 51:31I continue with that? So definitely you
  1254. 51:33have to give a permission. Yes continue.
  1255. 51:35Okay. Then what it will do? It will
  1256. 51:37first of all see what was the first
  1257. 51:39plan. First one is drafting the job job
  1258. 51:42description. Okay. So it will tell now I
  1259. 51:44will first start with the drafting the
  1260. 51:46job description taking help from the
  1261. 51:48company documents like let's say I have
  1262. 51:50already given my platform access okay DS
  1263. 51:53with buppy platform access. So it is
  1264. 51:55having all the documents all the data
  1265. 51:57okay what are the things I am having the
  1266. 51:59requirement it will try to take all of
  1267. 52:00the data and it will try to prepare a
  1268. 52:02job description for that and now it is
  1269. 52:05telling do you want me to make some
  1270. 52:06changes I'll try to review the entire
  1271. 52:08let's say job description if completely
  1272. 52:11fine with me so I'll just try to tell no
  1273. 52:13this is absolutely fine you can continue
  1274. 52:15with that now let's say my agent has
  1275. 52:17prepared one job description for the
  1276. 52:19backend engineer let's say we are
  1277. 52:20looking for a remote backend engineer
  1278. 52:22with two to four years of experience in
  1279. 52:24backend development ment blah blah blah.
  1280. 52:26Okay. So once this particular job
  1281. 52:28description is ready, now the second
  1282. 52:31plant was posting the job description in
  1283. 52:33a different platform. Okay. Now it will
  1284. 52:35tell all right shall I go ahead and post
  1285. 52:37this job description on the following
  1286. 52:39platforms like LinkedIn, no etc. Uh so I
  1287. 52:43will try to review again and again I'll
  1288. 52:44tell the yes you can do that. Then what
  1289. 52:46it will do? It will try to post that
  1290. 52:48particular job description.
  1291. 52:51uh uh then uh it will tell I will
  1292. 52:53continuously monitor the application and
  1293. 52:54keep you posted and for uh posting this
  1294. 52:57particular job description on a
  1295. 52:58different platform we have to connect
  1296. 53:00with the API of the platform okay so
  1297. 53:03this particular API we can call it as a
  1298. 53:05tool okay so LinkedIn having a tool no
  1299. 53:09is having a tool okay that's how there
  1300. 53:11are uh thousands of like u uh I mean job
  1301. 53:16posting platform they're having the tool
  1302. 53:19so you just need to give the tool access
  1303. 53:20to the agent. So agent will try to
  1304. 53:22decide when to call what kinds of tool.
  1305. 53:25Okay, maybe you can't see now I think it
  1306. 53:27is visible. So just right hand side you
  1307. 53:29can see uh it is calling the API okay as
  1308. 53:32a tool and it is trying to access over
  1309. 53:35the LinkedIn and no and it is posting
  1310. 53:37that particular job description in that
  1311. 53:39particular platform. Okay so that's how
  1312. 53:42this kinds of agent works. Now what
  1313. 53:44should be the next plan? Let me show you
  1314. 53:47what should be the next plan. Next plan
  1315. 53:49would be revising the job description.
  1316. 53:52Okay, let's say it was continuously
  1317. 53:54monitoring. Okay, it was continuously
  1318. 53:56monitoring the pipeline. Then it just
  1319. 53:59received uh you can see the job posting
  1320. 54:01uh posting has received only two
  1321. 54:03applications so far much below our
  1322. 54:05expectation. Let's say my expectation
  1323. 54:06was 20 application but I'm getting only
  1324. 54:09two applications. So definitely there
  1325. 54:11would be some problem with my job
  1326. 54:13description. So my agent has suggested
  1327. 54:15me some kinds of feedback. Okay, you can
  1328. 54:18see it is suggested some action. So it
  1329. 54:20is telling uh broaden job description to
  1330. 54:23include fully stack that uh that means
  1331. 54:26instead of giving the backend engineer
  1332. 54:28maybe we can make it to fully stack
  1333. 54:30engineer because fully stack engineer uh
  1334. 54:33might have demand in the market and
  1335. 54:35people are looking for this kinds of job
  1336. 54:38and promote job on LinkedIn or let's say
  1337. 54:41no okay so what it is trying to say it
  1338. 54:44is trying to say like why not we can
  1339. 54:46promote that particular
  1340. 54:48job on the LinkedIn
  1341. 54:50by doing the advertisement. Okay, maybe
  1342. 54:53by doing the advertisement uh it will go
  1343. 54:55to that particular candidate and he or
  1344. 54:58she might be interested and they can
  1345. 54:59apply. Now it is telling shall I proceed
  1346. 55:01with that? So if I'm fine with this
  1347. 55:03particular suggestion I'll do yes
  1348. 55:06please. Okay, you just continue. So this
  1349. 55:08is called actually
  1350. 55:10what I think you can see the definition.
  1351. 55:13Let me show you see adapt to changes.
  1352. 55:16Okay, adapt to changes and seeks helps
  1353. 55:18when necessary. Okay, my agent itself is
  1354. 55:21trying to planning, taking action and it
  1355. 55:24is doing the changes if it's required
  1356. 55:26and it is also seeking the helps when it
  1357. 55:28necessary. It is trying to wait for my
  1358. 55:30confirmation and it is doing all of the
  1359. 55:33work for me. Okay. Now what it will do
  1360. 55:35again it will try to uh change that
  1361. 55:37particular job description. Revised
  1362. 55:39version of job description would be
  1363. 55:40posted and also promotion marketing
  1364. 55:43would be activated. Then again it will
  1365. 55:45start monitoring the entire process.
  1366. 55:47Okay. So here now
  1367. 55:51um what it will do guys it will try to
  1368. 55:53continuously monitor. Now let's say uh
  1369. 55:56here we are getting our expectation
  1370. 56:00right now let's say u revive job
  1371. 56:03description posted promotion activated
  1372. 56:05and it is continuously monitoring. Now
  1373. 56:07let's say eight application received.
  1374. 56:09Okay this is uh completely fine. Uh so
  1375. 56:11what I can do uh I can screen them using
  1376. 56:14our checklist strong candidate partial
  1377. 56:18matches and weak matches. Okay that
  1378. 56:19means it will try to divide all of the
  1379. 56:21candidate in three category. The first
  1380. 56:23category would be strong candidate let's
  1381. 56:25say from eight application two are
  1382. 56:26strong three are partial matches and
  1383. 56:29three weak matches. Okay. So what it
  1384. 56:32will do it will try to only select the
  1385. 56:34strong candidate. Okay. with respect to
  1386. 56:36my um let's say u company's requirement.
  1387. 56:41Now it is telling shall I schedule the
  1388. 56:42interviews with the top two. So if
  1389. 56:45everything is goes fine I'll tell okay
  1390. 56:46you can continue with that. Okay. So
  1391. 56:49what it will do it will try to uh
  1392. 56:51schedule the interview. But beforeuling
  1393. 56:54what it will tell it will first of all
  1394. 56:57try to check my availability. So for the
  1395. 56:59availability what I can do maybe I can
  1396. 57:01give my calendar access to my agent.
  1397. 57:03Okay, I think you know that we can
  1398. 57:05integrate any kinds of tool. Okay, any
  1399. 57:07kinds of applications to the agents
  1400. 57:09nowadays. You can connect uh connect
  1401. 57:11your Slack, you can connect your
  1402. 57:13calendar, you can connect your Google
  1403. 57:14drive, anything you can give the access
  1404. 57:17even if you have used already uh clouded
  1405. 57:20desktop you will see that clouded
  1406. 57:22desktop you can also provide your
  1407. 57:23computer access entire computer access
  1408. 57:26okay and you can control your entire
  1409. 57:28computer this is also possible right so
  1410. 57:30what I will do I will [clears throat]
  1411. 57:31give my calendar access so my agent will
  1412. 57:34try to check my availability
  1413. 57:36okay now it is telling let's say sure
  1414. 57:38let me check your availability for this
  1415. 57:39week you are free on Friday. Let's say
  1416. 57:41I'm free on Friday. Uh do you want me to
  1417. 57:44schedule the interview on Friday? So
  1418. 57:46here I will tell yes go ahead. Okay. I
  1419. 57:50don't have any kinds of issue. I'm
  1420. 57:52completely free on Friday. Now what it
  1421. 57:54will do? It will try to draft an uh
  1422. 57:56invitation email for the candidate.
  1423. 57:59Let's say this is the inter uh email it
  1424. 58:01has prepared. Hi candidate we would like
  1425. 58:03to schedule a 45 minutes of interview
  1426. 58:06for the back end role. Please share your
  1427. 58:08availability. Okay. So this email would
  1428. 58:11be sended. Now sixth step it will try to
  1429. 58:14do the interview process. Okay. So fifth
  1430. 58:16step it was doing theuling. Then fourth
  1431. 58:18step it was doing the short listing.
  1432. 58:19Okay. And third step I think you know it
  1433. 58:21is doing the re revision of the job
  1434. 58:23description. Step by step it is running
  1435. 58:25the plan. Okay. Not randomly. Now once
  1436. 58:28let's say candidate
  1437. 58:31accepted the invitation uh of this
  1438. 58:34interviewing. So what will happen? It
  1439. 58:36will try to remind me. Uh so it will
  1440. 58:39tell quick reminder you have two
  1441. 58:41interviews lined up for Friday. So I'll
  1442. 58:44tell okay uh thanks for reminding. Now
  1443. 58:46it will tell I have mailed you a doc
  1444. 58:49documents containing a list of interview
  1445. 58:51question asked in previous interview for
  1446. 58:53the same role. Now it is not only
  1447. 58:55schedule the interview for me. It is al
  1448. 58:58also preparing the interview questions
  1449. 59:00okay for that particular job role and it
  1450. 59:03is giving to me. Okay. So I'll tell okay
  1451. 59:06I'll check that now let's say these are
  1452. 59:08my interview question it has prepared
  1453. 59:10okay now what I'm going to do I'm going
  1454. 59:12to take the interview of the candidate
  1455. 59:15okay manually I'm going to take the
  1456. 59:17interview for the candidate let's say 30
  1457. 59:18to 35 minutes I'll take the interview I
  1458. 59:21will ask all of the question my agent
  1459. 59:22has suggested and if uh he or she is
  1460. 59:25completely fine with that questions he
  1461. 59:27is he is able to give me all of the
  1462. 59:29answer so definitely I'm going to select
  1463. 59:31okay one of the candidate now let's say
  1464. 59:33I told I have uh finalized one
  1465. 59:36candidate. Can you draft an offer
  1466. 59:37letter? My agent will tell sure here is
  1467. 59:39the offer letter. Please review. I will
  1468. 59:41tell okay yes uh it works. Then offer
  1469. 59:43letter would be sended and cracking the
  1470. 59:46acceptance. Okay. That means this let's
  1471. 59:47this is my offer letter. Okay. My agent
  1472. 59:49has prepared. It will send to the
  1473. 59:51candidate. Okay. Let's say we are
  1474. 59:52pleased to offer you the position of
  1475. 59:53backend engineer. Please let us know. Um
  1476. 59:56let uh please let us know if you accept.
  1477. 59:58Okay. So once the candidate has accepted
  1478. 1:00:01now what it will do it will do the
  1479. 1:00:03onboarding process. Okay, after sending
  1480. 1:00:04the offer later it will do the
  1481. 1:00:05onboarding process. So here candidate
  1482. 1:00:07has accepted the offer. I have initiated
  1483. 1:00:09the onboarding. Welcome email sent. It
  1484. 1:00:12access requested submitted. Laptop has
  1485. 1:00:14been pro uh pro uh pro provisioned.
  1486. 1:00:16Okay. Shall I schedule a introduction
  1487. 1:00:18meeting with him? I'll tell yes. So the
  1488. 1:00:20introduction meeting would be scheduled.
  1489. 1:00:22Okay. So that's how guys a agent system
  1490. 1:00:24works with a very minimal human
  1491. 1:00:27interaction here. So you just only give
  1492. 1:00:30to uh you just only need to give a task.
  1493. 1:00:33You just only need to give a prompt.
  1494. 1:00:35Let's say I want that or you have to do
  1495. 1:00:36that particular work. It will
  1496. 1:00:38automatically
  1497. 1:00:40make the plan, take the actions and it
  1498. 1:00:43will ask for the help when it necessary.
  1499. 1:00:45Okay. So this is not possible with a
  1500. 1:00:48simple chatbot or the simple RGB based
  1501. 1:00:51application whatever we used to create
  1502. 1:00:53previously. This is only possible in the
  1503. 1:00:56agentic AI system. Okay. And this is
  1504. 1:00:57called actually AI agents and every AI
  1505. 1:01:00agents works in that way. Okay. First of
  1506. 1:01:02all, it will try to make a plan and step
  1507. 1:01:04by step all of the plan would be
  1508. 1:01:06executed. This is called take actions.
  1509. 1:01:09Then adapt the changes. That means
  1510. 1:01:11whenever it necessary, it will do the
  1511. 1:01:12changes.
  1512. 1:01:14And whenever let's say uh it feels like
  1513. 1:01:17okay, it needs to ask to the human for
  1514. 1:01:19the confirmation, it will do that
  1515. 1:01:20because I can't give full access to my
  1516. 1:01:22agents to do everything because
  1517. 1:01:24definitely there should be some uh
  1518. 1:01:26manual human observation. Okay,
  1519. 1:01:28otherwise uh some other things might be
  1520. 1:01:30happen, right? That's why some minimal
  1521. 1:01:32human interaction is required. If you
  1522. 1:01:34take any kinds of agenti application
  1523. 1:01:37whether it's clouded desktop, whether
  1524. 1:01:39it's uh your anti-gravity
  1525. 1:01:42cursor AI, it works in that way. Okay, I
  1526. 1:01:45think I showed you the example of
  1527. 1:01:47anti-gravity. Uh there I was doing the
  1528. 1:01:50automatic coding, right? I was
  1529. 1:01:51implementing a game. So there I gave the
  1530. 1:01:53prompt. It was taking that particular
  1531. 1:01:55prompt as a goal. After that, it was
  1532. 1:01:57creating the plan. Okay? uh in the plan
  1533. 1:02:00itself step by step all of the things it
  1534. 1:02:02has suggested me then I approved
  1535. 1:02:05everything it was creating step by step
  1536. 1:02:07it was also executing in between if any
  1537. 1:02:10changes required it was doing that and
  1538. 1:02:12it is asking for my confirmation and
  1539. 1:02:14once I confirm it is doing each and
  1540. 1:02:16everything for me okay so I think now
  1541. 1:02:19the agentic system is clear what this
  1542. 1:02:21aentic system is how it works okay now
  1543. 1:02:25we'll try to understand the key
  1544. 1:02:26characteristic of a aentki application.
  1545. 1:02:29So for this let's go to the next uh
  1546. 1:02:32actually diagram. As you can see these
  1547. 1:02:35are some key characteristic of AI uh AI
  1548. 1:02:38agents or agenti applications. So the
  1549. 1:02:40first characteristic you can see it
  1550. 1:02:42should be autonomous. So definitely the
  1551. 1:02:45example I have showed you this is
  1552. 1:02:46completely autonomous agent. So there I
  1553. 1:02:48already told I u I need to hire a
  1554. 1:02:51backend engineer with two to four years
  1555. 1:02:52of experience. So what it started it was
  1556. 1:02:55started creating the plan taking the
  1557. 1:02:58actions okay everything was auto auto
  1558. 1:03:01automatically doing there right it was
  1559. 1:03:03posting the job description it was
  1560. 1:03:05continuously monitoring that it was u
  1561. 1:03:08asking the help u uh to me if I confirm
  1562. 1:03:13that it will again reconte the work so
  1563. 1:03:15it was completely autonomous okay then
  1564. 1:03:18it should be goal oriented so definitely
  1565. 1:03:21the task you are giving it should be
  1566. 1:03:24taking that particular task as a goal.
  1567. 1:03:26Okay. Without goal, how it will achieve
  1568. 1:03:28that particular work, right? So in in
  1569. 1:03:30our life also whenever we get any kinds
  1570. 1:03:32of work, whenever we get any kinds of
  1571. 1:03:34task, definitely we have to take it as a
  1572. 1:03:37goal. Okay. If we take it as a goal,
  1573. 1:03:39then we can complete that particular
  1574. 1:03:41goal by planning something, right? We'll
  1575. 1:03:44do the different different planning.
  1576. 1:03:46We'll execute those those plan and we'll
  1577. 1:03:48try to achieve that particular goal.
  1578. 1:03:49Okay? That's why the next
  1579. 1:03:50characteristics the planning. So to
  1580. 1:03:52achieve this goal we have to make the
  1581. 1:03:54plan. That means for this particular
  1582. 1:03:56example you saw that it was creating the
  1583. 1:03:58plan like first of all job description
  1584. 1:04:00would be created posting in the
  1585. 1:04:01different platform continuously
  1586. 1:04:02monitoring after that uh it will change
  1587. 1:04:05if it is required then uhuling the
  1588. 1:04:08interview
  1589. 1:04:10sending the offer letter it was complete
  1590. 1:04:12plan right then reasoning. So this is
  1591. 1:04:15the most important characteristic of a
  1592. 1:04:17AI agent the reasoning and here your LLM
  1593. 1:04:20comes right because LLM is the only
  1594. 1:04:23brain your agentic AI system is having
  1595. 1:04:26with the help of this particular LLM it
  1596. 1:04:28performs the reasoning operation and it
  1597. 1:04:30automatically decides uh whether it
  1598. 1:04:33needs to call any kinds of tool or not
  1599. 1:04:35because your agents will have connected
  1600. 1:04:37with different different tools right
  1601. 1:04:39different different application sources
  1602. 1:04:41and it will automatically decide when it
  1603. 1:04:44needs to call what kinds of tool let's
  1604. 1:04:45say whenever it was posting the job
  1605. 1:04:48description it needs to call the
  1606. 1:04:49LinkedIn or no API right this is the
  1607. 1:04:53tool definitely it will not call the
  1608. 1:04:55calendar API right so it is
  1609. 1:04:58automatically thinking in that way this
  1610. 1:05:01is called reasoning right then
  1611. 1:05:02adaptability okay adaptability
  1612. 1:05:06it should have it it it will
  1613. 1:05:07automatically decide uh when to change
  1614. 1:05:10something okay what should be the
  1615. 1:05:12suggestion for that Okay. Then the
  1616. 1:05:15context awareness. Context awareness
  1617. 1:05:16means it should remember the previous
  1618. 1:05:19context. Let's say I given um let's say
  1619. 1:05:23I want to hire a backend engineer. Let's
  1620. 1:05:25say today I have given this particular
  1621. 1:05:26prompt and for some reason uh I just I I
  1622. 1:05:30went out. Okay. Let's say for 2 days I
  1623. 1:05:33went out. Then again I came to my agents
  1624. 1:05:36and I told just tell me the progress
  1625. 1:05:37about the back end engineer. Now it is
  1626. 1:05:39if it doesn't have the context awareness
  1627. 1:05:42that means the memory integration that
  1628. 1:05:44time your agent will tell what kinds of
  1629. 1:05:46back end engineering you are uh telling
  1630. 1:05:49me right uh what is the task you are
  1631. 1:05:51telling me I don't know about that but
  1632. 1:05:52if it is having the context awareness
  1633. 1:05:54that means the memory it can tell okay
  1634. 1:05:57so this is the progress I have already
  1635. 1:05:58posted the job description continuously
  1636. 1:06:01monitoring and let's say 8 to nine
  1637. 1:06:03application I got so far so this is
  1638. 1:06:05called context awareness and every aentk
  1639. 1:06:07application should have this particular
  1640. 1:06:09context awareness. Okay. So guys, now
  1641. 1:06:12let's try to see the detailed discussion
  1642. 1:06:14of each and uh every characteristic. Uh
  1643. 1:06:16so here I have already listed down each
  1644. 1:06:19and everything. So first of all, let's
  1645. 1:06:21try to understand this autonomy. Okay,
  1646. 1:06:24this autonomy means the autonomous the
  1647. 1:06:26first characteristic. So as you can see
  1648. 1:06:28autonomy refers uh to the AI systems
  1649. 1:06:32ability to make decisions and take
  1650. 1:06:35actions on its own to achieve a given
  1651. 1:06:38goal without needing step-by-step human
  1652. 1:06:41interaction. That means if you have
  1653. 1:06:44already seen the example of our AI
  1654. 1:06:45recruiter so there it was kinds of
  1655. 1:06:49autonomous okay it was uh it was
  1656. 1:06:52autonomous agent and it it doesn't need
  1657. 1:06:55any kinds of stepby-step human
  1658. 1:06:57interaction so there I was not giving
  1659. 1:06:59step-by-step human interaction I was not
  1660. 1:07:01giving step-by-step prompt what to do
  1661. 1:07:03right so the things is that I have only
  1662. 1:07:05given my uh requirement my goal so it
  1663. 1:07:10took that particular prompt as a goal
  1664. 1:07:12It was creating the plan. It was
  1665. 1:07:14executing step by step. That's why you
  1666. 1:07:17can see it is uh proactive. That means
  1667. 1:07:20continuously it is working on that
  1668. 1:07:22particular goal. Then autonomy in
  1669. 1:07:24multiple facts like execution. It was
  1670. 1:07:26executing the plan step by step. It was
  1671. 1:07:29doing the decision making. Okay. Uh by
  1672. 1:07:31the decision itself it was uh thinking
  1673. 1:07:34like what to do when it needs to post it
  1674. 1:07:36on different different platform when it
  1675. 1:07:38needs to make the changes. Then tool
  1676. 1:07:40uses. Okay. Let's say when to use what
  1677. 1:07:42kinds of tool let's say whenever I want
  1678. 1:07:44to post the job description what kinds
  1679. 1:07:46of tool I need to call definitely to
  1680. 1:07:48call the LinkedIn
  1681. 1:07:51and no
  1682. 1:07:53right so this kinds of ability my
  1683. 1:07:56autonomous agents will be having that's
  1684. 1:07:57why the first characteristic the
  1685. 1:07:59autonomy we can also call it as a
  1686. 1:08:01autonomous right now the uh thing is
  1687. 1:08:05that autonomy can be controlled
  1688. 1:08:07permission scopes that means you can
  1689. 1:08:09limit
  1690. 1:08:10what uh what tools or actions the agents
  1691. 1:08:14can perform independent uh independently
  1692. 1:08:16can screen candidate but needs approval
  1693. 1:08:19before rejecting anyone okay that means
  1694. 1:08:21it's not like that I am given the full
  1695. 1:08:23autonomous permission to my agents so
  1696. 1:08:26definitely you can set the limit you can
  1697. 1:08:28set the permission so let's say once uh
  1698. 1:08:30one interviewer
  1699. 1:08:33uh having the screening round uh so
  1700. 1:08:35before approval or rejecting so
  1701. 1:08:37definitely I I have to see that manually
  1702. 1:08:41then I will approve that then my agents
  1703. 1:08:42will do that for me. Then human in loop
  1704. 1:08:45we can also call it as a HITL. So insert
  1705. 1:08:48checkpoints where human input is
  1706. 1:08:51required before continuing. That means
  1707. 1:08:54in this case let's say my agent was
  1708. 1:08:55telling can I post this particular job
  1709. 1:08:57description or not. Okay, this is called
  1710. 1:08:59human in loop and every agents are
  1711. 1:09:02having this kinds of functionality.
  1712. 1:09:03Okay, going forward we'll be
  1713. 1:09:05implementing the agents right with
  1714. 1:09:07different different uh framework. So
  1715. 1:09:10there also you are having this kinds of
  1716. 1:09:12functionality with the help of that you
  1717. 1:09:13can um you can actually create this
  1718. 1:09:16kinds of system whenever uh your agent
  1719. 1:09:18is uh needed your human approval it will
  1720. 1:09:21ask for that then you can continue and
  1721. 1:09:23it will start working on that. Then
  1722. 1:09:25override controls allow users to stop,
  1723. 1:09:28pause or change the agents behavior at
  1724. 1:09:31any time. Pause screening command to
  1725. 1:09:34halt
  1726. 1:09:35resume process. Okay. So what happens?
  1727. 1:09:38Let's say in my agents, okay, whatever
  1728. 1:09:41I'm doing, it's completely fine. But it
  1729. 1:09:43should have
  1730. 1:09:46uh it should have my control. Okay, my
  1731. 1:09:49control means let's say I can stop this
  1732. 1:09:51particular agents anytime. I can pause
  1733. 1:09:53anytime. Let's say my um screening route
  1734. 1:09:57is going on in between if I feel like
  1735. 1:09:58okay I have to stop the screening route
  1736. 1:10:00I if I give the command it should stop
  1737. 1:10:02that okay it should stop the process
  1738. 1:10:05that time okay so this is called
  1739. 1:10:07actually override controls then
  1740. 1:10:09guardrails and policies so definitely
  1741. 1:10:12your agent should have guardrails and
  1742. 1:10:13policies nowadays you will see that
  1743. 1:10:16agent integrates different different
  1744. 1:10:18guardrails okay and for this one
  1745. 1:10:20framework came in the market called
  1746. 1:10:21guardrails AI with the help On top of
  1747. 1:10:23that you can define hard rules or
  1748. 1:10:25ethical boundaries to the agent must
  1749. 1:10:27follow. That means let's say if I give
  1750. 1:10:29you one example it will tell never
  1751. 1:10:31schedule
  1752. 1:10:33interview on weekends. Let's say
  1753. 1:10:35weekends I'm completely occupied. I'm
  1754. 1:10:37not available. So I can give the
  1755. 1:10:39restriction. I can give the rules. Never
  1756. 1:10:42schedule interviews on weekends. So my
  1757. 1:10:44agent will never do that. And if you see
  1758. 1:10:47nowadays all the agenti application is
  1759. 1:10:49having this kinds of guidels and
  1760. 1:10:50policies. Let's say if you're asking any
  1761. 1:10:52kinds of violating content, if you're
  1762. 1:10:55asking any kinds of sexual content, if
  1763. 1:10:56you're asking any kinds of let's say
  1764. 1:10:59adult content, definitely it will not
  1765. 1:11:00give you the response with respect to
  1766. 1:11:02that because it has a guardrails and
  1767. 1:11:04policies restriction in the agent
  1768. 1:11:06itself. Okay. And for this we are having
  1769. 1:11:09some library, we having some framework
  1770. 1:11:12definitely will also see in our playlist
  1771. 1:11:14itself. Okay. Then uh autonomy can be
  1772. 1:11:18dangerous. The application autonomously
  1773. 1:11:22send uh sends out job offers with
  1774. 1:11:24incorrect salaries or terms. So if you
  1775. 1:11:27completely make it automated, so what
  1776. 1:11:28we'll do uh there is a possibility your
  1777. 1:11:31agents will send a job uh job letter
  1778. 1:11:34with incorrect salaries. Let's say your
  1779. 1:11:36budget is one lakh but your agent is
  1780. 1:11:38sending the expected salary 10 lakhs,
  1781. 1:11:41right? So there definitely this is this
  1782. 1:11:43is going to be an issue. So that time
  1783. 1:11:45the applications shortlisted candidate
  1784. 1:11:47by age or nationality violating anti-
  1785. 1:11:51discrimination laws. Okay, this is
  1786. 1:11:52another uh terms then the application uh
  1787. 1:11:55spending extra
  1788. 1:11:57on LinkedIn ads. Let's say sometimes
  1789. 1:11:59what will happen if it is running
  1790. 1:12:00autonomously although you are getting a
  1791. 1:12:03good uh let's say application uh from
  1792. 1:12:07your job description but still your
  1793. 1:12:08agent will feel like okay I need more
  1794. 1:12:10and it is spending more money on
  1795. 1:12:12LinkedIn ads. Okay. So these kinds of
  1796. 1:12:14things definitely you have to uh
  1797. 1:12:16overcome. Okay. By uh actually doing the
  1798. 1:12:20human in loop hit okay functionality
  1799. 1:12:24inside your agent. Now the next uh
  1800. 1:12:27things we are having which is uh this
  1801. 1:12:31goal oriented.
  1802. 1:12:33Okay goal oriented. Now you can see what
  1803. 1:12:35is goal oriented. Being a goal oriented
  1804. 1:12:37means that the AI system operates with a
  1805. 1:12:40persistent objective in mind and
  1806. 1:12:43continuously directs its actions to
  1807. 1:12:46achieve that object rather than just
  1808. 1:12:48responding to the isolated prompts.
  1809. 1:12:51Okay, that means if you read here you'll
  1810. 1:12:54see that
  1811. 1:12:56goal acts as a com compass for a
  1812. 1:12:58autonomy. Okay. So to make your agent
  1813. 1:13:03autonomous definitely there should be a
  1814. 1:13:05goal. In this case our goal was hire a
  1815. 1:13:07backend engineer. Okay. This was the
  1816. 1:13:09goal and will act as a compass for the
  1817. 1:13:12autonomy. That means your autonomous
  1818. 1:13:14agent should follow this particular goal
  1819. 1:13:16and to achieve this goal it needs to
  1820. 1:13:18execute different different plan. Okay.
  1821. 1:13:20Now goal can be goal can comes with
  1822. 1:13:22constraint. Definitely you can set some
  1823. 1:13:24constraint. In this case, let's say my
  1824. 1:13:26constraint was four to two to four years
  1825. 1:13:28of experience candidate I only want.
  1826. 1:13:30Okay. Then goals are stored in the core
  1827. 1:13:32memory. That means goal should be stored
  1828. 1:13:34in the core memory. That means in the
  1829. 1:13:36context awareness memory otherwise your
  1830. 1:13:39agent will forget that. What to do?
  1831. 1:13:40Right? Let's say if I give you a basic
  1832. 1:13:44actually template the common template
  1833. 1:13:46for all the agents it stores the data in
  1834. 1:13:48the memory. So this is a JSON format.
  1835. 1:13:50Let's say you can store any kinds of
  1836. 1:13:53database here. Uh internally agent uses
  1837. 1:13:56a specific database or storage services
  1838. 1:13:59and it stores this kinds of meta data so
  1839. 1:14:02that it can remember. So in this case
  1840. 1:14:04let's say the goal was hire a backend
  1841. 1:14:06engineer. The constraint was 2 to four
  1842. 1:14:09years of experience. Remote is true.
  1843. 1:14:11Stack Python Django cloud. Okay. These
  1844. 1:14:14are the skills I'm looking for. Start is
  1845. 1:14:16active. My agent is always active. when
  1846. 1:14:19I posted the job description. This
  1847. 1:14:22particular date would be also saved.
  1848. 1:14:23Progress job uh description is created.
  1849. 1:14:26True. If not created, it should be
  1850. 1:14:28false. Okay. Posted on different
  1851. 1:14:31platform like LinkedIn and angel list or
  1852. 1:14:34no. Yeah, it has posted. And this is the
  1853. 1:14:36list. How many application received so
  1854. 1:14:39far? Only eight applications. Interview
  1855. 1:14:42schedules with two applications. Okay.
  1856. 1:14:44So this is the storing uh I mean
  1857. 1:14:47strategy for every agents. So let's say
  1858. 1:14:50each and every framework is having
  1859. 1:14:51different way they stores the data but
  1860. 1:14:54this is the common if I tell uh one
  1861. 1:14:57common let's say structure. So this is
  1862. 1:14:59the common structure that's how the goal
  1863. 1:15:01should be stored in the core memory.
  1864. 1:15:03Okay. All the uh running instance
  1865. 1:15:06metadata would be saved in the core
  1866. 1:15:07memory. That's how it usually saves and
  1867. 1:15:10it will take that particular data from
  1868. 1:15:12the memory itself to continue the plan
  1869. 1:15:15to continue the goal. Okay, that's how
  1870. 1:15:17one agent remembers each and everything.
  1871. 1:15:19Now I think you are getting now goals
  1872. 1:15:22can be altered as well. Let's say once
  1873. 1:15:25you have set one goal, you can also
  1874. 1:15:26change that particular goal to another
  1875. 1:15:28one. This is also possible here. Okay.
  1876. 1:15:31Now the next characteristic it is the
  1877. 1:15:33planning.
  1878. 1:15:35Okay, planning. So you can see planning
  1879. 1:15:37is is the agent's ability to break down
  1880. 1:15:39a highle goal into structured sequence
  1881. 1:15:42of actions or sub goals and decide the
  1882. 1:15:45best path to achieve the desired
  1883. 1:15:47outcome. Okay, that means let's say I
  1884. 1:15:50have given a prompt I have to hire a
  1885. 1:15:52backend engineer. Now to achieve this
  1886. 1:15:54particular goal, what uh this agent has
  1887. 1:15:57to do? Agent has to create a
  1888. 1:16:00different different Okay, agent has to
  1889. 1:16:02create a different different uh plan. I
  1890. 1:16:05think you saw that what was the plan. So
  1891. 1:16:07for that particular example, it was uh
  1892. 1:16:10preparing the job description, posting
  1893. 1:16:13on different different platform. Okay,
  1894. 1:16:15then it was uh continuously monitoring
  1895. 1:16:17that this was the plan. Now whenever it
  1896. 1:16:20is planning, you'll see that generating
  1897. 1:16:23multiple candidate plans. It will only
  1898. 1:16:25not let's say proposed one plan. It
  1899. 1:16:27might give you multiple plan. Okay,
  1900. 1:16:29let's say plan A post a job description
  1901. 1:16:32on LinkedIn, GitHub, jobs or angel list.
  1902. 1:16:37Okay, plan B is that use internal
  1903. 1:16:39referrals. Okay, and hiring agencies.
  1904. 1:16:43So, it has suggested you two plans. Now,
  1905. 1:16:46it is asking for your feedback. Okay,
  1906. 1:16:50now based on your choice, you can select
  1907. 1:16:53which plan you want to go ahead with. So
  1908. 1:16:56whenever your agent
  1909. 1:16:59uh agents are working it has the
  1910. 1:17:01reasoning capacity that means uh it
  1911. 1:17:03should also minimize my cost right and
  1912. 1:17:06if it is suggesting me to plan so
  1913. 1:17:10definitely if I'm taking the plan A so
  1914. 1:17:12there I will I will let's say spend less
  1915. 1:17:16less amount because here I directly post
  1916. 1:17:18on LinkedIn GitHub jobs and handle list
  1917. 1:17:20okay but if I'm taking the plan B I if
  1918. 1:17:22I'm taking some hiring agency so
  1919. 1:17:24definitely I have to take their
  1920. 1:17:25subscription plan right so there I have
  1921. 1:17:27to pay more money so get it so that's
  1922. 1:17:29why it is giving you different different
  1923. 1:17:32plan okay then evaluate each plan as I
  1924. 1:17:36told you agents will itself evaluate the
  1925. 1:17:38plan let's say plan A is perfect or plan
  1926. 1:17:41B is perfect for this particular work
  1927. 1:17:43based on that it will give you the
  1928. 1:17:45suggestion then the efficiency which is
  1929. 1:17:47faster so if I'm going with plan A or
  1930. 1:17:49plan B which is faster so definitely
  1931. 1:17:51plan um uh A is little bit faster
  1932. 1:17:54because I can directly
  1933. 1:17:56post the jobs on the platform itself and
  1934. 1:17:59get the applications. Okay. Then which
  1935. 1:18:01one is having less cost? Definitely plan
  1936. 1:18:03A is having less cost. Then risk will it
  1937. 1:18:07fail if we get no applications? Okay.
  1938. 1:18:09Then alignment with constraints remote
  1939. 1:18:11jobs only budget. Okay. So these are my
  1940. 1:18:15uh steps inside the plan. So based on
  1941. 1:18:18this particular evaluation steps it will
  1942. 1:18:21select the plan. Okay. Now third step
  1943. 1:18:23select the best plan with the help of
  1944. 1:18:26human in loop. That means it will
  1945. 1:18:28definitely ask to the human for the best
  1946. 1:18:29plan which one you would like to go
  1947. 1:18:31ahead. So which of these option do you
  1948. 1:18:33prefer a pre-programming policy uh favor
  1949. 1:18:37low cost channel first? Okay. So
  1950. 1:18:39definitely whenever I will take any
  1951. 1:18:41kinds of plan I'll try to check this
  1952. 1:18:43particular low cost
  1953. 1:18:45okay uh option in my mind. So yes uh
  1954. 1:18:48this was the u I mean characteristic
  1955. 1:18:52which is planning. Now the next
  1956. 1:18:54characteristic the reasoning. Now let's
  1957. 1:18:56try to understand this reasoning guys.
  1958. 1:18:59So what is reasoning? First of all let's
  1959. 1:19:01try to understand. As you can see
  1960. 1:19:02reasoning is the uh cognitive process
  1961. 1:19:05through which an agentic system
  1962. 1:19:07interprets informations draws conclusion
  1963. 1:19:10and makes decisions both while planning
  1964. 1:19:13ahead and while executing the actions in
  1965. 1:19:15real time. Reasoning uh during planning
  1966. 1:19:18goals decompositions break down abstract
  1967. 1:19:21goals into cons uh concrete steps tool
  1968. 1:19:25selection decide which tool will be
  1969. 1:19:27needed uh for which step resource uh
  1970. 1:19:30estimation estimated time dependencies
  1971. 1:19:33and risk. Okay, as I already told you,
  1972. 1:19:35whenever a aentic system is working,
  1973. 1:19:38uh it will be working with respect to
  1974. 1:19:41the reasoning because behind the
  1975. 1:19:43reasoning one LLM works, right? And LLM
  1976. 1:19:45has the u actually intelligence um
  1977. 1:19:48capacity so that it can understand uh
  1978. 1:19:51and it can automatically make the
  1979. 1:19:53decision. It can automatically let's say
  1980. 1:19:56break down the goals. Okay, it can
  1981. 1:19:58automatically tell you what kinds of
  1982. 1:19:59tools should be selected. You can also
  1983. 1:20:02uh like work on the resources
  1984. 1:20:04estimations like estimated time,
  1985. 1:20:05dependencies and risk. Okay. So with the
  1986. 1:20:08help of this reasoning guys, these
  1987. 1:20:10agents would be more powerful, more
  1988. 1:20:13efficient. Why? Because I told you if
  1989. 1:20:17one agent is one agent doesn't have the
  1990. 1:20:20reasoning capacity that means this
  1991. 1:20:22should be the simple chatbot only. Okay,
  1992. 1:20:24this should be the simple chatbot only.
  1993. 1:20:26Why a chatbot is different from a AI
  1994. 1:20:29agent? Okay. Why AI agent is powerful?
  1995. 1:20:32Because of this reasoning. Okay. Let's
  1996. 1:20:35say if I'm having a agent, if I'm giving
  1997. 1:20:37any kinds of input and it is connected
  1998. 1:20:40with different different tools, right?
  1999. 1:20:42Some kinds of tools it is connected.
  2000. 1:20:43Now, whenever I'm giving a input, now
  2001. 1:20:46this will perform this reasoning
  2002. 1:20:48operation. It will decide the question
  2003. 1:20:50human is asking whether I have to
  2004. 1:20:52directly give the answer. I have to
  2005. 1:20:54refer the tool for that. Okay. So, this
  2006. 1:20:56is called actually reasoning. So,
  2007. 1:20:58reasoning is super important here. Okay.
  2008. 1:21:01Now here you can see reasoning,
  2009. 1:21:03duration, execution, decision making,
  2010. 1:21:05choosing between option uh three
  2011. 1:21:08candidate matches, schedule uh for two
  2012. 1:21:10uh two uh best candidate and reject one.
  2013. 1:21:14So this kinds of decision making is
  2014. 1:21:15taking your uh agent okay with the help
  2015. 1:21:18of this reasoning with the help of this
  2016. 1:21:20LLM. Now, HITL handling
  2017. 1:21:24knowing when to pause and ask for help.
  2018. 1:21:27Uh unsure about the salary range. Okay,
  2019. 1:21:29for an example, let's say with the help
  2020. 1:21:31of this reasoning, it is automatically
  2021. 1:21:33decide when it should ask for the help
  2022. 1:21:36to the human when it needs to ask for
  2023. 1:21:38the confirmation from the human. Okay,
  2024. 1:21:40in this case, let's say uh my uh my
  2025. 1:21:43recruiter agent is asking what should be
  2026. 1:21:46the salary range just try to tell me.
  2027. 1:21:48Then error handling, interpreting tools,
  2028. 1:21:50API failure and re re uh re uh
  2029. 1:21:54recovering. Okay, let's say sometimes
  2030. 1:21:56some of the tool might be down right
  2031. 1:21:58that time uh how this particular agent
  2032. 1:22:01will handle that particular error. Let's
  2033. 1:22:03say if my tool to tool A is not working
  2034. 1:22:06so definitely it will try to move to
  2035. 1:22:08tool B. Okay. So this kinds of ability
  2036. 1:22:11this reasoning will be having. Now the
  2037. 1:22:14next one adaptability. So what is
  2038. 1:22:16adaptability? You can see adaptability
  2039. 1:22:18is the agent's ability to modify its
  2040. 1:22:21plan, strategies or action responses to
  2041. 1:22:23unexpected conditions all while staying
  2042. 1:22:27aligned with the goal. Okay. So that
  2043. 1:22:29means I told you let's say in that
  2044. 1:22:31particular case I think you remember
  2045. 1:22:34uh we got very less application right
  2046. 1:22:36and my agent was automatically give you
  2047. 1:22:39the suggestion and it was it was telling
  2048. 1:22:41like I need to change the job
  2049. 1:22:43description to backend engineering to
  2050. 1:22:45full stack engineer. So this is called
  2051. 1:22:47adaptability. Your agent is
  2052. 1:22:48automatically modifying the plans,
  2053. 1:22:50modifying the strategy. Then again it is
  2054. 1:22:52working with respect to that. Okay. You
  2055. 1:22:54can see failures in uh then external
  2056. 1:22:57feedbacks and changing the goals.
  2057. 1:23:00Okay. Now what is the next next uh
  2058. 1:23:05characteristic is the context awareness.
  2059. 1:23:07I already told you what is context
  2060. 1:23:09awareness. Context awareness is the
  2061. 1:23:10agent's ability to understand, retain
  2062. 1:23:13and utilize relevant information from uh
  2063. 1:23:16from the ongoing task, past interaction,
  2064. 1:23:19user preferences and environmental
  2065. 1:23:22uh cues to make better decisions through
  2066. 1:23:24the multiple steps. Okay. And if I'm
  2067. 1:23:27talking about context awareness, this is
  2068. 1:23:29nothing but it's a memory. Okay. You can
  2069. 1:23:31see context awareness is implemented
  2070. 1:23:34through memory. Here we create two kinds
  2071. 1:23:36of memory. one is short memory, one is
  2072. 1:23:38long me long-term memory, short-term
  2073. 1:23:40memory and long-term memory. So as you
  2074. 1:23:41can see
  2075. 1:23:43uh if my uh agent doesn't have the
  2076. 1:23:47context of my previous let's say uh
  2077. 1:23:50goals or plan so then how it will
  2078. 1:23:52progress the current one. So definitely
  2079. 1:23:55to run the current progress it should
  2080. 1:23:58have the previous context right. So
  2081. 1:24:00let's say in this case I have given I
  2082. 1:24:02want to hire a backend engineer with two
  2083. 1:24:03to four years of experience. So it
  2084. 1:24:05should have these kinds of informations
  2085. 1:24:07in the context memory based on that it
  2086. 1:24:09will make the decision. Okay, this is
  2087. 1:24:10what actually it is explaining and what
  2088. 1:24:13are the tool responses it is getting
  2089. 1:24:15definitely it will also try to uh store
  2090. 1:24:18that particular responses to the context
  2091. 1:24:20memory so that it can give you the
  2092. 1:24:22better response with respect to that.
  2093. 1:24:24Now at the end this context awareness
  2094. 1:24:26implemented through memory. So here we
  2095. 1:24:28create short-term memory and long-term
  2096. 1:24:29memory. Short-term memory we create for
  2097. 1:24:31the current state. Let's say if one
  2098. 1:24:33current state is running if it is
  2099. 1:24:34creating some metadata we will be
  2100. 1:24:36storing in the short-term memory and
  2101. 1:24:37long-term memory means the whole
  2102. 1:24:39conversation the whole uh user
  2103. 1:24:41interaction it is doing it should have
  2104. 1:24:43the u u present in the long-term memory.
  2105. 1:24:46Okay. So this is the idea. So yes guys
  2106. 1:24:48these are some characteristic uh we
  2107. 1:24:51usually have inside any kinds of AI
  2108. 1:24:53agents and how you will understand this
  2109. 1:24:55particular application is a AI agents
  2110. 1:24:57application or authentic application. If
  2111. 1:24:59this application is having this kinds of
  2112. 1:25:01characteristic definitely you can uh
  2113. 1:25:04think about this is a aenti application.
  2114. 1:25:06Okay. Definitely in the architecture
  2115. 1:25:07itself these kinds of character uh
  2116. 1:25:10characteristic should be mentioned. So
  2117. 1:25:12guys uh now we'll try to see the
  2118. 1:25:14components of agenti application what
  2119. 1:25:17are the component one AI agent is having
  2120. 1:25:20uh using uh you can see the first
  2121. 1:25:21component is the brain. Okay whenever
  2122. 1:25:23I'm talking about the brain so here LLM
  2123. 1:25:27would be utilized. You can use any kinds
  2124. 1:25:29of LLM here. So LLM has the reasoning
  2125. 1:25:32capacity with the help of that it will
  2126. 1:25:34make the decisions. It will try to do
  2127. 1:25:37the HITL operation. It will do the uh
  2128. 1:25:41tool selections. Okay. All the
  2129. 1:25:42operations be happening with respect to
  2130. 1:25:43this particular brain. And the second is
  2131. 1:25:46the orchestrator. So what is
  2132. 1:25:47orchestrator? To build a entire aenti
  2133. 1:25:50system, okay, we need some orchestrator.
  2134. 1:25:54Orchestrator means this is the
  2135. 1:25:56framework. Okay, framework let's say it
  2136. 1:25:58will do the connection with the LLM that
  2137. 1:26:00means brain it will make the connection
  2138. 1:26:02with tool then whenever it is uh
  2139. 1:26:05required for the tool calling it will
  2140. 1:26:07perform the tool calling operation
  2141. 1:26:08whenever it is required let's say it
  2142. 1:26:10will uh call the uh h ITL that means
  2143. 1:26:14human in loop right it will ask for the
  2144. 1:26:16uh approval from the human so these
  2145. 1:26:18kinds of things if I want to create a
  2146. 1:26:20complete aent application I need to use
  2147. 1:26:22some framework I can't create with the
  2148. 1:26:25help of simple python or I can't with
  2149. 1:26:27the help of simple tensorflow right or
  2150. 1:26:29langen this is not possible so I have to
  2151. 1:26:31use some end to-end framework for that
  2152. 1:26:33okay so in the market there are some
  2153. 1:26:35famous framework like we are having crew
  2154. 1:26:37AI
  2155. 1:26:39okay we are having langraph
  2156. 1:26:44we are having autogen
  2157. 1:26:47some some no code platform is also
  2158. 1:26:49available like n okay so a apart from
  2159. 1:26:52that some other like framework are also
  2160. 1:26:54available but these are framework
  2161. 1:26:56actually very uh common and very popular
  2162. 1:26:59and very powerful in the market nowadays
  2163. 1:27:01and people use that developer use that
  2164. 1:27:03to create agenti applications. Okay. So
  2165. 1:27:05throughout the entire um this uh course
  2166. 1:27:08guys we'll try to master these are the
  2167. 1:27:10framework we'll see the entire crew AI
  2168. 1:27:12framework we'll try to develop a AI
  2169. 1:27:14agent with help of crew AI okay end to
  2170. 1:27:16end multi- aent system we'll try to
  2171. 1:27:17create then lang graph we'll try to
  2172. 1:27:19explore we'll try to create end to end
  2173. 1:27:20application with lang graph we'll try to
  2174. 1:27:22see the autogen we'll try to understand
  2175. 1:27:24the entire autogen autogen component
  2176. 1:27:26we'll create the AI agents with autogen
  2177. 1:27:28we'll try to see some no code platform
  2178. 1:27:30as well like n we'll see how we can uh
  2179. 1:27:34create the AI agents without writing any
  2180. 1:27:36kinds of code by doing some drag and
  2181. 1:27:38drop operation each and everything we'll
  2182. 1:27:40be learning. Okay. So that's why
  2183. 1:27:42orchestrator is also required and this
  2184. 1:27:43is one other component of a AI agent and
  2185. 1:27:46orchestrator means I AI agent building
  2186. 1:27:49framework. Okay. Always remember langen
  2187. 1:27:52can be also utilized with the help of
  2188. 1:27:54lang also you can create some of the
  2189. 1:27:56simple agents but uh later on
  2190. 1:27:58[clears throat] langen published
  2191. 1:27:59actually langraph so people are moving
  2192. 1:28:01to the langraph for building these kinds
  2193. 1:28:03of AI agents. Okay. Now [clears throat]
  2194. 1:28:05the next one is the tool. So definitely
  2195. 1:28:09tool should be available as a component.
  2196. 1:28:11Here we can utilize any kinds of tool
  2197. 1:28:13whether it's any kinds of search tool,
  2198. 1:28:15whether it is any kinds of calendar tool
  2199. 1:28:18or any kinds of application tool. Okay.
  2200. 1:28:20If you just open the internet and if you
  2201. 1:28:22search like agentic AI tools list, okay,
  2202. 1:28:25you'll see that there are thousands of
  2203. 1:28:26tool listers available. Okay, whether it
  2204. 1:28:28is search, whether it is uh any kinds of
  2205. 1:28:31application with your Google drive, with
  2206. 1:28:33your calendar. So, let me show you some
  2207. 1:28:35of the list.
  2208. 1:28:38So guys, as you can see there is a
  2209. 1:28:39GitHub called AINE tools catalog and
  2210. 1:28:42there are some other website as well you
  2211. 1:28:44will be getting over the internet. So if
  2212. 1:28:45you open it uh open this up. So this uh
  2213. 1:28:49this is having all kinds of uh tool uh
  2214. 1:28:51tools and toolkit as you can see. Uh so
  2215. 1:28:53we are having archives. So tools to read
  2216. 1:28:56archive papers. So I think you know if
  2217. 1:28:58we read any kinds of research paper we
  2218. 1:29:00go to the archive website. Okay
  2219. 1:29:02archive.org. So this is also a tool. Uh
  2220. 1:29:05this tool is available in the framework
  2221. 1:29:07itself. You can use this tool for
  2222. 1:29:09reading any kinds of research paper. You
  2223. 1:29:11can connect your AI aens with the
  2224. 1:29:12research paper uh actually world. Okay.
  2225. 1:29:15Then uh by search is there. Bing search
  2226. 1:29:17is there. B search is there. These are
  2227. 1:29:19my search tool. Okay. Then code doc
  2228. 1:29:22search is there. CSV search is there.
  2229. 1:29:23That's how you can see Google search is
  2230. 1:29:25there. We are having different different
  2231. 1:29:27tool. Okay. So this is for the code
  2232. 1:29:29interpreter. Okay. These are the code
  2233. 1:29:31interpreter. If you want to interpret
  2234. 1:29:32any kinds of code, these tools you can
  2235. 1:29:34use. If you want to do a productivity,
  2236. 1:29:35these tools you can use. Okay. You can
  2237. 1:29:37connect with your calendar, email, zoom.
  2238. 1:29:39Okay. This is for regular automation.
  2239. 1:29:42Now this is for web browsing. If you
  2240. 1:29:43want to browse the web, these tool you
  2241. 1:29:45can use. If you want to connect with the
  2242. 1:29:46database, these are the database tools
  2243. 1:29:48are available. If you want to do the
  2244. 1:29:49file operation, these are the tools are
  2245. 1:29:51available. Okay. So that's how whatever
  2246. 1:29:53tool you want everything is available
  2247. 1:29:56okay in the orchestrator framework in
  2248. 1:29:57the AI agents you can connect with
  2249. 1:29:59anyone okay
  2250. 1:30:02now next we are having the memory
  2251. 1:30:06memory is another component so I told
  2252. 1:30:09you context uh awareness is required so
  2253. 1:30:12here we use something called memory okay
  2254. 1:30:15so memory should be also integrated and
  2255. 1:30:17for memory development uh we use
  2256. 1:30:20orchestrator framework in the
  2257. 1:30:21orchestrator framework Mark itself we
  2258. 1:30:22are having different different memory
  2259. 1:30:23function either you can also use
  2260. 1:30:25different different database for the
  2261. 1:30:26memory you can do anything here then the
  2262. 1:30:29supervisor so this is the
  2263. 1:30:32hittl that means human in loop okay
  2264. 1:30:36human in the loop so with the help of
  2265. 1:30:38the supervisor what it does it try uh it
  2266. 1:30:41try to interact with the human when any
  2267. 1:30:44helps is uh required it will try to uh
  2268. 1:30:46ask for the help it will ask for the
  2269. 1:30:48human guidance or feedback and it will
  2270. 1:30:51continue agents. Okay. So these six
  2271. 1:30:53actually components uh sorry five
  2272. 1:30:56components are available in any kinds of
  2273. 1:30:58AI agents and this is the highle
  2274. 1:31:00actually diagram I have shown you. Some
  2275. 1:31:02other component might be available as a
  2276. 1:31:05lowle but this is the main one. Okay. So
  2277. 1:31:07if you find these are the components are
  2278. 1:31:09available inside AI agents. uh yeah you
  2279. 1:31:12can I mean select that particular
  2280. 1:31:15application as aka application and
  2281. 1:31:17whenever you are creating you have to um
  2282. 1:31:20take care these are the component okay
  2283. 1:31:22inside your application now uh let me
  2284. 1:31:27show you the component explanation as I
  2285. 1:31:30already told you the brain wise here
  2286. 1:31:32what we do we use a large language model
  2287. 1:31:34and what is the use of large language
  2288. 1:31:36model the goal interpretation planning
  2289. 1:31:38reasoning tool selections okay
  2290. 1:31:40everything is uh everything we do with
  2291. 1:31:43the help of this particular brain or
  2292. 1:31:44large language model. The orchestrator
  2293. 1:31:46orchestrator is a framework
  2294. 1:31:49uh AI agents implementation framework
  2295. 1:31:50with the help of uh we can do task
  2296. 1:31:52sequencing conditional routing, ret
  2297. 1:31:55logic, looping, iterations and
  2298. 1:31:57delegations. Okay. Then tools we are
  2299. 1:31:59having so tools with the help of tools
  2300. 1:32:01we can uh connect our AI agents with
  2301. 1:32:03external sources. Okay. uh and to
  2302. 1:32:05knowledge base as well. That's if you're
  2303. 1:32:06creating a ragbased agents that time our
  2304. 1:32:09uh knowledge base should be external
  2305. 1:32:10sources. Okay, this is this would be
  2306. 1:32:12perform as a tool that time. Now the
  2307. 1:32:14next component I told you the memory. So
  2308. 1:32:16what memory does? So memory actually
  2309. 1:32:19basically uh stores all of the context
  2310. 1:32:22of the conversation and uh we create
  2311. 1:32:25actually two kinds of memory short-term
  2312. 1:32:27memory and long-term memory and it will
  2313. 1:32:29uh do the state uh tracking. Okay.
  2314. 1:32:33um research tracking is required. I
  2315. 1:32:34already told you I already showed you
  2316. 1:32:36previously, right? Uh it was uh storing
  2317. 1:32:38the data in a JSON format. So this is
  2318. 1:32:40also required. Then the supervisor so
  2319. 1:32:43approval uh requested for HITL that
  2320. 1:32:46means human in the loop. Then guardrails
  2321. 1:32:48uh enforcement then age case uh
  2322. 1:32:51escalation. Okay. So let's say if you
  2323. 1:32:53want to block some unsafe or non uh
  2324. 1:32:57complaint behavior, you can use the
  2325. 1:32:58guardrails evaluation. I will also show
  2326. 1:33:00you how to perform the guard's
  2327. 1:33:02evaluation and uh age uh case uh
  2328. 1:33:05escalation that means alert human when
  2329. 1:33:07uncertainity conflict arises. Okay. And
  2330. 1:33:10you already understood about this uh
  2331. 1:33:12htil okay human in loop uh human in the
  2332. 1:33:15loop format. So yes guys these are some
  2333. 1:33:17components are available of AI agents
  2334. 1:33:20and whenever we are developing our own
  2335. 1:33:22AI agents we have to take care these are
  2336. 1:33:24the part and every AI agents are having
  2337. 1:33:26this kinds of component uh nowadays.
  2338. 1:33:29Okay. So apart from that I think uh uh
  2339. 1:33:32there is nothing uh inside a if you feel
  2340. 1:33:34like okay if there is any new things you
  2341. 1:33:36can just do let me know in the comment
  2342. 1:33:38section definitely I'll try to cover
  2343. 1:33:39that as well. Okay but so far my
  2344. 1:33:42understanding I think these are some uh
  2345. 1:33:44we have to follow whenever we are
  2346. 1:33:46creating or whenever we are working on
  2347. 1:33:48aentki system. So yes guys uh this is
  2348. 1:33:50all about from this video. Uh I hope you
  2349. 1:33:53have understood and this was helpful for
  2350. 1:33:55you. I think I already told you uh in my
  2351. 1:33:58previous uh video uh like there are uh
  2352. 1:34:01some components are available especially
  2353. 1:34:04whenever I'm talking about uh the
  2354. 1:34:06agentic AI uh one of the component is
  2355. 1:34:09the orchestrator right orchestrator
  2356. 1:34:11means there we use some kinds of
  2357. 1:34:14framework okay with the help of these
  2358. 1:34:16are the framework we create we implement
  2359. 1:34:18the AI agents whether it's a single
  2360. 1:34:20agents whether it's a multi multiAI uh
  2361. 1:34:23agent system uh we try to create these
  2362. 1:34:26kinds of things right
  2363. 1:34:28so there is a concept guys uh you have
  2364. 1:34:32to understand before I start with this
  2365. 1:34:34kinds of orchestrator framework the
  2366. 1:34:36concept name is asynchronous programming
  2367. 1:34:39okay so why this asynchronous
  2368. 1:34:41programming is required uh because if
  2369. 1:34:43you see u going forward we'll be
  2370. 1:34:46creating the multi- aent system and to
  2371. 1:34:49create the multi- aent system guys we'll
  2372. 1:34:51be using this kinds of orchestrator
  2373. 1:34:53framework and internally This
  2374. 1:34:55orchestrator framework uses asynchronous
  2375. 1:34:57programming. Okay, that means it will
  2376. 1:34:59run your agents in parallel. Let's say
  2377. 1:35:02you have created uh 20 agents. So what
  2378. 1:35:06it will do instead of running u agents
  2379. 1:35:09as a sequentially, it will run all of
  2380. 1:35:12the agents in parallel so that your
  2381. 1:35:14execution would be more fast. So this
  2382. 1:35:16concept I'm going to discuss in detail
  2383. 1:35:18guys. No need to worry. Uh first of all,
  2384. 1:35:21let me show you one thing. actually uh I
  2385. 1:35:23have just figured out
  2386. 1:35:25let's say if I go to the Google so here
  2387. 1:35:28if I search like is lang graph uses
  2388. 1:35:31asynchronous in the back end for multi-
  2389. 1:35:33aents so I think you know lang graph is
  2390. 1:35:35one of the orchestrator framework with
  2391. 1:35:37the help of lang graph we create agentic
  2392. 1:35:40AI applications right and we'll be also
  2393. 1:35:43mastering this langraph inside our codes
  2394. 1:35:45so as you can see the response was yes
  2395. 1:35:47lang graph is uh designed with first
  2396. 1:35:50class asynchronous supports in the back
  2397. 1:35:52end for multi- aent system that means uh
  2398. 1:35:56it is utilizing the asynchronous
  2399. 1:35:58programming asynchronous concept in the
  2400. 1:35:59back end okay now if I just go below
  2401. 1:36:03let's say I have asked for about the
  2402. 1:36:05autogen because autogen also will be
  2403. 1:36:07covering inside our course so as you can
  2404. 1:36:09see autogen also utilizes asynchronous
  2405. 1:36:12programming at it core but it is uh
  2406. 1:36:16architecture fundamentally different
  2407. 1:36:17from the langraph state uh langraph's
  2408. 1:36:20state machine approach approach but
  2409. 1:36:22internally it is uses asynchronous
  2410. 1:36:24programming concept. Now again I asked
  2411. 1:36:26like uh what about crew AI? Okay so you
  2412. 1:36:30can see crewi also supports asynchronous
  2413. 1:36:32execution but it approaches
  2414. 1:36:34orchestration differently than langraph
  2415. 1:36:36and autogen while uh langraph uses uh a
  2416. 1:36:40state machine and autogen uses a actor
  2417. 1:36:43model. Crew AI is built around
  2418. 1:36:46role-based collaboration and
  2419. 1:36:47processdriven execution model. Okay. But
  2420. 1:36:51the main fun is that all of the
  2421. 1:36:53orchestrator framework we are using for
  2422. 1:36:55developing these kinds of multi- aents
  2423. 1:36:57application internally it is uses
  2424. 1:37:00asynchronous okay as synchronous
  2425. 1:37:02programming. Now before I start with
  2426. 1:37:05these are the orchestrator framework
  2427. 1:37:06first of all I want to clarify what is
  2428. 1:37:08asynchronous programming why it is
  2429. 1:37:10required how asynchronous works okay
  2430. 1:37:12what is parallelism what is uh let's say
  2431. 1:37:16sequential execution each and everything
  2432. 1:37:17I'm going to clarify then we'll start
  2433. 1:37:20with the uh orchestrator framework
  2434. 1:37:22understanding but after that there is
  2435. 1:37:24one more topic uh we have to cover which
  2436. 1:37:27is nothing but pentic pyntic validation
  2437. 1:37:30this is also important because you will
  2438. 1:37:31see that Whatever large language model
  2439. 1:37:33we are having it will generate the
  2440. 1:37:35unstructured output and to make it a
  2441. 1:37:37structured even whenever we are giving
  2442. 1:37:40any kinds of prompt to make our prompt
  2443. 1:37:43uh more structured we use this pentic
  2444. 1:37:45validation okay so this pentic
  2445. 1:37:47validation will be understanding in the
  2446. 1:37:49next video but in this video I will only
  2447. 1:37:50focus on the asynchronous understanding
  2448. 1:37:54okay so here I'm going to give you the
  2449. 1:37:56detailed understanding of asynchronous
  2450. 1:37:59with a theoretical understanding as well
  2451. 1:38:01as the practical understanding as well.
  2452. 1:38:03So let me show you guys what is this
  2453. 1:38:05asynchronous. After that your
  2454. 1:38:07understanding would be more clear and
  2455. 1:38:10you can easily understand these are the
  2456. 1:38:11framework whenever you will be doing the
  2457. 1:38:13coding.
  2458. 1:38:15So let me give you the definition of the
  2459. 1:38:17asynchronous programming. So here is the
  2460. 1:38:19definition.
  2461. 1:38:20Um here is a simple definition you can
  2462. 1:38:23see asynchronous programming in Python.
  2463. 1:38:26Okay, you can see asynchronous
  2464. 1:38:27programming in Python is a programming
  2465. 1:38:30paradigm that allows code to handle okay
  2466. 1:38:33multiple task uh concurrently without
  2467. 1:38:36blocking the program's execution. It is
  2468. 1:38:39primary used to IO bound task example
  2469. 1:38:42network uh request file input and output
  2470. 1:38:46operation database queries. Okay,
  2471. 1:38:48allowing the program to perform other
  2472. 1:38:51operations while waiting for slow
  2473. 1:38:54external events to complete. That means
  2474. 1:38:56this as asynchronous programming will
  2475. 1:38:59help you. Okay, asynchronous programming
  2476. 1:39:01will help you. Okay, asynchronous
  2477. 1:39:03programming will help you to run your
  2478. 1:39:05task in parallel. Okay, so you are not
  2479. 1:39:08supposed to wait for the uh execution.
  2480. 1:39:11Let's say we know that we use synchron
  2481. 1:39:13synchronous programming so far. Yes or
  2482. 1:39:15no guys, we use synchronous programming
  2483. 1:39:18so far. In synchronous programming, what
  2484. 1:39:20happens? Let's say if I execute a code
  2485. 1:39:22block, first of all, it will complete
  2486. 1:39:24that. Okay, after the execution is
  2487. 1:39:28complete, okay, then it will execute the
  2488. 1:39:30second part of that particular code.
  2489. 1:39:32Okay, but in between, let's say if you
  2490. 1:39:34are waiting for the execution, okay, if
  2491. 1:39:36you're using asynchronous programming,
  2492. 1:39:38it can run another task in parallel.
  2493. 1:39:41Okay, so these are the like say
  2494. 1:39:43functionality we'll be getting here. Now
  2495. 1:39:45you can ask me why this is required.
  2496. 1:39:47Okay, why this asynchronous programming
  2497. 1:39:49is required inside AI agents
  2498. 1:39:50implementation. Agentic AI, you can
  2499. 1:39:53create two kinds of agent. One is the
  2500. 1:39:54simple agent. Okay. One is the simple
  2501. 1:39:58agent. So basically simple agents you
  2502. 1:40:00create
  2503. 1:40:02only one block. Okay. It can only handle
  2504. 1:40:05one particular task. Okay. But whenever
  2505. 1:40:10let's say you have complex problem you
  2506. 1:40:12have to divide the task in smaller
  2507. 1:40:13chunks. And what you will do? You will
  2508. 1:40:15be creating multiple agents. Okay.
  2509. 1:40:18Multiple agents you will be creating.
  2510. 1:40:19Let's say this is agent one. This is
  2511. 1:40:21agent two. This is agent three. Okay.
  2512. 1:40:24And what will happen? You will assign
  2513. 1:40:26the task for all the agents. And these
  2514. 1:40:29agents will be executing either
  2515. 1:40:32independently,
  2516. 1:40:34independently
  2517. 1:40:38or dependently.
  2518. 1:40:43Okay. Dependently.
  2519. 1:40:45So it's your design philosophy. If you
  2520. 1:40:47are making it as a independently that
  2521. 1:40:49time it will run as an independently. If
  2522. 1:40:51you are making it to dependent okay it
  2523. 1:40:53will run as a dependently. So basically
  2524. 1:40:56what happens let's say if you run these
  2525. 1:40:58are the agents okay these are the agents
  2526. 1:41:01in a synchronous programming okay in a
  2527. 1:41:03synchronous programming what will happen
  2528. 1:41:05first of all these agents need to be
  2529. 1:41:07completed these agents execution need to
  2530. 1:41:09be completed once this agent uh when
  2531. 1:41:12this agents will be executed then it
  2532. 1:41:14will move to the next agents okay next
  2533. 1:41:17code block then this agents will be
  2534. 1:41:19executed okay once it is completed then
  2535. 1:41:21it will go to this particular agents
  2536. 1:41:23okay then it will try to run this
  2537. 1:41:25particular agent. So let's say this
  2538. 1:41:27agents is taking 3 minute to run. Sorry,
  2539. 1:41:30let's say here I can just tell you
  2540. 1:41:33let's say this agency is taking 1 minute
  2541. 1:41:34to run. This agency is also taking let's
  2542. 1:41:37say 1.5 minute to run. Okay. This agency
  2543. 1:41:40is also taking let's say 1 minute to
  2544. 1:41:41run. So what is happening? You have to
  2545. 1:41:43wait for 1 minute. Again you have to
  2546. 1:41:45wait for 1.5 minute. Again you have to
  2547. 1:41:46wait for 1 minute. Okay. So if you like
  2548. 1:41:50uh add all of the time you will see that
  2549. 1:41:52at the end you are having okay 3.5
  2550. 1:41:55minutes 3.5 minutes you have to wait for
  2551. 1:41:58the execution but if you run this task
  2552. 1:42:00in parallel okay if you run this task in
  2553. 1:42:02parallel let's say this particular
  2554. 1:42:04agents will do the online search
  2555. 1:42:05operation so basically if you're doing
  2556. 1:42:07the online search operation you'll be
  2557. 1:42:09hitting some URL like right URL and to
  2558. 1:42:11get the response this will take some
  2559. 1:42:13time let's say sometimes this web server
  2560. 1:42:16might be slow that time it will be
  2561. 1:42:17giving you flow response. So instead of
  2562. 1:42:19waiting for that you can execute your
  2563. 1:42:22other agents. So let's say these agents
  2564. 1:42:23will try to collect the uh images. These
  2565. 1:42:26agents will try to collect the let's say
  2566. 1:42:29any other file okay from the internet.
  2567. 1:42:31So don't wait to execute any other
  2568. 1:42:34agents. Just try to run them in a
  2569. 1:42:36synchronous way. Okay, in a parallel
  2570. 1:42:38way. So each of the agents will be
  2571. 1:42:40running in a parallel way. So let's say
  2572. 1:42:42this if this agent is also taking 1
  2573. 1:42:44minutes. Okay. So simultaneously you are
  2574. 1:42:47running something okay in the back end.
  2575. 1:42:48So you are not supposed to wait for 3.5
  2576. 1:42:50minutes. Get it? So that is the things I
  2577. 1:42:53just wanted to tell you. So let's say
  2578. 1:42:55whenever you are creating multi- aent
  2579. 1:42:57system and whenever you are creating
  2580. 1:42:58let's say independent connection okay
  2581. 1:43:01independent let's say policy that time
  2582. 1:43:03you should use this asynchronous
  2583. 1:43:05programming inside um inside let's say
  2584. 1:43:08Python or let's say whatever programming
  2585. 1:43:09you're using you have to follow that.
  2586. 1:43:11And if you see any kinds of agents code
  2587. 1:43:13you will be uh seeing people are using
  2588. 1:43:16this as okay uh essence
  2589. 1:43:20this particular syntax people are using
  2590. 1:43:22that okay so what is this essence as
  2591. 1:43:24means asynchronous okay as synchronous
  2592. 1:43:27functionality so in python there is a
  2593. 1:43:28library called asense IO so we'll be
  2594. 1:43:30following that particular library to
  2595. 1:43:32implement this particular code okay so
  2596. 1:43:33let me give you one example of
  2597. 1:43:35asynchronous and synchronous programming
  2598. 1:43:38so let's say here I can write
  2599. 1:43:40synchronous Synchronous
  2600. 1:43:45programming
  2601. 1:43:52and this side we have asynchronous
  2602. 1:43:54programming.
  2603. 1:44:07So in synchronous programming what
  2604. 1:44:08happens? Let's say
  2605. 1:44:12what I can do I can give you one
  2606. 1:44:14example. Uh let's say here
  2607. 1:44:18um let's say you are you are having a
  2608. 1:44:23you are having a
  2609. 1:44:27gas stove. Okay. Gas stove.
  2610. 1:44:31Uh in this gas stove you only have one
  2611. 1:44:35uh
  2612. 1:44:37one fire section. Okay. one fire
  2613. 1:44:40section. So let's say you are having uh
  2614. 1:44:42three dishes. Okay, you are having three
  2615. 1:44:45dishes
  2616. 1:44:47to cook.
  2617. 1:44:50So what you will do? First of all, you
  2618. 1:44:52will take the first dish and you will
  2619. 1:44:54cook that. Once first dish is complete,
  2620. 1:44:56then you will take the second dish. Then
  2621. 1:44:58you have to complete then you will be
  2622. 1:45:00taking the third dish. Then you will be
  2623. 1:45:01completing. Okay, that's how you can see
  2624. 1:45:03it is taking T1, it is taking T2, it is
  2625. 1:45:06taking T3 time. Okay. So basically you
  2626. 1:45:09have to wait for u you have to wait for
  2627. 1:45:13the previous execution or let's say
  2628. 1:45:14previous task to be completed then you
  2629. 1:45:16can start the remaining task. But in
  2630. 1:45:19asynchronous programming what happens
  2631. 1:45:21let's say you are having same gas stove
  2632. 1:45:24but here you are having let's say three
  2633. 1:45:26fired section. You are having three fire
  2634. 1:45:29section and you are having three dishes.
  2635. 1:45:32Okay, let's say dish one,
  2636. 1:45:34dish two and dish three. So what you
  2637. 1:45:38have to do? You just need to
  2638. 1:45:41run all of them simultaneously.
  2639. 1:45:44Basically you are giving three dish to
  2640. 1:45:46the three fire section. Okay. Now at the
  2641. 1:45:49T1 time, okay, your all of the dishes
  2642. 1:45:52should be completed. So you are not
  2643. 1:45:54supposed to wait for the T1, T2 and T3
  2644. 1:45:56to be completed. Okay. So this is the
  2645. 1:45:58difference between synchronous
  2646. 1:46:00programming and asynchronous
  2647. 1:46:01programming. I hope you get it guys. So
  2648. 1:46:03in Python we usually follow this
  2649. 1:46:04synchronous programming. That means if
  2650. 1:46:06you're running a function first of all
  2651. 1:46:08that function would be completed then
  2652. 1:46:10the remaining code would be executed.
  2653. 1:46:12Now in programming we we call it as a
  2654. 1:46:16sub routine. Let me just write here
  2655. 1:46:19sub
  2656. 1:46:21routine
  2657. 1:46:24and we also call it as cool routine.
  2658. 1:46:29I'll be discussing about what is this
  2659. 1:46:32okay cool routine. So what is sub
  2660. 1:46:34routine? So let me write a program to
  2661. 1:46:36explain. Let's say here I can write a
  2662. 1:46:38function.
  2663. 1:46:40So I'll just write a function. Let's say
  2664. 1:46:42def.
  2665. 1:46:45Okay. Diff. So let's say I will
  2666. 1:46:50um I'll give the function name
  2667. 1:46:53fetch.
  2668. 1:46:56Okay. Fetch let's say data. This is the
  2669. 1:47:00function name. So it is having some code
  2670. 1:47:05inside that. Okay. Now here I'm creating
  2671. 1:47:08another function. Let's say def main.
  2672. 1:47:13Okay. Now what I'm doing I'm calling
  2673. 1:47:15this particular function. Okay, this
  2674. 1:47:17function inside this particular main
  2675. 1:47:19function fetch
  2676. 1:47:21data.
  2677. 1:47:23Okay, I'm calling inside that
  2678. 1:47:29I'm calling inside that sorry yeah now
  2679. 1:47:34after calling let's say in this main
  2680. 1:47:36function also there are some code line.
  2681. 1:47:39So what is happening here? Let's say if
  2682. 1:47:41you're uh if you're using sub routine so
  2683. 1:47:44that time uh whenever you are executing
  2684. 1:47:47your code first of all your code will uh
  2685. 1:47:51come here okay your code will come here
  2686. 1:47:53and it will see you are calling a
  2687. 1:47:55function inside that which function you
  2688. 1:47:57are calling this particular function
  2689. 1:47:59okay now what it will what will happen
  2690. 1:48:02first of all it will go to this function
  2691. 1:48:03and it will execute all of the code it
  2692. 1:48:06will execute all of the code now let's
  2693. 1:48:07say you are running fetch data that
  2694. 1:48:10means let's say you are trying to fetch
  2695. 1:48:12some kinds of data from the internet,
  2696. 1:48:13you are using some kinds of API, some
  2697. 1:48:16kinds of URL. Okay? And whenever it is
  2698. 1:48:18hitting that particular API or URL, it
  2699. 1:48:20is taking some kinds of time, right? So
  2700. 1:48:23you have to wait for this particular
  2701. 1:48:24time. So see once this time is over,
  2702. 1:48:29that means this execution is over then
  2703. 1:48:31you will be able to execute your
  2704. 1:48:32remaining code. Okay? Till then you have
  2705. 1:48:35to wait for this execution. Okay? So
  2706. 1:48:39this is the idea of serve routine. That
  2707. 1:48:41means you are waiting for a task to be
  2708. 1:48:44completed. Then your remaining code
  2709. 1:48:46would be executed. Then your remaining
  2710. 1:48:48code would be executed. Although you are
  2711. 1:48:50waiting here, although you are waiting
  2712. 1:48:52here, you don't have any kinds of other
  2713. 1:48:53task. You just need to wait for the
  2714. 1:48:55execution. Okay? And once execution is
  2715. 1:48:58completed, then you will be able to
  2716. 1:49:00execute. You'll be able to see the other
  2717. 1:49:03execution of the program. But in code
  2718. 1:49:06routine, what happens? So let's say here
  2719. 1:49:07I'm having a function
  2720. 1:49:10here I'm having a function and uh we use
  2721. 1:49:12something called asynchronous okay
  2722. 1:49:14asynchronous syntax. So for this we use
  2723. 1:49:16something called asins
  2724. 1:49:18uh essence. Okay this is the keyword as
  2725. 1:49:21so we'll write the function as def let's
  2726. 1:49:23say fetch
  2727. 1:49:26data this is the function let's say
  2728. 1:49:29inside that you are having some kinds of
  2729. 1:49:31code. Okay now again you are having a
  2730. 1:49:34main function here. So I'll just write
  2731. 1:49:36diff
  2732. 1:49:38main. So what you are doing you are
  2733. 1:49:41calling this particular
  2734. 1:49:43um okay you are calling this particular
  2735. 1:49:45function div sorry uh fetch
  2736. 1:49:51okay fetch data
  2737. 1:49:55you are calling that and inside main you
  2738. 1:49:58are having some other code okay you are
  2739. 1:50:00having some other code as well. Now what
  2740. 1:50:02is happening? Just try to see whenever
  2741. 1:50:04your Python will come here it will see
  2742. 1:50:06that you are executing a function which
  2743. 1:50:08function this function you are executing
  2744. 1:50:10and it will see this particular keyword
  2745. 1:50:13called essence. Okay, that that time
  2746. 1:50:15Python will automatically understand
  2747. 1:50:17that this code you have written it will
  2748. 1:50:19run in a asynchronous way. That means
  2749. 1:50:22let's say here you are doing a API call
  2750. 1:50:24and it is taking some time t1 okay
  2751. 1:50:26instead of waiting for this particular
  2752. 1:50:28time again it will come here okay and
  2753. 1:50:31execute the remaining code you have okay
  2754. 1:50:33after this function that means at the t
  2755. 1:50:36time itself this code would be executed
  2756. 1:50:38and this code would be also executed so
  2757. 1:50:40you are not supposed to wait for the
  2758. 1:50:42previous execution so this is called co
  2759. 1:50:44routine and if you're using this asins
  2760. 1:50:47these are the things so it internally
  2761. 1:50:48uses this concept and now we'll go for
  2762. 1:50:51the practical. We'll uh try to see like
  2763. 1:50:54practically everything how it works. Uh
  2764. 1:50:56then I think your understanding would be
  2765. 1:50:58more clear. Okay. First of all, I'm
  2766. 1:51:00going to explain the synchronous
  2767. 1:51:02programming.
  2768. 1:51:04Okay. Now here I'm going to write two
  2769. 1:51:08function. Let's say for the first
  2770. 1:51:11function I'm going to write uh fetch
  2771. 1:51:16DC fetch weather.
  2772. 1:51:25Okay, fetch weather.
  2773. 1:51:28Um and the second function I'm going to
  2774. 1:51:30create def fetch news.
  2775. 1:51:38P news. Okay.
  2776. 1:51:41Now what I'm going to do, I'm going to
  2777. 1:51:45import the time module as well just to
  2778. 1:51:48see the execution time. So import time
  2779. 1:51:55import time. Okay. Now inside that as of
  2780. 1:51:58now I'm not going to write any logic.
  2781. 1:51:59Simply I'm going to write just a print
  2782. 1:52:01statement. I'm going to give let's say
  2783. 1:52:03fetching weather data. Then here I'm
  2784. 1:52:06going to just mention a time
  2785. 1:52:09uh let's say to fetch the weather data
  2786. 1:52:12you have to wait for some time. Okay. So
  2787. 1:52:14this time I'm going to assign with the
  2788. 1:52:15help of this time module. So here I'm
  2789. 1:52:17going to give let's say I will be
  2790. 1:52:20waiting for 4 seconds. Okay 4 seconds.
  2791. 1:52:24So it it is for the simulate a network
  2792. 1:52:27delay. Let's say if you are hitting any
  2793. 1:52:29kinds of API so definitely to get the
  2794. 1:52:31response you have to wait for some time.
  2795. 1:52:33So let's say this time I have set 4
  2796. 1:52:34seconds here. Okay. Now once uh we stop
  2797. 1:52:39for four 4 seconds. Now simply I'm going
  2798. 1:52:41to just print let's say weather data
  2799. 1:52:43fetched. Okay. So this message I'm going
  2800. 1:52:45to write. Now similar wise here also I'm
  2801. 1:52:48going to write uh I'm going to write
  2802. 1:52:52facing facing news data and uh again
  2803. 1:52:56I'll give some time. Let's say here I
  2804. 1:52:57have given 2 seconds and uh once my data
  2805. 1:53:01uh news fetching is done so I'll tell
  2806. 1:53:03news data fetched. Okay. So as of now
  2807. 1:53:06just try to consider this is a function.
  2808. 1:53:08This will fetch the weather information
  2809. 1:53:11and this will fetch the news. Okay. Now
  2810. 1:53:14if you see this function and this
  2811. 1:53:16function doesn't have any uh dependency.
  2812. 1:53:20These two functions are independent.
  2813. 1:53:22Okay. These two functions are
  2814. 1:53:23independent. That means if you want to
  2815. 1:53:26fetch the weather, you don't need the
  2816. 1:53:27news. If you want to fetch the news, you
  2817. 1:53:30don't need the weather. So these are
  2818. 1:53:32independent function. Okay. But once I
  2819. 1:53:36will execute this code, okay, let's say
  2820. 1:53:38if if I write another function here,
  2821. 1:53:40I'll just write another function def
  2822. 1:53:43main. Okay, in the main function, I'm
  2823. 1:53:45going to call uh I'm going to call these
  2824. 1:53:47two function. See first of all I'm
  2825. 1:53:50starting the time just to see the time
  2826. 1:53:51like how much time it takes to execute
  2827. 1:53:54the two function. So that's why I
  2828. 1:53:56starting the start I'm taking the start
  2829. 1:53:58time then I'm calling these two function
  2830. 1:54:00together fetch weather and fetch news.
  2831. 1:54:02You can see fetch weather and fetch news
  2832. 1:54:04I'm calling then I'm taking the end time
  2833. 1:54:06then I'm doing the substract operation
  2834. 1:54:08from end time to start time and this
  2835. 1:54:10will be uh this will be my execution
  2836. 1:54:14time of my program. But if you see here
  2837. 1:54:16these two functions are independent.
  2838. 1:54:19This these two functions is not
  2839. 1:54:20dependent. Although it's independent
  2840. 1:54:23okay it's not dependent.
  2841. 1:54:25So what whenever you will call the
  2842. 1:54:28function you have to wait for the you
  2843. 1:54:31have to wait for the previous function
  2844. 1:54:34to be completed to run the next
  2845. 1:54:36function. This is the issue. Okay. So I
  2846. 1:54:40can see these two functions are
  2847. 1:54:41completely independent. But whenever I'm
  2848. 1:54:43calling this function, first of all,
  2849. 1:54:45this function will execute. So let's say
  2850. 1:54:47whenever you will execute the program.
  2851. 1:54:49So your interpreter will come here.
  2852. 1:54:51Okay, your interpreter will come here.
  2853. 1:54:53Then it will go inside this particular
  2854. 1:54:55function. Then it will execute all of
  2855. 1:54:57the code. And here it will wait for the
  2856. 1:54:594 seconds. Okay, 4 seconds it will try
  2857. 1:55:02to wait. But see in the four 4 seconds
  2858. 1:55:06it doesn't have any work to do. So it
  2859. 1:55:08will be waiting. Then once 4 secondond
  2860. 1:55:11is over this code would be executed then
  2861. 1:55:13your program will come here. Okay then
  2862. 1:55:15it will be executed. That means first of
  2863. 1:55:17all the previous function would be
  2864. 1:55:19executed then the next function would be
  2865. 1:55:20executed. So you can also check. So
  2866. 1:55:22let's say if I want to show you. So I'll
  2867. 1:55:25call this particular main function here.
  2868. 1:55:28Okay. I'll call this main function. Now
  2869. 1:55:30if I execute see facing weather it is
  2870. 1:55:33waiting for 4 seconds. Now weather
  2871. 1:55:35fetch. Now see facing news. Now it wait
  2872. 1:55:38for 2 seconds. then news face and total
  2873. 1:55:40time taken you can see 6 uh point
  2874. 1:55:43something seconds. Okay. Now you can
  2875. 1:55:46also take this code uh in one of the
  2876. 1:55:49amazing website called python tutor.
  2877. 1:55:51Python tutor.com. Here also you can
  2878. 1:55:53visualize this code.
  2879. 1:55:58Let me open the python tutor.
  2880. 1:56:01Now I'll select the python programming.
  2881. 1:56:07I'll paste my code here.
  2882. 1:56:09Visualize the execution.
  2883. 1:56:19Okay. Now it has started. Okay. It has
  2884. 1:56:22started. Now simply time is not defined.
  2885. 1:56:25Okay. So the basically I need to import
  2886. 1:56:28the time here. Right. So let's edit the
  2887. 1:56:30code.
  2888. 1:56:34So here I'll import the time module
  2889. 1:56:39for time.
  2890. 1:56:41Now I'll visualize the execution
  2891. 1:56:46import time. It's giving you an error.
  2892. 1:56:48Time f not found or supported. Only
  2893. 1:56:51these modules can be imported. Okay.
  2894. 1:56:54Because this is a like a website. Okay.
  2895. 1:56:56Python tutor website. So here you can
  2896. 1:56:58you can't import any uh let's say these
  2897. 1:57:01are the library you can't you can import
  2898. 1:57:03but some other library you can't import.
  2899. 1:57:05So for this what I can do I can remove
  2900. 1:57:07the time as of now I just wanted to only
  2901. 1:57:10just let you know that how it is
  2902. 1:57:12executing. Let's say I will also remove
  2903. 1:57:14the time part. Uh here also I'll remove
  2904. 1:57:17the time part here also and here also.
  2905. 1:57:21Uh let's say this is my message. Okay
  2906. 1:57:25this is my simple message. Let's say
  2907. 1:57:31executed.
  2908. 1:57:34Now simply do the visualization.
  2909. 1:57:39Okay. Now see um here I have the
  2910. 1:57:42control. The first of all Python
  2911. 1:57:44interpreter will come here. Uh it has
  2912. 1:57:47seen like here I am having a function
  2913. 1:57:50called fetch weather. Then it will go to
  2914. 1:57:51the next line that is next function.
  2915. 1:57:54then it will go to the next function
  2916. 1:57:56which is main and in the main function
  2917. 1:57:59you can see uh I'm calling here this
  2918. 1:58:01particular main function so it will go
  2919. 1:58:03into into the main function and it will
  2920. 1:58:06see like I'm calling fetch weather
  2921. 1:58:08function okay so it will go inside fetch
  2922. 1:58:10weather and it will do all of the
  2923. 1:58:12operation okay see it is doing all of
  2924. 1:58:14the operation now let's say this
  2925. 1:58:16function is taking some time so it will
  2926. 1:58:18wait okay it will wait for 2 minutes 1
  2927. 1:58:20minutes okay how much time it is taking
  2928. 1:58:22it will try to wait for Right. So once
  2929. 1:58:24execution is completed then again it
  2930. 1:58:26will come here. Okay. Then you can see
  2931. 1:58:28it will execute another function which
  2932. 1:58:30is fetch news. Now again it will go
  2933. 1:58:32inside fetch news and it will do all of
  2934. 1:58:34the execution and try to come here. That
  2935. 1:58:37means you have to wait. Okay. You have
  2936. 1:58:38to wait for the previous execution to be
  2937. 1:58:42complete. Then you will be able to run
  2938. 1:58:43the new code. Okay. That's how you have
  2939. 1:58:45to wait. Okay. You have to wait uh for
  2940. 1:58:48the previous execution. And definitely
  2941. 1:58:50it is taking lots of time. And now just
  2942. 1:58:52try to consider if you're running a
  2943. 1:58:53multiple agents together and if it is
  2944. 1:58:56running synchronously. So first of all
  2945. 1:58:59first agent would be completed second
  2946. 1:59:00agent would be completed. So execution
  2947. 1:59:02time it will take more that time we run
  2948. 1:59:05it is an asynchronous way. So that we
  2949. 1:59:07are not need to open we don't need to
  2950. 1:59:09open for uh we don't need to wait for
  2951. 1:59:11the previous execution. Okay the time it
  2952. 1:59:14is taking it's completely fine. I will
  2953. 1:59:16simultaneously run for all of the
  2954. 1:59:19function and you'll be executing
  2955. 1:59:20together. Okay. So now we'll try to see
  2956. 1:59:22that particular example as well how it
  2957. 1:59:24will work. Now we'll see this
  2958. 1:59:26synchronous programming
  2959. 1:59:29sorry asynchronous programming
  2960. 1:59:34asynchronous programming. Now here to uh
  2961. 1:59:39implement asynchronous function you need
  2962. 1:59:42to import one library called
  2963. 1:59:45import sorry import.
  2964. 1:59:49Okay. Assence io okay as io this
  2965. 1:59:52particular library and I'm going to also
  2966. 1:59:55import time library
  2967. 1:59:58let's me import all of them then here
  2968. 2:00:00I'm going to again write the same
  2969. 2:00:02function
  2970. 2:00:04same function I will copy the code
  2971. 2:00:09and simply I'm going to mention here now
  2972. 2:00:11instead of giving simply this definition
  2973. 2:00:14I'm going to write asins keyword okay
  2974. 2:00:17before that now once I have written as
  2975. 2:00:19keyword
  2976. 2:00:20Okay, as since keyword at the first of
  2977. 2:00:22this particular function now Python will
  2978. 2:00:25automatically understand I need to run
  2979. 2:00:26this function in asynchronous mode and
  2980. 2:00:29here it is taking the time. So maybe I
  2981. 2:00:31can use another keyword here called ait.
  2982. 2:00:33Okay, a so simply I'm going to give it
  2983. 2:00:37here.
  2984. 2:00:39Okay, even you can also return something
  2985. 2:00:41if you want. Okay, you can also return
  2986. 2:00:43like uh what is the return this function
  2987. 2:00:46will be returning for you. H now sim uh
  2988. 2:00:50same uh similar wise I'll also do it for
  2989. 2:00:53this particular function so essence
  2990. 2:00:59okay now simply here I'm going to write
  2991. 2:01:01a okay have it so why you are writing a
  2992. 2:01:06here because here it is taking the time
  2993. 2:01:09okay here it is taking the time and uh
  2994. 2:01:13whenever here it is taking the time your
  2995. 2:01:15python uh interpreter will come here and
  2996. 2:01:17whenever it will see the ait so it will
  2997. 2:01:20tell like you don't need to wait for
  2998. 2:01:21this particular execution so you can
  2999. 2:01:23execute your other uh code okay whatever
  3000. 2:01:27you have so this code would be executing
  3001. 2:01:29and at the same time you can also
  3002. 2:01:31execute your other code okay I'll tell
  3003. 2:01:33you okay how it will execute
  3004. 2:01:36uh then uh simply in the main function
  3005. 2:01:38also I'm going to make it as ess as
  3006. 2:01:43okay essence and uh here
  3007. 2:01:47uh instead of calling like that I'm
  3008. 2:01:49going to simply call it as a
  3009. 2:01:52uh as since io dot gatherthered okay
  3010. 2:01:55there is a function and inside that you
  3011. 2:01:57have to give the fetch weather
  3012. 2:02:00fetch weather uh function and fetch news
  3013. 2:02:03function both you have to provide okay
  3014. 2:02:06then you can uh calculate the end time
  3015. 2:02:10and simply you can print the time taken
  3016. 2:02:12of this particular function now if you
  3017. 2:02:15want to execute uh what you can do you
  3018. 2:02:17You can simply
  3019. 2:02:19uh you can simply call this main
  3020. 2:02:21function. How you can use the aid
  3021. 2:02:24keyword main. Now see if I execute
  3022. 2:02:28see what will happen.
  3023. 2:02:34Okay. Um there is a error. Oh sorry uh
  3024. 2:02:38whenever you are using this average
  3025. 2:02:39right you don't need to use the time
  3026. 2:02:40that time uh you can use essence
  3027. 2:02:46uh essence io. sleep. Okay. So you are
  3028. 2:02:48not supposed to use time that time.
  3029. 2:02:50Okay. You have to use essence io. Okay.
  3030. 2:02:53Now same things I'll be giving it here.
  3031. 2:03:00Same things I'll give it it here. Uh now
  3032. 2:03:04I think it is fine. Now let's execute.
  3033. 2:03:09Now see guys it has taken only 3 seconds
  3034. 2:03:13and if I show my previous code it has
  3035. 2:03:15taken 6 seconds. Okay. So the time
  3036. 2:03:18reduced by half. Okay. The time reduced
  3037. 2:03:21by half. Just try to consider. Now just
  3038. 2:03:24think like this is a big program. Okay.
  3039. 2:03:26This is a big program. This is a big
  3040. 2:03:28agents and it is running so many stuff.
  3041. 2:03:30Now if you run it run it in a
  3042. 2:03:33synchronous programming. Now just try to
  3043. 2:03:35consider how much time it it should
  3044. 2:03:37take. Okay. But if you are using
  3045. 2:03:39asynchronous programming see it will be
  3046. 2:03:42reducing the time half. Okay. because it
  3047. 2:03:45is running everything in parallel. It is
  3048. 2:03:48running everything in parallel. Okay. So
  3049. 2:03:50you are not supposed to wait for the
  3050. 2:03:53previous execution to be complete. Okay.
  3051. 2:03:55So all of the executions are doing
  3052. 2:03:57simultaneously.
  3053. 2:04:00Okay. So that's why this asynchronous
  3054. 2:04:02programming okay this asense IO is
  3055. 2:04:05required whenever you are implementing
  3056. 2:04:07uh any kinds of AI agents uh with any
  3057. 2:04:10kinds of framework whether you are using
  3058. 2:04:11autogen you are using langraph you're
  3059. 2:04:14using crew AI try to use this particular
  3060. 2:04:17things in your development okay this is
  3061. 2:04:20good practice there are two concept
  3062. 2:04:23you'll be getting which is
  3063. 2:04:25uh the first is para
  3064. 2:04:29leism
  3065. 2:04:30Okay.
  3066. 2:04:32And the second thing you will be getting
  3067. 2:04:36qy.
  3068. 2:04:39So what is parallelism? Running
  3069. 2:04:45multiple
  3070. 2:04:48uh tasks
  3071. 2:04:52simultaneously
  3072. 2:04:58using
  3073. 2:05:01multiple
  3074. 2:05:06trades.
  3075. 2:05:09Okay. Or process.
  3076. 2:05:16And what is uh concurrency? So let me
  3077. 2:05:19write it here. Um simply
  3078. 2:05:23here I can write concurrency.
  3079. 2:05:31Concurrency means uh managing
  3080. 2:05:39multiple
  3081. 2:05:41tasks
  3082. 2:05:44that can
  3083. 2:05:47start
  3084. 2:05:50run
  3085. 2:05:52and okay finish
  3086. 2:05:57with
  3087. 2:05:59over overlapping
  3088. 2:06:03times.
  3089. 2:06:05Okay. So, let me uh show you
  3090. 2:06:09a graph. I think by seeing the graph you
  3091. 2:06:11will be able to understand
  3092. 2:06:14what is the exact meaning.
  3093. 2:06:22So this is the graph.
  3094. 2:06:24So this is the concurrency. You can see
  3095. 2:06:27uh task is running. Okay. Context
  3096. 2:06:30switching to the task two. Then again
  3097. 2:06:33task one is running. Again it is doing
  3098. 2:06:35the context switching. Okay. But in
  3099. 2:06:38parallelism you can see it is utilizing
  3100. 2:06:41okay it is utilizing multi uh multiore.
  3101. 2:06:44Okay. Let's say uh in the first CPU core
  3102. 2:06:48it is running task one and in the second
  3103. 2:06:51CPU core it is running task two but here
  3104. 2:06:53it is only utilizing the same code only
  3105. 2:06:55but doing um doing this uh concurrency
  3106. 2:06:59operation. Okay. So guys I think you
  3107. 2:07:02have seen this asynchronous concept. Uh
  3108. 2:07:05the main thing is that right now all of
  3109. 2:07:08the orchestrator framework uses this
  3110. 2:07:10kinds of asynchronous uh functionality
  3111. 2:07:13in their back end. So we don't need to
  3112. 2:07:15manually uh use the asynchronous inside
  3113. 2:07:18our development inside our code but if
  3114. 2:07:20you want you can also use uh if you want
  3115. 2:07:23you can also uh design your own pipeline
  3116. 2:07:25design your own agents that time you can
  3117. 2:07:28write the code from scratch but whatever
  3118. 2:07:31u let's say u orchestrator framework
  3119. 2:07:34we'll be using like langraph then
  3120. 2:07:36autogen crew ai right so everything uh
  3121. 2:07:40already having this kinds of things are
  3122. 2:07:42integrated okay in the back end. So I
  3123. 2:07:45don't need to take care this part. But
  3124. 2:07:47in future whenever I will do some coding
  3125. 2:07:49maybe these are the terminology will
  3126. 2:07:50come that time um I want you to don't uh
  3127. 2:07:54actually uh confuse with the syntax.
  3128. 2:07:57Okay that's why I have clarified each
  3129. 2:07:59and everything before I go ahead with
  3130. 2:08:01the AI agents implementation. So in this
  3131. 2:08:04video I'm going to discuss another very
  3132. 2:08:06important topic especially whenever you
  3133. 2:08:09are creating any kinds of AI agents
  3134. 2:08:11application. uh the terms is pientic.
  3135. 2:08:15Okay. So first of all I will give you
  3136. 2:08:18the idea why this pientic is required
  3137. 2:08:21and uh without pentic what would be the
  3138. 2:08:23problem then we'll try to understand the
  3139. 2:08:26entire pyic concept. So this is my
  3140. 2:08:29promise of uh if you complete the entire
  3141. 2:08:32video guys I think you should not be
  3142. 2:08:35having any kinds of uh doubt related uh
  3143. 2:08:39pientic whether you are working in uh AI
  3144. 2:08:42agents whether you are working with any
  3145. 2:08:44other let's say uh AI application
  3146. 2:08:46development because everywhere nowadays
  3147. 2:08:48we use this particular pentic concept
  3148. 2:08:50okay for the data validation
  3149. 2:08:53so I think you already know that uh in
  3150. 2:08:56python all of the variable is uh dynamic
  3151. 2:09:00variable. Uh basically we uh use the
  3152. 2:09:03dynamic concept here that means uh here
  3153. 2:09:05we don't mention any uh data type okay
  3154. 2:09:09of a variable. Let's say if I'm creating
  3155. 2:09:11a variable named um a and inside that if
  3156. 2:09:15I'm storing uh let's say one integer
  3157. 2:09:17value which is four you can u actually
  3158. 2:09:21um remove that four and you can also
  3159. 2:09:24store any other data type let's say
  3160. 2:09:26string flo or boolean any kinds of data
  3161. 2:09:29type in the same variable itself okay
  3162. 2:09:31without uh actually mentioning the data
  3163. 2:09:33type okay so that's how python works uh
  3164. 2:09:36it works actually dynamically everything
  3165. 2:09:39in short any other programming language
  3166. 2:09:41uh we use the static approach. So there
  3167. 2:09:44we uh first of all mention the data type
  3168. 2:09:47then we uh create the variable and
  3169. 2:09:49stores the data but in Python actually
  3170. 2:09:52everything works uh as a dynamically. So
  3171. 2:09:54here you don't need to mention the data
  3172. 2:09:56types or any kinds of let's say uh hints
  3173. 2:09:59related that right. So guys to make you
  3174. 2:10:02understand what I'm going to do I'm
  3175. 2:10:04going to open my computer screen and
  3176. 2:10:06there I'm going to discuss each and
  3177. 2:10:07everything related uh to this pientic.
  3178. 2:10:13So guys uh here you can see um I'm
  3179. 2:10:15inside my computer screen. So first of
  3180. 2:10:18all I have mentioned the pyentic uh
  3181. 2:10:22definition like what exactly the pyic
  3182. 2:10:24is. So as you can see Pentic is the most
  3183. 2:10:27widely used data validation and uh
  3184. 2:10:30settings management library for Python
  3185. 2:10:33utilizing type hints to ensure data
  3186. 2:10:35structure integrity. As you can see it
  3187. 2:10:39validates parts data at runtime to match
  3188. 2:10:42specified types making it essential for
  3189. 2:10:45building robust APIs and handling
  3190. 2:10:48external data with it uh with its core
  3191. 2:10:51logic written in Rust for high
  3192. 2:10:53performance.
  3193. 2:10:54So this is the definition of pientic. Um
  3194. 2:10:57basically we use this pientic for the uh
  3195. 2:11:00data validation. Uh I'm going to u tell
  3196. 2:11:03you about more uh more about this data
  3197. 2:11:05validation. What is data validation? why
  3198. 2:11:07it is required and u I mean how it
  3199. 2:11:11actually uh solves one amazing problem
  3200. 2:11:14actually uh whenever we try to create
  3201. 2:11:16any kinds of end to end application uh
  3202. 2:11:18especially whenever you are working
  3203. 2:11:20inside AI domain if you're working in
  3204. 2:11:22machine learning deep learning uh
  3205. 2:11:24generative AI agentic AI anywhere uh
  3206. 2:11:27whenever you are developing the
  3207. 2:11:28application uh you have to use this
  3208. 2:11:30pientic okay now here I have listed down
  3209. 2:11:33some key features and benefit of the
  3210. 2:11:35pientic as you can see Here are some key
  3211. 2:11:38features and benefit. So for data
  3212. 2:11:39validation and parsing we use this
  3213. 2:11:41pentic. Uh so here you can see defines
  3214. 2:11:44how data should be structured using
  3215. 2:11:47standard Python types automatically
  3216. 2:11:48enforcing the uh these rules. uh
  3217. 2:11:51basically see uh inside aentic why it is
  3218. 2:11:54required because here we'll be working
  3219. 2:11:56with the large language model and you
  3220. 2:11:58know that large language model u always
  3221. 2:12:01will give you the output in unstructured
  3222. 2:12:02manner and if I want to get a structured
  3223. 2:12:05output if I want to get the relevant
  3224. 2:12:07response only that time this pentic data
  3225. 2:12:10validation is required and whenever we
  3226. 2:12:11are also passing any kinds of input
  3227. 2:12:13prompt okay we have to also make it
  3228. 2:12:16structured so that uh I can get uh the
  3229. 2:12:19efficient response from my large lang
  3230. 2:12:21based model. Okay, instead of giving
  3231. 2:12:22some unstructured data as an input then
  3232. 2:12:26uh for the type uh hint and integration.
  3233. 2:12:28So uses Python uh type annotations to
  3234. 2:12:31define schemas reducing uh the needs for
  3235. 2:12:34verbose validation code. Then definitely
  3236. 2:12:36for the fast performance uh we will be
  3237. 2:12:38using that uh basically it is written in
  3238. 2:12:41rust uh actually language that's why it
  3239. 2:12:43is extremely fast. Then strict and lax
  3240. 2:12:46mode is available inside this pyic.
  3241. 2:12:48Okay. Basically uh here you can um uh do
  3242. 2:12:52the uh enforcing strict type and you can
  3243. 2:12:54also perform the um you can also
  3244. 2:12:58performing this uh lax mode. Okay, for
  3245. 2:13:00converting let's say uh any other data
  3246. 2:13:03type to another data type. Okay, this is
  3247. 2:13:05also possible here. Then uh clear error
  3248. 2:13:08handling. Okay, provides detail errors
  3249. 2:13:10when the data validation fails. and JSON
  3250. 2:13:13schema generation. Pyntic models can
  3251. 2:13:15easily generate JSON schema for
  3252. 2:13:16documentations or validation uh in other
  3253. 2:13:19languages. Okay. Now it is telling
  3254. 2:13:21pyentic models. What is this pyentic
  3255. 2:13:23model? I'm going to tell you. So this is
  3256. 2:13:24nothing but a class. Okay. We create a
  3257. 2:13:26class uh and we inherit with this with
  3258. 2:13:30this pyic actually base model. Okay. So
  3259. 2:13:32that's why we call it as a pyic models.
  3260. 2:13:35So whenever I'm going to show you the
  3261. 2:13:37practical that time it would be more
  3262. 2:13:38clear. Okay. So first of all uh let's
  3263. 2:13:41try to understand the problem okay
  3264. 2:13:43problem without this pentic if I'm not
  3265. 2:13:46using pyntentic so what will happen and
  3266. 2:13:48what would be the issue actually we'll
  3267. 2:13:50be having okay then I'll try to use the
  3268. 2:13:51pidentic and uh I'm going to show you
  3269. 2:13:54the benefit itself so for this I'm going
  3270. 2:13:56to turn off my camera window guys so
  3271. 2:13:58that you can see the entire screen uh
  3272. 2:14:00you don't miss any kinds of code snippet
  3273. 2:14:03okay whatever I'm going to write I think
  3274. 2:14:05that would be good for you so guys
  3275. 2:14:08whenever we are working with any kinds
  3276. 2:14:09of application whether it's related
  3277. 2:14:11MLDDL or aentki it doesn't matter uh we
  3278. 2:14:15will be working with the data for sure
  3279. 2:14:17right so let's say here I'm going to uh
  3280. 2:14:20take one example I'm going to let's say
  3281. 2:14:22create a function I'm going to name it
  3282. 2:14:24as u let's say
  3283. 2:14:27um let's say add
  3284. 2:14:31or let's say uh add
  3285. 2:14:36patient
  3286. 2:14:42data.
  3287. 2:14:44Okay. So this is my function. So
  3288. 2:14:47basically this will take the name of the
  3289. 2:14:49patient and age of the patient. Okay. Um
  3290. 2:14:53now what I'm going to do let's say this
  3291. 2:14:55function uh add this informations to the
  3292. 2:14:58database that means the hospital
  3293. 2:15:01database. But as of now uh I'm giving
  3294. 2:15:03you the demo. So here I don't have any
  3295. 2:15:05kinds of database. So simply what I'm
  3296. 2:15:07going to do I'm going to print uh those
  3297. 2:15:10uh variable here. Okay. So let's say I'm
  3298. 2:15:12going to print the name and I'm also
  3299. 2:15:15going to print the age. Okay. So once it
  3300. 2:15:17is done maybe I can give you a message
  3301. 2:15:21called um
  3302. 2:15:24data
  3303. 2:15:26addit successfully. Okay. So let's say
  3304. 2:15:28this is my message. Okay. Once let's I
  3305. 2:15:30will call this function. It will add
  3306. 2:15:31this informations to the database. And
  3307. 2:15:34here I will get a message. Let's say
  3308. 2:15:35database um data added successfully to
  3309. 2:15:40the
  3310. 2:15:42database. Okay. Let's say this is my
  3311. 2:15:44masses. Now let's say if I execute this
  3312. 2:15:48code uh let me take some cell. So if I
  3313. 2:15:52want to let's say um insert the data
  3314. 2:15:55first of all I have to call this
  3315. 2:15:56function add patient data. So inside
  3316. 2:15:58that let's say I'm going to give the
  3317. 2:16:00patient name. Let's say I'm going to
  3318. 2:16:03give BP and age is 25. Okay. Now let's
  3319. 2:16:06say if I just execute the code, you will
  3320. 2:16:10see that BP and the age has successfully
  3321. 2:16:13added to the database. That means it's
  3322. 2:16:15working fine. Okay. Now let's say this
  3323. 2:16:18code is written by the senior programmer
  3324. 2:16:21and uh he has given this code to the
  3325. 2:16:23junior programmer. He told like okay
  3326. 2:16:25this is the function and this function
  3327. 2:16:27you can use for adding any kinds of uh
  3328. 2:16:31let's say patient informations to the
  3329. 2:16:33hospital database. Okay. Now what junior
  3330. 2:16:36programmer will do definitely you will
  3331. 2:16:39see the like um uh function definition.
  3332. 2:16:43So you can see this function definition
  3333. 2:16:45is that uh this function takes uh two
  3334. 2:16:47argument. One is the name and another is
  3335. 2:16:50the age. And the data type is any. That
  3336. 2:16:52means you can pass any kinds of data
  3337. 2:16:54type here because here I haven't
  3338. 2:16:55strictly mentioned you have to pass uh
  3339. 2:16:58string or you have to pass integer
  3340. 2:17:00float. Okay, this kinds of uh let's say
  3341. 2:17:02type hinting I haven't done. So what he
  3342. 2:17:04will do he will try to add any kinds of
  3343. 2:17:06data here. Okay, maybe let's say um he
  3344. 2:17:09has given BP here patient um let's say
  3345. 2:17:12name. Now he can also give the age like
  3346. 2:17:15that. Let's say instead of 25 like that
  3347. 2:17:17he will write like that 25. Okay, 25 in
  3348. 2:17:21string. Now if I execute this code,
  3349. 2:17:25still see my data is added to the
  3350. 2:17:27database. But whenever let's say senior
  3351. 2:17:29programmer is trying to fetch this data.
  3352. 2:17:31Okay, let's say there is another
  3353. 2:17:33function. That function fetch the data.
  3354. 2:17:36So whenever let's say he's fetching the
  3355. 2:17:37data, let's say he wants to uh he wants
  3356. 2:17:40to filter out those patient u the
  3357. 2:17:43patient age is above 25. Okay. So what
  3358. 2:17:46he will do? You'll let's say write a
  3359. 2:17:48condition if uh patient
  3360. 2:17:52okay if patient age is uh let's say
  3361. 2:17:57greater than
  3362. 2:18:00greater than 25
  3363. 2:18:04okay 25 then he will try to
  3364. 2:18:08let's say call those patient okay he has
  3365. 2:18:11tried to call those patient now just try
  3366. 2:18:14to see here my junior programmer has
  3367. 2:18:16added the patient information like that
  3368. 2:18:19in a string format 25 but again senior
  3369. 2:18:23program is trying to filter out the
  3370. 2:18:24patient informations by the integer data
  3371. 2:18:26type okay definitely this kinds of uh I
  3372. 2:18:29mean filter I can't ever perform on my
  3373. 2:18:32database if you're using SQL I think you
  3374. 2:18:34know that you can't do that because here
  3375. 2:18:35it is a string type here you are um
  3376. 2:18:38giving the integer type so definitely
  3377. 2:18:40this patient will be missed that time
  3378. 2:18:42okay not only this patient uh I mean
  3379. 2:18:45similar kinds of if you're doing the
  3380. 2:18:46same thing instead of giving the integer
  3381. 2:18:48if you're giving the uh string type that
  3382. 2:18:50time patient will definitely missed out
  3383. 2:18:52okay for the filter operation so this is
  3384. 2:18:56the like problem now you can tell okay
  3385. 2:18:58then I can easily solve this problem so
  3386. 2:19:00what I can do maybe uh instead of uh
  3387. 2:19:04giving it like that so what I will do
  3388. 2:19:07let's say I'll try to maybe add a
  3389. 2:19:10condition here so simply here I'll add a
  3390. 2:19:13condition so If
  3391. 2:19:17type first of all I'll check the type if
  3392. 2:19:20type of name
  3393. 2:19:22is equal equal
  3394. 2:19:27okay equal equal string str and type of
  3395. 2:19:31age is integer okay then I'm going to um
  3396. 2:19:34sorry then I'm going to insert the
  3397. 2:19:37informations to the database okay
  3398. 2:19:39otherwise in the else condition I'm
  3399. 2:19:41going to
  3400. 2:19:42give a error ES
  3401. 2:19:45okay so I'm going to raise exception
  3402. 2:19:48raise let's say
  3403. 2:19:51type error
  3404. 2:19:57type error so here I'm going to tell uh
  3405. 2:19:59invalid data type for the name and age
  3406. 2:20:01name should be string and s should be in
  3407. 2:20:03the integer format okay now let's say if
  3408. 2:20:05I execute this code and now let's say if
  3409. 2:20:09I am trying to add right now uh these
  3410. 2:20:12kinds of things. Okay. So what will
  3411. 2:20:14happen? Okay. One more thing I have to
  3412. 2:20:16add which is uh the hinting type
  3413. 2:20:18hinting. So name variable should be
  3414. 2:20:21string and age as variable should be
  3415. 2:20:23integer. Now if I execute now see if
  3416. 2:20:25junior programmer comes here and he uh
  3417. 2:20:27if he sees see the uh let's say function
  3418. 2:20:30definition he will be able to see that
  3419. 2:20:32okay this function takes two argument.
  3420. 2:20:34One is name should be string and s
  3421. 2:20:36should be integer. Okay. So let's say if
  3422. 2:20:38I give integer data right now let's say
  3423. 2:20:4025
  3424. 2:20:43it will work perfectly okay there should
  3425. 2:20:45not be any kinds of error but if is
  3426. 2:20:47trying to give like that let's say again
  3427. 2:20:5025 so definitely that time one error
  3428. 2:20:53would be coming here okay now it is
  3429. 2:20:56working completely fine it's not like
  3430. 2:20:57that uh you won't be able to do that you
  3431. 2:21:00will be able to do that now your uh
  3432. 2:21:02senior programmer will be able to fetch
  3433. 2:21:04the information very easily because you
  3434. 2:21:06are following the same data type. Okay,
  3435. 2:21:08whatever data type your senior
  3436. 2:21:10programmer expected okay so this is the
  3437. 2:21:13thing but the problem is that let's say
  3438. 2:21:17whenever you [clears throat] will be
  3439. 2:21:18creating a big application it's not like
  3440. 2:21:20that you will be creating a single
  3441. 2:21:21function there would be lots of function
  3442. 2:21:23okay so let's say you want to create
  3443. 2:21:25another function uh let's say the
  3444. 2:21:27function name is update information okay
  3445. 2:21:30update patient information instead of
  3446. 2:21:32add patients maybe I can add update
  3447. 2:21:37patient data. Okay, that time again it
  3448. 2:21:39will take the name and age of the
  3449. 2:21:41patient. Again you have to check this
  3450. 2:21:43condition. Okay, you have to check this
  3451. 2:21:45condition whether name is a string and
  3452. 2:21:47age type is integer. Then you will allow
  3453. 2:21:49to update. Okay, let's see here I can
  3454. 2:21:51tell um update uh update uh let me
  3455. 2:21:57accept this uh data updated successfully
  3456. 2:21:59in the database otherwise what I will do
  3457. 2:22:01I'll just try to raise the invalid uh
  3458. 2:22:03let's say array but uh whenever we be
  3459. 2:22:06creating the real application it's not
  3460. 2:22:08like that we'll be working with uh two
  3461. 2:22:11to three input data there would be lots
  3462. 2:22:13of data and for all the data I have to
  3463. 2:22:15write this particular condition okay so
  3464. 2:22:17again this is a manual task we have to
  3465. 2:22:19do and how many function you'll be
  3466. 2:22:20creating in every function you have to
  3467. 2:22:22definitely check that okay you have to
  3468. 2:22:24definitely check that let's say another
  3469. 2:22:26condition comes up the condition is
  3470. 2:22:30uh condition is let's say um yeah
  3471. 2:22:33definitely let's say you have given your
  3472. 2:22:35data type it should be name should be
  3473. 2:22:37string and it should be integer it's
  3474. 2:22:39completely fine but let's say your
  3475. 2:22:41junior programmer insert the data like
  3476. 2:22:43that let's say instead of giving uh
  3477. 2:22:45positive 25 he will be giving negative -
  3478. 2:22:48255 type now age can't cannot be never
  3479. 2:22:52never negative right age cannot uh uh I
  3480. 2:22:56mean it should not be negative but if I
  3481. 2:22:58let's say add this negative number again
  3482. 2:23:00it will be adding this particular number
  3483. 2:23:02successfully okay but this is another
  3484. 2:23:04issue definitely right now you can tell
  3485. 2:23:07me okay then what I can do maybe I can
  3486. 2:23:09uh add another condition here so what I
  3487. 2:23:13will do let's say uh here maybe I will
  3488. 2:23:16add another condition inside this in uh
  3489. 2:23:19add patient data. So here I'm going to
  3490. 2:23:21check another condition. If the age is
  3491. 2:23:25uh
  3492. 2:23:27uh if age is greater than
  3493. 2:23:30okay
  3494. 2:23:33um age is greater than
  3495. 2:23:37equal um zero that time I will allow
  3496. 2:23:41this condition.
  3497. 2:23:43Okay, I'll allow this condition
  3498. 2:23:45otherwise I will raise another exception
  3499. 2:23:47h cannot be negative. Okay, and this uh
  3500. 2:23:50um uh this uh already I'm checking this
  3501. 2:23:53information whether it is a string or
  3502. 2:23:55integer. Okay, so this is the else block
  3503. 2:23:57for this particular if and this is the
  3504. 2:23:59else block for this particular if. Okay,
  3505. 2:24:02now here I have written the multi- uh
  3506. 2:24:04conditional statement. So here also you
  3507. 2:24:07have to do the same thing. Okay, here
  3508. 2:24:08also you have to do the same thing.
  3509. 2:24:11Okay. So, so I'll remove this part.
  3510. 2:24:14Okay. Here also you have to add the same
  3511. 2:24:16thing. Now if I execute this code now
  3512. 2:24:19see now it will um check that and it
  3513. 2:24:22will raise the value um value error that
  3514. 2:24:24means h cannot be negative. But if I'm
  3515. 2:24:26passing the positive that time it will
  3516. 2:24:28be working. There should not be any
  3517. 2:24:30kinds of problem. Okay. But every time
  3518. 2:24:33whenever the condition is changing okay
  3519. 2:24:36uh because it's it is true right
  3520. 2:24:38whenever you are creating a application
  3521. 2:24:40your application should handle this
  3522. 2:24:42kinds of scenario because as a user I
  3523. 2:24:45can pass anything right um I can pass
  3524. 2:24:48anything I can pass negative number I
  3525. 2:24:50can pass string number anything I can
  3526. 2:24:52pass in your application but your
  3527. 2:24:55application should uh handle this this
  3528. 2:24:57kinds of scenario your application
  3529. 2:24:59should validate the data I'm passing
  3530. 2:25:00whether it is validated or not. Okay. So
  3531. 2:25:03either you can do this validation by
  3532. 2:25:05writing this kinds of manual conditional
  3533. 2:25:07statement. Either you can use the
  3534. 2:25:09pientic one. Okay. Pentic data
  3535. 2:25:11validator. So how to use pyic? I'm going
  3536. 2:25:13to tell you but I was just showing you
  3537. 2:25:16the problem. What would be the problem
  3538. 2:25:17if you're using this uh like traditional
  3539. 2:25:20approach traditional conditional
  3540. 2:25:22approach. So here you have to write this
  3541. 2:25:24kinds of condition manually every time.
  3542. 2:25:26Okay. And again if you're creating any
  3543. 2:25:28other function again you have to rewrite
  3544. 2:25:30the code and your code size would be
  3545. 2:25:31very big that time. Okay. So this is the
  3546. 2:25:33problem. Now let's try to see how to use
  3547. 2:25:37this pentic to solve this problem. Now
  3548. 2:25:39here I have already written how to use
  3549. 2:25:41the pyic. So in pentic first of all
  3550. 2:25:43we'll define a pyntic model that
  3551. 2:25:45represents the ideal schema of a data.
  3552. 2:25:48Now what is model? Okay model means
  3553. 2:25:51model means this is a class. Okay. Here
  3554. 2:25:52we'll try to define a class of pentic.
  3555. 2:25:55Basically we'll try to uh inherit with
  3556. 2:25:58the pidentic based model. Okay. After
  3557. 2:26:01that we'll try to uh define the schema
  3558. 2:26:03here. Okay. We'll try to define the
  3559. 2:26:04schema. Now what is schema? I'll tell
  3560. 2:26:07you. Uh then uh the second thing uh in
  3561. 2:26:10uh instantiate u model with raw input uh
  3562. 2:26:15usually a dictionary or JSON like
  3563. 2:26:17structure. So once my uh let's say
  3564. 2:26:19pentic models is pentic class is ready.
  3565. 2:26:22I will prepare my data. Okay. I'll
  3566. 2:26:24prepare my input data in uh in a
  3567. 2:26:25dictionary. It should be uh definitely
  3568. 2:26:27in a dictionary or JSON like format. Uh
  3569. 2:26:30then uh we'll try to pass the validated
  3570. 2:26:33u model object to the functions uh
  3571. 2:26:37functions.
  3572. 2:26:39Um okay here I missed one thing. Uh see
  3573. 2:26:42here basically what we will do pentic
  3574. 2:26:44will automatically validate the data uh
  3575. 2:26:46whether it is correct format or not the
  3576. 2:26:48data we are passing if does not meets
  3577. 2:26:50the model requirement pentic raises the
  3578. 2:26:52validation error okay then once let's
  3579. 2:26:54say my uh data validation meets it is uh
  3580. 2:26:57let's say validated successfully that
  3581. 2:27:00time uh it will try to I will try to
  3582. 2:27:02pass the validated uh model objects to
  3583. 2:27:04the function the function we have
  3584. 2:27:05created okay for any kinds of logic
  3585. 2:27:07let's say for database insertion or
  3586. 2:27:09update database insertion we can pass to
  3587. 2:27:12that particular function and our code
  3588. 2:27:15will be working. Okay. Now this thing
  3589. 2:27:17we'll try to see in a practical manner.
  3590. 2:27:19So for this uh first of all you have to
  3591. 2:27:21install the pyentic inside your
  3592. 2:27:23environment. So how to install pyic
  3593. 2:27:25maybe in the requirement.txt txt you can
  3594. 2:27:27mention the pyntic package and
  3595. 2:27:29definitely you just try to take pyic uh
  3596. 2:27:32like more than one that means uh it
  3597. 2:27:34should be pentic two version because in
  3598. 2:27:36two function there are lots of update
  3599. 2:27:38came but don't use one version because
  3600. 2:27:40what one version that was older and
  3601. 2:27:43there you will be getting lots of issue
  3602. 2:27:45okay I'll try to suggest you use uh this
  3603. 2:27:47pyic two or more than two okay you can
  3604. 2:27:49use this one now once you have added in
  3605. 2:27:52the requirements so simply you can open
  3606. 2:27:53up your terminal and just write this
  3607. 2:27:55command pip install hypena
  3608. 2:27:57requirement.txt. So it will be
  3609. 2:27:59installing this pyantic inside your
  3610. 2:28:01environment. Okay. So for me it is
  3611. 2:28:03already satisfied because initially I
  3612. 2:28:05already installed this pyic in my
  3613. 2:28:06environment. So once it is done um this
  3614. 2:28:09is the notebook guys. I'm also going to
  3615. 2:28:10share you all of the source code in the
  3616. 2:28:12description section. From there you can
  3617. 2:28:14download and you can try in your system.
  3618. 2:28:16Now here you definitely select the
  3619. 2:28:18kernel the environment you are creating.
  3620. 2:28:19Just try to select that. So for me I
  3621. 2:28:21have created this LLM demo. I'll try to
  3622. 2:28:23select this. Now here I'll be doing the
  3623. 2:28:25coding example. Now first of all here
  3624. 2:28:28you have to import this uh pientic based
  3625. 2:28:30model from pientic. So you have to
  3626. 2:28:33import like that from pientic. So I'm
  3627. 2:28:35getting the code suggestion
  3628. 2:28:37because here I'm using uh this Microsoft
  3629. 2:28:40copilot. Um yeah so maybe I'll take the
  3630. 2:28:44suggestion. So from pentic
  3631. 2:28:48pentic import I'm going to import the
  3632. 2:28:50base model first of all. Okay. So first
  3633. 2:28:53of all I'm going to show you the simple
  3634. 2:28:55example then I'm going to um show you
  3635. 2:28:57the advanced example of pyic as well.
  3636. 2:28:59Okay first of all let's start with the
  3637. 2:29:01simple example. Now once it is imported
  3638. 2:29:04now what I'm going to do guys I'm going
  3639. 2:29:05to simply write a pentic class. Okay so
  3640. 2:29:09let's say the class name is patient
  3641. 2:29:13okay patient data. So let's say this is
  3642. 2:29:15my class and definitely you have to
  3643. 2:29:18inherit this particular class with base
  3644. 2:29:20model. Okay. So this is called actually
  3645. 2:29:22pentic model. So this becomes actually
  3646. 2:29:23padentic model. Right? Now inside that
  3647. 2:29:26you have to define the schema. So schema
  3648. 2:29:28means like how many data you will be
  3649. 2:29:31using. Okay. So here I'll be using two
  3650. 2:29:33data. One is the name other is the age
  3651. 2:29:35because I'm replicating the same example
  3652. 2:29:37previously I have given. So here I was
  3653. 2:29:38considering name and age. Okay. These
  3654. 2:29:41two information only. And here I have
  3655. 2:29:43mentioned the name should be in a string
  3656. 2:29:45and age should be in integer. Okay. Now
  3657. 2:29:49what I'm going to do, I'm going to again
  3658. 2:29:51maybe copy the same uh function I
  3659. 2:29:54created or or let's write that. So div
  3660. 2:29:59add patient data.
  3661. 2:30:01Okay, add patient data. So this was the
  3662. 2:30:04function previously I written.
  3663. 2:30:08Okay, but there I passed this name and
  3664. 2:30:13uh name and uh directly. But here you
  3665. 2:30:16don't need to give like that. So here
  3666. 2:30:18what you have to do you have to
  3667. 2:30:21uh you have to give the uh you have to
  3668. 2:30:24give the pentic object. Okay. But before
  3669. 2:30:27that uh let me show you what to do.
  3670. 2:30:33So as of now let's uh just pass it. And
  3671. 2:30:38now the second step we have to uh in uh
  3672. 2:30:43instantiate the model with the raw
  3673. 2:30:44input. Uh so we have to prepare our raw
  3674. 2:30:46input. So input should be in a
  3675. 2:30:48dictionary or JSON like a structure. So
  3676. 2:30:50let's try to prepare the input. So input
  3677. 2:30:52is basically my patient information. So
  3678. 2:30:55patient
  3679. 2:30:59patient data
  3680. 2:31:03is equal to
  3681. 2:31:06um it should be a dictionary.
  3682. 2:31:10First of all I will add the name.
  3683. 2:31:16Okay.
  3684. 2:31:18Name NH. Okay. So, this is a dictionary
  3685. 2:31:21format. Now, what I will do, I'll just
  3686. 2:31:23try to
  3687. 2:31:25just try to pass uh this particular data
  3688. 2:31:28to my uh to my where to my pentic
  3689. 2:31:32object. So, here what is the pyic
  3690. 2:31:34object? Pentic object is nothing but my
  3691. 2:31:37patient data. Okay. So, what I'm going
  3692. 2:31:39to do, I'm going to pass it to the
  3693. 2:31:40patient data. So here let's try to
  3694. 2:31:43create um object of patient
  3695. 2:31:52okay patient
  3696. 2:31:55let's say this is the
  3697. 2:31:57um this is patient is equal to
  3698. 2:32:01um patient data and we'll be passing the
  3699. 2:32:05data and here I have given two star
  3700. 2:32:06because this is a dictionary and we have
  3701. 2:32:08to unpack the value right key and value
  3702. 2:32:10so that's why We are given this uh two
  3703. 2:32:12uh star here. Two star means you are
  3704. 2:32:14unpacking the data. Okay. Now this will
  3705. 2:32:16become a pyic object. Okay. Now we have
  3706. 2:32:19created a pentic object. Okay. Now this
  3707. 2:32:21particular object will be passing to the
  3708. 2:32:23function. All of the function will be
  3709. 2:32:25creating here. Whether it's a add
  3710. 2:32:27patient data, update patient data will
  3711. 2:32:29be um like passing those informations
  3712. 2:32:31inside the function. Now right now this
  3713. 2:32:34function uh can't take the name and a
  3714. 2:32:37separately. Instead of that it will take
  3715. 2:32:39what? It will take the
  3716. 2:32:41patient. Okay, patient object
  3717. 2:32:45that means the pidentic object. So that
  3718. 2:32:46means here I can uh make this particular
  3719. 2:32:50input name is at patient and the type of
  3720. 2:32:53the patient should be patient data. That
  3721. 2:32:54means this particular class and this is
  3722. 2:32:57your pentic model right? This is your
  3723. 2:32:58pentic class. Now why I have given
  3724. 2:33:00patient data? Because inside that I have
  3725. 2:33:02prepared the schema. That means this add
  3726. 2:33:05patient data function takes the data.
  3727. 2:33:09Okay, take the data and the what is the
  3728. 2:33:11data format? Data format should be uh
  3729. 2:33:14definitely there would be a variable
  3730. 2:33:15called name and name name should be
  3731. 2:33:17string and there should be another
  3732. 2:33:19variable called age. Edge should be
  3733. 2:33:21integer type. Okay. So that's how we are
  3734. 2:33:23giving the type. But initially we are
  3735. 2:33:25giving the data like that. We are giving
  3736. 2:33:27the name and we are mentioning okay this
  3737. 2:33:29should be the string. Then we are giving
  3738. 2:33:31the s this should be the integer. Okay.
  3739. 2:33:33But here we're doing the manual stuff.
  3740. 2:33:34But here right now we just created a
  3741. 2:33:37identic class and we're passing this
  3742. 2:33:38particular class object and it will
  3743. 2:33:40automatically understand okay what to do
  3744. 2:33:42what should be the format inside that
  3745. 2:33:43what should be the structure inside
  3746. 2:33:44that. This is called actually schema.
  3747. 2:33:46Okay schema means the data and the date
  3748. 2:33:48type of the data. Okay this is called
  3749. 2:33:50actually schema. Now once it is done now
  3750. 2:33:53simply here I can add the present
  3751. 2:33:55information. So simply I can print
  3752. 2:33:59the information. So right now see I
  3753. 2:34:00don't I can't actually directly print
  3754. 2:34:02the name right I can't directly print
  3755. 2:34:04the name here because we are not taking
  3756. 2:34:08the name as a name variable we are
  3757. 2:34:10taking as a patient right so we can call
  3758. 2:34:12like that patient dot name because
  3759. 2:34:14inside this particular patient data
  3760. 2:34:17object we'll be having the variable name
  3761. 2:34:19okay now we'll do for the same we'll do
  3762. 2:34:22for the age also so print patient edge
  3763. 2:34:25okay now once it is done I'll tell data
  3764. 2:34:27inserted successfully to the database So
  3765. 2:34:30similar wise I'll create for the update.
  3766. 2:34:34I'll create for the update. So let's
  3767. 2:34:36make it as update.
  3768. 2:34:39Okay. Now it will again take the same
  3769. 2:34:42patient uh uh patient data object that
  3770. 2:34:45means the pentic object
  3771. 2:34:47and once it is done we'll try to tell
  3772. 2:34:51data updated successfully in the
  3773. 2:34:53database. Okay. And everything will
  3774. 2:34:54remain same. Now let's try to see
  3775. 2:34:57whether it is working or not. Now simply
  3776. 2:34:59what I will do first of all let's say I
  3777. 2:35:00will add the patient data
  3778. 2:35:04okay add the patient data so inside this
  3779. 2:35:07add patient you have to pass this
  3780. 2:35:08patient information okay patient because
  3781. 2:35:11this is my pentic object we already
  3782. 2:35:14created with the help of this pentic
  3783. 2:35:16class now we'll try to pass it there now
  3784. 2:35:19see bp uh 25 data added successfully to
  3785. 2:35:22the database now let's say I want to
  3786. 2:35:24update the data simply I'll call the
  3787. 2:35:25update patient data inside that I will
  3788. 2:35:27again pass the patient object. Now see
  3789. 2:35:30the patient information is already
  3790. 2:35:33updated. Now let's say in updated
  3791. 2:35:39okay so what I can do instead of patient
  3792. 2:35:42uh I can give patient one let's say you
  3793. 2:35:44can create multiple patient that time
  3794. 2:35:47uh you can do that okay patient one
  3795. 2:35:49patient two like that you can do so
  3796. 2:35:51let's say this is the patient one
  3797. 2:35:52information okay this is patient one
  3798. 2:35:54information this is updated okay so
  3799. 2:35:56whenever you are doing the update
  3800. 2:35:58operation so make sure you are giving
  3801. 2:36:01any other name so simply what I can do
  3802. 2:36:06see before giving to the update function
  3803. 2:36:10first of all you have to validate with
  3804. 2:36:12the help of pidentic so let's say now
  3805. 2:36:13name is equal to Alex
  3806. 2:36:16uh let's say this is patient two we are
  3807. 2:36:19um we are giving this particular raw
  3808. 2:36:21data to the pentic okay pentic object
  3809. 2:36:24because here I already told you inst uh
  3810. 2:36:26instantiate the model with the raw input
  3811. 2:36:29data so we are initiating the model okay
  3812. 2:36:32the pentic model with the raw data. The
  3813. 2:36:34raw data we are passing here. Okay, raw
  3814. 2:36:36data we are passing here and this is uh
  3815. 2:36:38doing the validation. If everything is
  3816. 2:36:40fine uh it will tell okay you can
  3817. 2:36:42continue then we are giving to the
  3818. 2:36:45function. Now see this function is
  3819. 2:36:46working fine. Okay it should be patient
  3820. 2:36:49two not patient one it should be patient
  3821. 2:36:51two. Now see now it's become Alex. Okay.
  3822. 2:36:55Now the things I want to show you the
  3823. 2:36:57benefit actually uh using this pentic
  3824. 2:36:59which is that let's say uh by mistake
  3825. 2:37:02you have given um let's say string 25.
  3826. 2:37:06Okay you have given string 25 instead of
  3827. 2:37:08giving uh 25. So now what we will do
  3828. 2:37:11let's say if I execute the code see pyic
  3829. 2:37:14will not give you any kinds of
  3830. 2:37:16exception. Instead of that what it will
  3831. 2:37:17do it will try to convert this string 25
  3832. 2:37:20to integer. Okay so you don't need to do
  3833. 2:37:22it manually. So by default uh actually
  3834. 2:37:25internally this pyantic will handle this
  3835. 2:37:27kinds of scenario. So this will try to
  3836. 2:37:29convert to the um integer type. Okay,
  3837. 2:37:32you don't need to manually do that. So
  3838. 2:37:33here also you can do the same thing.
  3839. 2:37:35Let's say if I give string 25 your data
  3840. 2:37:37should be updated successfully. Okay.
  3841. 2:37:39Now let's say in future you want to add
  3842. 2:37:41any other information. So you don't need
  3843. 2:37:43to update these at the code that time.
  3844. 2:37:45Okay. Manually. So here let's say you
  3845. 2:37:47want to add the weight
  3846. 2:37:50uh weight for the patient. Okay. So
  3847. 2:37:52let's say weight usually I can mention
  3848. 2:37:54with the help of float data type because
  3849. 2:37:56weight should be float. Now simply what
  3850. 2:37:58I can do I can also print the weight
  3851. 2:38:00here.
  3852. 2:38:01Okay. Now here also I can do the same
  3853. 2:38:04thing. I can update the weight. And here
  3854. 2:38:07you can give the weight information
  3855. 2:38:09right. Let's say weight is uh 70.5 kg.
  3856. 2:38:13Now if I add the information see still
  3857. 2:38:17it will be working. Okay, I'm getting
  3858. 2:38:19one error because whenever I'm updating
  3859. 2:38:21the information here, I haven't passed
  3860. 2:38:23the weight. I have to pass the weight
  3861. 2:38:24here. Now see, it will work
  3862. 2:38:26successfully. Okay, so there should not
  3863. 2:38:28be any kinds of problem. Okay, but in
  3864. 2:38:30our previous example, you'll see that
  3865. 2:38:32every time I have to handle this kinds
  3866. 2:38:33of scenario manually. But in pyentic, we
  3867. 2:38:36don't need to handle that. Okay, we'll
  3868. 2:38:37try to just prepare a pyic class and in
  3869. 2:38:41this particular class, we'll try to
  3870. 2:38:42handle each and everything for me. Okay,
  3871. 2:38:44but you have to make sure whenever you
  3872. 2:38:45are giving your raw data, try to first
  3873. 2:38:47of all validate. Okay, try to first of
  3874. 2:38:50all validate with uh your pyic then try
  3875. 2:38:52to pass to the main function. Now I
  3876. 2:38:55think this particular concept will be
  3877. 2:38:57clear enough the strict and lax mode. So
  3878. 2:38:59basically what it do it attempts uh to
  3879. 2:39:02uh co uh qu cos the data example
  3880. 2:39:07converting uh this string one to integer
  3881. 2:39:10one that means automatically try to
  3882. 2:39:12convert for you. Okay. But if you want
  3883. 2:39:14to raise the exception, you can also do
  3884. 2:39:15that. Okay. Everything is possible here.
  3885. 2:39:19And one more thing I want to show you.
  3886. 2:39:21Now, let's say if you want to add um any
  3887. 2:39:25other type data, let's say instead of
  3888. 2:39:27giving this uh uh let's say this is this
  3889. 2:39:30is a number. Okay. Now let's say you are
  3890. 2:39:32not giving the number, you are giving
  3891. 2:39:34like that 70.
  3892. 2:39:37Okay. Say 70.
  3893. 2:39:41Okay. 70. Now see if I execute it will
  3894. 2:39:44throw you the error. Okay, it will tell
  3895. 2:39:46input should be a valid number. Unable
  3896. 2:39:49to parse the string to a number because
  3897. 2:39:52we can't convert this uh this text to
  3898. 2:39:55the number, right? This is not a number.
  3899. 2:39:57This is a other text. This is a like
  3900. 2:40:00kinds of word we are passing. Okay. But
  3901. 2:40:03it should be a number. Whether you are
  3902. 2:40:05giving as a string or integer doesn't
  3903. 2:40:08matter. It should be as a number. So if
  3904. 2:40:10you're giving as a number that time it
  3905. 2:40:12will be able to convert it to the
  3906. 2:40:14integer. Okay. But if you're giving
  3907. 2:40:16completely text type it will not allow
  3908. 2:40:17that time. Okay. So yeah that's how the
  3909. 2:40:20things work. But this is a very uh basic
  3910. 2:40:22type example I have given. Now we'll try
  3911. 2:40:25to move to the advance of this pentic. I
  3912. 2:40:27will try to see like more depth
  3913. 2:40:29validation how it can be done. We can
  3914. 2:40:31add so many parameters so many stuff
  3915. 2:40:33here. we can add so many let's say um
  3916. 2:40:36verification and we can uh make it like
  3917. 2:40:38more powerful. So guys so far we have
  3918. 2:40:41seen a very easy example uh of the
  3919. 2:40:45pentic. Now we'll try to make it uh
  3920. 2:40:48slight complex. Okay. Uh so what I'm
  3921. 2:40:51going to do maybe I can copy the same
  3922. 2:40:55uh same class.
  3923. 2:40:58So this is the class. So I'll copy this
  3924. 2:41:02or I can copy the entire
  3925. 2:41:05code
  3926. 2:41:08and I will paste it here. Okay. Now see
  3927. 2:41:10here what I'm going to do instead of
  3928. 2:41:12taking name age and weight maybe I'll
  3929. 2:41:15take some more uh extra variable. Let's
  3930. 2:41:18say here I'll take um
  3931. 2:41:21another uh another data called married.
  3932. 2:41:24Okay. Whether this patient is married or
  3933. 2:41:26not.
  3934. 2:41:29married. So this should be a boolean um
  3935. 2:41:33data type because either patient should
  3936. 2:41:36be married if married it should be yes
  3937. 2:41:38either no. So if yes or no comes into
  3938. 2:41:41picture so we can consider in boolean
  3939. 2:41:42type data type then I can take another
  3940. 2:41:46um data which is allergies. Okay whether
  3941. 2:41:51patient is having allergies or not. Okay
  3942. 2:41:53if he or she is having allergies. So
  3943. 2:41:56what kinds of allergies uh he or she is
  3944. 2:41:59having? See allergies is is it's not a
  3945. 2:42:01single let's say type. Okay, there
  3946. 2:42:03should be multiple types. Someone got
  3947. 2:42:04allergies from let's say dust. Someone
  3948. 2:42:07will be getting allergies from any kinds
  3949. 2:42:09of food, right? It should be different
  3950. 2:42:11different let's say type. So
  3951. 2:42:12[clears throat] that's why we'll be
  3952. 2:42:13taking as a list. Now you can ask me why
  3953. 2:42:16I'm taking this particular things as a
  3954. 2:42:19list. Okay? Because it should be list of
  3955. 2:42:22allergies. Okay? uh let's say uh one
  3956. 2:42:24patient will have uh might have multiple
  3957. 2:42:26allergies okay type or let's say one
  3958. 2:42:29patient would have only single type okay
  3959. 2:42:30so instead of taking a single type maybe
  3960. 2:42:32we can take a list of the type uh I mean
  3961. 2:42:35list type so that if one patient is
  3962. 2:42:38having multiple allergies so I can
  3963. 2:42:39easily store them right but if you're
  3964. 2:42:41taking list so you don't need to
  3965. 2:42:44directly um I mean write this list okay
  3966. 2:42:47if you are I mean writing in that way it
  3967. 2:42:49should it it won't be working so for is
  3968. 2:42:52what you have to do you have to import
  3969. 2:42:54this list from the typing module. So you
  3970. 2:42:56just need to import list from typing
  3971. 2:42:58module. So there is a module called
  3972. 2:42:59typing and in this typing we'll we'll be
  3973. 2:43:02having all kinds of typing okay inside
  3974. 2:43:04python. So we are importing the list.
  3975. 2:43:06Okay, we're telling we need a list. Now
  3976. 2:43:08it should be a list. Okay, so here we'll
  3977. 2:43:10be telling this should be a list type.
  3978. 2:43:14Okay, now I can't actually write list
  3979. 2:43:17like that because see what will happen
  3980. 2:43:19if I open up my blackboard.
  3981. 2:43:23See patient is having allergies. Okay,
  3982. 2:43:26all allergies is nothing but it's a
  3983. 2:43:28list. Okay, it's a list. Now the thing
  3984. 2:43:31is that inside that we have to write the
  3985. 2:43:34allergist type. Let's say this is dust
  3986. 2:43:36type and what is dust? Dust is a string
  3987. 2:43:40right now let's say food. Okay food is
  3988. 2:43:43also a string. Okay so type cannot be
  3989. 2:43:47any kinds of number. Okay it should be a
  3990. 2:43:49definitely a string type. That's why I'm
  3991. 2:43:51telling
  3992. 2:43:53u the list we are creating of the
  3993. 2:43:54allergies inside the list will be
  3994. 2:43:57storing a string type data. Okay.
  3995. 2:44:00because allergist type should be always
  3996. 2:44:01a string. So that's how whenever we are
  3997. 2:44:03creating any application we have to
  3998. 2:44:05think about the data type what should be
  3999. 2:44:06the data type okay uh the data we are
  4000. 2:44:09getting what should be the type okay you
  4001. 2:44:11have to think about in that way so
  4002. 2:44:13allergies should be list and inside list
  4003. 2:44:16the data we'll be storing it should be
  4004. 2:44:17string okay that's why we can uh write
  4005. 2:44:21this particular syntax and this is
  4006. 2:44:22called schema okay we are creating the
  4007. 2:44:24schema right now and we are extending
  4008. 2:44:26this particular pentic model I think you
  4009. 2:44:29get it right now I'll add another let's
  4010. 2:44:33say data which is contact
  4011. 2:44:39okay contact information. So contact
  4012. 2:44:41information let's say I want to keep it
  4013. 2:44:43as a dictionary. Uh let's say someone
  4014. 2:44:45will pass let's say um contact
  4015. 2:44:47information like that. Uh let's say
  4016. 2:44:52um he or she will be writing in that
  4017. 2:44:53way. Let me tell you.
  4018. 2:44:57So contact we want to take it in that
  4019. 2:45:00way. Let's say contact info is equal to
  4020. 2:45:02it should be a dictionary. So inside
  4021. 2:45:04that first of all user will pass the
  4022. 2:45:06email address. Okay. So let's say this
  4023. 2:45:09is the email address.
  4024. 2:45:16Okay. And this is my phone number.
  4025. 2:45:23Okay. Phone number. Let's say this is my
  4026. 2:45:25phone number like that. Okay. I think
  4027. 2:45:29you are getting and this should be also
  4028. 2:45:30string type data. Okay. So that's why uh
  4029. 2:45:33I'll be taking this contact info as a
  4030. 2:45:35dictionary. Now inside this dictionary
  4031. 2:45:40uh I'm going to mention okay I'm going
  4032. 2:45:42to mention what kinds of data I want to
  4033. 2:45:45take
  4034. 2:45:47dictionary should be
  4035. 2:45:52string type okay key should be also
  4036. 2:45:54string value should be also string okay
  4037. 2:45:56that's why we're mentioning the data
  4038. 2:45:58type and this is a dict and again I
  4039. 2:46:01can't use the python uh default
  4040. 2:46:03dictionary function I have to import
  4041. 2:46:05from this typing Okay. So simply I'm
  4042. 2:46:08going to import this dict. And now I'll
  4043. 2:46:10mention it here. Okay. That's it. Now
  4044. 2:46:15let's try to um execute. But before
  4045. 2:46:18executing I think you have to know we
  4046. 2:46:20have to prepare the raw data. Now let's
  4047. 2:46:22try to prepare the raw data. So we are
  4048. 2:46:24already getting the suggestion. We'll
  4049. 2:46:25accept that. So here you can see we have
  4050. 2:46:28added
  4051. 2:46:30uh we have added uh this uh one
  4052. 2:46:34married. Yeah. married. So this is we
  4053. 2:46:38have added
  4054. 2:46:40this is true.
  4055. 2:46:42Uh you can also give it as a string. You
  4056. 2:46:44can also give it as a boolean. It
  4057. 2:46:46doesn't matter. It will work. Then uh
  4058. 2:46:49you can uh see we are giving the
  4059. 2:46:51allergies. So allergies we are giving as
  4060. 2:46:54a list. As you can see we are having an
  4061. 2:46:57um allergies from peanuts and selffish.
  4062. 2:47:00Okay. Then uh we are giving the contact
  4063. 2:47:03info. Let's say this is my email address
  4064. 2:47:06and this is the phone number. Okay. Now
  4065. 2:47:08let's try to execute uh whether uh it is
  4066. 2:47:11able to work or not. See I'm not going
  4067. 2:47:14to update uh these are the function. You
  4068. 2:47:15can if you want you can also update with
  4069. 2:47:17all of these variable. You can print all
  4070. 2:47:18of them but uh let's do it quickly. So
  4071. 2:47:21here I'm going to do I'm going to simply
  4072. 2:47:23execute. Okay. Now see uh information is
  4073. 2:47:26added successfully. That means it's
  4074. 2:47:28working fine right now. But in some case
  4075. 2:47:31let's say if I am giving instead of
  4076. 2:47:34let's say uh this u allergies instead of
  4077. 2:47:37giving this string if I'm giving any
  4078. 2:47:38kinds of integer number let's say 23
  4079. 2:47:41okay it will give you the error okay it
  4080. 2:47:44will tell one validation error from this
  4081. 2:47:48patient data that means the pentic model
  4082. 2:47:50so allergies it is coming from the
  4083. 2:47:52allergies okay allergies field input
  4084. 2:47:55should be a valid string not the integer
  4085. 2:47:57okay so that's how You can specify this
  4086. 2:48:00one. So I'll come here again. I'll
  4087. 2:48:03change it now. Execute. See it will work
  4088. 2:48:06perfectly. Okay. So that's how any okay
  4089. 2:48:10any kinds of type you can mention inside
  4090. 2:48:12your pentic model. Okay. Any kinds of
  4091. 2:48:15speak uh schema you can mention inside
  4092. 2:48:17your pyic model. Everything is possible
  4093. 2:48:20here. Okay. So guys uh we have seen um
  4094. 2:48:23another example. uh now I'm going to
  4095. 2:48:26talk about uh this required and optional
  4096. 2:48:28fields. Okay, what is this required and
  4097. 2:48:31op optional fields? Let's try to
  4098. 2:48:32understand. See whenever we are creating
  4099. 2:48:34this schema right we are creating this
  4100. 2:48:36pentic model uh that time uh whatever
  4101. 2:48:40data we are taking right whatever data
  4102. 2:48:42we are uh let's whatever schema we are
  4103. 2:48:45um writing we have to give all of this
  4104. 2:48:47field right we have to give all of this
  4105. 2:48:49field whenever we are preparing the raw
  4106. 2:48:51data so if you skip any of them okay so
  4107. 2:48:53if you skip any of them what will happen
  4108. 2:48:55so let me show you the example I'll copy
  4109. 2:48:57this code I'll add it here let's say
  4110. 2:49:00these are my schema right let's say I I
  4111. 2:49:02I will let's say um I will let's say um
  4112. 2:49:07not provide this allergies. So what will
  4113. 2:49:09happen? So if I remove the allergies
  4114. 2:49:10from here,
  4115. 2:49:13let's say I will completely delete this
  4116. 2:49:15allergy field.
  4117. 2:49:18Okay, I'll delete this. Now if I execute
  4118. 2:49:20it will throw you an error. Okay, it
  4119. 2:49:21will tell one validation error from uh
  4120. 2:49:23patient data allergies field required.
  4121. 2:49:26Okay, but you haven't given this
  4122. 2:49:27particular data. So this is the issue.
  4123. 2:49:29Okay. Now let's say uh I want to make it
  4124. 2:49:32as optional. Let's say if user is not
  4125. 2:49:34also giving this allergy, it's
  4126. 2:49:36completely fine. It should be completely
  4127. 2:49:38optional. That means my code will still
  4128. 2:49:40execute. So for this what I can do? I
  4129. 2:49:43can make it optional. So to make it
  4130. 2:49:45optional, simply you have to import
  4131. 2:49:49optional from typing. Okay, optional
  4132. 2:49:51from typing. And you have to pass this
  4133. 2:49:54data type inside the optional.
  4134. 2:49:57Okay, inside the optional.
  4135. 2:50:00And one more thing you have to define
  4136. 2:50:02which is one default value which is
  4137. 2:50:05none. Okay. So I'm getting one error.
  4138. 2:50:08Let me check.
  4139. 2:50:12Okay. The error I'm getting it should
  4140. 2:50:13not be parenthesis. It should be this
  4141. 2:50:15square bracket. That's why that error
  4142. 2:50:18was coming. Now it's fine. Okay. Now
  4143. 2:50:20this allergies uh field should be
  4144. 2:50:21optional. If you are also not giving
  4145. 2:50:23it's completely fine. uh um I mean it
  4146. 2:50:26will still work and by default this
  4147. 2:50:29allergies uh field uh will get one value
  4148. 2:50:32which is none. I can show you by
  4149. 2:50:33printing that. So what I can do I can
  4150. 2:50:37print it.
  4151. 2:50:39So just for simplicity let let's remove
  4152. 2:50:41this function. Okay I'll only keep one
  4153. 2:50:45function. So here I'll just try to print
  4154. 2:50:48patient
  4155. 2:50:50dot allergies.
  4156. 2:50:53Okay. Now if I see show you my data
  4157. 2:50:56there
  4158. 2:50:57uh there I already removed this
  4159. 2:50:59allergist field. Now if I still execute
  4160. 2:51:02it will work and you can see this
  4161. 2:51:04allergies parameter is getting none.
  4162. 2:51:05Okay, this is getting none because the
  4163. 2:51:07default uh default value I have set as
  4164. 2:51:10none. Okay and it is completely
  4165. 2:51:12optional. If you give also it will work.
  4166. 2:51:14Okay, if you skip it, it will also work.
  4167. 2:51:17Now let's say if I give this value
  4168. 2:51:20so after married I think
  4169. 2:51:24I'll copy from my previous example this
  4170. 2:51:27special data
  4171. 2:51:31and I will pass it here.
  4172. 2:51:34Okay. Now here I have given this
  4173. 2:51:35allergies field. Now if I execute still
  4174. 2:51:38it will work but now it will take the
  4175. 2:51:40value because we have given the value
  4176. 2:51:42itself. Okay. But if you don't give it
  4177. 2:51:46still it will work but it will take as a
  4178. 2:51:48none. Okay. Now one more thing I told
  4179. 2:51:50you about the default value. See you can
  4180. 2:51:52also set the default value to any kinds
  4181. 2:51:54of field. Let's say in the married one I
  4182. 2:51:56can set any kind of default value. Okay.
  4183. 2:51:58Let's say if user is not giving any
  4184. 2:51:59kinds of value still it will take the
  4185. 2:52:01default value. Let's say married is
  4186. 2:52:03equal to by default I will be make it as
  4187. 2:52:04false. Now if I let's say remove this
  4188. 2:52:09married field as well still it will
  4189. 2:52:12work. So that particular okay I can
  4190. 2:52:15print and show you
  4191. 2:52:19here I'll print it
  4192. 2:52:24patient domarit
  4193. 2:52:26now see by default it is coming as a
  4194. 2:52:28false okay that means you can also pass
  4195. 2:52:30any default value if you want. Okay. And
  4196. 2:52:33you can also make any kinds of field as
  4197. 2:52:34optional. Okay. This is also possible
  4198. 2:52:37here. So guys, we have seen the optional
  4199. 2:52:40and required field. Now I'm going to
  4200. 2:52:42show you another uh example which is
  4201. 2:52:45related data validation. So in Pentic, I
  4202. 2:52:48told you uh we can also perform the data
  4203. 2:52:51validation if you want. Uh see uh data
  4204. 2:52:54validation means let's say the data you
  4205. 2:52:56are giving uh you can also validate
  4206. 2:52:58whether it is in same uh format or same
  4207. 2:53:01let's say it follows the same uh same
  4208. 2:53:04structure or not. Okay. So for an
  4209. 2:53:06example, I'm going to uh let's say
  4210. 2:53:12take one example.
  4211. 2:53:14I'll copy the same code. So this is like
  4212. 2:53:18becoming big line. So what I can do
  4213. 2:53:19maybe I can just press an enter
  4214. 2:53:23just to make it as a little bit shorter.
  4215. 2:53:25Okay. So what I'm going to do I'm going
  4216. 2:53:27to
  4217. 2:53:29take another variable
  4218. 2:53:32called email. Okay. As of now let's try
  4219. 2:53:35to consider um I'm also
  4220. 2:53:39taking one informations from the
  4221. 2:53:40patient. Uh that means his email and
  4222. 2:53:43here I'm going to remove the email.
  4223. 2:53:45Okay. So in contact information let's
  4224. 2:53:47only I'm going to take his phone number.
  4225. 2:53:49Okay. This is fine for us. So email I'm
  4226. 2:53:52going to take it as se separately. So
  4227. 2:53:54what I can do you can tell me okay I can
  4228. 2:53:57make it maybe string because email
  4229. 2:53:59usually would be any kinds of string
  4230. 2:54:00type data yes or no right but if I'm
  4231. 2:54:03taking as a string type data so what
  4232. 2:54:04will happen let me show you so let's say
  4233. 2:54:06I'm taking as a string type data email
  4234. 2:54:10and now uh after name I have to pass the
  4235. 2:54:13email so let's say email
  4236. 2:54:19okay email should be email so this
  4237. 2:54:22should
  4238. 2:54:27H.
  4239. 2:54:29Okay. So let's say BP at the rate
  4240. 2:54:31example.com or let's say B at the rate
  4241. 2:54:34uh gmail.com. Okay. Let's say this is my
  4242. 2:54:38email. It's completely fine. Okay. Now
  4243. 2:54:40let's see if I execute it will work. See
  4244. 2:54:42it is working fine. There is no error.
  4245. 2:54:44Okay. But let's say if I not giving this
  4246. 2:54:48at the rate sign. Now if I still let's
  4247. 2:54:50execute my code, it will be working.
  4248. 2:54:53Okay, although this email format is not
  4249. 2:54:55good. Okay, although this email format
  4250. 2:54:58is not correct but still my uh code is
  4251. 2:55:02working. Okay, then what is the use of
  4252. 2:55:04that? So here actually data validation
  4253. 2:55:06comes into picture. So basically see if
  4254. 2:55:08I am doing manually with the help of
  4255. 2:55:10Python. So you can tell me okay I can
  4256. 2:55:13use regular expression library and I can
  4257. 2:55:14validate whether this email it is
  4258. 2:55:17correct or not. Okay, I think you know
  4259. 2:55:19with help of regular expression also we
  4260. 2:55:20can handle this scenario but we are
  4261. 2:55:22using the pyic. Okay, and definitely we
  4262. 2:55:25are using it for my benefit. Right. So
  4263. 2:55:27in pentic instead of giving this email
  4264. 2:55:30as a string you can also give this
  4265. 2:55:34particular format um to the email
  4266. 2:55:37format. Okay. So inside this pyic we're
  4267. 2:55:40having another function called email
  4268. 2:55:43string email str. Okay. So what this
  4269. 2:55:46email list here does it does the data
  4270. 2:55:47validation that means it will
  4271. 2:55:49automatically check whether you are what
  4272. 2:55:52kinds of email you are giving it is in
  4273. 2:55:53correct format or not. If it is not
  4274. 2:55:55correct format that that time it will
  4275. 2:55:56throw you the error. Okay. Now instead
  4276. 2:55:58of giving this uh string maybe I can
  4277. 2:56:00give this email list here. Now what will
  4278. 2:56:02happen now? See if I execute this code
  4279. 2:56:06if I execute this code it will throw you
  4280. 2:56:08error. The error should be uh this
  4281. 2:56:10email. Okay value is not valid email
  4282. 2:56:12address. Now unless and until I'm not
  4283. 2:56:14giving the valid email address. Let's
  4284. 2:56:16say if I give this at the red sign right
  4285. 2:56:18now now it will work perfectly. Okay,
  4286. 2:56:20there should not be any kinds of issue.
  4287. 2:56:22So that's how you can perform the data
  4288. 2:56:23validation. Before giving the data, we
  4289. 2:56:25can validate whether data we are passing
  4290. 2:56:27it is it is um incorrect format or not.
  4291. 2:56:30It is validated or not. Okay, I think
  4292. 2:56:32you get now similar uh um similar things
  4293. 2:56:36you can do with another let's say data
  4294. 2:56:38validator.
  4295. 2:56:40uh the name of the data validator is
  4296. 2:56:41like any URL. Okay, any URL actually
  4297. 2:56:44validates any kinds of u um let's say
  4298. 2:56:47web URL. The web URL you are passing
  4299. 2:56:49whether it is uh in correct format or
  4300. 2:56:51not. So let's say uh I'm also giving the
  4301. 2:56:54patient uh LinkedIn information. Okay.
  4302. 2:56:57So let's say this is uh this is a IT uh
  4303. 2:57:00IT patient hospital. We are only taking
  4304. 2:57:03the IT IT patients. Okay. it I it
  4305. 2:57:06background related patients and we are
  4306. 2:57:07also taking their LinkedIn profile okay
  4307. 2:57:09to our database so what I'm going to do
  4308. 2:57:11maybe I can create another field here
  4309. 2:57:13I'm going to name it as LinkedIn
  4310. 2:57:16uh link then
  4311. 2:57:19okay
  4312. 2:57:21LinkedIn URL
  4313. 2:57:27um yeah and the type should be any URL
  4314. 2:57:30because this should be a URL format
  4315. 2:57:32right any URL now here what I'm going to
  4316. 2:57:34do I'm going to pass a URL, LinkedIn
  4317. 2:57:37URL. So I'm already getting a
  4318. 2:57:39suggestion.
  4319. 2:57:42So maybe I can hit another enter.
  4320. 2:57:50Okay. So here we are taking the URL as
  4321. 2:57:53you can see w https uh/ww
  4322. 2:57:57um dot uh or let's say I will copy my
  4323. 2:58:00LinkedIn profile. So this is my LinkedIn
  4324. 2:58:03profile.
  4325. 2:58:05uh I will add it here.
  4326. 2:58:09Okay. Now see if I execute this will
  4327. 2:58:12this thing will work fine. Okay. There
  4328. 2:58:13should not be any error. But let's say
  4329. 2:58:15if I'm not giving this https. Okay. If
  4330. 2:58:19I'm only giving this ww or let's I'm
  4331. 2:58:22also removing this ww. Okay. Now if I
  4332. 2:58:23execute see it will give you the error.
  4333. 2:58:26It is telling input should be a valid
  4334. 2:58:27URL. Okay. Otherwise it should not be
  4335. 2:58:30working. So this is the work of data
  4336. 2:58:31validator. Okay. That's how in ping
  4337. 2:58:34pyntic there are some default validator
  4338. 2:58:36um validator uh are present. Uh you can
  4339. 2:58:40simply see the documentation and you can
  4340. 2:58:42do the validation. Okay, if you want
  4341. 2:58:44this is possible here. Now one more
  4342. 2:58:46thing I will show you which is uh let's
  4343. 2:58:48say uh here we used uh some of the um I
  4344. 2:58:52mean already available uh data validator
  4345. 2:58:56um validator like email uh email string
  4346. 2:58:59then any URL okay but let's in some
  4347. 2:59:02cases uh there should be some of the
  4348. 2:59:04data uh and for those data this kinds of
  4349. 2:59:07validator won't be available okay that
  4350. 2:59:10time how you can actually validate those
  4351. 2:59:12data let's say uh here what I can I can
  4352. 2:59:16show you one example. Let's say here the
  4353. 2:59:18name we are passing um I want to make a
  4354. 2:59:21restriction and the maximum
  4355. 2:59:25length of a name should not be more than
  4356. 2:59:28uh 50 character. Okay. That time how I'm
  4357. 2:59:30going to do this kinds of validation.
  4358. 2:59:32Okay. So for this we can use the custom
  4359. 2:59:35um custom validator and we can write
  4360. 2:59:38this custom validator with the help of
  4361. 2:59:40one uh one amazing actually function
  4362. 2:59:42called field. So what you can do
  4363. 2:59:46uh you can simply import this field from
  4364. 2:59:49pentic.
  4365. 2:59:51So you have to import this field from
  4366. 2:59:52pentic.
  4367. 2:59:55Just a minute. Yeah, you have to import
  4368. 2:59:58this field from pentic. Now here simply
  4369. 3:00:01you just need to define this. Okay,
  4370. 3:00:03let's say name that should be string.
  4371. 3:00:06And here I'm going to write the field.
  4372. 3:00:11Okay, field. inside the field I'm going
  4373. 3:00:13to tell the maximum length of a name
  4374. 3:00:17should uh should be only 50 character
  4375. 3:00:19okay it should not be above 50 character
  4376. 3:00:22okay now let's say if I execute my code
  4377. 3:00:26it will work fine completely because
  4378. 3:00:28right now the name I'm using it is less
  4379. 3:00:30than 50 character but if you increase it
  4380. 3:00:33let's say I will add something big
  4381. 3:00:40okay now if I execute ute you'll see
  4382. 3:00:42that it will throw an error. The string
  4383. 3:00:44should be have most um 50 character.
  4384. 3:00:47Okay. So that's how you can do the data
  4385. 3:00:50validation uh in your custom data if you
  4386. 3:00:53want. So like that I can also let's say
  4387. 3:00:55set to any another field. Let's say I
  4388. 3:00:58want to restrict the age uh age field
  4389. 3:01:01here. I want uh whatever age uh user is
  4390. 3:01:04passing it should be it should be
  4391. 3:01:07greater than zero and uh lesser than
  4392. 3:01:10actually let's say 100. Okay. So for
  4393. 3:01:12this what I can do? I can add another
  4394. 3:01:14field here. Uh I'm going to write is
  4395. 3:01:16equal to field. So there is a parameter
  4396. 3:01:19called GT. Okay. GT means greater than
  4397. 3:01:23greater than zero. And there is another
  4398. 3:01:24parameter called uh LT. Okay. LT means
  4399. 3:01:28lesser than. So here I'm going to tell
  4400. 3:01:30let's say 100. Okay. Now if let's say
  4401. 3:01:33user is giving the age let's say minus
  4402. 3:01:3725. So this is definitely lesser than
  4403. 3:01:40zero. So that time it will give you the
  4404. 3:01:42error because input should be greater
  4405. 3:01:44than zero. But we are giving uh lesser
  4406. 3:01:47than zero. Okay. Now if you're giving
  4407. 3:01:49the correct information, it is working
  4408. 3:01:51fine. Okay. Like that we can also let's
  4409. 3:01:53say
  4410. 3:01:55add this kinds of validator inside our
  4411. 3:01:57allergies. Okay. Let's say this is the
  4412. 3:01:59list of the allergies we are taking and
  4413. 3:02:00all all of the values should be string.
  4414. 3:02:02Now we can also define the field here.
  4415. 3:02:05So I'm going to write the field.
  4416. 3:02:08Okay, field. Uh so here let's say the
  4417. 3:02:12allergies uh we are taking uh from the
  4418. 3:02:15user. So only
  4419. 3:02:18uh user can pass actually let's say
  4420. 3:02:20maximum five five allergies. Okay, five
  4421. 3:02:23allergy list. So that time I can define
  4422. 3:02:25the max length
  4423. 3:02:27should be
  4424. 3:02:29five. Okay. Now let's say if user is
  4425. 3:02:33giving more than that
  4426. 3:02:35okay allergies I make it as a optional
  4427. 3:02:38so what I can do I can maybe add the
  4428. 3:02:40data here previously I had the allergist
  4429. 3:02:43maybe I can copy H so from here I can
  4430. 3:02:46copy
  4431. 3:03:01Okay. So here I can add it after
  4432. 3:03:05married I can add the allergies.
  4433. 3:03:09Married also removed right previously.
  4434. 3:03:12Okay. Because this was optional. So here
  4435. 3:03:13I can add the allergies.
  4436. 3:03:17It should be a comma. Now if you're
  4437. 3:03:19giving more value here,
  4438. 3:03:28okay, that time it will throw you error.
  4439. 3:03:31Okay, because it should be five item but
  4440. 3:03:33we are giving more than five. Okay, so
  4441. 3:03:36this is another issue. So let me
  4442. 3:03:39Yeah, now it's working fine. Okay. So
  4443. 3:03:43that's how guys we can uh set our custom
  4444. 3:03:45data uh validator. Okay. We can set with
  4445. 3:03:48that of this field. Now this field you
  4446. 3:03:51can also use for another purpose uh to
  4447. 3:03:53add some other metadata. Okay. To add
  4448. 3:03:55some other informations about the schema
  4449. 3:03:58about the pentic model. Okay. I'm going
  4450. 3:04:00to show you.
  4451. 3:04:04So guys now let's try to understand um
  4452. 3:04:07apart from this um um data validation uh
  4453. 3:04:11like custom data validation okay where
  4454. 3:04:14we can use this field okay so see field
  4455. 3:04:17we can also use for the metadata
  4456. 3:04:20information let's say whenever we are
  4457. 3:04:23creating the schema you can also pass
  4458. 3:04:24any kinds of metadata here okay other
  4459. 3:04:27informations like description okay some
  4460. 3:04:30other example you can provide here so
  4461. 3:04:32that whenever this code is using any
  4462. 3:04:34other programmer or let's say other
  4463. 3:04:36let's say uh other person they can
  4464. 3:04:40easily understand what this field does
  4465. 3:04:42okay they can easily understand now see
  4466. 3:04:44the way we have written right now this
  4467. 3:04:46is completely fine but it does it
  4468. 3:04:48doesn't have any kinds of information
  4469. 3:04:49about the name let's say what name does
  4470. 3:04:51but if I add some other metadata like
  4471. 3:04:54description and all by reading the
  4472. 3:04:56description I think other person will
  4473. 3:04:57easily understand what to do right so
  4474. 3:04:59for this here I have uh given another
  4475. 3:05:01demo I have already written this
  4476. 3:05:02particular demo
  4477. 3:05:03So see here if you want to write any
  4478. 3:05:06kinds of metadata
  4479. 3:05:08metadata um inside your um schema that
  4480. 3:05:11time you can use this particular field
  4481. 3:05:14uh function but with that you have to
  4482. 3:05:16use another function called annotated.
  4483. 3:05:18Okay so you have to import this
  4484. 3:05:19annotated from typing. So now you have
  4485. 3:05:22to write the syntax like that. Okay
  4486. 3:05:23previously I was writing like that.
  4487. 3:05:26Okay, I was directly giving the string
  4488. 3:05:27field and all but right now if you want
  4489. 3:05:29to write the metadata first of all you
  4490. 3:05:31have to give the annotated object then
  4491. 3:05:33inside that you have to define the data
  4492. 3:05:35type okay the type int let's say this is
  4493. 3:05:37a string then you will be giving the
  4494. 3:05:39field so here my field was like maximum
  4495. 3:05:42length 50 now here I can pass some other
  4496. 3:05:44metadata like name or like the title
  4497. 3:05:46okay so name of the patient so the uh so
  4498. 3:05:49that means this particular name field is
  4499. 3:05:50nothing but it's a name of the patient
  4500. 3:05:52and you can also give the description
  4501. 3:05:54okay what this does this give the name
  4502. 3:05:56of the patient in less than 50 character
  4503. 3:05:58then you can also provide some example
  4504. 3:06:00okay so that by seeing this particular
  4505. 3:06:02example your programmer can understand
  4506. 3:06:04okay this actually works like that so
  4507. 3:06:06here I have given example like bap and
  4508. 3:06:08Alex so this is less than 50 characters
  4509. 3:06:10okay so similar wise you can uh use this
  4510. 3:06:13for all the field you are having let's
  4511. 3:06:15say I have given some other example I
  4512. 3:06:17have added this inside the weight okay
  4513. 3:06:19the same uh see here we mentioned like
  4514. 3:06:23this is flot here We have given the
  4515. 3:06:26field. Okay. Right now I'm going to
  4516. 3:06:28remove this trick parameter. I'm going
  4517. 3:06:29to tell you why this is required. Now
  4518. 3:06:32here you can also provide the
  4519. 3:06:33description. Okay.
  4520. 3:06:36Uh description and all everything can be
  4521. 3:06:39done. Okay. So this should be mentioned
  4522. 3:06:41inside field variable. So here you can
  4523. 3:06:43mention like description. Okay. Weight
  4524. 3:06:47of the patient in kg. Then married also
  4525. 3:06:50I have given the same thing annotated.
  4526. 3:06:52Then this is boolean type field. uh I
  4527. 3:06:54have given the default value. So see if
  4528. 3:06:56you want to give the default value. So
  4529. 3:06:57previously how I was giving I was giving
  4530. 3:07:00like that let's say I was just giving a
  4531. 3:07:02equal sign and giving the value but
  4532. 3:07:05right now you're using this field. So
  4533. 3:07:07inside field itself you can give the
  4534. 3:07:08default value. Let's say in default is
  4535. 3:07:10equal to none. So by default it will
  4536. 3:07:11take as a none. Let's say if you're
  4537. 3:07:12giving any other let's say true false it
  4538. 3:07:14will take as true false. Okay. Now here
  4539. 3:07:17I have given the description. Okay. Now
  4540. 3:07:18for allergies also you can do the same
  4541. 3:07:21thing. You can mention like okay this is
  4542. 3:07:24uh optional because previously this
  4543. 3:07:26allergies was optional and the data type
  4544. 3:07:29is list uh and inside that we are taking
  4545. 3:07:31the in uh string type data field is uh
  4546. 3:07:35default value we are setting as a none
  4547. 3:07:37you can also give the default value if
  4548. 3:07:38you want and maximum length should be
  4549. 3:07:40five okay so for contact details also
  4550. 3:07:42you can do the same thing but I left
  4551. 3:07:43this part okay now see if I execute
  4552. 3:07:47this is giving you an error the error is
  4553. 3:07:52uh field required contact details.
  4554. 3:07:56Okay. So the error is that here I have
  4555. 3:07:58written contact details but here I have
  4556. 3:08:00given contact information. So here you
  4557. 3:08:03have to give the same name same name.
  4558. 3:08:05Now if I execute it will be working
  4559. 3:08:06fine. Okay. Now one more thing I wanted
  4560. 3:08:08to show you which is this trick
  4561. 3:08:10parameter. Let's say I told you um in my
  4562. 3:08:13previous demo I think you remember uh
  4563. 3:08:16whenever let's say we are giving let's
  4564. 3:08:17say weight is equal to a string number.
  4565. 3:08:20Okay. But here what is the type I have
  4566. 3:08:22mentioned? Weight is equal to it should
  4567. 3:08:24be a float number. So by default my
  4568. 3:08:26pentic is converting this particular
  4569. 3:08:28string to a float because this is the
  4570. 3:08:30number. Okay. But always it is not
  4571. 3:08:33necessary to convert it. Okay
  4572. 3:08:35automatically convert it. Let's say you
  4573. 3:08:36are creating an application there you
  4574. 3:08:38only want to take this kinds of let's
  4575. 3:08:41say number as a string. That time you
  4576. 3:08:43should not be convert to the float data
  4577. 3:08:45type. That time you can uh write one
  4578. 3:08:48parameter.
  4579. 3:08:49Uh so here you can write a parameter the
  4580. 3:08:52parameter name is strict. Okay strict.
  4581. 3:08:55So you have to make it as true. Okay. So
  4582. 3:08:58if you make it as true. So what will
  4583. 3:08:59happen? You have given uh float type.
  4584. 3:09:02But if you are trying to give this uh
  4585. 3:09:05string type it will throw you error. See
  4586. 3:09:07it is throwing you error. It is telling
  4587. 3:09:09weight uh should be uh input um it it
  4588. 3:09:13should be a valid number float type
  4589. 3:09:14number. But we are giving string type.
  4590. 3:09:16Okay, that's why it's not working. So
  4591. 3:09:18now if I make it as float. Okay, so it
  4592. 3:09:21will be working right now. So if you're
  4593. 3:09:23giving integer also again it will throw
  4594. 3:09:25an error because here I make it as a
  4595. 3:09:27strict. Okay, strict parameter. So
  4596. 3:09:29that's how you have all kinds of
  4597. 3:09:31customiz customizable option inside
  4598. 3:09:33Pythic. Whatever you want, you can do
  4599. 3:09:36everything here. Okay, this is possible.
  4600. 3:09:39So guys uh we have seen some uh data
  4601. 3:09:42validator uh validation actually
  4602. 3:09:44strategy how we can do that. Now I'm
  4603. 3:09:48going to uh discuss about this uh um
  4604. 3:09:51validator um in advanced level. Uh we
  4605. 3:09:55call it as a field validator. Okay. So
  4606. 3:09:57see so far the validation we have done
  4607. 3:10:00uh this was like the simple validation.
  4608. 3:10:02Uh so we used some of the predefined
  4609. 3:10:04validator and uh we also like uh given
  4610. 3:10:08some some of the like um custom
  4611. 3:10:11constraint there. Okay. But let's say uh
  4612. 3:10:14you have some complex scenario where you
  4613. 3:10:17have to do uh a complete field
  4614. 3:10:19verification. Okay. So for an example
  4615. 3:10:22let me uh let me tell you like um the
  4616. 3:10:25problem statement. The problem statement
  4617. 3:10:26is that let's say um the application we
  4618. 3:10:30have created um let's say this is a
  4619. 3:10:32hospital application. So basically this
  4620. 3:10:35stores the patient information. Okay.
  4621. 3:10:39Then it performs the diagnosis to the
  4622. 3:10:40patients. Okay. Now just try to consider
  4623. 3:10:44this hospital has also connect
  4624. 3:10:45connection with some of the bank. Let's
  4625. 3:10:47say uh u some of the bank it has the
  4626. 3:10:50connection. Let's say HDFC bank it has
  4627. 3:10:53the connection. ICICI bank it has the
  4628. 3:10:56connection okay now what happens if it
  4629. 3:10:59is having the connection with the banks
  4630. 3:11:01let's say whatever patients are coming
  4631. 3:11:03from these are the banks so they will be
  4632. 3:11:05getting 50% discount okay they will be
  4633. 3:11:08getting 50% discount from this
  4634. 3:11:09particular hospital and if the patient
  4635. 3:11:12is not from these are the banks so they
  4636. 3:11:14have to pay 100% about the money so this
  4637. 3:11:17kinds of let's say validation I want to
  4638. 3:11:19add inside this application now how to
  4639. 3:11:21do that so definitely this is little bit
  4640. 3:11:23complicated created. So for this I have
  4641. 3:11:25already created the code as you can see
  4642. 3:11:28I just copy pasted the same code but
  4643. 3:11:30what I have done I just redu uh reduced
  4644. 3:11:33the u I mean some extra coded uh so that
  4645. 3:11:36you can uh understand easily see what I
  4646. 3:11:38have done uh the previous uh uh
  4647. 3:11:40validation I showed you with the help of
  4648. 3:11:42annotated I removed each and everything
  4649. 3:11:44I just taken my previous example okay
  4650. 3:11:46previous this clean example so here you
  4651. 3:11:49can see this is the cleaned example okay
  4652. 3:11:51I have taken the name email age married,
  4653. 3:11:54allergies, contract. Okay, these are the
  4654. 3:11:55things I have taken. Now let's say I
  4655. 3:11:58want to check the email here. Okay, I
  4656. 3:12:00want to check the email here because
  4657. 3:12:02only I will understand whether this
  4658. 3:12:05patient uh he's from any bank or not.
  4659. 3:12:08How I'm going to understand? Because
  4660. 3:12:10patient will give their email address,
  4661. 3:12:12right? So if I'm a like a very uh I mean
  4662. 3:12:16common person, so I'll give my common
  4663. 3:12:18email address like at thegmail.com and
  4664. 3:12:20all right. But if anyone is working in
  4665. 3:12:23the bank so definitely they will be
  4666. 3:12:25having uh their bank domain email
  4667. 3:12:27address okay let's say hdfc.com or
  4668. 3:12:30icici.com okay like that so email is the
  4669. 3:12:33best u field I can uh do this kinds of
  4670. 3:12:36validator so for this what you have to
  4671. 3:12:38do you have to write a custom function
  4672. 3:12:40okay so the function name is I have
  4673. 3:12:43given email validator okay you can give
  4674. 3:12:44any name but I have given email
  4675. 3:12:46validator and whenever you are creating
  4676. 3:12:48this function make sure you have to give
  4677. 3:12:50two decorator One is the field
  4678. 3:12:52validator. So field validator you have
  4679. 3:12:54to import from pientic. So you can see I
  4680. 3:12:56have imported from pientic. Uh field
  4681. 3:12:58validator and inside that you have to
  4682. 3:13:00mention which field you want to
  4683. 3:13:02validate. So here I'll tell I want to
  4684. 3:13:03validate this email. Make sure the
  4685. 3:13:05spelling should be same. Okay. Email
  4686. 3:13:07field should be validated and another
  4687. 3:13:09decorator you have to get called class
  4688. 3:13:10method because this is the method of
  4689. 3:13:12this particular class. That's why this
  4690. 3:13:14class method. Now this is my function.
  4691. 3:13:16So this function takes two argument. One
  4692. 3:13:18is the class class object itself. Okay.
  4693. 3:13:20And this is the value. Value means uh
  4694. 3:13:23let's say user is giving the email right
  4695. 3:13:25email address let's say abcdgmail.com
  4696. 3:13:28or sdfc.com. Okay. So this is called
  4697. 3:13:31actually value. So this particular value
  4698. 3:13:32will come and I have to validate this
  4699. 3:13:34particular value. Okay. So for this what
  4700. 3:13:36I have done I created a list uh I named
  4701. 3:13:39it as valid domains. So here I just
  4702. 3:13:41listed all of the bank uh let's say
  4703. 3:13:43domain. Let's say sdfc.com ici.com. You
  4704. 3:13:47can also give any other uh bank domain
  4705. 3:13:49if you want. Then what I'm doing first
  4706. 3:13:51of all the value I'm getting from the
  4707. 3:13:53user let's say whatever email user is
  4708. 3:13:56passing okay I'm just trying to extract
  4709. 3:13:58this last part okay as you can see let's
  4710. 3:14:00say if this is the email address I'm
  4711. 3:14:01extracting this particular part so this
  4712. 3:14:03code is doing that so I'm splitting with
  4713. 3:14:05the help of this address then I'm taking
  4714. 3:14:07the last value that means this
  4715. 3:14:09particular part then what I'm checking
  4716. 3:14:11if domain name not in our valid domain
  4717. 3:14:14that means if particular this domain
  4718. 3:14:15name is it is not available inside our
  4719. 3:14:17valid domains that means this is not
  4720. 3:14:19U uh this is not a a patient from the
  4721. 3:14:21bank. Okay. This is a common people.
  4722. 3:14:23Okay. So that time I'm raising exception
  4723. 3:14:25not a valid domain. Okay. Otherwise we
  4724. 3:14:28are returning the value. Simple. Now
  4725. 3:14:30let's try uh whether it's working or
  4726. 3:14:32not. See here I have given simple email
  4727. 3:14:34address buppygmail.com. So definitely it
  4728. 3:14:37will throw error because uh I'm not from
  4729. 3:14:39the bank. Uh okay. Still it is working.
  4730. 3:14:43Okay. The issue is that uh this should
  4731. 3:14:45be patient data object. Okay. Not
  4732. 3:14:47patient. uh this should be patient data
  4733. 3:14:49object uh patient data class. Now if I
  4734. 3:14:52execute now see it is giving you error.
  4735. 3:14:54It's telling value error not a valid
  4736. 3:14:56domain. Okay that means uh this
  4737. 3:14:58particular person it is not from the
  4738. 3:15:00bank. Now say if I give the bank domain
  4739. 3:15:03let's say I'll give sdfc.com.
  4740. 3:15:09Okay.
  4741. 3:15:11Now it should be working.
  4742. 3:15:15Still some error.
  4743. 3:15:18build required
  4744. 3:15:22merit.
  4745. 3:15:27Okay. So here I haven't passed the
  4746. 3:15:28merit, right? Uh so let's give the merit
  4747. 3:15:32as well.
  4748. 3:15:37Married
  4749. 3:15:38is equal to true. Now if I execute, see
  4750. 3:15:41it's working fine. Okay. Because this
  4751. 3:15:43particular person uh he's from the bank
  4752. 3:15:46itself. Okay. So that's how you can do
  4753. 3:15:48advanced level uh uh validation. Okay.
  4754. 3:15:51This is called field validator. Now you
  4755. 3:15:53can also do some transformation with the
  4756. 3:15:56validation as well. Now let's say I will
  4757. 3:15:57be working on another example.
  4758. 3:16:01So one more thing you can do uh with the
  4759. 3:16:03help of this field validator you can um
  4760. 3:16:06you can definitely validate but uh if
  4761. 3:16:08you want you can also do do the
  4762. 3:16:10transformation. Let's say the name you
  4763. 3:16:12are getting from the user. Uh you want
  4764. 3:16:14to store this particular name in a
  4765. 3:16:17uppercase format always. Okay. If user
  4766. 3:16:19is also not giving it's completely fine
  4767. 3:16:20but you want to make it uppercase and
  4768. 3:16:23you want to u save inside the database.
  4769. 3:16:25So for this again you can write another
  4770. 3:16:27validator
  4771. 3:16:29uh field validator. So see this is the
  4772. 3:16:32function I have created called transform
  4773. 3:16:35name and I told you you have to use two
  4774. 3:16:37decorator. One is field validator. Now
  4775. 3:16:39you have to specify which field I'll
  4776. 3:16:41tell name field and the class method
  4777. 3:16:43decorator. Now it will take class object
  4778. 3:16:46and the value. Now whatever value user
  4779. 3:16:48is giving that means the name. I'm just
  4780. 3:16:50doing the upper operation. Okay. And I'm
  4781. 3:16:51returning it. Now see uh here I'm giving
  4782. 3:16:54let's say lower case BP. But if I
  4783. 3:16:56execute this code still you will see
  4784. 3:16:58that in the database all of the uh
  4785. 3:17:00character would be in upper case. Okay.
  4786. 3:17:01So this is called transformation with
  4787. 3:17:03the help of this field validator. That
  4788. 3:17:04is also uh we can do here.
  4789. 3:17:08So guys, now we'll understand one
  4790. 3:17:10another important concept which is model
  4791. 3:17:12validator. So previously I told you
  4792. 3:17:15about this field validator. So in field
  4793. 3:17:17validator uh what uh I was performing.
  4794. 3:17:20So let's say if I want to do a single
  4795. 3:17:22field validation that time I was using
  4796. 3:17:25this field validator. Okay. But let's
  4797. 3:17:27say there is a condition you have to
  4798. 3:17:29verify multiple field. Okay. Multiple
  4799. 3:17:31field means let's say u the system you
  4800. 3:17:34have created you want to add another
  4801. 3:17:35functionality which is let's say if
  4802. 3:17:38patient age is greater than 60 okay that
  4803. 3:17:41time in the contact details there should
  4804. 3:17:43be a emergency number so this kinds of
  4805. 3:17:45uh validation I want to do okay so that
  4806. 3:17:48time with the help of only field
  4807. 3:17:49validator I can't do that because I
  4808. 3:17:51can't um I can't actually mention two
  4809. 3:17:54field together in the field validator
  4810. 3:17:55okay only one field can be mentioned so
  4811. 3:17:57we solve this particular problem with
  4812. 3:17:59the help of this model validator
  4813. 3:18:01So for this this is a very simple
  4814. 3:18:03concept. So let me show you how to add
  4815. 3:18:05this. So here you have to add this uh
  4816. 3:18:08add this code.
  4817. 3:18:10So here I'll just try to define the
  4818. 3:18:13indentation
  4819. 3:18:14and you have to import this model
  4820. 3:18:16validator from pi identical. Okay. There
  4821. 3:18:19is another validator called model
  4822. 3:18:21validator. You have to import and inside
  4823. 3:18:23that you have to uh give this parameter
  4824. 3:18:25as after mode is equal to after. And
  4825. 3:18:27here you will be creating the function.
  4826. 3:18:30The function name is uh validate
  4827. 3:18:31emergency contract. This will take the
  4828. 3:18:33class. Okay. And this will take the
  4829. 3:18:35model. Model means the entire schema.
  4830. 3:18:37Okay. So if you give the model that
  4831. 3:18:39means you can access all of the schema.
  4832. 3:18:41Okay. Uh from inside this particular
  4833. 3:18:43function. So here you can see here I'm
  4834. 3:18:45checking if model.hage that means I'm
  4835. 3:18:47extracting the age if it is um greater
  4836. 3:18:50than 60
  4837. 3:18:52and uh emergency not in model. Okay,
  4838. 3:18:56that means if emergency phone number is
  4839. 3:18:58not available that time you're raising
  4840. 3:19:00one exception value error patient older
  4841. 3:19:03than six uh 60 must have a emergency
  4842. 3:19:05contact. Okay, then we're retaining the
  4843. 3:19:07model. Now let's try to check this
  4844. 3:19:09whether it's working or not. So let's
  4845. 3:19:10say right now my age is 25 that means
  4846. 3:19:13this kinds of uh this condition uh will
  4847. 3:19:15not match. So it will work fine. So if I
  4848. 3:19:17execute see it is working fine. There is
  4849. 3:19:19no error. uh but if I let's say make my
  4850. 3:19:22age uh to more than 60 let's say 70 now
  4851. 3:19:27this will throw you error it is telling
  4852. 3:19:29uh value error patient older than 60
  4853. 3:19:32must have emergency contact number now
  4854. 3:19:34here I have to add the emergency contact
  4855. 3:19:36number so maybe after the phone number I
  4856. 3:19:39can add a emergency number now if I
  4857. 3:19:41execute see it's working fine okay so
  4858. 3:19:43this is called actually model uh
  4859. 3:19:45validator so that means if you have
  4860. 3:19:47multiple uh field verification that time
  4861. 3:19:49you can use this model validator Okay,
  4862. 3:19:51inside your application.
  4863. 3:19:54Now let's try to understand another
  4864. 3:19:56concept which is computed uh fields. Now
  4865. 3:19:59with the help of computed fields, what
  4866. 3:20:00we can do? Let's try to understand.
  4867. 3:20:02Let's say in the same example um I want
  4868. 3:20:05to do another thing. Let's say
  4869. 3:20:08um here I have added another
  4870. 3:20:10informations another data called height.
  4871. 3:20:11Okay. Now um see what computed field
  4872. 3:20:15does. It does a computation itself.
  4873. 3:20:17Okay. Let's say if user is giving any
  4874. 3:20:20kinds of information and it has to
  4875. 3:20:23recreate or let's say generate a
  4876. 3:20:25completely new information by utilizing
  4877. 3:20:27the same information that time we'll be
  4878. 3:20:29using computed fields. Let's say in this
  4879. 3:20:31case my patient has given me weight and
  4880. 3:20:33height but I want to calculate inside my
  4881. 3:20:36pent uh the BMI okay BMI of the patient
  4882. 3:20:40I'm not taking the BMI from the patient
  4883. 3:20:42itself instead of that what I want with
  4884. 3:20:45the help of weight and height I want to
  4885. 3:20:46calculate the BMI. So that time I'll be
  4886. 3:20:48using this computed field. So you have
  4887. 3:20:51to first of all import this computed
  4888. 3:20:52field from pi identic. We have already
  4889. 3:20:53imported. Now you have to again uh use
  4890. 3:20:57this as a decorator and you have to
  4891. 3:20:59write a function here. So my function
  4892. 3:21:01name is BMI and again you have to use
  4893. 3:21:03another um another actually um uh
  4894. 3:21:07another uh decorator which is property.
  4895. 3:21:09Okay, you have to use this property. Uh
  4896. 3:21:12so the property I think this is already
  4897. 3:21:13available.
  4898. 3:21:15uh this property is already available
  4899. 3:21:17inside Python. This is default one. So
  4900. 3:21:18you don't need to import from anywhere.
  4901. 3:21:20Then this is the function we are writing
  4902. 3:21:22BMI and we are giving the self parameter
  4903. 3:21:25and this returns uh the float value.
  4904. 3:21:27Okay. Because BMI should be float and
  4905. 3:21:29here we are calculating the BMI. We you
  4906. 3:21:31can see here we are taking the weight.
  4907. 3:21:34Okay. Uh then we are dividing with the
  4908. 3:21:37help of this height and we are squaring
  4909. 3:21:38it. Okay. Then we are taking the uh BMI.
  4910. 3:21:41Okay. We are calculating this BMI. We
  4911. 3:21:43are taking the result and this result we
  4912. 3:21:44are trying to returning it. Now if I
  4913. 3:21:47want to print this so I I have to just
  4914. 3:21:49simply write patient.bmi right now see
  4915. 3:21:51BMI I haven't written here okay inside
  4916. 3:21:53my schema instead of that I'm
  4917. 3:21:55calculating it and I'm returning it. So
  4918. 3:21:57that's why I have to call with the help
  4919. 3:21:59of this particular function. Let's say
  4920. 3:22:00if this function name is BMI test you
  4921. 3:22:02have to also give BMI test here. Okay
  4922. 3:22:04this is required. Now simply let me show
  4923. 3:22:05you whether it works or not. So here I
  4924. 3:22:07have already given the height. uh height
  4925. 3:22:09let's say I'm considering in meter and
  4926. 3:22:11weight I'm considering in kg. Okay. Now
  4927. 3:22:13if I execute now see it is also giving
  4928. 3:22:15you the BMI. Okay. So this is called
  4929. 3:22:17actually computed field. So if you want
  4930. 3:22:19to compute anything with uh with the
  4931. 3:22:21existing uh schema you are having
  4932. 3:22:23existing data you are having you can use
  4933. 3:22:25this computed field at time.
  4934. 3:22:29So guys now we'll discuss about another
  4935. 3:22:31important concept inside pentic which is
  4936. 3:22:33nested model. Uh so sometimes what
  4937. 3:22:36happens whenever we create the fields um
  4938. 3:22:39so field might be uh complex field as
  4939. 3:22:42well. So let me give you one example.
  4940. 3:22:44Let's say here I have this particular um
  4941. 3:22:48pentic model that means the class
  4942. 3:22:50patient data. So here I'm having the
  4943. 3:22:52patient information like name, gender,
  4944. 3:22:54age and another information I have which
  4945. 3:22:57is address. Okay. Now address field
  4946. 3:23:00might be complex field because address I
  4947. 3:23:02can't write in a single uh let's say
  4948. 3:23:05word. So inside a address there should
  4949. 3:23:07be three kinds of entity. One is city,
  4950. 3:23:09pin and state. Okay. Now here I'm not
  4951. 3:23:14going to write uh this kinds of syntax.
  4952. 3:23:16Okay. Because this is not possible here.
  4953. 3:23:18So instead of that what we can do we can
  4954. 3:23:21create another actually pentic um class.
  4955. 3:23:24Okay pyic model and we can make it as a
  4956. 3:23:27nested. Okay. Uh so how it can be done?
  4957. 3:23:30So let's say here I have created my
  4958. 3:23:32patient data. This is my model. And here
  4959. 3:23:35I have created another model which is uh
  4960. 3:23:37address. Okay. And again I inherited
  4961. 3:23:38with the help of this base model. Okay.
  4962. 3:23:40Now here I've given three entities,
  4963. 3:23:43state and pin. Now first of all I've
  4964. 3:23:46created the address uh as you can see
  4965. 3:23:47address dict. So city is equal to I have
  4966. 3:23:49given Google state is equal to harana.
  4967. 3:23:52Pin is equal to this is the pin. Okay.
  4968. 3:23:54Now this particular address you have to
  4969. 3:23:56pass where to this address model. Okay.
  4970. 3:23:58So we are passing it to the address
  4971. 3:24:00model. We are unpacking that. Okay. Now
  4972. 3:24:02this will uh this will return me one
  4973. 3:24:04pentic object. Okay. Now I'm going to
  4974. 3:24:06create my patient information right now.
  4975. 3:24:08So you can see name uh gender age and
  4976. 3:24:12now right now address is equal to see
  4977. 3:24:14what I have done. I have given this
  4978. 3:24:15particular object this class. Okay.
  4979. 3:24:17Address should be this class. So I'm
  4980. 3:24:19passing this particular object right
  4981. 3:24:20now. Okay. Address is equal to this
  4982. 3:24:22address. Then this patient information
  4983. 3:24:24I'm passing inside my patient uh model.
  4984. 3:24:26Okay. Now this is giving you the patient
  4985. 3:24:28information. Now inside this patient
  4986. 3:24:30information you are having all of the
  4987. 3:24:32information whether it is related
  4988. 3:24:34patient data, whether it is related
  4989. 3:24:35address. Now let me show you. So here
  4990. 3:24:37I'm importing first of all all of the
  4991. 3:24:39patient uh you can see data. So inside
  4992. 3:24:42patient I am having name age okay and
  4993. 3:24:44the address. Okay address object is also
  4994. 3:24:45available. Now if I want to uh let's say
  4995. 3:24:48access the name I can do that. If I want
  4996. 3:24:50to access the address I can also do
  4997. 3:24:52that. Now let's if I want to only access
  4998. 3:24:55the patient city. So you just need to
  4999. 3:24:58write patient uh address dot city. So
  5000. 3:25:01this will give you the city. Okay. So
  5001. 3:25:03that's how you can write this nested
  5002. 3:25:05models. This is also possible inside
  5003. 3:25:07pyic. Okay. I hope you get it.
  5004. 3:25:12So guys uh one more last thing I'm going
  5005. 3:25:14to discuss about this pentic which is uh
  5006. 3:25:17serialization. That means you can also
  5007. 3:25:20um export your uh pentic object u as a
  5008. 3:25:24dictionary or as JSON. For this we use
  5009. 3:25:27serialization. So I have taken the same
  5010. 3:25:29example. So only the last part what I
  5011. 3:25:31have done. So here you can see let's say
  5012. 3:25:33this is my final object uh of my u
  5013. 3:25:37nested uh nested model. So what I'm
  5014. 3:25:39doing I'm just doing model.dum. If you
  5015. 3:25:41do model dump so what will happen? It
  5016. 3:25:43will return you as a dictionary. See you
  5017. 3:25:45are exporting your object as a
  5018. 3:25:47dictionary. Okay, you can see this is a
  5019. 3:25:49Python dictionary. Okay, but if you're
  5020. 3:25:51using this uh JSON dump, okay, this
  5021. 3:25:54should be uh string that means it's a
  5022. 3:25:56JSON format. Now, you can use uh JSON
  5023. 3:25:59library to export um I mean you can also
  5024. 3:26:02export it. You can also dump it and you
  5025. 3:26:04can also load it um let's say later on.
  5026. 3:26:06Okay, this is required. Let's say
  5027. 3:26:07whenever let's say you have created a
  5028. 3:26:09pyic object okay you have done some data
  5029. 3:26:12validation and all and you want to uh
  5030. 3:26:14take it as a take it as a let's say file
  5031. 3:26:17and uh let's say you want to load it
  5032. 3:26:19later on you can do do this kinds of
  5033. 3:26:21serialization okay this is also possible
  5034. 3:26:23it's like a like in machine learning we
  5035. 3:26:25train model right after training the
  5036. 3:26:27model we save the model right we
  5037. 3:26:28serialize the model so it's kind of that
  5038. 3:26:30okay now guys uh with that our uh
  5039. 3:26:33discussion has been end and we have
  5040. 3:26:35understood all of the concept concept
  5041. 3:26:37related pyntic. Okay. And I think now
  5042. 3:26:40you are pretty much comfortable with
  5043. 3:26:42pyic. You should not be having any kinds
  5044. 3:26:44of issue with the pyic whether you are
  5045. 3:26:46working in uh aentic whether you are
  5046. 3:26:49working in machine learning deep
  5047. 3:26:50learning anywhere you will see this
  5048. 3:26:52kinds of concept will be available.
  5049. 3:26:53Okay. Now one thing I want to show you.
  5050. 3:26:55So if I go to Google and if I search
  5051. 3:26:57like why pyentic is important for AI
  5052. 3:26:59agent. As you can see uh pyntic is
  5053. 3:27:01crucial for agent because it brings the
  5054. 3:27:04structure relability and type safety for
  5055. 3:27:06software engineering to be uh
  5056. 3:27:09traditionally unstructured and
  5057. 3:27:10unpredictable word of large language
  5058. 3:27:12models. Okay. By leveraging the Python
  5059. 3:27:14typhoons and uh runtime data validation.
  5060. 3:27:16Pyic ensures that AI agents interact uh
  5061. 3:27:19realy with external docs APIs and
  5062. 3:27:22databases. Okay. So here are some of the
  5063. 3:27:24uh you can see uh concept they have
  5064. 3:27:27given. you can go through that you'll
  5065. 3:27:29see that uh at the end this particular
  5066. 3:27:31concept is very much required whenever
  5067. 3:27:33we're working with aentki application.
  5068. 3:27:35Okay. So yes guys I think you have
  5069. 3:27:37understood all of the concept. If you
  5070. 3:27:39have liked it please try to subscribe to
  5071. 3:27:41my channel and share this video with
  5072. 3:27:43your friends and family. So in this
  5073. 3:27:45video I'm going to show you how you can
  5074. 3:27:47implement uh AI agents with the help of
  5075. 3:27:50this langen. Okay. But if you're
  5076. 3:27:53completely new to the langen, if you
  5077. 3:27:55don't know about anything about the
  5078. 3:27:56langen, so definitely there would be a
  5079. 3:27:58prerequisite for this session uh which
  5080. 3:28:01is the langen and this langen video is
  5081. 3:28:03already available on my YouTube channel.
  5082. 3:28:05As you can see, I am having a complete
  5083. 3:28:08langen crash course on my YouTube
  5084. 3:28:10channel. The uh video name is ultimate
  5085. 3:28:12langen crash crash course for
  5086. 3:28:14developers. Okay, so I'm going to add
  5087. 3:28:16this uh uh add this video link in the
  5088. 3:28:19description. If you're completely new to
  5089. 3:28:21the langen guys, first of all, go ahead
  5090. 3:28:23with this particular uh video then you
  5091. 3:28:26will be able to understand each and
  5092. 3:28:28everything about the langen then it
  5093. 3:28:30would be easy for you to understand this
  5094. 3:28:32langen agent's creation. Okay. But if
  5095. 3:28:36you already familiar with this langen um
  5096. 3:28:38you don't need to go through this
  5097. 3:28:39recording. It's completely fine. You can
  5098. 3:28:42continue with this particular lecture.
  5099. 3:28:44But those who are completely new, I'm
  5100. 3:28:46telling you guys please try to complete
  5101. 3:28:47the langen then you can start with the
  5102. 3:28:49phase three. So in this video I'm going
  5103. 3:28:52to implement a single agent system uh
  5104. 3:28:56application with the help of langen. Uh
  5105. 3:28:58there I'm going to teach you um like
  5106. 3:29:01what are the things you need to
  5107. 3:29:02implement this kinds of single uh agents
  5108. 3:29:06uh let's say workflow uh and how you can
  5109. 3:29:10utilize langen okay for uh for this
  5110. 3:29:12particular task. So guys uh in this
  5111. 3:29:14video we are not only going to implement
  5112. 3:29:18uh our AI agents after implementing it I
  5113. 3:29:21will also show you how we can deploy
  5114. 3:29:22these kinds of agents over the cloud
  5115. 3:29:24platform. So this is going to be very
  5116. 3:29:26interesting video uh and this is going
  5117. 3:29:28to be our first agent. Okay the first
  5118. 3:29:30agent uh uh application we'll be
  5119. 3:29:33creating with the help of Langen. Uh so
  5120. 3:29:35this is going to be a single agent uh
  5121. 3:29:38system guys. Don't worry, I'm also going
  5122. 3:29:39to show you the multi- aent system as
  5123. 3:29:41well in the next video. Uh so each and
  5124. 3:29:43everything I'm going to clarify. So make
  5125. 3:29:45sure you watch this video till the end.
  5126. 3:29:47So guys, uh before implementing this AI
  5127. 3:29:50agents, first of all, let me give you
  5128. 3:29:52the idea about AI agents. Although I
  5129. 3:29:54have given you the detailed introduction
  5130. 3:29:55of AI agents, but let's uh do some quick
  5131. 3:29:59revision. As you can see, an AI agents
  5132. 3:30:02is an intelligent system that receives a
  5133. 3:30:04highle goal from a user and autonomously
  5134. 3:30:08plans, decides and execute a sequence of
  5135. 3:30:11action by using external tools, APIs or
  5136. 3:30:15knowledge sources all while maintaining
  5137. 3:30:17the context reasoning over multiple
  5138. 3:30:20steps, adapting to new informations and
  5139. 3:30:22optimizing for the intented outcome.
  5140. 3:30:26Okay, that means agentic AI application
  5141. 3:30:30or AI agents is having a kinds of power.
  5142. 3:30:34Uh basically it uh it has lots of
  5143. 3:30:38connection with uh external like tools,
  5144. 3:30:41APIs or knowledges. So whenever we are
  5145. 3:30:45giving any kinds of prompt okay it is
  5146. 3:30:47taking it as a uh goal okay and with
  5147. 3:30:50respect to the goal it is planning all
  5148. 3:30:53of the uh let's say task one by one okay
  5149. 3:30:58and once all of the let's say task is
  5150. 3:31:01ready it will try to execute those task
  5151. 3:31:03okay as sequence and whenever it
  5152. 3:31:06required any kinds of external tools or
  5153. 3:31:08APIs it will try to use that okay that
  5154. 3:31:11means if I give you uh brief idea about
  5155. 3:31:14the traditional LLM and
  5156. 3:31:18uh uh and the current AI agents what
  5157. 3:31:20would be the different between them so
  5158. 3:31:22let's say I think you know previously we
  5159. 3:31:24use only large language model right
  5160. 3:31:28large language model and here we pass a
  5161. 3:31:30prompt okay prompt so what will happen
  5162. 3:31:33this large language model will take that
  5163. 3:31:36prompt and it will give you a kinds of
  5164. 3:31:38answer or response okay but this large
  5165. 3:31:41language model doesn't have any external
  5166. 3:31:44connection with any kinds of tool APIs
  5167. 3:31:47or knowledge sources. Okay. So whenever
  5168. 3:31:49you are asking something it should be
  5169. 3:31:51available in the knowledge base itself
  5170. 3:31:53of the LLM. That means u this
  5171. 3:31:56information should be available when
  5172. 3:31:58they train this particular LLM. Okay.
  5173. 3:32:00But the difference of this AI agent is
  5174. 3:32:02that whenever you are giving a prompt to
  5175. 3:32:04the AI agents. So definitely internally
  5176. 3:32:07AI agents is utilizing the large
  5177. 3:32:08language model as a brain. Right? It is
  5178. 3:32:11utilizing large language model as a
  5179. 3:32:13brain so that it can perform the
  5180. 3:32:15reasoning operation. Okay, reasoning
  5181. 3:32:17operation and I I think you know why
  5182. 3:32:20reasoning is required because with the
  5183. 3:32:21help of this reasoning it will decide
  5184. 3:32:23when to utilize what kinds of tool or
  5185. 3:32:26what kinds of external sources APIs or
  5186. 3:32:28knowledge sources whatever right so
  5187. 3:32:30whenever we are giving a prompt to the
  5188. 3:32:32AI agents so basically what it is doing
  5189. 3:32:34it is trying to utilize the large
  5190. 3:32:36language model it is performing the
  5191. 3:32:38reasoning operation okay and when it is
  5192. 3:32:40required any kinds of external tools for
  5193. 3:32:43getting the informations it will try to
  5194. 3:32:45use that particular tools or any kinds
  5195. 3:32:47of API any kinds of let's say uh
  5196. 3:32:50external knowledge sources it will try
  5197. 3:32:52to utilize then this will give you the
  5198. 3:32:54response okay
  5199. 3:32:56uh with respect to the prompt you are
  5200. 3:32:58asking okay but whenever it is doing
  5201. 3:33:01this kinds of operation so basically it
  5202. 3:33:04is running some of the plan right
  5203. 3:33:06internally it is running some of the
  5204. 3:33:07plan uh it is making the decision okay
  5205. 3:33:10then it is executing these are the
  5206. 3:33:12workflow one by one okay so this is
  5207. 3:33:14called actually AI agents I think you
  5208. 3:33:17already know that and to make this
  5209. 3:33:20particular agent okay to utilize these
  5210. 3:33:23LLM tools and everything we need the
  5211. 3:33:25orchestration framework okay we need the
  5212. 3:33:27orchestration framework so with the help
  5213. 3:33:29of that particular framework we can uh
  5214. 3:33:31integrate like large language model we
  5215. 3:33:33can integrate like external tools APIs
  5216. 3:33:35knowledge base okay then uh we'll try to
  5217. 3:33:38integrate the reasoning ability so it
  5218. 3:33:41happens with the help of one
  5219. 3:33:42orchestration framework so in this video
  5220. 3:33:44we'll be using langen orchestration
  5221. 3:33:48framework. Okay, apart from langchen
  5222. 3:33:51actually other orchestration frameworks
  5223. 3:33:54are also available uh which is only
  5224. 3:33:56designed for AI agents like langraph,
  5225. 3:33:58crew AI, autogen okay we'll try to
  5226. 3:34:01discuss definitely but uh I want you to
  5227. 3:34:04first of all show you the first
  5228. 3:34:06orchestration uh orchestration framework
  5229. 3:34:09uh actually lang uh developed okay for
  5230. 3:34:12the AI agents. So we not only use langen
  5231. 3:34:16for agent uh generative application
  5232. 3:34:18development still you can use langen to
  5233. 3:34:20implement uh these kinds of AI agents
  5234. 3:34:23but langen is having some like
  5235. 3:34:26limitation I'll tell you about the
  5236. 3:34:27limitation in the next video what is the
  5237. 3:34:29limitation we are having why we have to
  5238. 3:34:31use lang graph uh crew AI okay these are
  5239. 3:34:33the things definitely I'm going to tell
  5240. 3:34:35you each and everything so now let's try
  5241. 3:34:39to see how we can implement uh these
  5242. 3:34:41kinds of AI agents uh with the help of
  5243. 3:34:44this langen. So for this I'm going to
  5244. 3:34:46open up my uh local uh local actually
  5245. 3:34:49directory and there I'm going to launch
  5246. 3:34:50my VS code and all of the setup we'll be
  5247. 3:34:53doing and we'll start the development.
  5248. 3:34:56So guys I'm inside my local directory.
  5249. 3:34:58So here what I'm going to do uh I'm
  5250. 3:35:00going to open up my visual code studio
  5251. 3:35:02here. So let's open up my visual studio
  5252. 3:35:05code.
  5253. 3:35:10So this is my Visual Studio Code. Let me
  5254. 3:35:14zoom
  5255. 3:35:18and I also need to open up my terminal
  5256. 3:35:21here. So I'll open up my terminal.
  5257. 3:35:26Okay. So the first step here will be uh
  5258. 3:35:29creating a virtual environment and we'll
  5259. 3:35:31do the requirement installation for this
  5260. 3:35:33agent. So let's try to create a file
  5261. 3:35:36here. I'm going to name it as readme.md
  5262. 3:35:41and inside that I'm going to mention all
  5263. 3:35:43of the command you need to execute. So
  5264. 3:35:44to create a environment you have to uh
  5265. 3:35:47execute this command. So contact create
  5266. 3:35:49rate create n um I'll name it as lang uh
  5267. 3:35:53lang agent uh that means lang chain
  5268. 3:35:55agent you can give any name it's up to
  5269. 3:35:57you. Then you can specify the python
  5270. 3:35:59version. So, python is equal to I'll be
  5271. 3:36:02taking
  5272. 3:36:03uh 3.11
  5273. 3:36:05and hyphen y that means I want to give
  5274. 3:36:08the yes permission. Once it is done, you
  5275. 3:36:10have to activate the environment and you
  5276. 3:36:12have to install the requirements. Okay.
  5277. 3:36:14Now, you can copy this command one by
  5278. 3:36:16one and you can execute inside your
  5279. 3:36:18terminal. So, for me uh this uh
  5280. 3:36:20environment is already available. So,
  5281. 3:36:22what I'm going to do, I'm going to
  5282. 3:36:23activate directly. But if you don't have
  5283. 3:36:25guys first of all try to execute the
  5284. 3:36:27first command then execute the second
  5285. 3:36:29command. So see guys this lang agent is
  5286. 3:36:31already available. This environment is
  5287. 3:36:33already available. Now I'm going to add
  5288. 3:36:35the requirements. So let's create
  5289. 3:36:38another file here.
  5290. 3:36:40I'm going to name it as requirement.txt.
  5291. 3:36:42Inside that you have to mention all of
  5292. 3:36:44the requirements for this particular
  5293. 3:36:47agent. So I have already listed down all
  5294. 3:36:50of the requirements you need guys. So
  5295. 3:36:52these are the requirements you need. So
  5296. 3:36:54I need langen I need langen community I
  5297. 3:36:57need langen code I need langen openi
  5298. 3:37:00I need um uh this things I don't need I
  5299. 3:37:04need request then tabi python and
  5300. 3:37:06pythonb okay I'm going to tell you why
  5301. 3:37:09this uh uh this thing are required
  5302. 3:37:11actually let me tell you see langchen I
  5303. 3:37:13think you know this is the main
  5304. 3:37:15framework this is the main orchestration
  5305. 3:37:16framework and to uh run this langchen
  5306. 3:37:19you need some other dependency package
  5307. 3:37:21like langchen community and langen core
  5308. 3:37:23And uh here we'll be using a large
  5309. 3:37:26language model because I think you so
  5310. 3:37:28internally agent uses a large language
  5311. 3:37:30model for the reasoning and this is the
  5312. 3:37:31main brain. So for this large language
  5313. 3:37:34model I'm going to use this open AI.
  5314. 3:37:35Okay, open AI provider. So uh from open
  5315. 3:37:38AI I'm going to use a particular model
  5316. 3:37:41and uh here you can uh change with any
  5317. 3:37:43kinds of model if you want. Let's say
  5318. 3:37:44you can also uh use any free provider
  5319. 3:37:47like open router. You can also use grock
  5320. 3:37:50API. Okay, you can also use Gemini API.
  5321. 3:37:52You can use anything but I have the open
  5322. 3:37:54AI that's why I'm going to use the open
  5323. 3:37:56AI. But whenever you are using this
  5324. 3:37:57kinds of free model so there are some
  5325. 3:38:00limitation definitely so you won't be
  5326. 3:38:02getting any kinds of good response from
  5327. 3:38:03this kinds of free model. That's why I'm
  5328. 3:38:06using my open AI model so that I can uh
  5329. 3:38:08show you the best response I'll be
  5330. 3:38:10getting from my agent itself. Okay. But
  5331. 3:38:13this course uh this model is changeable
  5332. 3:38:15guys. This provider provider is
  5333. 3:38:16changeable anytime you can change with
  5334. 3:38:18any model any provider. So simply you
  5335. 3:38:20just need to copy that uh model
  5336. 3:38:23initialization code and if you give to
  5337. 3:38:25the chat GP and if you ask like let's
  5338. 3:38:26say I want to use open router this free
  5339. 3:38:28model so definitely you'll be getting
  5340. 3:38:30that. So let me first of all uh write
  5341. 3:38:32the code then I think you will be able
  5342. 3:38:33to understand. Then request I need let's
  5343. 3:38:35say if I want to hit some of the URL
  5344. 3:38:37external URL or external website
  5345. 3:38:40external API that time I need this
  5346. 3:38:41request module. Uh I'll tell you why
  5347. 3:38:43this request module I I'll be using
  5348. 3:38:44here. Then tab python. So tab is a tool
  5349. 3:38:47okay search tool. So with the help of
  5350. 3:38:49tably what you can do you can perform
  5351. 3:38:51the internet search operation. Okay. So
  5352. 3:38:54uh the agents we'll be implementing will
  5353. 3:38:55try to uh add this tool so that my
  5354. 3:38:57agents will be able to search any kinds
  5355. 3:39:00of content over the internet and
  5356. 3:39:02python.b I need for the environment
  5357. 3:39:04management I'll be using open api key. I
  5358. 3:39:06need dav API key. All of the API key I'm
  5359. 3:39:08going to mention inside my env. Okay. So
  5360. 3:39:11let me create a file called env. So
  5361. 3:39:14inside that I'm going to mention all of
  5362. 3:39:15the API key. But first of all you have
  5363. 3:39:18to install this requirement txt. So
  5364. 3:39:20let's copy this command. open up the
  5365. 3:39:22terminal and simply execute that.
  5366. 3:39:26So for me it is already installed. Uh it
  5367. 3:39:28will tell like requirement is already
  5368. 3:39:30satisfied but for you it will take some
  5369. 3:39:32time. Okay. So see it has executed. Um
  5370. 3:39:37okay I think everything is fine.
  5371. 3:39:40H
  5372. 3:39:46okay. So here another package you need
  5373. 3:39:48which is langen
  5374. 3:39:57langen hub
  5375. 3:40:01okay langen hub is also required I'll
  5376. 3:40:02tell you why langen hub is required so
  5377. 3:40:05let me install again done
  5378. 3:40:10okay langen
  5379. 3:40:12okay spelling is not correct so let's
  5380. 3:40:14copy the spelling
  5381. 3:40:21Now I think
  5382. 3:40:23yeah everything is fine. So for me it is
  5383. 3:40:26already satisfied for for you it might
  5384. 3:40:27take some time. So once installation is
  5385. 3:40:29completed guys. So what I can do I can
  5386. 3:40:31simply create a folder. uh I can let's
  5387. 3:40:35say
  5388. 3:40:38give the folder name as research
  5389. 3:40:42and inside that I'm going to create a uh
  5390. 3:40:45Jupyter notebook file. I'm going to name
  5391. 3:40:46it as agent
  5392. 3:40:49uh
  5393. 3:40:50demo
  5394. 3:40:52ipy nbv. Okay.
  5395. 3:40:56Yeah.
  5396. 3:40:59Perfect. So one more thing I I have to
  5397. 3:41:02do which is this file. I will copy this
  5398. 3:41:04one and I will paste it inside resource
  5399. 3:41:06as well. Okay. Because uh if I want to
  5400. 3:41:10execute this notebook file definitely I
  5401. 3:41:12need this. So that's why I have done
  5402. 3:41:14that. Uh yeah. Now guys what I'm going
  5403. 3:41:18to do I'm going to first of all import
  5404. 3:41:20some necessary library. But before that
  5405. 3:41:22let's select our environment. So Python
  5406. 3:41:24environment which is lang agent. Okay.
  5407. 3:41:27I'm going to select that. So simply I'm
  5408. 3:41:29going to import some required library.
  5409. 3:41:33So I need operating system. Then I need
  5410. 3:41:37certify.
  5411. 3:41:39Okay. Why I need certify? I will tell
  5412. 3:41:41you. Then I need request
  5413. 3:41:44import
  5414. 3:41:49request. Then I need env.
  5415. 3:41:56So let me copy all of the input I need
  5416. 3:41:58here. Yeah. So I need uh ENB. Uh so I
  5417. 3:42:04will import load env because with the
  5418. 3:42:06help of this load envoirment
  5419. 3:42:08variable and whatever key we are having
  5420. 3:42:10inside that we can load. Then from
  5421. 3:42:12langchen openi we are importing chat
  5422. 3:42:14openi. So this is the class uh we can
  5423. 3:42:17use to load any kinds of large language
  5424. 3:42:19model from openi provider. Then we are
  5425. 3:42:22also importing this tools.
  5426. 3:42:25Okay. Why this tool is required? I'll
  5427. 3:42:26tell you. But as of now, let me delete
  5428. 3:42:29this option and also delete this uh
  5429. 3:42:32delete this library because these two
  5430. 3:42:34things I want to show you later on.
  5431. 3:42:35First of all, let's create a simple
  5432. 3:42:36agents. Then I'm going to show you how
  5433. 3:42:38we can improve this particular agent.
  5434. 3:42:39Okay. Then from langen community I'm
  5435. 3:42:42importing this tably search result.
  5436. 3:42:45Okay, that means this tab search tool.
  5437. 3:42:47As I already told you, we are also
  5438. 3:42:48installing this uh tab python. So tab is
  5439. 3:42:51one of the search tool. With the help of
  5440. 3:42:53that you can perform the internet search
  5441. 3:42:54operation. So we can import this uh tab
  5442. 3:42:57from the tool and it is available in
  5443. 3:42:59langen community. Okay that's why you
  5444. 3:43:01also install langen community. We are
  5445. 3:43:02importing tools tab search and tab
  5446. 3:43:05search result. Okay so once it is done
  5447. 3:43:07so simply I'm going to uh okay another
  5448. 3:43:10package I need which is
  5449. 3:43:13uh langen hub. Okay. So from langen
  5450. 3:43:17import
  5451. 3:43:19hub. So now let me import all of them.
  5452. 3:43:23So it is asking uh it will install some
  5453. 3:43:25required IPI kernel package. So let's
  5454. 3:43:27install.
  5455. 3:43:29So if you're doing it for the first time
  5456. 3:43:32um let's say in VS code first time means
  5457. 3:43:35in a like uh if you are creating a first
  5458. 3:43:38Jupyter notebook file and if you're
  5459. 3:43:40executing so initially it will install
  5460. 3:43:42some dependency uh IPI related uh
  5461. 3:43:45package. Okay. So it is installing.
  5462. 3:43:47Let's wait once this installation is
  5463. 3:43:48complete then we can execute again.
  5464. 3:43:54Okay, it has executed successfully.
  5465. 3:43:55There is no issue. Okay, now here guys
  5466. 3:43:58what I'm going to do simply I'm going to
  5467. 3:44:01um import uh some agent related
  5468. 3:44:04functionality from langen. So first of
  5469. 3:44:06all I need
  5470. 3:44:08um two things. So from langen
  5471. 3:44:14dot agent okay it is available inside
  5472. 3:44:17agent module
  5473. 3:44:19uh I'm going to import
  5474. 3:44:22create
  5475. 3:44:24uh create react agent okay so there is a
  5476. 3:44:27a function we are having called create
  5477. 3:44:31react agent okay so this thing I'm going
  5478. 3:44:35to tell you what is this create react
  5479. 3:44:37agent the full form of this uh react
  5480. 3:44:39agent is reasoning
  5481. 3:44:42uh reasoning and action. Okay, so the
  5482. 3:44:45full form of this react is reasoning and
  5483. 3:44:47action.
  5484. 3:44:49Okay, we can we can call it as a react
  5485. 3:44:51agent. I'll tell you how this react
  5486. 3:44:53agent works. Uh what is the mechanism
  5487. 3:44:55behind it? But as of now just try to
  5488. 3:44:57think this is the agent uh we mostly use
  5489. 3:45:01from the langen. Apart from that some
  5490. 3:45:03other uh let's say agent function we are
  5491. 3:45:05having in the langen but this is the
  5492. 3:45:08most popular one people uses. Okay. um
  5493. 3:45:11react uh sorry reasoning and action
  5494. 3:45:14agent.
  5495. 3:45:16Now once it is done I'm going to import
  5496. 3:45:19another
  5497. 3:45:20functionality which is agent exeutor.
  5498. 3:45:23Okay I'm also going to tell you why this
  5499. 3:45:24agent exeutor is required and how this
  5500. 3:45:27works with the react agent. Okay. So
  5501. 3:45:29these two library I need. Now let's try
  5502. 3:45:32to import them. Yeah. So once we have
  5503. 3:45:35imported now simply
  5504. 3:45:38uh what we have to do guys we have to uh
  5505. 3:45:41we have to load the environment
  5506. 3:45:43variable. Okay we have to load the
  5507. 3:45:45environment variable because in the
  5508. 3:45:47environment variable itself we'll be
  5509. 3:45:49mentioning all of our API key. So first
  5510. 3:45:51first of all I need my open API key
  5511. 3:45:53because I already told you for the large
  5512. 3:45:55language model uh we'll be using openi
  5513. 3:45:58right. So let's try to mention the open
  5514. 3:46:00API key. So how we can get the open API
  5515. 3:46:02key guys I think you know simply you
  5516. 3:46:04just need to go to open AI uh API
  5517. 3:46:06provider. So here you can go to the API
  5518. 3:46:08platform and uh left hand side you will
  5519. 3:46:11see the option called uh API key. Okay
  5520. 3:46:14simply create a API key here and you
  5521. 3:46:16just need to copy the API key. Okay so
  5522. 3:46:19for me I already have the API key. Let
  5523. 3:46:20me show you. I'll just copy
  5524. 3:46:24copy this API key.
  5525. 3:46:29So this is my API key guys. Don't use my
  5526. 3:46:31API key. I'm going to review after this
  5527. 3:46:33recording. Just try to create your own
  5528. 3:46:34API key. And uh you don't need to
  5529. 3:46:36necessarily create use this open API
  5530. 3:46:38key. If you want, you can also use any
  5531. 3:46:40other like LLM provider. Okay, it's
  5532. 3:46:43completely fine. Now with that, I also
  5533. 3:46:45need another API key which is the tabi.
  5534. 3:46:49Okay, taby API key because uh what
  5535. 3:46:52happens? Let's say whenever I will be
  5536. 3:46:54initializing the search tool, okay,
  5537. 3:46:56search tool of the tab. Uh so to use
  5538. 3:46:58this tab, I need a API key. So how to
  5539. 3:47:00get the table API key? So for this you
  5540. 3:47:02have to visit tavly.com. Okay. Or you
  5541. 3:47:06can search like tavly API key. So
  5542. 3:47:08instead of taby there are some other
  5543. 3:47:10like search tool are available like sar
  5544. 3:47:12api duck duck go search uh and other
  5545. 3:47:14tools are also available but I'm going
  5546. 3:47:16to use this tably one. So simply click
  5547. 3:47:18on tably api key.
  5548. 3:47:21So you have to create a account if you
  5549. 3:47:23don't have account. So I already have
  5550. 3:47:24the account guys. I created with the
  5551. 3:47:25help of my Gmail. So once you are inside
  5552. 3:47:28the dashboard you will be seeing this
  5553. 3:47:29kinds of interface. So from here you can
  5554. 3:47:31create a API key. Okay. So for me I
  5555. 3:47:33already have created some API key but
  5556. 3:47:34let me show you how to create the API
  5557. 3:47:36key. So let's say here I'm going to
  5558. 3:47:37create a API key called my key. Okay.
  5559. 3:47:41Once it is done just create the API key.
  5560. 3:47:44Okay. Your key is created and initially
  5561. 3:47:47whenever you are creating an account you
  5562. 3:47:48will be getting 1,000 free credit. I
  5563. 3:47:51think this is enough for learning but if
  5564. 3:47:52you want to use it for the production
  5565. 3:47:54that time you have to take their premium
  5566. 3:47:55plan. Okay. Now let's copy this key and
  5567. 3:47:58what I'm going to do I'm going to open
  5568. 3:47:59up my env
  5569. 3:48:03inside that I'm going to mention my tabi
  5570. 3:48:09table APAK. So let's make let me copy.
  5571. 3:48:12So this is my tab APK.
  5572. 3:48:16Okay APK done. Now let's uh initialize
  5573. 3:48:21this thing. But I have to load the
  5574. 3:48:24environment first of all. load
  5575. 3:48:25environment variable.
  5576. 3:48:28Let's load.
  5577. 3:48:35Yeah. So here we are loading the
  5578. 3:48:37environment variable. But before loading
  5579. 3:48:38it, so here you can see I'm setting this
  5580. 3:48:41SSL uh certify file. Okay. Uh so from
  5581. 3:48:46this certify uh library you can see we
  5582. 3:48:48have already imported and here we are
  5583. 3:48:50calling v because what happens if you're
  5584. 3:48:52using windows operating system so
  5585. 3:48:54sometimes it will it it might give you
  5586. 3:48:56some path related issue okay because
  5587. 3:48:58what happens window windows by default
  5588. 3:49:00uh open some older uh path okay and uh
  5589. 3:49:05that's why this issue usually raises so
  5590. 3:49:08what this code does actually it will uh
  5591. 3:49:10tell your windows that uh it will always
  5592. 3:49:13try to use the trusted
  5593. 3:49:15C uh certificate authority uh uh so that
  5594. 3:49:19uh whenever it is initializing the
  5595. 3:49:22uh path uh it will load the updated one.
  5596. 3:49:25Okay, instead of loading the old one,
  5597. 3:49:28okay, you can also search over the
  5598. 3:49:29internet, you can read about this SSL
  5599. 3:49:32certified file. Okay, I think you will
  5600. 3:49:33be able to understand. But if you're
  5601. 3:49:34using any other operating system like
  5602. 3:49:36Mac OS or Linux, I think that time it is
  5603. 3:49:38not required. But if you're getting the
  5604. 3:49:40path related issue, that time you can
  5605. 3:49:41add this code guys. Okay. Uh this is
  5606. 3:49:43optional. Uh for me actually I was
  5607. 3:49:45having this issue that's why I have
  5608. 3:49:47added but for you if you don't have
  5609. 3:49:48issue uh if you don't have issue you
  5610. 3:49:50don't need to add it. Okay. It's
  5611. 3:49:51completely fine. So once it is done now
  5612. 3:49:53we are getting our open API key and uh
  5613. 3:49:56we are loading it here in this
  5614. 3:49:58particular variable and we are also
  5615. 3:50:00loading our tably API key. Okay once it
  5616. 3:50:02is done let's try to load them.
  5617. 3:50:10Now
  5618. 3:50:12uh we'll be initializing the tab search
  5619. 3:50:15result uh object. So I can name it as a
  5620. 3:50:20search tool.
  5621. 3:50:25Search tool is equal to tably search
  5622. 3:50:29result.
  5623. 3:50:32And inside that there is a parameter you
  5624. 3:50:35can mention like max result. Okay max
  5625. 3:50:37result means how many result you want
  5626. 3:50:40after doing the internet search
  5627. 3:50:42operation. Let's see what searching for
  5628. 3:50:45a topic. Let's see what searching give
  5629. 3:50:46me some latest news. So how many search
  5630. 3:50:50result you want? How many reference
  5631. 3:50:51website you want? So if if it is let's
  5632. 3:50:53say two, this will give me two relevant
  5633. 3:50:56uh let's say um result. Okay. If you if
  5634. 3:50:59it is five, it will give me five
  5635. 3:51:00reference. That's how it works. Okay.
  5636. 3:51:02Now let me uh show you how this thing
  5637. 3:51:05will work.
  5638. 3:51:07So simply what I will do, I'll just try
  5639. 3:51:09to initialize it. Now let's try to test
  5640. 3:51:11it.
  5641. 3:51:13Search
  5642. 3:51:15tool
  5643. 3:51:17dot invoke
  5644. 3:51:21inside that I'm going to let's say give
  5645. 3:51:23what is the capital of French
  5646. 3:51:30okay or let's say I'll tell
  5647. 3:51:38okay now s spelling is not correct
  5648. 3:51:45Now fine. Now here I can tell
  5649. 3:51:50give me
  5650. 3:51:54the latest news on AI. Now
  5651. 3:51:58I will store it in a variable called
  5652. 3:52:01result.
  5653. 3:52:04Now simply I'm going to show this
  5654. 3:52:07result.
  5655. 3:52:10search tool is not defined. I have to
  5656. 3:52:12execute this. Now re-execute this.
  5657. 3:52:19Okay. Now see uh it is real time
  5658. 3:52:22searching over the internet and it is
  5659. 3:52:24referring some of the website. You can
  5660. 3:52:26see this is the URL. So this is the
  5661. 3:52:27first website it is referring for the
  5662. 3:52:29latest news on AI. Uh let me show you
  5663. 3:52:32this website. This is referring this uh
  5664. 3:52:35blog google.com. So here is the latest
  5665. 3:52:39AI news announced in March 2026 and
  5666. 3:52:43there is another reference you will get
  5667. 3:52:45see uh this one this is another website
  5668. 3:52:48uh from here also it is getting the
  5669. 3:52:50informations that means now my maximum
  5670. 3:52:54result is two I'm getting two actually
  5671. 3:52:57um
  5672. 3:52:59internet search reference if you if you
  5673. 3:53:00make it as three four you'll be getting
  5674. 3:53:02four reference okay like that okay
  5675. 3:53:04that's how you can use this tab Search
  5676. 3:53:07for real time internet search operation
  5677. 3:53:10and this is called actually search tool
  5678. 3:53:12and you can use this tool with your
  5679. 3:53:14agent because agent should be always
  5680. 3:53:17connected with uh this kinds of external
  5681. 3:53:19tool like this kinds of realtime tool
  5682. 3:53:22whenever it needs any kinds of latest
  5683. 3:53:24information it will be using this tool
  5684. 3:53:25to get this informations okay uh with
  5685. 3:53:28you and again I'm telling you I'm
  5686. 3:53:30creating a single agent system here uh
  5687. 3:53:33I'm not creating multi- aent system I'm
  5688. 3:53:34also going to show you how we can create
  5689. 3:53:36the multi agent system as well. Okay,
  5690. 3:53:38each and everything I'm going to cover
  5691. 3:53:39but in this video we'll be only focusing
  5692. 3:53:41on the uh single agent system. Okay,
  5693. 3:53:45fine. Now our search tool is ready. Now
  5694. 3:53:49simply what I'm going to do, I'm going
  5695. 3:53:50to initialize me my large language
  5696. 3:53:53model. So let's initialize our large
  5697. 3:53:55language model.
  5698. 3:53:57So this is the large language model
  5699. 3:53:58guys. So from chat openaii, we are
  5700. 3:54:00taking this GPT 3.5 turbo model. You can
  5701. 3:54:02also use GPT45. It's up to you.
  5702. 3:54:04Temperature this is the creativity
  5703. 3:54:05parameter. I I I just kept it with zero.
  5704. 3:54:08And here you need to pass the open API
  5705. 3:54:10key. Now let's initialize the LLM. So on
  5706. 3:54:13it is initialized. Let me also test
  5707. 3:54:14whether my LM is working or not. I'll
  5708. 3:54:16just do the invoke operation. LM.infoke.
  5709. 3:54:20Now here I'm telling let's say
  5710. 3:54:24uh what is the year is it
  5711. 3:54:28and the result we'll be getting again we
  5712. 3:54:30will store
  5713. 3:54:34spawns
  5714. 3:54:43see uh this is is it currently uh 2022
  5715. 3:54:472.
  5716. 3:54:51Okay. Why it is giving you it is uh
  5717. 3:54:54currently 2022 because this GBT3.5 turbo
  5718. 3:54:59uh has been trained till 2022. Okay, it
  5719. 3:55:01doesn't have any latest information
  5720. 3:55:03after that. Okay, that's why this agent
  5721. 3:55:05is required. I told you right in my
  5722. 3:55:07introduction session why uh we don't use
  5723. 3:55:10the large language model only. Why agent
  5724. 3:55:12is required? Okay, why realtime tool is
  5725. 3:55:14required? Each and everything I've
  5726. 3:55:15already clarified. Now let me ask
  5727. 3:55:17another question. Let's say
  5728. 3:55:19tell me
  5729. 3:55:22a joke about AI.
  5730. 3:55:25Now see it is giving you a joke. Okay,
  5731. 3:55:27that means it's working fine perfectly.
  5732. 3:55:30Now I need a prompt guys. Okay. Um to
  5733. 3:55:34implement the agent I need a prompt.
  5734. 3:55:37And here we are using this uh
  5735. 3:55:41um create react agent function. And for
  5736. 3:55:43this create react agent function I need
  5737. 3:55:45a relevant prompt. So this prompt either
  5738. 3:55:48you can write manually either you can
  5739. 3:55:50download from langen hub. So that's why
  5740. 3:55:53we have already installed this langen
  5741. 3:55:54hub. I think you remember. So what is
  5742. 3:55:56langen hub? In the langen hub itself
  5743. 3:55:58there are uh like so many prompt uh like
  5744. 3:56:02pre predefined prompt are already
  5745. 3:56:03available. So there are lots of uh let's
  5746. 3:56:06say developer they have already
  5747. 3:56:07published their prompt. So you can use
  5748. 3:56:09the pre-existing prompt and you can use
  5749. 3:56:11it inside your application development.
  5750. 3:56:13But if you want you can also manually
  5751. 3:56:14write this prompt. Okay. But why we are
  5752. 3:56:16taking the predefined prompt uh because
  5753. 3:56:18uh we are using this create create react
  5754. 3:56:20agent functionality. Okay. And for
  5755. 3:56:22create uh for this create react agent
  5756. 3:56:24functionality. This prompt is like uh
  5757. 3:56:27very good and this is recommended prompt
  5758. 3:56:29to use that. Okay. Now let me show you
  5759. 3:56:31this prompt. You can copy the name and
  5760. 3:56:33if you go to Google
  5761. 3:56:36uh you can search it. You can search it
  5762. 3:56:39here. Let's say now you can open the
  5763. 3:56:42first website.
  5764. 3:56:45Okay. So you'll see this particular
  5765. 3:56:48prompt guys here. See this is already
  5766. 3:56:49available in the hub and you can see the
  5767. 3:56:52prompt guys. Answer the following
  5768. 3:56:53questions as best as you can. You have
  5769. 3:56:55access to the following tools blah blah
  5770. 3:56:57blah. Okay. I'm going to explain this
  5771. 3:56:58prompt later on. But first of all, let
  5772. 3:57:00me create the agents and then let me
  5773. 3:57:03explain okay what it does. Now my prompt
  5774. 3:57:05is ready. Now what I have to do guys, I
  5775. 3:57:08have to prepare my tools. So I only
  5776. 3:57:10created one tools which is my table
  5777. 3:57:12search tool. So what I will do, I'll
  5778. 3:57:14just try to add this tool. So let me
  5779. 3:57:16create a list.
  5780. 3:57:18Okay, inside that list I'm going to
  5781. 3:57:20mention my search tool. Let's if you're
  5782. 3:57:21using multiple tool, you can add inside
  5783. 3:57:24this particular list. Okay, I'm going to
  5784. 3:57:25tell you how we can add also. Now my
  5785. 3:57:28tool is also ready. Okay, I have to also
  5786. 3:57:30execute the prompt. Now see it has uh it
  5787. 3:57:33has get this particular prompt from that
  5788. 3:57:36length in hub itself. Now let me show
  5789. 3:57:38you the prompt. Now see guys, this is
  5790. 3:57:40the prompt. Okay, this is the prompt. It
  5791. 3:57:42has already got this particular prompt.
  5792. 3:57:44Great. Now you have to create the agent.
  5793. 3:57:48Okay, you have to create the agent.
  5794. 3:57:51Uh we have already got the prompt. We
  5795. 3:57:53have already got the tool.
  5796. 3:57:57Let me comment here.
  5797. 3:57:59Okay, tool is there. Now we'll be
  5798. 3:58:01creating the agent.
  5799. 3:58:07Yeah. So to create the agent guys, we'll
  5800. 3:58:09be using this function create react
  5801. 3:58:10agent. And this create react agent takes
  5802. 3:58:13actually uh three things. The first
  5803. 3:58:15thing is the large language model. um
  5804. 3:58:18like this is the brain of that
  5805. 3:58:20particular agent and we are passing our
  5806. 3:58:22large language model. The second is is
  5807. 3:58:24that tool. Okay, the tool it will be
  5808. 3:58:26using for uh actually external um search
  5809. 3:58:31operation or external reference. And the
  5810. 3:58:34third thing it needs the prompt. Okay,
  5811. 3:58:36that means you are telling uh your agent
  5812. 3:58:39how it should interact. Okay, how it
  5813. 3:58:41should perform the jobs each and
  5814. 3:58:42everything each and every instruction is
  5815. 3:58:44giving inside the prompt. Okay. So
  5816. 3:58:46whenever you are creating this uh uh
  5817. 3:58:48react agent that time you have to pass
  5818. 3:58:50this three thing. Okay. And this will
  5819. 3:58:52return you one agent object object.
  5820. 3:58:54Okay. Now let me execute. So I got the
  5821. 3:58:57agent object right now. Now what I have
  5822. 3:59:00to do I have to run this agent. Okay.
  5823. 3:59:01With the help of the agent executor we
  5824. 3:59:03have already imported. So as you can see
  5825. 3:59:05we have already uh imported this agent
  5826. 3:59:07executor. So let's use this agent
  5827. 3:59:10exeutor to run this agent. And don't
  5828. 3:59:12worry, I'm going to explain you why this
  5829. 3:59:14uh uh I mean how this create react agent
  5830. 3:59:17works, how this uh agent executor works.
  5831. 3:59:20Okay, why it is required and everything
  5832. 3:59:21I'm going to clarify. So now let me
  5833. 3:59:24define the executor. So this is our
  5834. 3:59:26executor. So as you can see we are
  5835. 3:59:29calling this agent exeutor and agent
  5836. 3:59:31exeutor takes another uh three argument.
  5837. 3:59:33The first one is the agent. The agent we
  5838. 3:59:35have created let's say here we have
  5839. 3:59:37created only one agent. Okay, which is
  5840. 3:59:39this one. we are passing it. Uh then we
  5841. 3:59:42are giving the tool. Okay. Uh the tool
  5842. 3:59:44we have initialized. Then there's
  5843. 3:59:47another parameter called verbose. So
  5844. 3:59:49verbose if you make it as true that
  5845. 3:59:51means whatever agent will execute let's
  5846. 3:59:54say whatever plan state it will execute
  5847. 3:59:56you'll be able to see the in the
  5848. 3:59:58terminal and if you make it as false you
  5849. 4:00:00you won't be able to see the logs. Okay.
  5850. 4:00:02So basically if you want to see the logs
  5851. 4:00:03of your agent you can make it as true
  5852. 4:00:05otherwise you can make it as false.
  5853. 4:00:06Okay. So this will give you the agent
  5854. 4:00:08executor object. So once you got the
  5855. 4:00:10agent executor object now you are ready
  5856. 4:00:12to run this agent. So to run this agent
  5857. 4:00:14guys we'll be using this agent executor
  5858. 4:00:18and we'll simply do the invoke operation
  5859. 4:00:21and here we are giving a input. So the
  5860. 4:00:23input wise we're giving find the capital
  5861. 4:00:25of India and then the find its current
  5862. 4:00:28weather. Okay. Uh so this thing I'm not
  5863. 4:00:31going to pass it right now because uh I
  5864. 4:00:34want to show you another things. Okay.
  5865. 4:00:36Now simply I'm going to tell uh find the
  5866. 4:00:39capital of India. Now uh it will give
  5867. 4:00:42you the response
  5868. 4:00:44and this response I'm going to print it.
  5869. 4:00:49Okay this response. So from the response
  5870. 4:00:52I I will uh print the output. Now let me
  5871. 4:00:54execute.
  5872. 4:00:57Now see agent is executing. So it is
  5873. 4:01:00telling entering new agent exeutor
  5874. 4:01:03chain. So I should use the search engine
  5875. 4:01:05to find the answer. So it is using the
  5876. 4:01:08search tool that means the tably search
  5877. 4:01:10tool and it is finding see it is action
  5878. 4:01:12is tably search tool it is util
  5879. 4:01:14utilizing then it refers a website. Okay
  5880. 4:01:17from the website itself it found that
  5881. 4:01:19the capital of India is New Delhi and
  5882. 4:01:22once it got the result okay now you can
  5883. 4:01:24see the final result which is New Delhi.
  5884. 4:01:26Okay. So let me uh give another input
  5885. 4:01:29here. So, I'm going to just write
  5886. 4:01:32um tell me the
  5887. 4:01:37latest
  5888. 4:01:40news about
  5889. 4:01:47Iran
  5890. 4:01:49and USA world. Okay. Now, let's execute.
  5891. 4:01:56So it is you can see it is using this
  5892. 4:01:58tably search tool. Okay. So as you can
  5893. 4:02:01see my execution is done. So it is using
  5894. 4:02:03this tably search tool and it is using
  5895. 4:02:05different different online sources and
  5896. 4:02:08it is extracting
  5897. 4:02:10uh the latest information. And now let
  5898. 4:02:13me show you the final output. So this is
  5899. 4:02:15the final output. The latest news on
  5900. 4:02:17Iran and USA war uh includes Iran
  5901. 4:02:20warning of consequences if the US
  5902. 4:02:23launches new attacks. Okay. blah blah
  5903. 4:02:26blah that mean it is able to give you
  5904. 4:02:27the real time okay the latest
  5905. 4:02:30informations although we are using the
  5906. 4:02:32GPT3.5 turbo
  5907. 4:02:35okay which is uh trend till 2022 but it
  5908. 4:02:38is able to give you the latest uh latest
  5909. 4:02:41actually informations about 2026 okay
  5910. 4:02:45now let me show you let's say if I'm not
  5911. 4:02:47passing any kinds of tool to the agent
  5912. 4:02:49so what will happen so here let's say
  5913. 4:02:52what I'm going to do
  5914. 4:02:54um h so let's say here I'm going to
  5915. 4:02:57create a empty
  5916. 4:03:00empty tool
  5917. 4:03:02okay so I'm not going to pass anything
  5918. 4:03:05in this tool
  5919. 4:03:07now let's execute now again I will
  5920. 4:03:10create the react agent again I will um
  5921. 4:03:15execute the agent executor then I will
  5922. 4:03:19ask this
  5923. 4:03:35Now see it is continuously looking for
  5924. 4:03:38the tool but it is not getting right.
  5925. 4:03:40See it is not getting. So execution is
  5926. 4:03:42done. If I uh print it the final
  5927. 4:03:45response, you'll see that agent is
  5928. 4:03:46stopped due to the iteration limit or
  5929. 4:03:49time limit. Okay. What happens? Because
  5930. 4:03:51whenever you are not providing any kinds
  5931. 4:03:54of external tools, okay, what it is
  5932. 4:03:56happening?
  5933. 4:03:57Uh it is not able to get any kinds of
  5934. 4:04:00tool which it can use for searching
  5935. 4:04:03these kinds of latest informations and
  5936. 4:04:05it is continuously running this tool a
  5937. 4:04:07loop. Okay. So there are uh there are
  5938. 4:04:10actually u limitation of this particular
  5939. 4:04:13loop. So once let's say it is not able
  5940. 4:04:15to get it. So this loop would be
  5941. 4:04:17finished and you are getting uh this
  5942. 4:04:19agent is stopped due to the iteration
  5943. 4:04:21limit or time limit. Okay. But if we
  5944. 4:04:23provide this tool, okay, if we provide
  5945. 4:04:26this tool
  5946. 4:04:28that time see my agent is working uh
  5947. 4:04:32working perfectly fine.
  5948. 4:04:37Okay, see it's working perfectly fine.
  5949. 4:04:39Now it is able to get the tool and it is
  5950. 4:04:42able to search the content on the
  5951. 4:04:44internet and it is giving you the um
  5952. 4:04:47answer. Okay, I hope you get it.
  5953. 4:04:51That means what is happening? Let's say
  5954. 4:04:53this [clears throat] is our agent.
  5955. 4:04:56This is our agent.
  5956. 4:04:59Okay. And here we are giving a prompt or
  5957. 4:05:04input
  5958. 4:05:06and uh what it is doing first of all
  5959. 4:05:08this input is coming to the agent and it
  5960. 4:05:11is utilizing LLM okay as a brain for the
  5961. 4:05:15reasoning operation and LLM is uh
  5962. 4:05:19deciding let's say the input we are
  5963. 4:05:21giving whether it needs any kinds of
  5964. 4:05:23tool or not. So the question we have
  5965. 4:05:25given so definitely it needs a tool
  5966. 4:05:27because here we are using very old LLM
  5967. 4:05:30right which is GPT3.5 Turbo okay it
  5968. 4:05:32doesn't have the informations about Iran
  5969. 4:05:34and USA world right because this this
  5970. 4:05:36happens actually this year that means
  5971. 4:05:38the current year now LM will tell okay I
  5972. 4:05:41don't have the information so what we
  5973. 4:05:43have to do we have to use a external
  5974. 4:05:45tool okay what we have to do we have to
  5975. 4:05:47use external tool so right now let's say
  5976. 4:05:49I have connected with tabuli search API
  5977. 4:05:52so what it is doing it is going to tabul
  5978. 4:05:56it is executing this tool. This tool is
  5979. 4:05:58giving you the response like it is
  5980. 4:06:00referring uh to website because there is
  5981. 4:06:02a parameter called uh um search result
  5982. 4:06:06uh that parameter I have like set it
  5983. 4:06:08two. So it will get two relevant uh
  5984. 4:06:10let's say informations about the uh USF
  5985. 4:06:15word. So this is returning to the agent
  5986. 4:06:17and now agent is getting that
  5987. 4:06:19information and it is giving you the
  5988. 4:06:21final output. Okay, it is giving you the
  5989. 4:06:23final output. That's how things are
  5990. 4:06:25working. And whenever you are not giving
  5991. 4:06:27this tool, right, that time what is
  5992. 4:06:29happening? Agent agent is continuously
  5993. 4:06:31looking for the tool but it is not able
  5994. 4:06:33to get it any kinds of response from the
  5995. 4:06:35tool. That that's how uh it is breaking
  5996. 4:06:38the loop. It is breaking the iteration
  5997. 4:06:40and it is giving you I uh I didn't got
  5998. 4:06:43the answer. Okay, the loop is uh
  5999. 4:06:46executed uh sorry the loop loop is
  6000. 4:06:50uh stopped. Okay, I think you saw this
  6001. 4:06:52final message here. Uh here is the final
  6002. 4:06:55message. Uh okay, I already like uh
  6003. 4:06:59replace it. I think you saw the message,
  6004. 4:07:01right? This loop is already closed. Uh
  6005. 4:07:02we are not able to uh execute that.
  6006. 4:07:05Okay, so that's how things are working.
  6007. 4:07:07Now let me explain about these uh two
  6008. 4:07:10things which is create react agent and
  6009. 4:07:13another is agent exeutor. Okay, how this
  6010. 4:07:15create create react agent works. Why why
  6011. 4:07:18we call it as a uh reasoning action
  6012. 4:07:21agent and why agent execute exeutor is
  6013. 4:07:25required to run this particular create
  6014. 4:07:27react agents. Okay, I'll try to discuss
  6015. 4:07:29this part right now.
  6016. 4:07:33So guys as you can see uh first of all
  6017. 4:07:35let's try to understand this uh react
  6018. 4:07:38agent how react agent works. So as you
  6019. 4:07:40can see React is a design pattern used
  6020. 4:07:43in AI agents that stands for reasoning
  6021. 4:07:46and acting. Okay. Um it allows a
  6022. 4:07:50language model LLM to uh inter
  6023. 4:07:54interleive internal reasoning thought
  6024. 4:07:56with external act actions like tool use
  6025. 4:08:00in a structured multiple process. Okay,
  6026. 4:08:03that means I told you if I want to
  6027. 4:08:06execute a agent, so I need some external
  6028. 4:08:09tools, right? And to select that
  6029. 4:08:13particular external tool definitely you
  6030. 4:08:14need a reasoning and that reasoning you
  6031. 4:08:16are doing with the help of LLM, some
  6032. 4:08:18kinds of large language model. large
  6033. 4:08:20language model is deciding okay now I
  6034. 4:08:22have to use this particular tool and you
  6035. 4:08:24are using that tool to get the response
  6036. 4:08:26and you are you uh and you are actually
  6037. 4:08:29sending that particular tool response to
  6038. 4:08:32the agent and agent is giving you the
  6039. 4:08:33structured output okay so the whole
  6040. 4:08:35system is working like that okay now we
  6041. 4:08:38are using this react react agent okay
  6042. 4:08:40from the langen so the react agent is
  6043. 4:08:43implemented in that way okay because
  6044. 4:08:44internally they have written all kinds
  6045. 4:08:46of code related this kinds of
  6046. 4:08:48orchestration that means It has the
  6047. 4:08:50connection with LLM. It has the
  6048. 4:08:52connection with lots of tool. Okay. So
  6049. 4:08:54once we are giving any kinds of prompt,
  6050. 4:08:56it is automatically deciding with the
  6051. 4:08:58help of LLM like what tool to use. Okay.
  6052. 4:09:01For the actions. So let's say once I
  6053. 4:09:03executed the tool uh then what will
  6054. 4:09:07happen uh this tool will give you some
  6055. 4:09:09kinds of response and you will be
  6056. 4:09:11structuring this particular output and
  6057. 4:09:13you will show uh show to the human.
  6058. 4:09:15Okay. So this is a multi-step process.
  6059. 4:09:17Okay. This is a multi-step process. That
  6060. 4:09:19means this is a kinds of loop. Okay. So
  6061. 4:09:21you can see instead of generating an
  6062. 4:09:23answer in one go the model thinks step
  6063. 4:09:25by step decides uh deciding uh what it
  6064. 4:09:28needs to do next and optionally calling
  6065. 4:09:31tools APIs calculator web search etc to
  6066. 4:09:35help it. Okay, that means not only um
  6067. 4:09:37not only like tabularly search tool,
  6068. 4:09:39okay, you can use any kinds of tool
  6069. 4:09:40here. Either you can use any kinds of
  6070. 4:09:41API, either you can use any kind
  6071. 4:09:43calculator, web search and anything.
  6072. 4:09:46Okay, now see this react works in three
  6073. 4:09:49step. So I have already given an example
  6074. 4:09:51as you can see the first step is nothing
  6075. 4:09:53but the thought.
  6076. 4:09:59Okay, thought. Then the second step you
  6077. 4:10:02can see action.
  6078. 4:10:05Okay. And the third step is nothing but
  6079. 4:10:08observation.
  6080. 4:10:14Observe.
  6081. 4:10:16Observation. Okay. Now see here is the
  6082. 4:10:19example. So what is thought? First of
  6083. 4:10:21all let's try to understand whenever we
  6084. 4:10:24are giving any kinds of prompt. Let's
  6085. 4:10:25say we are giving a prompt. Uh let's say
  6086. 4:10:28um we are giving a prompt. uh what is
  6087. 4:10:31the capital of France and tell me the uh
  6088. 4:10:36population
  6089. 4:10:38uh tell me the population for capital of
  6090. 4:10:41France. Okay, let's say this is my
  6091. 4:10:42prompt. So first of all what will
  6092. 4:10:44happen? We are using let's say this
  6093. 4:10:46react agent. So this prompt will go to
  6094. 4:10:48the react agent and react agent will try
  6095. 4:10:50to make a thought first of all. So the
  6096. 4:10:52what would be the first thought? First
  6097. 4:10:54thought is nothing but let's say I need
  6098. 4:10:55to find the capital of France. Okay. So
  6099. 4:10:58first of all this would be the thought.
  6100. 4:11:01Now for this particular thought it will
  6101. 4:11:02perform a kinds of action. Okay. So in
  6102. 4:11:05this action it will utilize external
  6103. 4:11:07tool. So in this case it will utilize
  6104. 4:11:09the search tool. Okay. And with the help
  6105. 4:11:12of search tool what it will do? It will
  6106. 4:11:14try to perform some action. Okay.
  6107. 4:11:16[clears throat] So let's say it has done
  6108. 4:11:18the searching operation the capital of
  6109. 4:11:20France on the internet and it got some
  6110. 4:11:22observation like okay the capital of
  6111. 4:11:25France is nothing but Paris. Okay. So
  6112. 4:11:28once it got the observation you can see
  6113. 4:11:30the first loop is complete. Okay the
  6114. 4:11:33first loop is complete and in the first
  6115. 4:11:35loop it has performed three things
  6116. 4:11:36action and observation. Now it will come
  6117. 4:11:39to the second loop. Now you can see in
  6118. 4:11:41the second loop again the thought will
  6119. 4:11:42apply. Now let's say it has already got
  6120. 4:11:45the Paris okay the capital of France.
  6121. 4:11:47Now it will tell now I need to find the
  6122. 4:11:49population of Paris. Okay what it will
  6123. 4:11:52do again it will perform my action.
  6124. 4:11:54Again it will maybe utilize a search
  6125. 4:11:56tool or any other tool it is having with
  6126. 4:11:58the help of this particular tool. It
  6127. 4:11:59will perform the action. Okay. So now it
  6128. 4:12:01will try to figure out the population of
  6129. 4:12:03Paris. Now let's say observation is 2.1
  6130. 4:12:06million. Uh it is the population of
  6131. 4:12:08Paris. Okay. Now you can see this is the
  6132. 4:12:12second loop. Okay. Second loop is
  6133. 4:12:15complete. Now it will perform the third
  6134. 4:12:18loop. Okay. Now you can see once it got
  6135. 4:12:21the final result. Okay. Once it got the
  6136. 4:12:23final result that time this loop would
  6137. 4:12:26be um this loop would be stopped. Okay.
  6138. 4:12:30Now how it will understand this loop
  6139. 4:12:33should be stopped because there we uh in
  6140. 4:12:36the prompt itself we try to set whenever
  6141. 4:12:38we we get the final answer. Now let's
  6142. 4:12:40say uh the uh third iteration you will
  6143. 4:12:42you'll see that now I know the final
  6144. 4:12:45answer. Okay. So once it knows the final
  6145. 4:12:47answer okay that time this particular
  6146. 4:12:51iteration should be stopped. Now you can
  6147. 4:12:53see it will return with the final answer
  6148. 4:12:54that time the Paris is Paris is capital
  6149. 4:12:57of France and has a population around
  6150. 4:13:002.1 million. Okay, that means the prompt
  6151. 4:13:04I think you remember I showed you one
  6152. 4:13:05prompt. Okay, we are using from langen
  6153. 4:13:07hub in the prompt also these kinds of
  6154. 4:13:11steps are available. Okay, and there we
  6155. 4:13:13strictly mentioned that once you got the
  6156. 4:13:15final answer. Okay, once you know the
  6157. 4:13:17final answer just try to stop this
  6158. 4:13:19particular iteration. Now let me show
  6159. 4:13:20you this uh prompt again. I think now it
  6160. 4:13:22would be clear to you. So guys, as you
  6161. 4:13:25can see this was the prompt. Now you can
  6162. 4:13:27see the prompt. Answer the following
  6163. 4:13:28questions as best you can. You have
  6164. 4:13:32access to the following tools. So I
  6165. 4:13:34think you remember in our agents we have
  6166. 4:13:35already provided the tool access. Okay.
  6167. 4:13:38All the tool access we are having. Now
  6168. 4:13:40we are telling use the following format.
  6169. 4:13:42Question. Okay. Question should be the
  6170. 4:13:44input uh questions you must answer.
  6171. 4:13:47Okay. The user input questions. Now you
  6172. 4:13:49can
  6173. 4:13:51uh you can have three things three step.
  6174. 4:13:53First of all thought. You should always
  6175. 4:13:55think about what to do. Okay. And this
  6176. 4:13:57thought how it will think with the help
  6177. 4:13:59of LM. Okay. Now with respect to the
  6178. 4:14:02thought it should perform some action.
  6179. 4:14:04Okay. The action to take uh should be
  6180. 4:14:06one of the tools. Okay. That means this
  6181. 4:14:08action should be tell with the help of
  6182. 4:14:10one of the tool. So once let's say we
  6183. 4:14:13have selected the tool. Now uh what
  6184. 4:14:16should be the action input? We have to
  6185. 4:14:18provide the action input. Now this will
  6186. 4:14:21perform the action and when whenever it
  6187. 4:14:24will get the response from the tool. So
  6188. 4:14:26this this is called actually observation
  6189. 4:14:28the result of the action. Okay. Once you
  6190. 4:14:30got the observation now this particular
  6191. 4:14:32step should be running continuously. You
  6192. 4:14:33can see this thought action action input
  6193. 4:14:36observation can repeat end times unless
  6194. 4:14:38and until thought is I know uh the final
  6195. 4:14:42answer. Okay. I know the final answer.
  6196. 4:14:44This particular this particular uh let's
  6197. 4:14:46say
  6198. 4:14:48um iteration should be continuously
  6199. 4:14:50running. Okay. Once you know the final
  6200. 4:14:52answer that just try to provide the
  6201. 4:14:54final answer. Let's say this is the
  6202. 4:14:55final answer of the original questions
  6203. 4:14:58and uh what will happen? It will try to
  6204. 4:15:02uh end that particular uh agent. Okay.
  6205. 4:15:04So every agents works like that guys.
  6206. 4:15:06Okay. I think you got it because the
  6207. 4:15:09main fun is behind a agent is to run
  6208. 4:15:11some of these steps. Okay. And
  6209. 4:15:14continuously this will run this steps
  6210. 4:15:16unless and until it found the final
  6211. 4:15:18answer. Okay. Once it found the final
  6212. 4:15:20answer then this particular loop would
  6213. 4:15:21be break and you will be getting the
  6214. 4:15:23final output. Okay. Now you can see the
  6215. 4:15:26question um as a as a like say um human
  6216. 4:15:30we have to give the question our
  6217. 4:15:32question and agent internally will try
  6218. 4:15:34to take the agent uh scrap uh scratch
  6219. 4:15:37pad. Okay. What is agent scratch pad?
  6220. 4:15:40Agent scratch pad is nothing but the
  6221. 4:15:42that three things. Okay. this thought
  6222. 4:15:45action and observation because
  6223. 4:15:47continuously it has to take that okay
  6224. 4:15:49continuously it has to take that to
  6225. 4:15:51understand the previous question action
  6226. 4:15:53and observation okay so these kinds of
  6227. 4:15:55things will be continuously happening
  6228. 4:15:57unless and until we're not going to
  6229. 4:15:59final answer okay now I think you got it
  6230. 4:16:03so that's why I told you uh we'll be
  6231. 4:16:06using this predefined react prompt for
  6232. 4:16:09this react agent uh you can also write
  6233. 4:16:11your own prompt but if you're writing so
  6234. 4:16:13you may miss down these are the option
  6235. 4:16:15and whenever you miss down these are the
  6236. 4:16:17let's say context or definitely your
  6237. 4:16:19agent uh might not give you the correct
  6238. 4:16:21response so that's why prompting is
  6239. 4:16:23always important whenever you're
  6240. 4:16:24creating your own agent system guys okay
  6241. 4:16:28so guys now I think you have understood
  6242. 4:16:31uh what is this uh create react agent
  6243. 4:16:33okay how it works uh now we'll try to
  6244. 4:16:36understand what is this executor is
  6245. 4:16:38agent exeutor okay why we need this
  6246. 4:16:40agent exeutor to run this uh react agent
  6247. 4:16:43let's try to understand about this.
  6248. 4:16:45uh one more thing I want to uh tell you
  6249. 4:16:47which is that let's say after using this
  6250. 4:16:49create react agent it takes three
  6251. 4:16:51parameter lm to send prompt we get the
  6252. 4:16:53agent object okay this is our final
  6253. 4:16:55agent object and to run this agent we
  6254. 4:16:57need this agent executor okay now let me
  6255. 4:17:00show you another diagram
  6256. 4:17:02so guys as you can see uh this is the
  6257. 4:17:06diagram of agent and agent executor now
  6258. 4:17:08we'll try to understand how this works
  6259. 4:17:11okay why this agent executor is required
  6260. 4:17:14so let's say we I have created a react
  6261. 4:17:16agent object which is nothing but our
  6262. 4:17:18agent. Okay, in the code itself I
  6263. 4:17:20already told you. Now to run this agent,
  6264. 4:17:22I need a agent executor. Okay, so why I
  6265. 4:17:25need this agent exeutor. See to run this
  6266. 4:17:28agent. Okay, I think you know internally
  6267. 4:17:30agent uh runs actually three step. One
  6268. 4:17:33is the first thing first thing is like
  6269. 4:17:35the uh this one which is um
  6270. 4:17:40um let me show you. Yeah. The first
  6271. 4:17:44thing is the thought. Okay. Thought
  6272. 4:17:54thought. Then second thing
  6273. 4:17:58is action
  6274. 4:18:00and the third thing is observation.
  6275. 4:18:06Okay. So to run this three step guys we
  6276. 4:18:09need this agent executor. Okay. Okay, to
  6277. 4:18:11run this three step we need this agent
  6278. 4:18:13executor. So without agent executor we
  6279. 4:18:16can't actually run this three steps.
  6280. 4:18:18Okay. So that's why whenever we have
  6281. 4:18:20created our agent to execute this agent
  6282. 4:18:24we need a agent executor and internally
  6283. 4:18:26agent executor handle these three
  6284. 4:18:28scenario. So what will happen in the
  6285. 4:18:29first iteration let's say uh you can see
  6286. 4:18:32this is the steps of agent executor
  6287. 4:18:34orchestrate the entire uh loop. So first
  6288. 4:18:36of all sends the input uh and previous
  6289. 4:18:39message to the agent. Okay. So what will
  6290. 4:18:42happen? This agent executor will try to
  6291. 4:18:44send the input. What is the input? Input
  6292. 4:18:47of nothing but the user input. Okay.
  6293. 4:18:50User input. Let's say user has asked
  6294. 4:18:53let's say um I think I can give you the
  6295. 4:18:56same example the previous example. Uh
  6296. 4:18:59what is the capital of friends? And uh I
  6297. 4:19:01need the population of capital of
  6298. 4:19:03friends. Let's say this is the input. So
  6299. 4:19:05first of all this agent executor will
  6300. 4:19:07try to send this input to the agent and
  6301. 4:19:09it will also send the previous message
  6302. 4:19:11to the agent. Previous message means
  6303. 4:19:13these three things start action and
  6304. 4:19:15observation. So initially for the first
  6305. 4:19:18time whenever you are executing the
  6306. 4:19:19agent definitely this three uh three
  6307. 4:19:22actually block would be completely
  6308. 4:19:24empty. Okay this three block complet uh
  6309. 4:19:26it should be completely empty. That
  6310. 4:19:27means whatever thought action and
  6311. 4:19:30observation you are sending it it should
  6312. 4:19:32be completely empty. So your agent will
  6313. 4:19:34only receive the user input that time.
  6314. 4:19:36Okay. Now once it got the user input now
  6315. 4:19:40your agent will decide okay whether it
  6316. 4:19:43has to use any kinds of tools or not.
  6317. 4:19:45Okay. Now you can see gets the next
  6318. 4:19:47action from the agent. Okay. Uh so you
  6319. 4:19:50can see
  6320. 4:19:52um uh yeah so sends the input and
  6321. 4:19:55previous message to the agent. Once it
  6322. 4:19:56is done, now uh agent will try to uh
  6323. 4:20:00let's say perform the reasoning
  6324. 4:20:01operation with the help of reasoning. Uh
  6325. 4:20:03it will decide the question we are
  6326. 4:20:05getting whether I need to use any kinds
  6327. 4:20:08of tools or not because agent is already
  6328. 4:20:10connected with the tools. I think I
  6329. 4:20:11showed you right. It has already
  6330. 4:20:12connected with tools. Okay, it has
  6331. 4:20:15connected with tools. Now agent will
  6332. 4:20:17decide whether it has to use any tools
  6333. 4:20:19or not. Let's say it has to use a tool.
  6334. 4:20:21What tool? The tabular search tool. Then
  6335. 4:20:23again agent will try to tell agent
  6336. 4:20:26executor they uh uh um that like I have
  6337. 4:20:30to use the tably search tool to give the
  6338. 4:20:33answer. Okay. Now what agent executor
  6339. 4:20:35will do? It will go to the tool. What
  6340. 4:20:38tool? The tably tool. Okay. Tablely tool
  6341. 4:20:41and it will hit the tably tool with the
  6342. 4:20:45question user is asking. Let's say the
  6343. 4:20:47first question was what is the capital
  6344. 4:20:49of French? Now tab will refer some
  6345. 4:20:51internet website and it will give you
  6346. 4:20:53the answer. Again agent will give this
  6347. 4:20:56answer to the agent. Okay. Now agent got
  6348. 4:20:58the answer. Let's say the capital of
  6349. 4:20:59France is Paris. Okay. Now what will
  6350. 4:21:02happen? This is the observation. You can
  6351. 4:21:04see execute the tool with provide an
  6352. 4:21:05input adds the tool observation back
  6353. 4:21:08into the history. Now what will happen
  6354. 4:21:10again? It will try to add uh add uh
  6355. 4:21:14inside this thought action observation
  6356. 4:21:16because it is already getting this
  6357. 4:21:17thought.
  6358. 4:21:19uh then action and observation. Now this
  6359. 4:21:22these are the parameter would be filled
  6360. 4:21:23up. Now what is the thought? Thought
  6361. 4:21:25should be uh let's say it already got
  6362. 4:21:28the um capital of friends which is Paris
  6363. 4:21:31action it has already taken it has used
  6364. 4:21:32the tabularly tool. Okay. And uh the
  6365. 4:21:35input was what is the capital of friends
  6366. 4:21:37and uh uh sorry thought should be uh it
  6367. 4:21:41already got the capital of friends.
  6368. 4:21:44Okay. Um and action should be it has
  6369. 4:21:47let's say already executed the tab tool
  6370. 4:21:49and observation should be the Paris.
  6371. 4:21:51Okay, it already got the Paris. Now it
  6372. 4:21:53will run the second loop. Okay, it will
  6373. 4:21:55run the second loop because it does it
  6374. 4:21:56didn't get the final answer yet. Okay,
  6375. 4:21:58it didn't get the final answer yet. Now
  6376. 4:22:01again what it will do again exe agent
  6377. 4:22:02executor will run. Okay, now agent uh
  6378. 4:22:06agent executor will run the thought.
  6379. 4:22:08What is the thought now? Next thought
  6380. 4:22:10should be this one. Next thought should
  6381. 4:22:13be this one. Now I need to uh I need to
  6382. 4:22:16find the population of Paris. Okay, this
  6383. 4:22:18should be the next part. Again go to the
  6384. 4:22:20agents. Again agents will decide whether
  6385. 4:22:23it has to use a tool or not. So again it
  6386. 4:22:26will tell okay I need to use the tab
  6387. 4:22:27search tool. Agent executor will go to
  6388. 4:22:29tab search tool. It will hit the tab
  6389. 4:22:32search again get the realtime
  6390. 4:22:33information pass it to the agent. Now
  6391. 4:22:35agent will again fill up this
  6392. 4:22:36information with thought action and
  6393. 4:22:37observation. You can see thought action
  6394. 4:22:40and observation. Okay let's see it got
  6395. 4:22:422.1 million. Okay, now it got the final
  6396. 4:22:45answer. Okay, now this agent will tell
  6397. 4:22:48now I have the [clears throat] final
  6398. 4:22:49answer. Now once agent executor got this
  6399. 4:22:51one. Let's say now I have the final
  6400. 4:22:53answer that time this agent executor
  6401. 4:22:55will stop. That means this is running
  6402. 4:22:56the entire loop. Okay, that means this
  6403. 4:22:59is running the entire loop. So once you
  6404. 4:23:00are getting the final answer, this
  6405. 4:23:02particular loop would be executed uh
  6406. 4:23:04exited and your application will stop
  6407. 4:23:06and you will be able to see the final
  6408. 4:23:08answer. Okay, so that's how things are
  6409. 4:23:10working guys. That's how the langen
  6410. 4:23:12agent and agent exeutor we are creating
  6411. 4:23:15it is working internally like that.
  6412. 4:23:17Okay. So whenever you are using this
  6413. 4:23:19react agent so definitely you have to
  6414. 4:23:21use this agent executor. This is very
  6415. 4:23:23much required. Now I think guys you are
  6416. 4:23:25pretty much clear about the langen
  6417. 4:23:27create agent. Okay how it works. Sorry
  6418. 4:23:31langen react agent how it works. Why we
  6419. 4:23:33need this agent exeutor along with that.
  6420. 4:23:36Okay. Now let me show you as a code.
  6421. 4:23:39So you can see the code guys. Uh in the
  6422. 4:23:41code itself we have already written this
  6423. 4:23:43create react agent. It takes lm tool and
  6424. 4:23:45prompt. Okay with the help of prompt it
  6425. 4:23:48performs all the instruction how this
  6426. 4:23:50react agent works. I think I already
  6427. 4:23:51showed you the prompt and to run this
  6428. 4:23:53agent I need the agent exeutor. That's
  6429. 4:23:55why we are giving this agent tool we are
  6430. 4:23:57also giving because I think you know
  6431. 4:23:59that uh agent executor will uh invoke
  6432. 4:24:02this tool. Okay that's why tool access
  6433. 4:24:04also I need to give to the agent
  6434. 4:24:05executor and there's another one
  6435. 4:24:07verbose. Okay. Barbos is the all the
  6436. 4:24:09execution is happening right internally.
  6437. 4:24:11See you can see the logs but if you make
  6438. 4:24:13it as false let's say I will make it as
  6439. 4:24:15false. So what will happens? You won't
  6440. 4:24:17be able to see any kinds of
  6441. 4:24:21execution. Let me again create the react
  6442. 4:24:24agent executor. Now if I run the agent
  6443. 4:24:28see you won't be able to see any kinds
  6444. 4:24:29of logs. See it executed but you can't
  6445. 4:24:33see any kinds of log but still you will
  6446. 4:24:34be able to see the output. Okay output
  6447. 4:24:36is there. But whenever you make it as
  6448. 4:24:38true right so you will be able to see
  6449. 4:24:42the
  6450. 4:24:44um log. So for this again I have to
  6451. 4:24:48execute the agent.
  6452. 4:24:58Now see this particular log you will be
  6453. 4:25:00able to see whatever decision uh
  6454. 4:25:02whatever thought actions and observation
  6455. 4:25:04your agent is performing you are able to
  6456. 4:25:06see that okay in live so that's why we
  6457. 4:25:09make it as uh this parameter as true
  6458. 4:25:11okay now I think you are clear enough
  6459. 4:25:13guys okay so yes guys so that's how we
  6460. 4:25:16can uh use this lang chain to develop
  6461. 4:25:19this kinds of single uh single actually
  6462. 4:25:23agent system and this is our first agent
  6463. 4:25:26guys uh This is like a very simple
  6464. 4:25:29agents we have created. Uh so don't
  6465. 4:25:31worry in the next video I'm going to
  6466. 4:25:33also show you how we can create the
  6467. 4:25:34multi- aent system. So here only one
  6468. 4:25:36agent is working right. But if you want
  6469. 4:25:38we can also create multiple agent and
  6470. 4:25:40that will be working together. Okay this
  6471. 4:25:42is also possible. Now uh what I'm going
  6472. 4:25:44to show you guys uh I'm going to show
  6473. 4:25:46you how we can convert it uh this
  6474. 4:25:48particular notebook in in a application
  6475. 4:25:51file that means app.py and we can run
  6476. 4:25:54that particular app.py Pi okay because I
  6477. 4:25:56have showed you the research right now
  6478. 4:25:58that means the experiment right now but
  6479. 4:26:00in production definitely will you will
  6480. 4:26:02not create the Jupyter notebook file
  6481. 4:26:04instead of that you have to create a
  6482. 4:26:05python file so let's say I'm
  6483. 4:26:07[clears throat] going to name it as
  6484. 4:26:08app.py Pi.
  6485. 4:26:10Okay. So, simply what you can do, you
  6486. 4:26:12can copy whatever code you have written
  6487. 4:26:15in the notebook in this app.py. See, I
  6488. 4:26:19just copy pasted the same code. Copy the
  6489. 4:26:23same code. But before that, let me show
  6490. 4:26:25you how we can improve this agent. Um,
  6491. 4:26:29if you want to improve it, if you want
  6492. 4:26:31to add some more tool, so how it can be
  6493. 4:26:33done. Let's say here I want to add
  6494. 4:26:35another tool and that particular tool
  6495. 4:26:37will real time search the weather
  6496. 4:26:39informations. Okay. Uh weather
  6497. 4:26:41informations given any kinds of location
  6498. 4:26:44because right now I'm using the
  6499. 4:26:46tabularly search tool. It is completely
  6500. 4:26:47fine. But I want my custom custom tool.
  6501. 4:26:51Let's say I have created a custom
  6502. 4:26:53function and that custom function I want
  6503. 4:26:54to use use as a tool. Okay. How it can
  6504. 4:26:57be done? Let's try to see that. So for
  6505. 4:26:59this uh what I'm going to do I'm going
  6506. 4:27:01to let's say import
  6507. 4:27:04this langen
  6508. 4:27:07dot
  6509. 4:27:09tool
  6510. 4:27:11okay import
  6511. 4:27:14there is a function called tool you have
  6512. 4:27:16to import that and I will import another
  6513. 4:27:18library called request okay this two
  6514. 4:27:21library I'll import once it is done now
  6515. 4:27:24simply here I'm going to create a
  6516. 4:27:26function so after this search tool maybe
  6517. 4:27:29I can create my custom function. So this
  6518. 4:27:31custom function will get the uh weather
  6519. 4:27:34information. Okay.
  6520. 4:27:37So I've already written a function. So
  6521. 4:27:39let me show you this function how it
  6522. 4:27:41works. So maybe I can show you test ip
  6523. 4:27:46or let's say here itself. I'm going to
  6524. 4:27:48show you how this function works.
  6525. 4:27:51Yeah. So this is my function guys. So
  6526. 4:27:53what this function does this function
  6527. 4:27:55takes a city name. Okay. or given any
  6528. 4:27:57kinds of location and it it it fetch the
  6529. 4:28:00current weather informations of that
  6530. 4:28:02particular city. So for this we are
  6531. 4:28:03using this weather stack API. Okay,
  6532. 4:28:06weatherstack API I think you know this
  6533. 4:28:08is a website weatherstack.com.
  6534. 4:28:10So let me show you
  6535. 4:28:14uh
  6536. 4:28:16this is the website
  6537. 4:28:23weatherst.com. Okay. So this is the
  6538. 4:28:27website guys. So here first of all you
  6539. 4:28:28have to create a account. Uh just sign
  6540. 4:28:30up with free. Okay. So once you sign up
  6541. 4:28:33you'll be able to see your dashboard.
  6542. 4:28:34Okay. So if you go to the dashboard
  6543. 4:28:37uh
  6544. 4:28:40so here you will be see this kinds of
  6545. 4:28:41interface okay and uh we are using the
  6546. 4:28:44free plan so in free plan only we can
  6547. 4:28:46search the real-time weather information
  6548. 4:28:48but if you're using the paid
  6549. 4:28:50subscription of this weather uh stack
  6550. 4:28:52that time you can perform location
  6551. 4:28:53search uh astronomy data hour by hour
  6552. 4:28:57okay full historical data so there been
  6553. 4:28:59so many things you can perform here but
  6554. 4:29:02I only need for the weather information
  6555. 4:29:04That means my free plan is completely
  6556. 4:29:05fine. So here you have the API key. You
  6557. 4:29:07just need to copy this API key. Okay. So
  6558. 4:29:10don't use my API key. I'm going to
  6559. 4:29:11remove it after the recording. So here
  6560. 4:29:13you have to pass this weather API key.
  6561. 4:29:15Now what I can do maybe in the itself I
  6562. 4:29:18can mention my
  6563. 4:29:20API key. Uh so here is
  6564. 4:29:24so I already collected this API key
  6565. 4:29:26guys. Let me show you.
  6566. 4:29:31So this is the API key. weather stack
  6567. 4:29:33API key and this is the API key I have
  6568. 4:29:35copy pasted from the dashboard. Okay.
  6569. 4:29:38Now simply here itself you have to load
  6570. 4:29:41this API key as well. So let's load it.
  6571. 4:29:44Weather stack API key west.get weather
  6572. 4:29:46stack API key. So you're also loading
  6573. 4:29:47this. Okay. Once it is done now see this
  6574. 4:29:50API key would be given here. Now how
  6575. 4:29:52these things will work let me show you.
  6576. 4:29:54I will copy this and uh I will paste it
  6577. 4:29:57here. Now f string I'm going to just
  6578. 4:30:01remove it.
  6579. 4:30:03because this is I have given only for
  6580. 4:30:05static variable f string I don't need
  6581. 4:30:14now if you give any city here let's say
  6582. 4:30:15I'll give
  6583. 4:30:18I'll give home
  6584. 4:30:24hit enter
  6585. 4:30:26uh okay you have to pass the API key
  6586. 4:30:28right so let's copy the API Okay.
  6587. 4:30:43Now if I hit enter, see you will be
  6588. 4:30:46getting uh response like that. Okay. So
  6589. 4:30:49this is having the informations about
  6590. 4:30:51the Mumbai uh the current uh weather
  6591. 4:30:54information as you can see. Okay. the
  6592. 4:30:56kind of weather information it is
  6593. 4:30:58having. Okay. Now I have to extract the
  6594. 4:31:00data from this particular JSON itself.
  6595. 4:31:03So what I have done I have written a
  6596. 4:31:05function here as you can see. So this
  6597. 4:31:07function hit this URL with this API key
  6598. 4:31:10and you can give any kinds of city name.
  6599. 4:31:12I'm hitting with the help of this
  6600. 4:31:13request library I have already imported
  6601. 4:31:15here as you can see request. So once we
  6602. 4:31:17get the response so what we are doing we
  6603. 4:31:20are just converting to the JSON. Now we
  6604. 4:31:22are telling if current not in data. So
  6605. 4:31:25I'll tell could not find the face
  6606. 4:31:26weather data because current parameter
  6607. 4:31:28should be there because in the current
  6608. 4:31:30one we are having the current weather
  6609. 4:31:31information. Okay, this temperature
  6610. 4:31:33weather it is having. Okay, so we are
  6611. 4:31:35getting this current key. Now once we
  6612. 4:31:37get the current key I'm taking the city
  6613. 4:31:39name, temperature, weather and humidity.
  6614. 4:31:41Okay, these are the information I'm
  6615. 4:31:42taking. If you want you can also take
  6616. 4:31:44any other information. It's completely
  6617. 4:31:45up to you. So this is a function custom
  6618. 4:31:47function. Now if I want to use this
  6619. 4:31:49custom function as a tool. So what I
  6620. 4:31:51have to do I have to write a decorator
  6621. 4:31:53at the tool I have imported. Okay. So
  6622. 4:31:56this tool I have imported. I have to
  6623. 4:31:58just give this particular tool. Now what
  6624. 4:32:00happens? This particular function
  6625. 4:32:01becomes a custom tool. That means this
  6626. 4:32:04tab search result this is a predefined
  6627. 4:32:06tool. This is already developed by some
  6628. 4:32:08other organization or other company or
  6629. 4:32:10other developer. But right now this get
  6630. 4:32:13weather data function we have created
  6631. 4:32:14this is our tool or custom tool. Okay.
  6632. 4:32:17That's how we can create our custom tool
  6633. 4:32:18and we can use it inside our agent.
  6634. 4:32:20Okay, this is also possible. Now let me
  6635. 4:32:22execute. Now simply what you have to do
  6636. 4:32:25uh here itself in the tool itself
  6637. 4:32:29uh where I have mentioned the tool. Huh?
  6638. 4:32:31In the tool you just need to give the
  6639. 4:32:33tool name which is get weather data.
  6640. 4:32:36Okay, that's it. Uh get weather data
  6641. 4:32:42name.
  6642. 4:32:43Yeah, now let's execute. I mean I will
  6643. 4:32:45execute from the beginning.
  6644. 4:33:04Okay. Now initialize the LM. Now we also
  6645. 4:33:07involving the LLM for some response. Now
  6646. 4:33:11facing the prompt. This is the prompt.
  6647. 4:33:14Now we're initializing our tools. Okay.
  6648. 4:33:16Now see you can pass list of the tools.
  6649. 4:33:18You can pass hundred of tools. Okay.
  6650. 4:33:20It's up to you. Now we are creating the
  6651. 4:33:22agent and we are passing the list of the
  6652. 4:33:24tools right now. Now my agent is having
  6653. 4:33:27multiple tools. Okay. One is the search
  6654. 4:33:28tool and this is the get weather tool.
  6655. 4:33:31Now I'll again execute.
  6656. 4:33:34Uh now uh my executor is ready. Now I
  6657. 4:33:37can give a prompt. So now I'll give this
  6658. 4:33:40particular prompt. Let's say
  6659. 4:33:45this is the problem. Find the capital of
  6660. 4:33:47India and then find the uh find its
  6661. 4:33:50current weather. Now see if I execute
  6662. 4:33:52you can real time see see I should first
  6663. 4:33:55search the capital of India uh uses the
  6664. 4:33:57weather data tool find the current
  6665. 4:33:59weather. See first of all it has used
  6666. 4:34:01the tably search tool to get the capital
  6667. 4:34:03of India. So it is referring some
  6668. 4:34:04website uh Indian website and it is
  6669. 4:34:07getting uh the capital of India which is
  6670. 4:34:08New Delhi. Okay. So we got the New
  6671. 4:34:11Delhi. Now once it got the New Delhi now
  6672. 4:34:13what it is doing guys it is utilizing it
  6673. 4:34:16is utilizing my get data tools. Okay my
  6674. 4:34:19get data tool and it is fetching the
  6675. 4:34:21weather informations. Okay so that's how
  6676. 4:34:24things are working guys. I think you got
  6677. 4:34:26it. Okay that means now it is having
  6678. 4:34:28multiple tools. So tably s it is
  6679. 4:34:32utilizing for the search operation.
  6680. 4:34:33Okay, for uh finding the capital of
  6681. 4:34:35India and my get weather data tool it is
  6682. 4:34:37utilizing to get the weather
  6683. 4:34:38informations and how it is deciding with
  6684. 4:34:41the help of this react agent. Okay,
  6685. 4:34:44because it is internally using LLM and
  6686. 4:34:46LLM is doing the reasoning. Okay, and it
  6687. 4:34:48is deciding what tool to call and this
  6688. 4:34:51kinds of tool calling and everything is
  6689. 4:34:52happening with the help of this agent
  6690. 4:34:53executor because it is running that
  6691. 4:34:55three-step that means uh I think I
  6692. 4:34:58showed you uh three-step means first of
  6693. 4:35:00all thought, actions and observation.
  6694. 4:35:02Okay, that's how things are working.
  6695. 4:35:05Okay, I hope you get it. Now, if I want
  6696. 4:35:07to uh convert everything in the app.py
  6697. 4:35:09guys, so this is the final code. So, let
  6698. 4:35:11me select my environment which is lang
  6699. 4:35:13agent. So, this is the final code. I
  6700. 4:35:15just copy pasted the same code, okay,
  6701. 4:35:17from my notebook. As you can see the
  6702. 4:35:19same code, nothing change. Okay, now I
  6703. 4:35:23can run the app.py. Let me show you. So,
  6704. 4:35:26I will open up my terminal and if I
  6705. 4:35:28execute my app.py.
  6706. 4:35:30So, python app.py Pi
  6707. 4:35:36uh okay so it is telling table okay uh
  6708. 4:35:39because I'm running the app.py and now
  6709. 4:35:41app.py will refer this env because
  6710. 4:35:43previously I created inside resource
  6711. 4:35:44folder so what I can do I can copy all
  6712. 4:35:46of the key and mention inside this
  6713. 4:35:48particular variable okay now let's
  6714. 4:35:51execute the terminal clear now again
  6715. 4:35:53execute app.py
  6716. 4:35:57Now see agent is executing.
  6717. 4:36:02Now see first of all it is uh getting
  6718. 4:36:04the capital of India.
  6719. 4:36:07Now once is uh got that it is utilizing
  6720. 4:36:10my custom tool get weather data and it
  6721. 4:36:13is giving you the temperature. Okay. Now
  6722. 4:36:16this is the final temperature. As you
  6723. 4:36:17can see the capital of India is New
  6724. 4:36:19Delhi and the current weather is 37 uh
  6725. 4:36:2337°C with H. Okay, perfect. That means
  6726. 4:36:26we have implemented our first agent
  6727. 4:36:29guys. Congratulation with the help of
  6728. 4:36:30Langen.
  6729. 4:36:32Okay, and don't worry, I'm also going to
  6730. 4:36:34show you how we can create the multi-
  6731. 4:36:35aent system in the next video. Now let's
  6732. 4:36:38say if you want to convert uh this uh
  6733. 4:36:40app to a user interface, this is also
  6734. 4:36:43possible. Maybe we can add uh streamlit
  6735. 4:36:46user interface. So what I have done
  6736. 4:36:48guys, I have uh just designed a
  6737. 4:36:50streamlit user interface with the help
  6738. 4:36:52of chat GPT. Uh you can also do that.
  6739. 4:36:55Okay, it's like very easy. Uh you just
  6740. 4:36:57go to the chat GP and tell I need a user
  6741. 4:36:59interface for this code. So it will
  6742. 4:37:02generate for you. Okay, so what I have
  6743. 4:37:04done guys? Uh I have already generated a
  6744. 4:37:09So what I can do? Let's say I'll rename
  6745. 4:37:11this file. Maybe I can name it as
  6746. 4:37:13main.py. pi. Now I'll create another
  6747. 4:37:15file here. I'm going to name it as
  6748. 4:37:16app.py.
  6749. 4:37:18Okay. Inside that I'm going to paste my
  6750. 4:37:20updated code.
  6751. 4:37:24So this code is having the streamlit
  6752. 4:37:26user interface.
  6753. 4:37:28Okay guys, so this is the code. So
  6754. 4:37:30nothing else. I just added the
  6755. 4:37:31streamlit. Uh I think you know streaml
  6756. 4:37:33is a python package with the help of we
  6757. 4:37:35can uh create the user interface without
  6758. 4:37:37writing any kinds of HTML and CSS code.
  6759. 4:37:39So first of all we have to install this
  6760. 4:37:41streamlit. Uh so I will add this in my
  6761. 4:37:43requirement streamlit. So let's install
  6762. 4:37:49pip install hyphen requirement.txt
  6763. 4:37:51Tasty.
  6764. 4:38:33Okay, installation is complete. Now if I
  6765. 4:38:35go to my app.py, now this error will
  6766. 4:38:38disappear. Yeah, now see only change uh
  6767. 4:38:42it has done it has set a streaml page
  6768. 4:38:45configuration. So there you can see it
  6769. 4:38:48has done a page configuration. Uh page
  6770. 4:38:50title is agentic assistant page icon. Uh
  6771. 4:38:54this is centered layout. This is the
  6772. 4:38:56title
  6773. 4:38:58and uh we have given a markdown search
  6774. 4:39:00and weather AI agents using langen. And
  6775. 4:39:04everything is same. The only thing is
  6776. 4:39:05that at the last uh it has added the
  6777. 4:39:08user query section. So there would be a
  6778. 4:39:10input box. So there I can give the query
  6779. 4:39:13and there would be a button. If I run
  6780. 4:39:15this button, so my agent will be
  6781. 4:39:17executing. Okay, so this is a simple
  6782. 4:39:19user interface code my uh chatgpt added.
  6783. 4:39:22Okay, inside my this main.py. Now let's
  6784. 4:39:25execute and see how this looks like. I
  6785. 4:39:28will clear and run streaml
  6786. 4:39:33run app.py.
  6787. 4:39:37I'll give the permission
  6788. 4:39:39now.
  6789. 4:39:45I'll show you this agent.
  6790. 4:39:52Okay. So here I'm getting an error. So
  6791. 4:39:54let me see the error.
  6792. 4:39:59Okay. So this error I'm getting because
  6793. 4:40:00I told you uh you have to add this line
  6794. 4:40:04otherwise this error might come because
  6795. 4:40:06I'm using Windows.
  6796. 4:40:10I will add in the app.py. I
  6797. 4:40:13here itself I will add that I have to
  6798. 4:40:15import certify
  6799. 4:40:18okay done now if I reexecute
  6800. 4:40:22it should work
  6801. 4:40:27see it's working now aentk assistant you
  6802. 4:40:30can see this is the user interface now
  6803. 4:40:32here I can give my query so maybe I can
  6804. 4:40:35pass
  6805. 4:40:38find the
  6806. 4:40:42capital
  6807. 4:40:44of let's say French
  6808. 4:40:48and uh
  6809. 4:40:50the current
  6810. 4:40:55weather.
  6811. 4:40:56Okay.
  6812. 4:40:58Now if I run my agent,
  6813. 4:41:02you can see agent is thinking.
  6814. 4:41:06So every agent actually thinks. Okay. If
  6815. 4:41:08you use any kinds of agent guys, you
  6816. 4:41:10will see that this uh thinking uh option
  6817. 4:41:13is there because internally it is
  6818. 4:41:15executing
  6819. 4:41:17uh that uh tools and everything all of
  6820. 4:41:21these obs uh I mean three steps are
  6821. 4:41:22executing like thought uh then action
  6822. 4:41:25and observation that's why it's taking
  6823. 4:41:27some time okay if you open any kinds of
  6824. 4:41:29agent uh let's say if you open VS code
  6825. 4:41:31agent if you open cloud desktop if you
  6826. 4:41:34open Gemini you will see that this um
  6827. 4:41:36process would be there Okay. Now see uh
  6828. 4:41:38response generated. The final response
  6829. 4:41:40is the capital of France is Paris and
  6830. 4:41:42the current weather there is 11°C with
  6831. 4:41:45rain and thunderstorm. Okay. That means
  6832. 4:41:48our agent is perfectly working fine.
  6833. 4:41:50Okay. Amazing. Now uh what we can do if
  6834. 4:41:54we want we can also deploy this over the
  6835. 4:41:56cloud because right now it is running on
  6836. 4:41:58local host and people can't access my
  6837. 4:42:01agent. So I can if I if I want I can
  6838. 4:42:03also um I mean host this. So if you want
  6839. 4:42:06to host this. So what I can do uh you
  6840. 4:42:09can use uh different different cloud
  6841. 4:42:10provider. You can use AWS, GCP, Azure.
  6842. 4:42:13But uh let me show you one amazing cloud
  6843. 4:42:16provider. There you can deploy this uh
  6844. 4:42:18agent as free. So the cloud name is
  6845. 4:42:21rendercloud. Okay, render.com. So if I
  6846. 4:42:23open render.com. So you have to first of
  6847. 4:42:25all create a account if you don't have
  6848. 4:42:26account. So I already have the account.
  6849. 4:42:28I'll just try to click on the dashboard.
  6850. 4:42:31I'll login with my Gmail.
  6851. 4:42:39Okay. Now simply what you have to do
  6852. 4:42:42here first of all you have to um I mean
  6853. 4:42:48upload this code to the GitHub. Okay. So
  6854. 4:42:51what I will do guys I'll simply upload
  6855. 4:42:54but before uploading I don't need to
  6856. 4:42:57upload this because if I upload my my
  6857. 4:43:01API key will be exposed. So here I will
  6858. 4:43:03add another file called dot get ignore.
  6859. 4:43:08Okay. Inside that I will mention env
  6860. 4:43:12should be ignored and in researchb
  6861. 4:43:18should be ignored. Okay. Now let's uh
  6862. 4:43:22create a GitHub repo. I'll open my
  6863. 4:43:24GitHub.
  6864. 4:43:27I'll go to the repository.
  6865. 4:43:31I'll click on new.
  6866. 4:43:34I can give a name. So let's say I'll
  6867. 4:43:36give
  6868. 4:43:38this name
  6869. 4:43:43search and
  6870. 4:43:47weather AI agents using langen.
  6871. 4:43:50Uh I'll add a readmi file.
  6872. 4:43:54Then simply create the repository.
  6873. 4:43:59and make sure you keep it as public.
  6874. 4:44:01Okay, you can also make it as private.
  6875. 4:44:03It's up to you. Now I'll click on code,
  6876. 4:44:05copy this link address. I'll open up my
  6877. 4:44:09local folder and clone this repo here.
  6878. 4:44:12So get clone
  6879. 4:44:18done. Now what I will do, I'll just copy
  6880. 4:44:21this. Git and paste it here. Okay. And
  6881. 4:44:25this folder I'm going to remove it. I
  6882. 4:44:27only need this. Git. Okay. Now from my
  6883. 4:44:29VS code itself, I can commit the changes
  6884. 4:44:32issue. Now if I show you see uh this env
  6885. 4:44:36is ignored. Now simply I'll commit the
  6886. 4:44:38changes.
  6887. 4:44:41Now I'll just write get add space dot.
  6888. 4:44:49Now get commit
  6889. 4:44:53m
  6890. 4:44:54uh I'll give updated.
  6891. 4:45:00Now get push
  6892. 4:45:03origin
  6893. 4:45:06main.
  6894. 4:45:10Okay. Now if I go to my GitHub
  6895. 4:45:13refresh
  6896. 4:45:16see all of the code are available. Okay.
  6897. 4:45:18Now let's try to reply. So I'll go to my
  6898. 4:45:20render
  6899. 4:45:22and here what I'm going to do guys I'm
  6900. 4:45:24going to just create a new web service.
  6901. 4:45:30Okay. Now here I will click on public
  6902. 4:45:33git repository. Now I'll copy the link
  6903. 4:45:38and paste it here. Now let's connect.
  6904. 4:45:43Done. Now you can give a other name also
  6905. 4:45:45if you want. Uh it has automatically
  6906. 4:45:48taken my um repository name. Now
  6907. 4:45:51everything just keep it as same. Uh only
  6908. 4:45:55here you just need to give a command.
  6909. 4:45:57Okay. See it will also install the
  6910. 4:45:58requirement. This requirement we are
  6911. 4:46:00having. Okay. Now let's give the command
  6912. 4:46:03of running streaml app. So this is the
  6913. 4:46:06command. So basically this command will
  6914. 4:46:08run the streaml server. Now here I will
  6915. 4:46:11take the free okay free instance and
  6916. 4:46:13here you'll be by default you'll be
  6917. 4:46:14getting 512 MB RAM and 0.1 CPU uh which
  6918. 4:46:19is a little bit slow uh but it is fine
  6919. 4:46:21for the learning if you want to let's
  6920. 4:46:23say professionally deploy it then you
  6921. 4:46:25can take their plan okay but I think
  6922. 4:46:27this is fine now here I'll try to add my
  6923. 4:46:29environment variable so here I'm having
  6924. 4:46:33open API key let's add it
  6925. 4:46:37and I have to give the blue.
  6926. 4:46:43I copy this.
  6927. 4:46:50Then I will add the environment
  6928. 4:46:52variable. Another one
  6929. 4:46:56tab API key.
  6930. 4:47:06I will add it here.
  6931. 4:47:09Then add another one
  6932. 4:47:12which is
  6933. 4:47:14this weather stack API key
  6934. 4:47:19and add the value
  6935. 4:47:27done. Now simply
  6936. 4:47:30um okay now simply I'll just do the
  6937. 4:47:33deployment deploy web service.
  6938. 4:47:41So this is the free instance. Uh it may
  6939. 4:47:43take some time guys. We'll wait once uh
  6940. 4:47:46this particular option is live. Okay.
  6941. 4:47:49Now it is building the entire uh
  6942. 4:47:51instance. Okay. Internally it will set
  6943. 4:47:52up everything. Once this is live we'll
  6944. 4:47:54be able to test that. Now see it's
  6945. 4:47:56running.
  6946. 4:48:15Now see it is installing the
  6947. 4:48:17requirements one by one. Uh let's wait.
  6948. 4:48:26So I will pause the video once this
  6949. 4:48:27installation everything is complete.
  6950. 4:48:29I'll come back.
  6951. 4:48:31So guys as you can see our application
  6952. 4:48:33is live right now. Uh everything is
  6953. 4:48:36fine. There is no added. Now there is a
  6954. 4:48:38link you can copy and you can open in
  6955. 4:48:40your browser.
  6956. 4:48:42So there you will be able to see your
  6957. 4:48:44agent.
  6958. 4:48:53So guys uh you can see this is our
  6959. 4:48:55application. This is completely live. Uh
  6960. 4:48:57if you're using free instance it may
  6961. 4:48:59take some time. Uh now we can test it.
  6962. 4:49:01So here I'll just tell find the capital
  6963. 4:49:06uh of Nepal
  6964. 4:49:10and
  6965. 4:49:11tell me the
  6966. 4:49:15weather
  6967. 4:49:17of that. Now I'll run the agent.
  6968. 4:49:24Now see agent is working internally.
  6969. 4:49:36So guys, here is the final response. The
  6970. 4:49:38capital of Nepal is Kathmandu and
  6971. 4:49:40current weather 20° C with drizzle and
  6972. 4:49:4494% humidity. Okay, amazing. Now you can
  6973. 4:49:48share this uh URL with anyone they will
  6974. 4:49:50be able to use your agent. So yes guys,
  6975. 4:49:53I hope you understood. I hope you have
  6976. 4:49:55seen how we can utilize uh this lang
  6977. 4:49:58chain to develop these kinds of AI
  6978. 4:50:02agents. But uh here we have created the
  6979. 4:50:04single agents. Okay, single agents
  6980. 4:50:06pipeline. Uh in the next video I'm going
  6981. 4:50:09to show you how we can create the multi-
  6982. 4:50:10aent system. Okay. So everything would
  6983. 4:50:12be covered. So guys uh we'll be
  6984. 4:50:15continuing with our complete agentic AI
  6985. 4:50:18course. And I think you remember in our
  6986. 4:50:20previous video I have already shown you
  6987. 4:50:23how we can implement uh a single AI
  6988. 4:50:26agents with the help of langen. So this
  6989. 4:50:28was our first AI agents implementation
  6990. 4:50:30with langen. Then I told you I'm also
  6991. 4:50:33going to show you how we can create
  6992. 4:50:35multi- aent system with the help of
  6993. 4:50:37langen. So in this video I'm going to uh
  6994. 4:50:40show you the entire implementation how
  6995. 4:50:42we can utilize lang chain orchestration
  6996. 4:50:45framework for implementing this kinds of
  6997. 4:50:47multi- aent AI system. Okay. So make
  6998. 4:50:50sure you watch this video till the end.
  6999. 4:50:53Uh you don't miss anything. If you
  7000. 4:50:55complete this video you'll be able to
  7001. 4:50:56implement u multi- aents AI system with
  7002. 4:50:59the help of langen. And in this video
  7003. 4:51:01I'm not only going to implement uh these
  7004. 4:51:04AI agents uh even after implementation
  7005. 4:51:07I'm also going to show you how we can
  7006. 4:51:09add the user interface and how we can
  7007. 4:51:11deploy this kinds of multi- aent system
  7008. 4:51:13on the cloud platform. I implemented a
  7009. 4:51:17weather AI agents with the help of
  7010. 4:51:19langin. So there I created a single
  7011. 4:51:22agent uh that has some tool connection
  7012. 4:51:25like I given tabuli search tool and I
  7013. 4:51:28created one of the custom tool. Okay. Uh
  7014. 4:51:31that particular tool uh can access any
  7015. 4:51:35kinds of uh realtime weather
  7016. 4:51:37informations given any kinds of city or
  7017. 4:51:40uh location whatever okay that means if
  7018. 4:51:42I show you the architecture diagram. So
  7019. 4:51:46yeah if I show you the architecture
  7020. 4:51:48diagram. So there let's say I created a
  7021. 4:51:50single agent. Let's say this is our
  7022. 4:51:53agent.
  7023. 4:51:56Okay. So this agent having some
  7024. 4:52:00connection with tool.
  7025. 4:52:02Let's say it is having connection with
  7026. 4:52:05tabuli.
  7027. 4:52:13Okay. Okay. And it is having connection
  7028. 4:52:15with
  7029. 4:52:16weather
  7030. 4:52:18API.
  7031. 4:52:25Okay. So whenever I was giving any kinds
  7032. 4:52:28of prompt or let's say input. So first
  7033. 4:52:31of all uh this will uh and definitely it
  7034. 4:52:34was connected with the LLM. Okay.
  7035. 4:52:37because LLM was the brain and with the
  7036. 4:52:40LLM actually it will perform the
  7037. 4:52:41reasoning operation and um whenever I
  7038. 4:52:45was giving any kinds of input then LLM
  7039. 4:52:47was deciding whether I need to use a
  7040. 4:52:50tool or not uh with respect to the
  7041. 4:52:51question let's say if I'm giving a
  7042. 4:52:53prompt uh just tell me the capital of
  7043. 4:52:56India and uh give me the weather
  7044. 4:52:58informations of that right so what it
  7045. 4:53:00will do it will first of all go to the
  7046. 4:53:02agents and it will search with the help
  7047. 4:53:04of tab like what is the capital of India
  7048. 4:53:07India then it will get let's say the
  7049. 4:53:09capital of India is Delhi. Now what it
  7050. 4:53:11will do again it will tell okay now uh
  7051. 4:53:14you just need to fetch the weather
  7052. 4:53:16information
  7053. 4:53:18of the uh Delhi. So with the help of uh
  7054. 4:53:20this weather API it will real time get
  7055. 4:53:23this informations and uh your agent will
  7056. 4:53:26try to refine the output and it will
  7057. 4:53:29show you the final output.
  7058. 4:53:32Okay. So that's how the things were
  7059. 4:53:33working and the whole system actually we
  7060. 4:53:36have orchestrated with the help of
  7061. 4:53:37langen. So there we used actually create
  7062. 4:53:40uh react agent right this functionality
  7063. 4:53:42we used from the langen and to execute
  7064. 4:53:45this create uh react agent we used agent
  7065. 4:53:47exeutor and the full form of uh react is
  7066. 4:53:51reasoning and uh action or acting
  7067. 4:53:54whatever you can say. So with the help
  7068. 4:53:56of that we created the agent. Okay. So
  7069. 4:53:58this was the previous architecture. Now
  7070. 4:54:01first of all let me give you u the
  7071. 4:54:03multi- aent uh we'll be implementing uh
  7072. 4:54:07for uh for this video. Uh first of all
  7073. 4:54:09I'm going to give you the idea what is
  7074. 4:54:12the system we're going to develop. Then
  7075. 4:54:14I'm also going to show you the
  7076. 4:54:16architecture diagram. Okay like what
  7077. 4:54:18would be the flow and how we can uh
  7078. 4:54:22create the AI agents how we can make the
  7079. 4:54:24connection with different different
  7080. 4:54:25tool. That means the entire uh overview
  7081. 4:54:27I'm going to give then we'll start with
  7082. 4:54:28the development. So for this uh this is
  7083. 4:54:31the uh this is the actually content I
  7084. 4:54:34have prepared. So as you can see uh
  7085. 4:54:36multi- aent system with the help of
  7086. 4:54:38langen we'll be developing in this
  7087. 4:54:40video. So a multi- aent uh research
  7088. 4:54:42assistant is a fully autonomous AI
  7089. 4:54:45system that thinks uh search reads and
  7090. 4:54:48writes on its own. Okay that means here
  7091. 4:54:50we'll be creating a multi- aent research
  7092. 4:54:52assistant. Okay basically this will
  7093. 4:54:54perform the research. So I think you
  7094. 4:54:56have seen in chart GPT or Gemini there
  7095. 4:54:58is a research option is available uh if
  7096. 4:55:01you open that uh uh let's say
  7097. 4:55:03application. So if you perform the
  7098. 4:55:05research so what it will do it will take
  7099. 4:55:06some time and it will perform the
  7100. 4:55:08research operation on the internet u uh
  7101. 4:55:11in a given topic right so that's how
  7102. 4:55:14we'll be also implementing a research
  7103. 4:55:15assistant so that research assistant
  7104. 4:55:18will be having some kinds of uh let's
  7105. 4:55:21say tool access and with the help of
  7106. 4:55:24tool it will perform the realtime
  7107. 4:55:26resource operation okay and here we are
  7108. 4:55:28not going to create a single agent
  7109. 4:55:30instead of that we'll be creating the
  7110. 4:55:32multi- aent system here so as you can
  7111. 4:55:33see mult multi- agent research assistant
  7112. 4:55:34a fully autonomous AI system that
  7113. 4:55:36thinks, searches, reads and writes its
  7114. 4:55:38own. Okay. Instead of a single AI
  7115. 4:55:41answering your question from tools, uh
  7116. 4:55:44here we'll be developing a team of
  7117. 4:55:46specialized intelligence agents. Okay. A
  7118. 4:55:48team of intelligence agents will be
  7119. 4:55:50developing here uh that collaborates
  7120. 4:55:52together to produce a professional
  7121. 4:55:54research report on a uh topic you give
  7122. 4:55:57them. That means if you are giving a
  7123. 4:55:59topic okay so what it will do it will
  7124. 4:56:01per uh it will use all of the like
  7125. 4:56:04specialized intelligent agents okay it
  7126. 4:56:07will work together and it will try to
  7127. 4:56:09give you a professional okay research
  7128. 4:56:11report on that particular topic. So it
  7129. 4:56:13it will not only research okay it will
  7130. 4:56:15also write the report for you okay and
  7131. 4:56:18you can see the search agent goes so the
  7132. 4:56:21first agent should be the search agents
  7133. 4:56:23with the help of search agents will be
  7134. 4:56:25uh doing the real time let's say
  7135. 4:56:26research operation over the internet the
  7136. 4:56:29search agent goes out on the live
  7137. 4:56:31internet and finds the most relevant
  7138. 4:56:33recent sources okay so it will perform
  7139. 4:56:36the research operation of all of the
  7140. 4:56:39internet sources it is having uh then
  7141. 4:56:42the reader agent then dives deep into
  7142. 4:56:44the those sources and scrap the scrap
  7143. 4:56:46and extracting meaningful content. That
  7144. 4:56:49means here I'm going to create another
  7145. 4:56:50agent. The agent name would be reader
  7146. 4:56:53agent. So that region agent uh what it
  7147. 4:56:55will do it will try to scrap and extract
  7148. 4:56:58okay all of the content from that
  7149. 4:57:00sources. Let's say the first agent will
  7150. 4:57:03return you the recent
  7151. 4:57:05uh recent relevant sources that mean
  7152. 4:57:08some URL. Okay. Now what we will do?
  7153. 4:57:10we'll just try to pass this URL to the
  7154. 4:57:12reader agent. So reader agent will take
  7155. 4:57:14those URL and it will open that URL and
  7156. 4:57:17whatever content it is having it will
  7157. 4:57:19extract a scrap then uh it will gather
  7158. 4:57:22those content. Okay. Then here we'll be
  7159. 4:57:25creating another actually
  7160. 4:57:27agent the writer agent uh writer agents
  7161. 4:57:30uh takes all that generated intelligence
  7162. 4:57:33and craft a well ststructured detailed
  7163. 4:57:36report. That means write uh there would
  7164. 4:57:38be another agent called writer. So this
  7165. 4:57:39will take all of the content and it will
  7166. 4:57:42uh prepare a draft. Okay, prepare a
  7167. 4:57:43draft report. And after preparing this
  7168. 4:57:46draft report, we'll be sending this
  7169. 4:57:47draft report to another agent called
  7170. 4:57:49critic agent. You can see and finally
  7171. 4:57:51the critic agent reviews the entire
  7172. 4:57:53reports, scores it and gives feedback
  7173. 4:57:56just like a senior researcher reviewing
  7174. 4:57:57a junior's work. Okay, that means at the
  7175. 4:58:00last we'll be creating another agent.
  7176. 4:58:01This agent will try to review. Okay,
  7177. 4:58:04whatever let's say your writer agent has
  7178. 4:58:06written, it will review. it will uh give
  7179. 4:58:08you the feedback. Okay, it will uh do
  7180. 4:58:10some marking. Okay, just like let's say
  7181. 4:58:12you are a senior researcher. Whenever
  7182. 4:58:14your junior is giving any kinds of task,
  7183. 4:58:16you are reviewing that and you're giving
  7184. 4:58:17the feedback. So, every single agent is
  7185. 4:58:19powered uh powered by a large language
  7186. 4:58:22model. Okay, connected through Langen's
  7187. 4:58:24modern LCAL pipeline and orchestrated
  7188. 4:58:27through a shared memory system that
  7189. 4:58:29makes them works uh as one unified
  7190. 4:58:32brain. Okay, so here we'll be utilizing
  7191. 4:58:34the modern langen guys. So previous
  7192. 4:58:37agent I created with the help of the old
  7193. 4:58:39lang um but in this development I'm
  7194. 4:58:42going to utilize the modern langen as
  7195. 4:58:44well which is lce langen uh langen
  7196. 4:58:48expression language so for this
  7197. 4:58:50definitely you need the understanding
  7198. 4:58:52about the fundamentals of langen so
  7199. 4:58:54that's why I told you langchen
  7200. 4:58:56prerequisite uh I mean definitely should
  7201. 4:58:58be there if you are working with this
  7202. 4:59:00kinds of agent so for this langen on my
  7203. 4:59:03YouTube channel I already have one
  7204. 4:59:05dedicated uh video guys ultimate langen
  7205. 4:59:08crash course for developers uh so it's
  7206. 4:59:10uh around seven more than 7 hours of
  7207. 4:59:13course 7 hours of recording so there I
  7208. 4:59:15already covered this LCL and everything
  7209. 4:59:18if you go to the time stamp section uh
  7210. 4:59:20you can see uh here I have already
  7211. 4:59:22covered this uh LCAL okay LCL okay the
  7212. 4:59:27modern uh langen which is langen
  7213. 4:59:30expression language okay so definitely
  7214. 4:59:32you should have understanding on this
  7215. 4:59:34other topic if you don't know please try
  7216. 4:59:36to go ahead with my langen lecture I
  7217. 4:59:38will add the link in the description
  7218. 4:59:40from there you can check it out okay so
  7219. 4:59:42the main fun is in this development
  7220. 4:59:44we'll be using the modern langen instead
  7221. 4:59:45of using the old langin uh uh I wanted
  7222. 4:59:48to show you both of the langen version
  7223. 4:59:50because still people uses old langen
  7224. 4:59:52okay uh and people also use like model
  7225. 4:59:55langen both I'm going to show you uh you
  7226. 4:59:58can use any of them okay it's completely
  7227. 5:00:00fine but I will recommend you to use the
  7228. 5:00:02model lang chain because in model lang
  7229. 5:00:05chain the updated langen so many
  7230. 5:00:07functionality came and people are moving
  7231. 5:00:09to that okay so instead of relying on
  7232. 5:00:11old langchen maybe you can use that one
  7233. 5:00:13okay so each and everything I'm going to
  7234. 5:00:14clarify now I think guys uh the project
  7235. 5:00:17introduction part is clear what to do
  7236. 5:00:19now let me show you the architecture
  7237. 5:00:22how we'll be building this kinds of
  7238. 5:00:23system so guys uh this is the
  7239. 5:00:25architecture I think uh you can see um
  7240. 5:00:28let me show you the architecture yeah so
  7241. 5:00:30this is the architecture so in this
  7242. 5:00:31architecture guys as you can see uh here
  7243. 5:00:34we'll be implementing multiple agents.
  7244. 5:00:36So that means let's say this is the
  7245. 5:00:37first agent uh we'll be developing and
  7246. 5:00:40here we'll be passing given research
  7247. 5:00:43topic. Let's say if I want to do a
  7248. 5:00:44research I will give the research topic.
  7249. 5:00:46So it will go to the first agent. Okay.
  7250. 5:00:49Uh so this agent will have uh some kinds
  7251. 5:00:52of tool access. So here I'm going to
  7252. 5:00:54give tably API that means tably search
  7253. 5:00:57tool access to this agent. So whatever
  7254. 5:01:00research you are giving to this agent.
  7255. 5:01:01So what it will do? It will use this
  7256. 5:01:03tably API and it will uh uh do the
  7257. 5:01:06realtime search operation over the
  7258. 5:01:08internet and it will get the relevant
  7259. 5:01:10sources. Okay. It will get the relevant
  7260. 5:01:12website for that particular topic uh to
  7261. 5:01:14this agent. Okay. Now what I will do
  7262. 5:01:17here this particular response I'm going
  7263. 5:01:19to save in a state memory. Okay. So here
  7264. 5:01:21I will try to create a state memory. So
  7265. 5:01:23state memory will try to save this
  7266. 5:01:24particular response so that and your
  7267. 5:01:27next agent can refer this particular
  7268. 5:01:29response. Okay, your second agent can
  7269. 5:01:32refer this kinds of response. Okay, so
  7270. 5:01:34that's why we are using the shared
  7271. 5:01:36memory concept. You can also improve
  7272. 5:01:37this particular memory uh by utilizing
  7273. 5:01:40some other technique. So this part I'm
  7274. 5:01:41going to also discuss in my future
  7275. 5:01:44lecture. So I think you you saw my
  7276. 5:01:46entire plan there. I told you we'll be
  7277. 5:01:49um I mean discussing this particular
  7278. 5:01:50memory part in detail but as of now just
  7279. 5:01:52try to consider we are using a state
  7280. 5:01:54memory uh you can also replace the state
  7281. 5:01:56memory with any other let's say uh other
  7282. 5:02:00um um like memory database you can use
  7283. 5:02:02that okay it's completely up to you but
  7284. 5:02:04here I'm going to use a state memory um
  7285. 5:02:07in Python okay I'll show you how we can
  7286. 5:02:09implement that so now we'll be creating
  7287. 5:02:11a second agent guys so this uh second
  7288. 5:02:14agent name is reader agent so this
  7289. 5:02:16reader reader agent will also have some
  7290. 5:02:18kinds of tool access. So here I'm going
  7291. 5:02:20to use a beautiful soup uh scrapper
  7292. 5:02:22tool. So what this beautiful soup
  7293. 5:02:24scrapper tool will do basically whatever
  7294. 5:02:27URL you are getting from the first agent
  7295. 5:02:29okay given topic. So this will take all
  7296. 5:02:32of the URL and with the help of
  7297. 5:02:34beautiful soup it will extract the
  7298. 5:02:36content from the URL. I think you know
  7299. 5:02:38with a beautiful soup we can perform the
  7300. 5:02:40web scrapping. We can scrap the content
  7301. 5:02:42from any kinds of given website right.
  7302. 5:02:44So that's why the first agent is
  7303. 5:02:46returning the web URL web uh sources and
  7304. 5:02:49with the help of second agent we are
  7305. 5:02:52extracting the content from the URL with
  7306. 5:02:55help of beautiful soup. Then what we
  7307. 5:02:58will do guys we'll try to pass this
  7308. 5:02:59content to another state uh let's say
  7309. 5:03:02memory uh called let's say scrapped
  7310. 5:03:04content. Okay maybe I can create another
  7311. 5:03:07uh another actually let's say object
  7312. 5:03:09here called scrap content inside that I
  7313. 5:03:10can save those informations. Okay. Now
  7314. 5:03:13here we'll be creating um another two
  7315. 5:03:16actually agent. You can also call it as
  7316. 5:03:18chain inside modern langen. Instead of
  7317. 5:03:20creating this kinds of like u agent in
  7318. 5:03:23lang what you can do you can create a
  7319. 5:03:25chain because at the end you got your
  7320. 5:03:28final uh you got your final important
  7321. 5:03:31content. Okay. If you got the final
  7322. 5:03:32important content now it would be easy
  7323. 5:03:34for you to generate that particular
  7324. 5:03:37report and it would be easy for you to
  7325. 5:03:40review that particular report. Okay. But
  7326. 5:03:42the main thing is in that section. So
  7327. 5:03:45basically here we are performing the
  7328. 5:03:46real-time source operation on a
  7329. 5:03:48different topic. After getting that
  7330. 5:03:49we're extracting the content. Then if we
  7331. 5:03:52have the final content guys we'll be uh
  7332. 5:03:54creating a writer chain. Okay. In lang
  7333. 5:03:56chain we we call it as a chain. Okay you
  7334. 5:03:58can also consider it's a agent. Okay
  7335. 5:04:01it's agent. It's a writer agent. So what
  7336. 5:04:02this writer chain will do it will take
  7337. 5:04:04that particular content. Okay your
  7338. 5:04:06beautiful extracted and it will write a
  7339. 5:04:09draft. Okay, it will write a draft
  7340. 5:04:11report on top that on top of that
  7341. 5:04:12particular
  7342. 5:04:14um content. Okay, because at the end it
  7343. 5:04:17has also connection with the LLM. Okay,
  7344. 5:04:19it has also connection with LLM. It is
  7345. 5:04:21also having connection with LLM. Okay,
  7346. 5:04:23so with the help of LLM with the help of
  7347. 5:04:24this uh content you got it will prepare
  7348. 5:04:28a draft. So once it has prepared a draft
  7349. 5:04:30what it will do guys, it will send this
  7350. 5:04:33draft to the critic chain. Now what this
  7351. 5:04:35critic chain will do it will try to
  7352. 5:04:37review this particular draft whether is
  7353. 5:04:39there any mistake or not is there any uh
  7354. 5:04:41let's say improvement section or not it
  7355. 5:04:43will try to review that once the review
  7356. 5:04:45is complete okay once the feedback is
  7357. 5:04:47complete then it will show you the final
  7358. 5:04:49output okay it will show you the final
  7359. 5:04:51output so you'll be able to see the
  7360. 5:04:52final output even you will also see the
  7361. 5:04:54feedback the ratings okay and everything
  7362. 5:04:57you will be able to see from this critic
  7363. 5:04:58chain that means the critic agent okay
  7364. 5:05:00because it is also having a connection
  7365. 5:05:02with the large language model all Right.
  7366. 5:05:04So yeah, this is the entire uh actually
  7367. 5:05:06architecture of this particular
  7368. 5:05:07multi-agent system. So this is going to
  7369. 5:05:10very interesting project guys. So make
  7370. 5:05:12sure you watch till the end. So I think
  7371. 5:05:13each and everything would be clear in
  7372. 5:05:15your mind. Okay. Now uh here is the step
  7373. 5:05:18guys we'll be following to develop the
  7374. 5:05:20entire agent. So first of all at the
  7375. 5:05:22first step guys we'll be setting up the
  7376. 5:05:23environment. Then second step we'll be
  7377. 5:05:26creating the tools. Okay. All of the
  7378. 5:05:27tools we'll be creating one by one. Then
  7379. 5:05:29third step we'll be creating all of the
  7380. 5:05:31agents one by one. Then fourth step will
  7381. 5:05:33be creating a pipeline. That means uh uh
  7382. 5:05:36uh why pipeline is required? Let's say
  7383. 5:05:38after creating end tools you have to
  7384. 5:05:40combine them. Okay, you have to uh you
  7385. 5:05:42have to add them together to work right.
  7386. 5:05:45So we we can do it in the pipeline
  7387. 5:05:47section. So once our pip entire agent
  7388. 5:05:49pipeline is ready then we can run and
  7389. 5:05:51test our agent. Okay. So this is the
  7390. 5:05:52entire step we'll be following for
  7391. 5:05:54developing this kinds of system. So
  7392. 5:05:56guys, now I'm going to give you the idea
  7393. 5:05:58why uh we have to create uh mostly
  7394. 5:06:02multi- aents AI uh AI application. Uh
  7395. 5:06:06what is the problem with the single
  7396. 5:06:08agent? So I think you know that uh this
  7397. 5:06:10is like very um I mean easy things you
  7398. 5:06:13can understand. Let's say um let's say
  7399. 5:06:16if there is a company okay if there is a
  7400. 5:06:19company
  7401. 5:06:21um let's say company uh what they does
  7402. 5:06:25let's say they takes a project okay they
  7403. 5:06:28takes a project
  7404. 5:06:32okay after taking this project so what
  7405. 5:06:34they do they just try to assign this
  7406. 5:06:37project to a team right team of employee
  7407. 5:06:43team of employee. So in this team uh
  7408. 5:06:46what we have we have multiple employee
  7409. 5:06:48let's employee one employee two
  7410. 5:06:52employee three and so on. Okay. So what
  7411. 5:06:56they do actually just just try to assign
  7412. 5:06:59this kinds of project as a task to the
  7413. 5:07:02team and definitely in the team itself
  7414. 5:07:05they will try to divide the task to
  7415. 5:07:07different different employee. Let's say
  7416. 5:07:09here are some of uh let's say employee
  7417. 5:07:11one is very good at with the front- end
  7418. 5:07:14development.
  7419. 5:07:16Okay, front end development. Employee 2
  7420. 5:07:19is like really good with let's say AI
  7421. 5:07:21development. Okay, and employee three is
  7422. 5:07:26good at with backend development.
  7423. 5:07:29Okay, backend development. So what they
  7424. 5:07:31will do? So the project they are having
  7425. 5:07:34uh so for the for the front- end
  7426. 5:07:37development for this project they will
  7427. 5:07:39assign the task to the employee one for
  7428. 5:07:41API development uh uh sorry AI
  7429. 5:07:44development for this project they will
  7430. 5:07:46assign the task to employee employee two
  7431. 5:07:48okay and for backend development for
  7432. 5:07:51this project they will assign the task
  7433. 5:07:53to the employee three okay that means
  7434. 5:07:56all of the project will have these are
  7435. 5:07:58the things are common right and it's not
  7436. 5:08:01like that there would be a single guy
  7437. 5:08:04okay single guy he can let's say handle
  7438. 5:08:08each and everything I can't say he
  7439. 5:08:10cannot handle he can handle definitely
  7440. 5:08:13let's say if I'm hiring a full stack
  7441. 5:08:15developer so definitely he will be able
  7442. 5:08:17to handle this kinds of scenario he will
  7443. 5:08:20be able to let's say implement the
  7444. 5:08:22entire project but what would be the
  7445. 5:08:24problem okay because if you see most of
  7446. 5:08:26the fully stack engineer so they will
  7447. 5:08:29have actually limited knowledge uh on
  7448. 5:08:32this uh on this actually let's say
  7449. 5:08:34individual topic. So for the end to end
  7450. 5:08:38development whatever things they need to
  7451. 5:08:40know they definitely will do that for
  7452. 5:08:42you. But when it comes to the deep
  7453. 5:08:45research, let's say I want to create
  7454. 5:08:47some AI features uh for this project and
  7455. 5:08:50uh I I need a deep research. Okay, I
  7456. 5:08:53need a very um very good uh let's say
  7457. 5:08:57good uh sources. Then after getting the
  7458. 5:08:59good sources, I have to refer that
  7459. 5:09:02sources and I have to build the AI
  7460. 5:09:03features. Okay. So if we are only
  7461. 5:09:06depending on this single let's say
  7462. 5:09:08employee so he wouldn't be able to do
  7463. 5:09:11that because he doesn't have actually
  7464. 5:09:14that much of depth knowledge on this AI
  7465. 5:09:16development okay he can only let's say
  7466. 5:09:19uh use some of the framework library and
  7467. 5:09:21he can implement that project for you
  7468. 5:09:23but when it comes to deep deep let's say
  7469. 5:09:25research let's say deep experiment he
  7470. 5:09:27won't be able to do that that means with
  7471. 5:09:29the help of single guy I can't perform
  7472. 5:09:32actually multiple task task can be
  7473. 5:09:34performed But the output the quality of
  7474. 5:09:36output we'll be expecting this should
  7475. 5:09:39not be good. Okay. This should not be
  7476. 5:09:40good. This should be uh this should be
  7477. 5:09:42kind of average output. But whenever we
  7478. 5:09:46are having this kinds of project
  7479. 5:09:47definitely will expect like very good
  7480. 5:09:50quality output from my team. Right? And
  7481. 5:09:52if we are uh if we are let's say
  7482. 5:09:54assigning this kinds of task to the
  7483. 5:09:56single employee so definitely single
  7484. 5:09:58employee won't be able to give the
  7485. 5:09:59quality output to me. So that's why
  7486. 5:10:02every company having a team and in that
  7487. 5:10:04particular team they they are hiring
  7488. 5:10:07okay different individual those who are
  7489. 5:10:10let's say expert expert in different
  7490. 5:10:12different field let's say someone is
  7491. 5:10:13expert in front end someone expert in AI
  7492. 5:10:15development someone is expert in uh back
  7493. 5:10:17end development okay and whatever
  7494. 5:10:20project they are getting they're uh
  7495. 5:10:21dividing their task to them so let's say
  7496. 5:10:23employee one has completed front end
  7497. 5:10:25employee two has completed AI
  7498. 5:10:26development employee three has completed
  7499. 5:10:28the backend development now they will
  7500. 5:10:30combine they combine everything and they
  7501. 5:10:32will prepare the project for you. Now
  7502. 5:10:34when it comes for research let's say
  7503. 5:10:35having a deep research on individual
  7504. 5:10:38let's say topic so easily these kinds of
  7505. 5:10:41employee can perform because he's only
  7506. 5:10:43expert in front end he knows about the
  7507. 5:10:45front end and if you give time okay if
  7508. 5:10:48you give time if you tell this uh let's
  7509. 5:10:50say employee just try to research and
  7510. 5:10:52add some more front end feature with
  7511. 5:10:54latest like framework he will be able to
  7512. 5:10:56do that okay because he don't need to
  7513. 5:10:58worry about the I development and back
  7514. 5:11:00end development he will only focus on
  7515. 5:11:01the front end development so that's
  7516. 5:11:03[snorts] for AI developer guy also I can
  7517. 5:11:05tell just try to explore more and add
  7518. 5:11:07some other AI features as well. So
  7519. 5:11:09definitely he will be able to do that
  7520. 5:11:10because he doesn't uh need to worry
  7521. 5:11:12about the front end and back end. Okay
  7522. 5:11:14then employee 3 I'll tell just try to
  7523. 5:11:17research more about the back end let's
  7524. 5:11:18say I don't want to use uh flask you
  7525. 5:11:20just need to use fast API just try to
  7526. 5:11:22explore fast API you'll be able to do
  7527. 5:11:24that okay so that's how individual
  7528. 5:11:26person is working on individual task and
  7529. 5:11:28the output we are getting from here this
  7530. 5:11:31is like very good quality output okay
  7531. 5:11:33good quality output we'll be getting
  7532. 5:11:37okay that's how whenever we are creating
  7533. 5:11:40kinds of agent application instead of
  7534. 5:11:42creating a single agent Okay, instead of
  7535. 5:11:44creating this kinds of single agent
  7536. 5:11:46because in single agent if I want to
  7537. 5:11:48perform all of this task okay if I want
  7538. 5:11:50to perform all of these tasks so
  7539. 5:11:51definitely the output should be very
  7540. 5:11:53poor and if I'm using multiple agent
  7541. 5:11:55okay the architecture I showed you I
  7542. 5:11:57think so this is the architecture
  7543. 5:12:00if I'm using multiple agent so here I'm
  7544. 5:12:03assigning a uh different different task
  7545. 5:12:06let's say first agent I have assigned
  7546. 5:12:07your task is to only fetch the real-time
  7547. 5:12:10data from the internet and give the uh
  7548. 5:12:12collect the URL. Okay. Then you will try
  7549. 5:12:14to save the state memory. Then second
  7550. 5:12:16agent I have given another task. Your
  7551. 5:12:18task is to take those URL and extract
  7552. 5:12:20the content from that. Okay. So after
  7553. 5:12:23extracting content agent save to the
  7554. 5:12:24state memory. Then third agent I told uh
  7555. 5:12:28um I mean let's say this agent just try
  7556. 5:12:31to take those content and write a report
  7557. 5:12:33on this particular resource. Okay. Your
  7558. 5:12:36task is uh your only task is to generate
  7559. 5:12:38the report. So it will try to generate
  7560. 5:12:40the report. Then the uh fourth agent I
  7561. 5:12:44told this agent you just need to take
  7562. 5:12:46this uh draft and try to review that
  7563. 5:12:49whether it is good or bad or it still it
  7564. 5:12:52needs some feedback just try to read
  7565. 5:12:53rate read this okay so this particular
  7566. 5:12:56agent only uh is responsible for rating
  7567. 5:12:59this okay or critique this particular
  7568. 5:13:01task so once everything is done then we
  7569. 5:13:03are getting the final output and this
  7570. 5:13:05final output would be very good quality
  7571. 5:13:07but if I am performing the same task
  7572. 5:13:09with a single agent so definitely
  7573. 5:13:10Definely the output would be very bad
  7574. 5:13:12quality. Okay. So that's why this multi-
  7575. 5:13:14aent things are required. Okay. That's
  7576. 5:13:16why you are uh will be developing multi-
  7577. 5:13:18aent system most of the time and all of
  7578. 5:13:20the application you can see. Okay.
  7579. 5:13:22Whatever application like cloud desktop
  7580. 5:13:24or you are using VS code anti-gravity
  7581. 5:13:27any anything you'll see that they're
  7582. 5:13:29using multiple agents in the back end.
  7583. 5:13:31They're running multiple agents. Okay.
  7584. 5:13:33They're adding let's say 100 and 100
  7585. 5:13:36like agents in their back end and
  7586. 5:13:38they're performing one kinds of task.
  7587. 5:13:40Okay. So yes, that's how guys uh we will
  7588. 5:13:43be following this multiple agent
  7589. 5:13:45development. And one more thing whenever
  7590. 5:13:46you are creating multiple agents, so
  7591. 5:13:48make sure all of the agents will have
  7592. 5:13:50kinds of tool access. Okay, if it is
  7593. 5:13:52required, definitely we'll give the tool
  7594. 5:13:54access and all of the agents will have a
  7595. 5:13:56large language model for the reasoning
  7596. 5:13:57operation. Okay, I think everything is
  7597. 5:14:00clear. Now we'll move on the uh
  7598. 5:14:02development part, guys.
  7599. 5:14:06So first of all I'm going to create a
  7600. 5:14:08GitHub repo for this multi- aent. So
  7601. 5:14:10let's try to create a GitHub repo. So
  7602. 5:14:13here I'm going to give a name.
  7603. 5:14:16Let's say
  7604. 5:14:22I'll give a name here
  7605. 5:14:26langen
  7606. 5:14:31multi-
  7607. 5:14:36multi- aent
  7608. 5:14:43research
  7609. 5:14:48research.
  7610. 5:14:50Okay, research system.
  7611. 5:14:55Uh I will make it as public repo and I
  7612. 5:14:57will add the readmi file. I'll also add
  7613. 5:15:00the g ignore. So here we'll be coding
  7614. 5:15:02with python. So I'll select the python.
  7615. 5:15:04After that you can select a license. So
  7616. 5:15:06let's take this u maybe apache license.
  7617. 5:15:10Okay. You can take any of the license.
  7618. 5:15:11It's up to you. On it once it is done
  7619. 5:15:13now let's try to create the repo.
  7620. 5:15:18Okay. So repo is created. Now we have to
  7621. 5:15:21clone this repo inside our local folder.
  7622. 5:15:24I'll click on this code. Copy this link
  7623. 5:15:26address. I'll open up my local folder.
  7624. 5:15:28And here I will just try to open my
  7625. 5:15:31terminal.
  7626. 5:15:37Now let's clone it. So get clone
  7627. 5:15:41paste this link.
  7628. 5:15:45Okay. So this directory is already exist
  7629. 5:15:47because previously I already created
  7630. 5:15:51uh so what I can do maybe I can rename
  7631. 5:15:53it.
  7632. 5:15:58Okay I can rename it.
  7633. 5:16:06Okay. Now just try to open your terminal
  7634. 5:16:08in this directory and just write get
  7635. 5:16:10clone
  7636. 5:16:14and paste that URL. Okay, you have
  7637. 5:16:17copied. Now if I hit enter, so you'll
  7638. 5:16:19see my repo has been cloned. I will go
  7639. 5:16:22inside that and I will also redirect my
  7640. 5:16:24terminal inside this uh directory. So
  7641. 5:16:27for this let's write cd command cd
  7642. 5:16:30langin
  7643. 5:16:32multi- aent
  7644. 5:16:34research.
  7645. 5:16:37Okay research system now I'm inside this
  7646. 5:16:39particular folder. Now here I'm going to
  7647. 5:16:42open up my quisel code studio
  7648. 5:16:48visual code studio.
  7649. 5:16:52Uh fine. Okay. Now the first thing guys
  7650. 5:16:56uh I told you so let me show you the
  7651. 5:16:58steps we'll be following.
  7652. 5:17:01Yeah. So this is my actually um
  7653. 5:17:06this is my actually note note file. So
  7654. 5:17:08in this particular file you will be
  7655. 5:17:10getting all the nodes and architecture
  7656. 5:17:12steps everything. So this is excali uh
  7657. 5:17:15like extension file. If you want to open
  7658. 5:17:17it up so you have to install one
  7659. 5:17:18extension from extension market called
  7660. 5:17:21excali. So if you can search here Xcali
  7661. 5:17:27Xcali drop okay so this particular
  7662. 5:17:30extension you have to install if you
  7663. 5:17:31install that you will be able to open
  7664. 5:17:33this okay in your VS code itself
  7665. 5:17:35uh fine so now if I show you my step
  7666. 5:17:39um if I show you my step so the first
  7667. 5:17:42step what I have to do uh I have to do
  7668. 5:17:46the environment setup okay let's try to
  7669. 5:17:48do the environment setup so for
  7670. 5:17:50environment setup here I'm going to
  7671. 5:17:51write all of these this step
  7672. 5:17:56here let's say
  7673. 5:17:58the first step you have to create the
  7674. 5:18:00environment so to create the environment
  7675. 5:18:02you can
  7676. 5:18:03use the same command I think you used
  7677. 5:18:05for the previous project
  7678. 5:18:08on create-en n you can give the name
  7679. 5:18:11let's say lang agent
  7680. 5:18:15then you can specify the python python
  7681. 5:18:18is equal to you can take 3.11
  7682. 5:18:22and y okay you are giving this
  7683. 5:18:24permission after that you have to
  7684. 5:18:26activate that then you have to install
  7685. 5:18:27the requirements okay so just try to
  7686. 5:18:30create the environment so for me I think
  7687. 5:18:32I already have the environment uh so I'm
  7688. 5:18:35going to just activate the copy
  7689. 5:18:39and activate the environment
  7690. 5:18:42so see this lang engine is already um
  7691. 5:18:45installed for me okay but if you don't
  7692. 5:18:47have just try to create the environment
  7693. 5:18:49then try to activate then after that
  7694. 5:18:51Let's install the requirement.
  7695. 5:18:53So here I'm going to add the
  7696. 5:18:54requirement.txt and inside that I'm
  7697. 5:18:57going to mention all of the requirement
  7698. 5:18:58package I need.
  7699. 5:19:01Um
  7700. 5:19:03yeah so these are my requirement guys.
  7701. 5:19:08Okay so these are my requirement uh I
  7702. 5:19:10need for this particular project. So you
  7703. 5:19:12can see we're installing langen. Um so I
  7704. 5:19:15think you remember in previous project
  7705. 5:19:17we use uh we installed actually langen
  7706. 5:19:19old version. So let me show you it was
  7707. 5:19:210.1 something I think. So this is the
  7708. 5:19:24like uh first agent repository that
  7709. 5:19:27means our single AI agent repository. So
  7710. 5:19:28if I go to the requirement.txt as you
  7711. 5:19:30can see we have installed langen 0.1
  7712. 5:19:33here. Okay but here we're installing
  7713. 5:19:35langen 0.2 that means this is the modern
  7714. 5:19:38langen the latest one. So here actually
  7715. 5:19:41lcl that means langen expression
  7716. 5:19:43language is supported but here this is
  7717. 5:19:44this was not supported. Okay. So, both I
  7718. 5:19:47have showed you uh but try to use the
  7719. 5:19:49latest one if you want. Okay. Uh latest
  7720. 5:19:51one is always good. Uh because older one
  7721. 5:19:54uh people are uh not using anymore. So
  7722. 5:19:57they are trying to u moving to the new
  7723. 5:19:59one. It doesn't mean older one cannot be
  7724. 5:20:02used. Still you can use old one. Okay.
  7725. 5:20:03There are some good functionality you
  7726. 5:20:05can use. But yeah uh whenever we have
  7727. 5:20:07the latest one so why not we can utilize
  7728. 5:20:09this this one. Okay. Then we are
  7729. 5:20:12installing this langen core community
  7730. 5:20:13openi lang openai. So you can use any
  7731. 5:20:16other LM provider as well. It's
  7732. 5:20:18completely fine. Simply you just need to
  7733. 5:20:19go to the RGP and tell let's say you
  7734. 5:20:21want to use open router or Gemini. So
  7735. 5:20:24you'll be able to see that they will
  7736. 5:20:25suggest you the code. Okay. You can
  7737. 5:20:26replace that code here. Okay. Then
  7738. 5:20:28streaml I need for creating the user
  7739. 5:20:30interface. Then tavly for this search
  7740. 5:20:33tool. And I told you we'll be creating
  7741. 5:20:35another tool which is a beautiful soup
  7742. 5:20:38extracting. So here we'll install this
  7743. 5:20:40beautiful to soup. And for beautiful
  7744. 5:20:42soup we need these are the dependency
  7745. 5:20:44package as well. Okay. Then python do uh
  7746. 5:20:46env for the environment management. So
  7747. 5:20:48these are the package we have to
  7748. 5:20:49install. So how to install? Let's copy
  7749. 5:20:51the command. So here's the command. I
  7750. 5:20:53will copy this and run in my terminal.
  7751. 5:20:58So for me it is already satisfied but
  7752. 5:21:00for you it may take some time. Okay.
  7753. 5:21:02Once it is done now we can create the
  7754. 5:21:04folder structure right now. So here what
  7755. 5:21:07I'm going to do I'm going to first of
  7756. 5:21:08all create a folder here. I'm going to
  7757. 5:21:11name it as src
  7758. 5:21:13and inside that I'm going to create a
  7759. 5:21:15constructor file
  7760. 5:21:18init_py
  7761. 5:21:24and uh inside that I'm going to create
  7762. 5:21:26another folder
  7763. 5:21:28uh I'm going to name it as
  7764. 5:21:32tools.
  7765. 5:21:35I'm going to create another folder
  7766. 5:21:37called agents.
  7767. 5:21:42Okay, then I need another folder
  7768. 5:21:49called pipeline.
  7769. 5:21:55Okay. Yeah. So once it is done then here
  7770. 5:21:59I'm going to create an endpoint which
  7771. 5:22:00should be my app.py.
  7772. 5:22:08Okay. And I need av file
  7773. 5:22:13for environment management.
  7774. 5:22:16So yeah, so this is my folder structure.
  7775. 5:22:18Uh
  7776. 5:22:20but uh right now I'm going to create
  7777. 5:22:21some of the file inside these are the
  7778. 5:22:23folder. Like first of all I have to
  7779. 5:22:26create a constructor file.
  7780. 5:22:33So this is called modular coding. We're
  7781. 5:22:35uh creating as a module each and every
  7782. 5:22:37separate module. Inside that we'll be
  7783. 5:22:40creating a file called agent.py.
  7784. 5:22:46Then pipeline also I'm going to create a
  7785. 5:22:48constructor
  7786. 5:22:50init_.py
  7787. 5:22:57and I'll be creating a file called
  7788. 5:22:59pipeline.py.
  7789. 5:23:07So for tools also we'll be doing the
  7790. 5:23:09same thing.
  7791. 5:23:28Okay, everything is done. Now let me
  7792. 5:23:31check. Let me verify everything is fine
  7793. 5:23:33or not. Uh yeah, I think everything is
  7794. 5:23:35fine. So now if I show you my step
  7795. 5:23:37again, uh we have prepared all of the
  7796. 5:23:40folders. Okay. Like for tools, we have
  7797. 5:23:43created a separate tools folder inside
  7798. 5:23:45src. So inside that we'll be writing all
  7799. 5:23:48of the tools in the tools.py. For agent
  7800. 5:23:51also we have done the same thing agent
  7801. 5:23:52and inside agents we'll be writing all
  7802. 5:23:54of the agents. For pipeline we have done
  7803. 5:23:56the same thing. For pipelines we'll be
  7804. 5:23:57writing the pipelines. Okay. and run and
  7805. 5:23:59test. We'll be using this endpoint which
  7806. 5:24:01is app.py. Okay, so everything is fine.
  7807. 5:24:04Um uh okay, one more thing I can do for
  7808. 5:24:07running uh and testing the agent. First
  7809. 5:24:09of all, let's say we'll try to test in
  7810. 5:24:11the main.py. Then once uh everything is
  7811. 5:24:13working fine, we can convert we can add
  7812. 5:24:15the user interface to the app.py. Okay.
  7813. 5:24:17Yeah. So now it's ready. Now let me
  7814. 5:24:19commit the changes to my GitHub. So
  7815. 5:24:21simply what I will do
  7816. 5:24:24uh I'll try to
  7817. 5:24:27uh commit the changes.
  7818. 5:24:30So get add space dot
  7819. 5:24:33get commit
  7820. 5:24:36m
  7821. 5:24:38um
  7822. 5:24:41agent setup
  7823. 5:24:43and folder structure
  7824. 5:24:50created
  7825. 5:24:54and get push
  7826. 5:24:57origin
  7827. 5:25:04done. Now if I go to my GitHub
  7828. 5:25:07refresh,
  7829. 5:25:09see my border structure is ready. Okay.
  7830. 5:25:13Now first thing let's try to work on
  7831. 5:25:15this.
  7832. 5:25:17Um
  7833. 5:25:19I'll open up my state. Yeah. So
  7834. 5:25:21environment setup and folder creation is
  7835. 5:25:23done. Now uh here what I can do maybe I
  7836. 5:25:25can write another things
  7837. 5:25:29folder structure.
  7838. 5:25:33Okay folder struct structure.
  7839. 5:25:37Yeah.
  7840. 5:25:41Now first of all we'll be uh creating
  7841. 5:25:43the tools. Okay let's try to create the
  7842. 5:25:45tools. Uh so here I'll close all of this
  7843. 5:25:53file.
  7844. 5:26:00But before creating the tools uh first
  7845. 5:26:01of all I have to collect uh this uh uh
  7846. 5:26:06secret credential. I need my openi API
  7847. 5:26:08key and I need table API key. Okay I
  7848. 5:26:11already showed you in my previous
  7849. 5:26:12implementation how to collect them. So I
  7850. 5:26:15already collected let me show you. So
  7851. 5:26:17this is my open API key and this is my
  7852. 5:26:19table API key. So for openi what you
  7853. 5:26:22have to do you have to visit openi API
  7854. 5:26:24platform. So there simply just try to
  7855. 5:26:27login with the API platform.
  7856. 5:26:30Once you have logged in just try to see
  7857. 5:26:33the API keys option
  7858. 5:26:39and create the new access uh secret key.
  7859. 5:26:42Okay. So for me I have already created.
  7860. 5:26:44Now for tabuli
  7861. 5:26:46you can visit tab API key tab.com
  7862. 5:26:49and see here if you don't want to use
  7863. 5:26:51open AI you can use Google Gemini API or
  7864. 5:26:54open router or gro API key anything you
  7865. 5:26:57can use. Okay only you just need to
  7866. 5:26:59change that model uh initialization
  7867. 5:27:01simply you can go to the chat GPT and
  7868. 5:27:03you can replace that okay very easy but
  7869. 5:27:05I have my openi account with me that's
  7870. 5:27:07why I'm going to use openi because I am
  7871. 5:27:08expecting good output from my agent.
  7872. 5:27:10Okay, that's why uh because in free API
  7873. 5:27:12there is some limitation. Um so after c
  7874. 5:27:15certain time actually uh this limit
  7875. 5:27:17would be offered. So that's why we are
  7876. 5:27:18using open air here. Now table also you
  7877. 5:27:21have to do the same thing. Uh here is a
  7878. 5:27:24API creation option. You can uh click
  7879. 5:27:26here you can create a new key. Okay for
  7880. 5:27:28me I already create the key. So this is
  7881. 5:27:30available. Okay. Now environment is
  7882. 5:27:32ready. Now simply let's try to create
  7883. 5:27:35the agent.
  7884. 5:27:37Uh what I'm going to do I'm going to
  7885. 5:27:39open this sorry not agent I'm going to
  7886. 5:27:42create a tool. So I'm going to open this
  7887. 5:27:44tools. Okay tools folder uh tools.py.
  7888. 5:27:47Okay I'm going to open it. So the very
  7889. 5:27:50first tools guys I have to create I
  7890. 5:27:51think you remember which is uh this web
  7891. 5:27:53search tool which is this web search
  7892. 5:27:56tool. If I show you my diagram web
  7893. 5:27:58search tool which is tab API. Okay. And
  7894. 5:28:01we'll try to connect with our first
  7895. 5:28:02agent. So let's try to create this table
  7896. 5:28:04search uh table search tool. So for this
  7897. 5:28:07let's import some library. First of all
  7898. 5:28:09I'm going to select my environment.
  7899. 5:28:12[clears throat] So I'm going to import
  7900. 5:28:14let's say
  7901. 5:28:16langen
  7902. 5:28:17dot tools
  7903. 5:28:21import
  7904. 5:28:23tool.
  7905. 5:28:25Okay.
  7906. 5:28:27Then I'm going to import request.
  7907. 5:28:32I'm going to import
  7908. 5:28:35um I'm going to import this uh env. So
  7909. 5:28:39from env
  7910. 5:28:41import load env.
  7911. 5:28:45Then
  7912. 5:28:47I need the operating system.
  7913. 5:28:51Okay, it should be import.
  7914. 5:28:57And one more thing I need to import the
  7915. 5:28:59table. So from
  7916. 5:29:01tably
  7917. 5:29:03import
  7918. 5:29:06tably client.
  7919. 5:29:10Yeah, you can also import tably from
  7920. 5:29:12langen uh because langen inside tools it
  7921. 5:29:15is tably tools is available. You can
  7922. 5:29:17import either you can import from tably
  7923. 5:29:21framework itself and you can create as
  7924. 5:29:24your custom tool. So in my previous
  7925. 5:29:26example taby I initialized from langium
  7926. 5:29:29u I didn't create it as a custom tool
  7927. 5:29:32but in this implementation I'm going to
  7928. 5:29:33show you how we can uh create tab as
  7929. 5:29:36your custom tool okay this is also
  7930. 5:29:37possible uh both you see and whatever
  7931. 5:29:40you like you can prefer that because in
  7932. 5:29:42my requirement I already installed this
  7933. 5:29:43tably python okay that's why we'll be
  7934. 5:29:45able to do that so simply first of all
  7935. 5:29:48load your environment variable and after
  7936. 5:29:51that let's create a tably object so
  7937. 5:29:54tably key
  7938. 5:29:55is equal to so tably client
  7939. 5:30:02here you have to pass the API key of the
  7940. 5:30:04tably so I'm going to get from my
  7941. 5:30:07involvement variable so west get env
  7942. 5:30:09table tably API key and inside this enb
  7943. 5:30:11I've already mentioned my table apak
  7944. 5:30:13okay it will try to load from here so
  7945. 5:30:15once I got it now I'll create a function
  7946. 5:30:17here so this function will try to
  7947. 5:30:19perform the web service operation with
  7948. 5:30:21help of tably so maybe I can name this
  7949. 5:30:23function function as web search. Okay,
  7950. 5:30:26web search
  7951. 5:30:33web search. So this will take a query
  7952. 5:30:39or I have already created let me show
  7953. 5:30:41you.
  7954. 5:30:44Yeah. So this is the function guys as
  7955. 5:30:47you can see. So websites this is the
  7956. 5:30:49function. This takes the query and what
  7957. 5:30:52[clears throat] it does it uh use tab
  7958. 5:30:55and it searchs that particular query
  7959. 5:30:56over the internet and max result is
  7960. 5:30:58equal to five that means it will give
  7961. 5:30:59you five sources okay five relevant uh
  7962. 5:31:02sources uh URL from the internet and
  7963. 5:31:06what we are doing
  7964. 5:31:08uh let me show you what we are doing
  7965. 5:31:09here let's say once we are getting all
  7966. 5:31:12of the five
  7967. 5:31:15uh five responses so let me just print
  7968. 5:31:17them one by
  7969. 5:31:21print result all of the results.
  7970. 5:31:25Now let's call this function
  7971. 5:31:31or we can also test inside our endpoint
  7972. 5:31:33which is main.py. Let's import from src
  7973. 5:31:38dot tools
  7974. 5:31:42dot tool import web then
  7975. 5:31:48websource
  7976. 5:31:51let's say what is the capital of French
  7977. 5:31:53okay I have given this one or let's say
  7978. 5:31:58latest
  7979. 5:32:02news on a research now if I execute
  7980. 5:32:07python
  7981. 5:32:09main.py.
  7982. 5:32:14Now see it is giving you five response.
  7983. 5:32:20Okay, five response. But this print
  7984. 5:32:23statement is not clear enough. So if you
  7985. 5:32:25want to make it clear enough, so what
  7986. 5:32:27you can do guys, you can install one
  7987. 5:32:28tool which is
  7988. 5:32:32rich. Let me add inside my environment
  7989. 5:32:35reach. Okay, so reach helps us to uh
  7990. 5:32:39actually um see the good print statement
  7991. 5:32:41and you can also use it for the login
  7992. 5:32:43debugging. So let me install the rich as
  7993. 5:32:46well
  7994. 5:32:54clear. I'll install my
  7995. 5:33:00requirements once it is done. Now let's
  7996. 5:33:02try to import the rich
  7997. 5:33:07in the tools. I'm going to import from
  7998. 5:33:10rich.
  7999. 5:33:13Okay. Import print. Now instead of this
  8000. 5:33:15print I'm going to use my rich print.
  8001. 5:33:18Okay. Now if I execute this will give
  8002. 5:33:21you beautiful output.
  8003. 5:33:26Now see this is uh clean right? This is
  8004. 5:33:29understandable.
  8005. 5:33:32Yeah. So you can see we are getting this
  8006. 5:33:33response from tably API. So Tableau API
  8007. 5:33:36what is it doing? It is going to
  8008. 5:33:37internet and it is searching
  8009. 5:33:41it is searching over uh different
  8010. 5:33:43different website. Okay. So this is the
  8011. 5:33:46first website reddit.com. So if I open
  8012. 5:33:48it up so here it has already discussed
  8013. 5:33:51about this uh uh latest AI research
  8014. 5:33:55news. Then again you can see there is
  8015. 5:33:58another website called artificial
  8016. 5:34:00intelligencenews.com.
  8017. 5:34:02Okay. So this is another news. So that's
  8018. 5:34:04how you have see uh that's how you can
  8019. 5:34:06see 1 2
  8020. 5:34:08uh 3 4 5. Okay. Total five uh response
  8021. 5:34:12we are getting here. Okay. Five uh URL
  8022. 5:34:14we are getting here from different
  8023. 5:34:16different website. Okay. Now what I can
  8024. 5:34:19do see I don't need all of the
  8025. 5:34:21informations because here I only need
  8026. 5:34:23this result. Okay. In the result I have
  8027. 5:34:25the URL. I have the title of that
  8028. 5:34:28particular let's say information and I
  8029. 5:34:31have a content. So in that content
  8030. 5:34:33actually some uh like uh one to two
  8031. 5:34:36lines headlines are there about the
  8032. 5:34:38content. Okay. So if I'm able to get
  8033. 5:34:40these are the three things I think this
  8034. 5:34:42is more than enough uh for my agents
  8035. 5:34:44because if I show you my agent
  8036. 5:34:47if I show you my agent here. So let's
  8037. 5:34:49say first agent what it will do it will
  8038. 5:34:51uh use tab API uh for real time data
  8039. 5:34:56data feting operation from different
  8040. 5:34:58different website and we have to take
  8041. 5:35:00there
  8042. 5:35:02these are the information URL title and
  8043. 5:35:04content. So this URL title and content
  8044. 5:35:06will try to save in the state result and
  8045. 5:35:08my second result will try to uh take
  8046. 5:35:11that and from the URL itself okay from
  8047. 5:35:13this URL itself it will try to extract
  8048. 5:35:16it will try to extract the content
  8049. 5:35:18because this is a web okay this is HTML
  8050. 5:35:21web so now what it can do uh it can
  8051. 5:35:23actually so extract the content and how
  8052. 5:35:26it extract I think you know if I perform
  8053. 5:35:27the inspect operation so there is a
  8054. 5:35:31option let's say if I want to
  8055. 5:35:34extract ract any text easily I can do
  8056. 5:35:37that let's say I can show you let's say
  8057. 5:35:40I want to extract this this particular
  8058. 5:35:41part if I click here so this is the
  8059. 5:35:43content of that okay I can easily
  8060. 5:35:45extract the content and this operation
  8061. 5:35:47we perform with alpha beautiful soap
  8062. 5:35:49okay so I'll try to do that as well so
  8063. 5:35:52here let me show you
  8064. 5:35:54I'll open it up
  8065. 5:35:57h now instead of taking all of the
  8066. 5:35:59content so what I'll do I'll just try to
  8067. 5:36:03Okay,
  8068. 5:36:06these are the information.
  8069. 5:36:09Okay, these are the information like I
  8070. 5:36:11need title, I need URL and I need
  8071. 5:36:14content. Okay, content I need and
  8072. 5:36:16content I'm only taking 300 word just to
  8073. 5:36:19make my uh let's say agent understand.
  8074. 5:36:21Okay, so this is the content related
  8075. 5:36:23that and it is available inside this
  8076. 5:36:25URL. You have to extract that. Okay, now
  8077. 5:36:27if I uh see after doing it I'm just
  8078. 5:36:30running a for loop because this result
  8079. 5:36:32will have a result keyword. Okay, we are
  8080. 5:36:35going inside that because this is a JSON
  8081. 5:36:37response. We are taking this key and
  8082. 5:36:38inside that we have title um URL title
  8083. 5:36:41and content. So inside that we are
  8084. 5:36:44extracting title, URL and content and we
  8085. 5:36:47are appending to this particular empty
  8086. 5:36:49list one by one. That means the five uh
  8087. 5:36:51five output should be there. Five uh
  8088. 5:36:53five links response should be there
  8089. 5:36:55inside that. Okay, because I'm getting
  8090. 5:36:56five response. Now let me show you. So
  8091. 5:36:59if I print this
  8092. 5:37:03uh if I first of all I'll return it.
  8093. 5:37:08I'll return it. So basically I'm
  8094. 5:37:10performing the joining operation. uh so
  8095. 5:37:12what the join will do it will try to
  8096. 5:37:14join as a string okay so every time it
  8097. 5:37:16will give a new line and it will join
  8098. 5:37:18all of the content now let me show you
  8099. 5:37:21how this thing will look like so maybe
  8100. 5:37:23now I'll try to receive it here let's
  8101. 5:37:25say
  8102. 5:37:27output
  8103. 5:37:32and print the output
  8104. 5:37:35now if I execute my
  8105. 5:37:38file
  8106. 5:37:45See I'm getting five output the title
  8107. 5:37:48and this is the URL of that content and
  8108. 5:37:51this is a like uh short paragraph of
  8109. 5:37:54that particular news. So if I go to the
  8110. 5:37:56reddit.com you'll see that an AWS user
  8111. 5:37:59started. Okay. So this thing is
  8112. 5:38:01available.
  8113. 5:38:07Yeah. Sorry from here. An entropic drops
  8114. 5:38:10a uh drops a new research paper today.
  8115. 5:38:13Okay. So, entropic uh drops a new
  8116. 5:38:15research paper today. So, that's how it
  8117. 5:38:17is taking 300 word from the entire
  8118. 5:38:19content. Okay. Entire content. Now, this
  8119. 5:38:22is the second one. This is the third
  8120. 5:38:23one. This is the fourth one. This is the
  8121. 5:38:25fifth one. That means we are getting
  8122. 5:38:26fifth uh response from our tab tool.
  8123. 5:38:29Okay. Which is amazing. Now, what I will
  8124. 5:38:32do guys? Um my first tool is ready.
  8125. 5:38:37My first tool is ready. That means this
  8126. 5:38:39particular tools is ready. Okay. Now I
  8127. 5:38:42have to work on this tool which is
  8128. 5:38:43beautiful soup scrapper tool. Now let's
  8129. 5:38:46try to also work on that. So for this I
  8130. 5:38:49again need to import some other library
  8131. 5:38:51like I need to import
  8132. 5:38:53uh
  8133. 5:38:55beautiful soup. So from
  8134. 5:38:59BS4
  8135. 5:39:02I import beautiful soup. Then I have to
  8136. 5:39:04import from
  8137. 5:39:08readability
  8138. 5:39:10import documents. Then I have to import
  8139. 5:39:22chart. Okay. Uh trafil uh tora. Okay.
  8140. 5:39:26This is uh this thing I need uh with
  8141. 5:39:28beautiful soup. Um uh that's why this is
  8142. 5:39:31a dependency package. And I also need
  8143. 5:39:33regular expression
  8144. 5:39:36import.
  8145. 5:39:38So if you have ever performed web
  8146. 5:39:40scrapping I think you know these are the
  8147. 5:39:41libraries useful
  8148. 5:39:43H.
  8149. 5:39:45So what I've done guys I have already
  8150. 5:39:46generated a function with chart GPT.
  8151. 5:39:56Let me show you the function.
  8152. 5:40:00Yeah. So this is the function I have
  8153. 5:40:02generated from chat GPT. Uh so basically
  8154. 5:40:05if it takes a URL okay it takes a URL
  8155. 5:40:08and what it does uh it uh ex scrap
  8156. 5:40:12actually all of the content from the
  8157. 5:40:13URL. Okay it perform the scrapping. So
  8158. 5:40:16here you can see uh we are using request
  8159. 5:40:19package. We are hitting the URL. After
  8160. 5:40:21that we are getting the JSON uh HTML
  8161. 5:40:23response and we are extracting the
  8162. 5:40:25content. Okay. So everything is
  8163. 5:40:27performing with help of beautiful soup.
  8164. 5:40:29And once we got the content, we are
  8165. 5:40:30returning the cleanup. And if exception
  8166. 5:40:32is occurring, we're raising the
  8167. 5:40:33exception. Okay, that's why exception
  8168. 5:40:35handle is also important. If you're
  8169. 5:40:36using any third party services,
  8170. 5:40:38definitely you can use try accept block.
  8171. 5:40:40Okay, this is required. So yes guys, uh
  8172. 5:40:42this is the scrapper function we have
  8173. 5:40:45created. You can also test it whether
  8174. 5:40:46it's working or not. So maybe let's say
  8175. 5:40:48here what I will do, I'll try to import
  8176. 5:40:50it as well to scrap URL.
  8177. 5:40:54Uh so this returns, right? This is
  8178. 5:40:56returns
  8179. 5:40:59H. This returns okay
  8180. 5:41:04return. So what I can do I can
  8181. 5:41:11I can show you let's say
  8182. 5:41:14results.
  8183. 5:41:17So this takes a URL. Okay. So maybe I
  8184. 5:41:20can provide a URL.
  8185. 5:41:23Let's say
  8186. 5:41:26I'll copy this URL.
  8187. 5:41:33Copy this URL and
  8188. 5:41:36I'll give inside there.
  8189. 5:41:41Okay. Then I will print the result.
  8190. 5:41:45Now see what happens
  8191. 5:41:48here.
  8192. 5:41:50Python main.py
  8193. 5:42:00Still we are getting this title URL.
  8194. 5:42:03Why?
  8195. 5:42:06Oh, okay. We using websites. I have to
  8196. 5:42:08use scrapper URL. Okay, scrap URL. This
  8197. 5:42:11function. Sorry, my mistake. Now, let's
  8198. 5:42:13again execute.
  8199. 5:42:19Okay. Now see from that HTML I'm getting
  8200. 5:42:22the content. Okay. I'm getting the
  8201. 5:42:24important content. Okay. So this
  8202. 5:42:27function is doing that. So this function
  8203. 5:42:29is going to that particular URL. Okay.
  8204. 5:42:31This function is going to that
  8205. 5:42:32particular URL and extracting all of the
  8206. 5:42:35content. Okay. You can see extracting
  8207. 5:42:37all of the content relevant content.
  8208. 5:42:40Okay. And it is giving me here. Now this
  8209. 5:42:42content I'll try to pass to my next
  8210. 5:42:45agent here.
  8211. 5:42:49next agent. So let's say my second aent
  8212. 5:42:52uh second agent will try to extract uh
  8213. 5:42:55this informations and it will save in
  8214. 5:42:57the state memory. Now I can use my
  8215. 5:42:59writer agents to use this particular
  8216. 5:43:00content and prepare a draft for me.
  8217. 5:43:02Okay. And my critic agent will try to
  8218. 5:43:04review that. This is the work I think
  8219. 5:43:06you are getting. So this is called
  8220. 5:43:07actually uh team. Okay. This is called
  8221. 5:43:10actually team and uh we are using
  8222. 5:43:14uh we are using list of agents to
  8223. 5:43:15performing for performing actually uh
  8224. 5:43:18task okay multiple task we are
  8225. 5:43:20performing with the of multiple agents
  8226. 5:43:22one by one okay so this is the beauty of
  8227. 5:43:26multi- aents instead of using the single
  8228. 5:43:28agent now one more thing I want to show
  8229. 5:43:30you see as of now I have created these
  8230. 5:43:33are the tool as a function okay and now
  8231. 5:43:37if I want to use it as a tool so what I
  8232. 5:43:39have to I think you remember we have to
  8233. 5:43:40give a decorator. Yesterday also we did
  8234. 5:43:43the same thing. So we have already
  8235. 5:43:44imported this tool from Langchen. So now
  8236. 5:43:46I can give a decorator. So here just
  8237. 5:43:48simply give the tool decorator.
  8238. 5:43:51Whenever you are giving the tool
  8239. 5:43:52decorator now you can invoke. Okay you
  8240. 5:43:54can invoke this tool. Let me show you
  8241. 5:43:59tool decorator. Now let's say right now
  8242. 5:44:01what I'm doing uh here right now I just
  8243. 5:44:04need to call this function and give the
  8244. 5:44:07input like that. Right. Now we have
  8245. 5:44:09converted as a tool. Now I can perform
  8246. 5:44:10the invoke operation. So how to perform
  8247. 5:44:12the invoke operation? Let me show you.
  8248. 5:44:14So let's say this is my tool web search
  8249. 5:44:16tool. Simply I'll do the invoke
  8250. 5:44:18operation.
  8251. 5:44:20Invoke operation.
  8252. 5:44:23Now here is the question. Let's say I'll
  8253. 5:44:25give what is the latest research on
  8254. 5:44:28using AI for climate change migration.
  8255. 5:44:31Now whatever response I'll get I'll try
  8256. 5:44:33to save inside a variable. That's the
  8257. 5:44:35result
  8258. 5:44:37and I'm going to print it.
  8259. 5:44:40Now let me show you. This will work as a
  8260. 5:44:43tool.
  8261. 5:44:48See now this is working as a tool. Okay.
  8262. 5:44:50You can perform the invoke operation.
  8263. 5:44:53All right. So similar guys you can also
  8264. 5:44:54perform the invoke on the scrap URL.
  8265. 5:44:57Okay. Both it will work with the help of
  8266. 5:44:58invoke. So now guys our tool is ready.
  8267. 5:45:02uh we have created
  8268. 5:45:05uh all the tool like tabularly tool as
  8269. 5:45:07well as the beautiful soap scrapper tool
  8270. 5:45:10uh and it is already working. Now the
  8271. 5:45:13next part we can work on the uh agents
  8272. 5:45:17implementation. Okay. Now I'm going to
  8273. 5:45:19show you how we can implement the
  8274. 5:45:21agents. But before that let me commit
  8275. 5:45:22the changes. I can also commit from my
  8276. 5:45:24VS code. So here I can tell uh tools
  8277. 5:45:30uh created for
  8278. 5:45:34agent
  8279. 5:45:35oh that's a tools created okay I'll
  8280. 5:45:38commit and send the changes
  8281. 5:45:43done now if I go back
  8282. 5:45:46I'll close this other tab
  8283. 5:45:57refresh.
  8284. 5:45:59Now see tools added already. Okay. Fine.
  8285. 5:46:03Now let's try to work on the next part
  8286. 5:46:05which is agent implementation. Okay.
  8287. 5:46:08We'll try to implement the agent.
  8288. 5:46:13So guys uh to implement the agent I'm
  8289. 5:46:15going to open this uh agent folder.
  8290. 5:46:18Inside that I have agent.py. Let me open
  8291. 5:46:20it up. Uh I can close these are the file
  8292. 5:46:22as of now.
  8293. 5:46:26So first of all here what I have to do
  8294. 5:46:28guys I have to create my first agent
  8295. 5:46:31which is uh search agent. Okay search
  8296. 5:46:34agent. So basically this will have the
  8297. 5:46:36connection with tab API. So let's try to
  8298. 5:46:40create that. I'm going to import some
  8299. 5:46:42necessary library.
  8300. 5:46:45Um so these are the library I need.
  8301. 5:46:49These are the library I need. So one
  8302. 5:46:52more thing I think you can observe. Um
  8303. 5:46:55right now I'm importing langen.agent
  8304. 5:46:58import create agent. Okay. But
  8305. 5:47:01previously I imported create react
  8306. 5:47:04agent. Okay. There are some difference
  8307. 5:47:07between them. Now see because previously
  8308. 5:47:10I showed you I installed actually old
  8309. 5:47:13version of the langen. So in old version
  8310. 5:47:15langen they implemented create react
  8311. 5:47:18agent that means uh reasoning and action
  8312. 5:47:20agent. Okay but in the latest version in
  8313. 5:47:24the updated version modern langen they
  8314. 5:47:26have replaced with create agent. Okay
  8315. 5:47:29this particular function. So for this I
  8316. 5:47:33did a Google search. Let me show you the
  8317. 5:47:34result. See I told is create agent and
  8318. 5:47:37create react agent same in langen it's
  8319. 5:47:40telling no uh they are not same um uh
  8320. 5:47:44though they both serve similar purpose
  8321. 5:47:47in recent langen updates create agent
  8322. 5:47:49has become the standard streamline
  8323. 5:47:52function while create react agent is
  8324. 5:47:54older implementation. Okay. So what they
  8325. 5:47:56have done they have updated the langen
  8326. 5:47:58package and what they did they actually
  8327. 5:48:02also worked on this create react agent
  8328. 5:48:05they and they updated with this react
  8329. 5:48:07agent sorry create agent right now
  8330. 5:48:10because create agent is nothing but it's
  8331. 5:48:12the updated version of create react
  8332. 5:48:13agent and this is more stable more
  8333. 5:48:15standard. Okay, that's why they're
  8334. 5:48:17recommending don't use create react
  8335. 5:48:18agent instead of use create agent only
  8336. 5:48:20because this is more standard and stream
  8337. 5:48:22light function. It's not
  8338. 5:48:29it's not like that you can't use uh
  8339. 5:48:31react agent you can use uh create react
  8340. 5:48:34agent but um I think it's good to go
  8341. 5:48:37with the updated one always. Okay. Now
  8342. 5:48:40here are some um like difference between
  8343. 5:48:42them. So you can see create react agent.
  8344. 5:48:44This is the modern recommended method in
  8345. 5:48:47core lang package. It creates an agent
  8346. 5:48:49that execute a built-in loops of tools
  8347. 5:48:52calling using highly flexible modern
  8348. 5:48:54middleware system. And uh apart from
  8349. 5:48:57that this create uh react agent is a
  8350. 5:49:00older implementation b strictly on
  8351. 5:49:02foundation react reasoning acting okay
  8352. 5:49:04prompting uh paper. It was previously
  8353. 5:49:08able uh available one older version of
  8354. 5:49:10langen
  8355. 5:49:12but has been deprecated in u um create
  8356. 5:49:16agent. Okay, that means the latest one.
  8357. 5:49:17Okay, so basically I think remember
  8358. 5:49:20whenever we use this create react agent
  8359. 5:49:22function we have to use another
  8360. 5:49:24additional function which is agent
  8361. 5:49:25executor and that has to perform three
  8362. 5:49:27things. One is the thoughts then action
  8363. 5:49:30then observation. I think I showed you
  8364. 5:49:32the detailed discussion in my uh
  8365. 5:49:34previous agent implementation. If you
  8366. 5:49:36have missed out just try to check it
  8367. 5:49:37out. So there we used to run three
  8368. 5:49:39things thought action and observation.
  8369. 5:49:42And uh for running this three step we
  8370. 5:49:44used to use agent executor with this
  8371. 5:49:46create react agent. But right now in
  8372. 5:49:48create agent you don't need to use that
  8373. 5:49:50separately. So they have integrated
  8374. 5:49:52everything that means that thought
  8375. 5:49:53action and observation all of the
  8376. 5:49:55execution process in the loop they have
  8377. 5:49:57inbuilt with this create react agent. So
  8378. 5:49:59they will take care each and everything.
  8379. 5:50:01You don't need to do these are the part.
  8380. 5:50:03Okay. So that's why this is like more
  8381. 5:50:04standard and optimized version of create
  8382. 5:50:07uh create react agent. Okay. So that's
  8383. 5:50:09why we'll be using this create agent
  8384. 5:50:11right now. Okay. I hope it's clear guys.
  8385. 5:50:13So that's why in my code you can see
  8386. 5:50:14instead of importing this create react
  8387. 5:50:16agent. Where's the code? Yeah react
  8388. 5:50:19agent I'm importing create agent only.
  8389. 5:50:21Okay. And all the code are same like
  8390. 5:50:23openi chat openi. Then we are also
  8391. 5:50:26importing the prompt template. If I want
  8392. 5:50:27to give my custom prompt I can set my
  8393. 5:50:29prompt with help of chat prompt
  8394. 5:50:31template. Then output parser I need
  8395. 5:50:33because I'm going to use the LCL lang
  8396. 5:50:35lang expression language the
  8397. 5:50:37[clears throat] modern langen uh let's
  8398. 5:50:39say uh syntax. So that's why output
  8399. 5:50:41parser is required and to understand
  8400. 5:50:42this one definitely you have to go
  8401. 5:50:44through my langen lecture guys there I
  8402. 5:50:46have discussed each and everything what
  8403. 5:50:47is lclput parser is required each and
  8404. 5:50:50everything I have already explained then
  8405. 5:50:51from tools we are importing
  8406. 5:50:54uh this is not tools anymore so this
  8407. 5:50:56thing I can import like that so in my
  8408. 5:50:59main.py Pi I have already imported I
  8409. 5:51:00will copy
  8410. 5:51:02and I'll replace it here. Okay. So from
  8411. 5:51:05src uh from src tools
  8412. 5:51:09uh we have created web search tool and
  8413. 5:51:11scrapper tool. Okay. Both we have
  8414. 5:51:13created and we're importing and
  8415. 5:51:15initializing the now the first thing we
  8416. 5:51:17have to set up the model.
  8417. 5:51:20Uh so lm is equal to
  8418. 5:51:24chat openai.
  8419. 5:51:26So I'm going to use this model.
  8420. 5:51:29This model. So here I can comment model
  8421. 5:51:36initialization.
  8422. 5:51:39Okay. Model initialization. So we are
  8423. 5:51:41using this GPT4 mini model. You can use
  8424. 5:51:44any model GPT5 whatever you can use. And
  8425. 5:51:46this is the creativity parameter I have
  8426. 5:51:48given zero. So this will give you the
  8427. 5:51:50LLM object. So right now I'm going to
  8428. 5:51:52create my first agent which is this
  8429. 5:51:54agent called search agent. Let's try to
  8430. 5:51:57create it. Now see if you're using
  8431. 5:51:59modern lang chain that means create
  8432. 5:52:02create agent function. It's like super
  8433. 5:52:04easy only you just need to create a
  8434. 5:52:05function. I'm going to name it as let's
  8435. 5:52:07say build
  8436. 5:52:10search
  8437. 5:52:12agent
  8438. 5:52:18and simply you just need to return that
  8439. 5:52:20okay return what return your create
  8440. 5:52:23agent
  8441. 5:52:25okay create agent and this will take
  8442. 5:52:27actually some parameter the first
  8443. 5:52:29parameter takes the model so model is
  8444. 5:52:32equal to I'll pass my llm
  8445. 5:52:34second parameter it takes tools. Okay,
  8446. 5:52:37the tools you want to connect with this
  8447. 5:52:38agent. So I want to connect this tool
  8448. 5:52:41actually web search tool because my
  8449. 5:52:43first agent will try to connect with my
  8450. 5:52:45web search tool which is tab API. Okay,
  8451. 5:52:47so what I'm going to do I'm going to
  8452. 5:52:48call this web source and pass it here.
  8453. 5:52:51Okay, and there is another thing you can
  8454. 5:52:53perform I think which is system prompt.
  8455. 5:52:54Okay, system prompt you can pass you can
  8456. 5:52:57tell your agent what to do. But system
  8457. 5:52:59prompt I think it is already given in
  8458. 5:53:01default. Uh the same system prompt I
  8459. 5:53:03think I showed you right uh yesterday.
  8460. 5:53:05uh I u downloaded from langen hub. So
  8461. 5:53:08basically it explains about the agent
  8462. 5:53:10behavior. Okay, how to work. So I don't
  8463. 5:53:12need to give it here because this is my
  8464. 5:53:14um search agent. So basically it will
  8465. 5:53:16take take a prompt uh so take a topic
  8466. 5:53:19and it will perform the uh live search
  8467. 5:53:21operation over the internet and this
  8468. 5:53:23will return you the URL content. Okay,
  8469. 5:53:25with respect to that. So for this uh the
  8470. 5:53:27manual prompting is not required. I
  8471. 5:53:29think the default prompt is fine
  8472. 5:53:30completely. But if you want you can also
  8473. 5:53:31change the system prompt. Okay, it's
  8474. 5:53:33completely up to you. So you can
  8475. 5:53:35generate a system from from chat JP and
  8476. 5:53:37you can pass it here. So this is my
  8477. 5:53:38first agent. So this is my
  8478. 5:53:43first
  8479. 5:53:45agent.
  8480. 5:53:48Okay, which is s agent. Now I'm going to
  8481. 5:53:51work on my second agent
  8482. 5:53:56which is scrapping agent. Okay, that
  8483. 5:53:58means this one uh reader agent. Okay, we
  8484. 5:54:01can name it as reader reader agent.
  8485. 5:54:06reader agent. So let's create it. So
  8486. 5:54:09similar wise, I will create this agent
  8487. 5:54:11as well. I'll copy this code. And uh
  8488. 5:54:14here this is my read reader agent.
  8489. 5:54:21Okay. And this will take this scrap URL
  8490. 5:54:24tool because this will connected with my
  8491. 5:54:27beautiful soup. That's why we're passing
  8492. 5:54:29this
  8493. 5:54:30scrap URL tool in this particular agent.
  8494. 5:54:32And if you want you can also change the
  8495. 5:54:34system prompt here. But I think default
  8496. 5:54:36for prompt is fine with me. I'm not
  8497. 5:54:38going to change the prompt. Okay. So my
  8498. 5:54:41uh first agent and second agent is done.
  8499. 5:54:44Now I'll be working with my uh I'll be
  8500. 5:54:47working with my
  8501. 5:54:51um third agent and fourth agent and see
  8502. 5:54:53this third agent and fourth agent I'm
  8503. 5:54:55not going to create in that way. Instead
  8504. 5:54:56of that I can utilize the modern langen
  8505. 5:54:59chain functionality. Okay this is called
  8506. 5:55:00LCL chain. So I think this is enough u
  8507. 5:55:03because in lang chen we can use this lcl
  8508. 5:55:06chen uh uh for for this kinds of
  8509. 5:55:09operation. Okay this is also possible.
  8510. 5:55:11Now let me show you how it can be
  8511. 5:55:13initialized. See if you haven't watched
  8512. 5:55:15that my ll in my langen so try to watch
  8513. 5:55:18that otherwise it would be little bit
  8514. 5:55:20confusion uh for you but if you watch
  8515. 5:55:22that uh session I think it would be
  8516. 5:55:24clear. So I have already created let me
  8517. 5:55:26show you
  8518. 5:55:29this is my writer chain that means my
  8519. 5:55:33writer agent
  8520. 5:55:35see so first of all here you have to
  8521. 5:55:38prepare a prompt okay custom prompt so
  8522. 5:55:40I'm using the chat prompt template and
  8523. 5:55:43what I'm doing I'm giving a system
  8524. 5:55:45prompt you are expert research writer
  8525. 5:55:47write a clean structure and insightful
  8526. 5:55:49reports a human write a detailed uh
  8527. 5:55:52research on report on the topic below
  8528. 5:55:54Okay. So first of all I will give the
  8529. 5:55:56topic and this topic will come from the
  8530. 5:55:58human human input and this will take the
  8531. 5:56:01research. Okay. And where it will get
  8532. 5:56:03the research. It will get the research
  8533. 5:56:05from this reader agent. Okay. Because
  8534. 5:56:08reader agent will try to
  8535. 5:56:10first of all uh first agent what it will
  8536. 5:56:12do it will give the URL okay URL of the
  8537. 5:56:15relevant uh relevant actually sources
  8538. 5:56:18and the second agent will try to extract
  8539. 5:56:20the content and it will save in the
  8540. 5:56:22state memory and writer agent will try
  8541. 5:56:24to take those content and write this uh
  8542. 5:56:27draft for you. So that's why this
  8543. 5:56:29research we are taking it from my reader
  8544. 5:56:31agent. Okay. So this will automatically
  8545. 5:56:32go to the uh go to the writer agent.
  8546. 5:56:36Okay. Now here you can see structure
  8547. 5:56:38report as I need these are the
  8548. 5:56:39informations in that report.
  8549. 5:56:40Introduction, key findings, minimum
  8550. 5:56:42three world explained points,
  8551. 5:56:44conclusion, okay, and sources. That
  8552. 5:56:46means whatever URL you refer, just try
  8553. 5:56:48to also refer the URL in the research
  8554. 5:56:49topic. You can change this kinds of
  8555. 5:56:52prompt uh with respect to your
  8556. 5:56:53requirement. You you can generate a
  8557. 5:56:55detailed report, you can generate a
  8558. 5:56:56short report, you can generate more sub
  8559. 5:56:59point here. You can customize it. Okay.
  8560. 5:57:01Now be detailed and uh factual and
  8561. 5:57:04professional. Okay. This is the entire
  8562. 5:57:06palm. Now we are creating the chain. So
  8563. 5:57:08writer chain is equal to writer prompt.
  8564. 5:57:10First of all you have to give the
  8565. 5:57:11prompt. Then you have to give the llm.
  8566. 5:57:13Then you have to give the str output. So
  8567. 5:57:14what will happen? This prompt will go to
  8568. 5:57:16this llm. Lm will try to work on that
  8569. 5:57:18because lm is expecting the topic and
  8570. 5:57:20research. We are already getting from
  8571. 5:57:21the topic from the user and research
  8572. 5:57:23from my second agent which is uh reader
  8573. 5:57:25agent. Agent reader agents will return
  8574. 5:57:27the content research content and with
  8575. 5:57:29the help of this research content it
  8576. 5:57:31will refer and write that particular um
  8577. 5:57:34report. Okay, just try to think about if
  8578. 5:57:36I give you the recent let's say recent
  8579. 5:57:40let's say I'm searching for tell me the
  8580. 5:57:43latest AI tools. So if I give you the
  8581. 5:57:47if I give you the let's say uh source
  8582. 5:57:49content source content means let's say
  8583. 5:57:51in from the internet I have collected
  8584. 5:57:53some URL and from URL I have extracted
  8585. 5:57:55some uh let's say
  8586. 5:57:58um I have extracted the content of that
  8587. 5:58:00particular latest information and I have
  8588. 5:58:02given to you. So this is the content and
  8589. 5:58:04now just try to prepare a report on
  8590. 5:58:05that. So what you will do you'll just
  8591. 5:58:07try to refer that and prepare the report
  8592. 5:58:08for me. Okay, the same thing we are
  8593. 5:58:10doing here. So that's why we don't need
  8594. 5:58:12to create an individual uh agent like
  8595. 5:58:14that. Okay, it can be done with the help
  8596. 5:58:16of this LCL chain. Okay, very easy. Now
  8597. 5:58:19same we'll try to do it for my critic
  8598. 5:58:21chain as well.
  8599. 5:58:23That means this one. So this one is
  8600. 5:58:25done. Now we'll performing for this one.
  8601. 5:58:27Let's do it.
  8602. 5:58:29So this is my critic chain. So here also
  8603. 5:58:32we are doing the same thing. We are
  8604. 5:58:33creating the prompt template first of
  8605. 5:58:34all. So you are a sharp and constructive
  8606. 5:58:37s research critic. Be honest and
  8607. 5:58:40specific human. Review the research on
  8608. 5:58:42below and evaluate it strictly. So we
  8609. 5:58:44are giving the report. Report means this
  8610. 5:58:46writer agent whatever it will return
  8611. 5:58:48you. We'll try to pass here. Now it will
  8612. 5:58:50respond like that. First of all it will
  8613. 5:58:51give you this four strength areas to
  8614. 5:58:54improve one line uh verdict. Okay. Then
  8615. 5:58:58uh we are preparing [clears throat] the
  8616. 5:58:59chain. So critic chain is equal to
  8617. 5:59:01critic prompt that means my critic
  8618. 5:59:02prompt lm and st output. So this will
  8619. 5:59:04become your critic chain that means this
  8620. 5:59:06part is also ready. Okay. Now we have to
  8621. 5:59:08combine them all together to make all of
  8622. 5:59:11the agent uh work together. Okay. So
  8623. 5:59:14these kinds of things we'll be
  8624. 5:59:16performing in the pipeline. Now we'll
  8625. 5:59:17try to create the pipeline. We'll try to
  8626. 5:59:18combine this agents all together. That
  8627. 5:59:21means first of all first agent will come
  8628. 5:59:23whatever output we'll be getting we'll
  8629. 5:59:25try to save in the state memory. Then
  8630. 5:59:26second agent will try to receive that.
  8631. 5:59:28Then uh we'll try to connect this
  8632. 5:59:30stability tool with first agent. Then uh
  8633. 5:59:33this tool with the second agent already
  8634. 5:59:34this is done. Okay, I have already
  8635. 5:59:36connected this tool. As you can see this
  8636. 5:59:38tool is already connected. Then once it
  8637. 5:59:40is done we'll try to connect the writer
  8638. 5:59:41agent as well as the critic chain. Okay,
  8639. 5:59:43critic agent or chain whatever you can
  8640. 5:59:45say. Now let's try to see how we can uh
  8641. 5:59:48create this pipeline. So my agent is
  8642. 5:59:50ready
  8643. 5:59:52and my tools is ready. Now I'll be
  8644. 5:59:54working on the pipeline.
  8645. 5:59:58So guys, our agent and tools everything
  8646. 6:00:01are ready. Now we can work on the
  8647. 6:00:03pipeline. So in the pipeline I told you
  8648. 6:00:05we'll try to connect all of the agents
  8649. 6:00:07uh together and we'll also try to uh
  8650. 6:00:10connect the state memory there. So for
  8651. 6:00:12this uh let's open up this pipeline.py
  8652. 6:00:15file. Uh it's available inside
  8653. 6:00:16pipelines. I'll open it up. Uh now let
  8654. 6:00:20me show you how it can be done.
  8655. 6:00:23Okay. So for this first of all we have
  8656. 6:00:25to import um we have to import this
  8657. 6:00:28agent. Okay the agent we have created
  8658. 6:00:30that means my search agent then reader
  8659. 6:00:33agent then my writer chain as well as
  8660. 6:00:37the critic chain. Okay. So all these
  8661. 6:00:40thing we have to import one by one. Uh
  8662. 6:00:43this is the critic chain. So let's
  8663. 6:00:44import in the pipeline. So I'm going to
  8664. 6:00:46write from
  8665. 6:00:48uh from src
  8666. 6:00:50dot aagents dot agent. So I'm going to
  8667. 6:00:54import first of all
  8668. 6:00:58build reader
  8669. 6:01:01uh build a search agent
  8670. 6:01:05then build reader agent then writer
  8671. 6:01:10chain then my
  8672. 6:01:14critic chain
  8673. 6:01:16okay critic chain now what I'm going to
  8674. 6:01:19do guys I'm going to write a function
  8675. 6:01:23Um already I prepared this function. Let
  8676. 6:01:25me show you what it will do.
  8677. 6:01:33Yeah.
  8678. 6:01:35So first of all I'll try to
  8679. 6:01:42add this.
  8680. 6:01:49So this is the function guys. Let me
  8681. 6:01:51explain. H
  8682. 6:01:55yeah so you can see the function name I
  8683. 6:01:57have kept run resource pipeline so this
  8684. 6:02:00will take the topic whatever topic user
  8685. 6:02:02will pass uh so first of all what I'm
  8686. 6:02:05doing guys I'm uh taking a state
  8687. 6:02:07dictionary here okay so why I'm taking a
  8688. 6:02:10dictionary because I told you we'll be
  8689. 6:02:11creating a state memory okay state
  8690. 6:02:13memory this is a temporary memory uh
  8691. 6:02:15once agent has executed uh successfully
  8692. 6:02:18then this uh particular memory would be
  8693. 6:02:20cleared so that's I told you later on if
  8694. 6:02:22you want you can also add the permanent
  8695. 6:02:24memory by adding some u memory database
  8696. 6:02:27that thing I'm going to definitely
  8697. 6:02:28discuss in future but as of now just try
  8698. 6:02:30to consider this is our this is our
  8699. 6:02:33state uh memory we are taking as a
  8700. 6:02:35dictionary. So every state it will try
  8701. 6:02:37to save some data inside that particular
  8702. 6:02:39dictionary. So first of all I'm just
  8703. 6:02:41doing a print statement uh just to see a
  8704. 6:02:44beautiful logs in my terminal. Okay. So
  8705. 6:02:47we are first of all telling searching
  8706. 6:02:49agent is working. Then we're giving like
  8707. 6:02:5150 uh this uh equal sign. Okay. Now what
  8708. 6:02:54we are calling guys? We're calling now
  8709. 6:02:56build s agent. Uh so we are creating an
  8710. 6:02:58object of that particular agent. Then we
  8711. 6:03:00are invoking it. Okay. What we are
  8712. 6:03:02invoking? We are invoking without
  8713. 6:03:04prompt. So user is giving a prompt. Find
  8714. 6:03:06the recent realable and detailed
  8715. 6:03:08information about this topic. And from
  8716. 6:03:10where we are getting the topic. Topic
  8717. 6:03:12will be given by the user. Okay. From
  8718. 6:03:14the user interface we'll try to pass the
  8719. 6:03:16topic. So this topic will come here. So
  8720. 6:03:18this uh search agent what it will do it
  8721. 6:03:20will use tably search API it will search
  8722. 6:03:22over the internet of that particular
  8723. 6:03:24topic and this will return you the
  8724. 6:03:26result. Okay, this will return the
  8725. 6:03:28search result. What would be the search
  8726. 6:03:29result? I think you remember this will
  8727. 6:03:31return you these are the search result
  8728. 6:03:34that means the title, URL and snippet
  8729. 6:03:37that means the content. Okay. So this is
  8730. 6:03:39the work of the first agent. You can see
  8731. 6:03:42and this particular state the first
  8732. 6:03:44agent whatever it is returning I'm going
  8733. 6:03:46to save inside state memory. So this is
  8734. 6:03:48what we are doing. You can see we are
  8735. 6:03:49calling this state and I'm adding a new
  8736. 6:03:52key which is search result and we're
  8737. 6:03:54storing this particular result in that
  8738. 6:03:56particular memory. Okay, you can see
  8739. 6:03:58search result. Uh we are getting the
  8740. 6:04:00message and we're getting the content of
  8741. 6:04:02that. Okay, content of that and we're
  8742. 6:04:04stringing uh storing in the state memory
  8743. 6:04:06and once it is done we're also printing
  8744. 6:04:08that particular memory what is we have
  8745. 6:04:11inside that particular state. Okay, so
  8746. 6:04:13this is for my first agent. So we have
  8747. 6:04:15completed till here. Now we will be
  8748. 6:04:18creating this particular option my
  8749. 6:04:20second agent. So this will connect it
  8750. 6:04:22with my previous state. It will take the
  8751. 6:04:24data and it will run my second state and
  8752. 6:04:25whatever output we'll be getting we'll
  8753. 6:04:27try to save in the state memory again.
  8754. 6:04:28So let's try to work on that. So my
  8755. 6:04:31second step my reader agent.
  8756. 6:04:34So this is my reader agent.
  8757. 6:04:38Yeah reader agent. Again I'm doing some
  8758. 6:04:40print statement. Now you can see I'm
  8759. 6:04:42initializing my reader agent. Again we
  8760. 6:04:44are doing the invoking operation of the
  8761. 6:04:45reader agent. Then we are giving the
  8762. 6:04:47prompt user based on the following
  8763. 6:04:49search topic. Uh so topic we are getting
  8764. 6:04:51from here. Okay. Uh pick the most
  8765. 6:04:54relevant URL and scrap it for deeper
  8766. 6:04:57content. That means it will scrap that
  8767. 6:04:59particular URL. And whatever let's say
  8768. 6:05:03uh URL we are having we are also passing
  8769. 6:05:05from my state. You can see we're calling
  8770. 6:05:07the state and I think you remember we
  8771. 6:05:09created a key called search result.
  8772. 6:05:10search result we are giving that
  8773. 6:05:12particular um I mean content that means
  8774. 6:05:17whatever URL my first agent has
  8775. 6:05:20extracted uh my first agent got from my
  8776. 6:05:23tab we have stored here and my second
  8777. 6:05:26agent is reading from that particular
  8778. 6:05:27state you can see it is reading from
  8779. 6:05:29that particular state that means all of
  8780. 6:05:30the URL title it will get then it will
  8781. 6:05:32perform the scrapping operation and
  8782. 6:05:34whatever scrap result we'll be getting
  8783. 6:05:35again we are saving in the state memory
  8784. 6:05:37again I'm creating another key called
  8785. 6:05:39scrap content inside this state and we
  8786. 6:05:41are saving the content inside that very
  8787. 6:05:44simple okay then we are printing that
  8788. 6:05:46particular content so this part is also
  8789. 6:05:48done second agent and second agent
  8790. 6:05:50response we are saving in the state
  8791. 6:05:52memory now we have to work on the writer
  8792. 6:05:54and uh critic now let's do it so first
  8793. 6:05:57of all I'm going to write my
  8794. 6:06:00writer
  8795. 6:06:03so this is the writer you can see again
  8796. 6:06:05I'm doing the print statement for
  8797. 6:06:06beautiful logs now we can
  8798. 6:06:10We created a uh variable here. So this
  8799. 6:06:12variable having two information. One is
  8800. 6:06:14the source result. Okay, source result
  8801. 6:06:17and one is the detail scrap content.
  8802. 6:06:19Okay, the search result we are getting
  8803. 6:06:20from where we're getting from uh this uh
  8804. 6:06:24source result. Okay, then what we are
  8805. 6:06:26doing? We are also getting the scrap
  8806. 6:06:28content. Scrap content means nothing but
  8807. 6:06:30uh my previous okay previous whatever
  8808. 6:06:32scrap content we got, we have in the
  8809. 6:06:35state memory, we are also getting that.
  8810. 6:06:36Okay, we are getting the scrap content.
  8811. 6:06:38Now we are writing our chain. You can
  8812. 6:06:40see uh chain.invoke. We are giving the
  8813. 6:06:43topic as well as the research combined.
  8814. 6:06:45That means both of the example we are
  8815. 6:06:46giving. Why we are giving the search
  8816. 6:06:48result? Because I told you I think you
  8817. 6:06:50remember here
  8818. 6:06:51if I show you my writer agent.
  8819. 6:06:56Writer agent. Okay. So here I uh told
  8820. 6:07:01uh you have to also mention the sources.
  8821. 6:07:03Okay. Sources uh list of the URL found
  8822. 6:07:05in the research. Okay. And if I want to
  8823. 6:07:08list down all the URL, so definitely I
  8824. 6:07:09have to pass the URL as a reference. So
  8825. 6:07:11this is what we are passing here. All
  8826. 6:07:13the URL we are passing. And whatever
  8827. 6:07:15content we got from the URL, we also
  8828. 6:07:17passing that. So it will prepare a draft
  8829. 6:07:19for me. And this particular draft report
  8830. 6:07:20we are again saving in the state memory.
  8831. 6:07:23Okay, we are saving in the state memory.
  8832. 6:07:25So that my critic chain can refer and it
  8833. 6:07:28can uh uh review that you can give the
  8834. 6:07:30feedback then we can get the final
  8835. 6:07:32output. Okay, so you can see we are
  8836. 6:07:33storing in the state memory and we are
  8837. 6:07:35printing that. Now the last things we
  8838. 6:07:37have to write the critic report.
  8839. 6:07:41Uh so this is the critic report. Again
  8840. 6:07:43we're doing the print statement. After
  8841. 6:07:45that uh we are calling the critics and
  8842. 6:07:47invoke and we're giving this report. The
  8843. 6:07:50last uh state was the report. We are
  8844. 6:07:53passing the report. Okay. So this will
  8845. 6:07:56basically take the feedback and again
  8846. 6:07:57I'm storing in the state memory as a
  8847. 6:08:00feedback and we are printing it here.
  8848. 6:08:02Okay. And we're returning the state. So
  8849. 6:08:04yeah this is the pipeline guys that
  8850. 6:08:06means this connection we have done
  8851. 6:08:07perfectly. Now let's test it whether
  8852. 6:08:09it's working or not. So what I will do?
  8853. 6:08:11So in the main.py I'm going to test it.
  8854. 6:08:15So simply here let's try to import first
  8855. 6:08:17of all this uh this function.
  8856. 6:08:22This is the main function run resource
  8857. 6:08:24pipeline. So here I'm going to import
  8858. 6:08:26it. So from src
  8859. 6:08:32dot pipelines
  8860. 6:08:34dot pipeline
  8861. 6:08:36import
  8862. 6:08:39run resource pipeline. Okay. Now simply
  8863. 6:08:42here I'm going to take a topic is equal
  8864. 6:08:44to let's say the impact of AI job market
  8865. 6:08:50in 2026.
  8866. 6:08:52Let's say this is my topic. Now I'll
  8867. 6:08:54going to pass inside my
  8868. 6:08:59run resource pipeline. Okay, run
  8869. 6:09:02resource pipeline. So basically what it
  8870. 6:09:04will do, it will
  8871. 6:09:06give you the final result. Okay, final
  8872. 6:09:09result. And although we are printing so
  8873. 6:09:11that's why we don't need to store it
  8874. 6:09:12here. So it will print in the terminal.
  8875. 6:09:15Now let me show you. I'll clear I'll run
  8876. 6:09:19my main.py.
  8877. 6:09:22Now see first of all research uh search
  8878. 6:09:24agent is working.
  8879. 6:09:37Now we got the uh source result okay
  8880. 6:09:40with URL. Now my second reader agent is
  8881. 6:09:43working. It is scrapping all of the
  8882. 6:09:45informations from the URL
  8883. 6:09:48on that topic.
  8884. 6:09:51Now see we got the
  8885. 6:09:54um content. Now my writer agent is
  8886. 6:09:57drafting the report.
  8887. 6:10:01Now it will prepare the report by
  8888. 6:10:03utilizing this content as well as the
  8889. 6:10:05URL. Now see my
  8890. 6:10:09final report is ready and it has also
  8891. 6:10:11given you the sources whatever sources
  8892. 6:10:13it has referred. Now critic agent is
  8893. 6:10:15also working and it has given you the
  8894. 6:10:16report. It told okay you got six out of
  8895. 6:10:1910 and there is some strength point here
  8896. 6:10:21is the areas of improvement and here is
  8897. 6:10:23the oneline verdict okay amazing that
  8898. 6:10:26means all of my agents are working
  8899. 6:10:28perfectly guys okay all of my agents are
  8900. 6:10:30working perfectly there is no error and
  8901. 6:10:32it is working together okay it is
  8902. 6:10:34working together and we're getting a
  8903. 6:10:36very detailed report on my given topic
  8904. 6:10:38okay but this thing I have to execute
  8905. 6:10:40from my terminal and it's not like uh
  8906. 6:10:42readable properly and if I give it to
  8907. 6:10:45like non-coder guy so definitely he
  8908. 6:10:46won't be able to execute that agent. So
  8909. 6:10:49what I can do maybe I can add a user
  8910. 6:10:50interface here. Uh to add the user
  8911. 6:10:53interface you can use uh any kinds of
  8912. 6:10:55framework. If you know front end
  8913. 6:10:56development you can use React NexJS.
  8914. 6:10:59Okay you can do it for you. But if you
  8915. 6:11:01don't know about HTML CSS React uh React
  8916. 6:11:04NexJS okay completely fine. There is a
  8917. 6:11:07library inside Python called streaml
  8918. 6:11:08with help of streaml you can create a
  8919. 6:11:10user interface. And again you don't need
  8920. 6:11:11to write the code from scratch. You can
  8921. 6:11:13use chat gpt. simply uh give this uh
  8922. 6:11:16pipeline code to the chart GPT and tell
  8923. 6:11:18just try to add a streaml UI interface
  8924. 6:11:20with that. So I have done the same
  8925. 6:11:21thing. So what I did guys with my chart
  8926. 6:11:23GPT I have generated a user interface
  8927. 6:11:26with the help of my streaml. Okay. So
  8928. 6:11:28charge GPT has given me a code. Let me
  8929. 6:11:30show you how this code looks like. So
  8930. 6:11:32this is the code.
  8931. 6:11:35This is the code. Okay. So you can see
  8932. 6:11:37this is a streamlit uh development.
  8933. 6:11:40Okay. I have to import this one only.
  8934. 6:11:43uh instead of importing like that in the
  8935. 6:11:45app.py I have to import like that. Yeah.
  8936. 6:11:47SRC agent, uh, build agent, uh, reader
  8937. 6:11:50agent, writer agent and prediction.
  8938. 6:11:52Fine. So, first of all, you can see it
  8939. 6:11:54is utilizing streaml and we have already
  8940. 6:11:56installed streaml inside our requirement
  8941. 6:11:58as you can see. Then we it is setting
  8942. 6:12:01the page configuration. It is adding
  8943. 6:12:03some custom CSS for the designing of my
  8944. 6:12:07um UI. Okay. Some color, background and
  8945. 6:12:10images. It has added uh some other like
  8946. 6:12:13markdown it has added. Okay. some HTML
  8947. 6:12:15content has added. See in streaml also
  8948. 6:12:17you can add HTML and CSS but again I
  8949. 6:12:20told you if you don't it's completely
  8950. 6:12:21fine just open up your any kinds of uh
  8951. 6:12:24assistant gemini or chat GPT or cloud
  8952. 6:12:27and try to give this pipeline.py Pi and
  8953. 6:12:29tell like okay I just need to add HTML
  8954. 6:12:33UI it will add it whatever user
  8955. 6:12:35interface you are getting just try to
  8956. 6:12:36run okay nobody's actually remember HTML
  8957. 6:12:39CSS nowadays okay because we have this
  8958. 6:12:41kinds of uh flexibility now this is a
  8959. 6:12:44simple actually uh interface we have
  8960. 6:12:47created with the help of streamlit again
  8961. 6:12:49you don't need to understand this code
  8962. 6:12:50uh this is like uh AI generated uh user
  8963. 6:12:54interface it's completely fine but there
  8964. 6:12:56would be definitely uh other guy in the
  8965. 6:12:58company they will be working on the
  8966. 6:13:00front- end development as per the
  8967. 6:13:01company requirement. Okay. But as a uh
  8968. 6:13:04agent engineer we don't need to worry
  8969. 6:13:05about the user interface but to run our
  8970. 6:13:07agent I need a user interface so that I
  8971. 6:13:10can show to my manager I can show to my
  8972. 6:13:12let's say customer uh so that uh they
  8973. 6:13:14can test my agent okay in the user
  8974. 6:13:16interface uh background okay instead of
  8975. 6:13:18giving the terminal access. So now if I
  8976. 6:13:21want to execute my app.py what I have to
  8977. 6:13:23do guys I have to run this app.py. So
  8978. 6:13:25simply I'm going to write a streaml
  8979. 6:13:28run
  8980. 6:13:30app.py. Now if I execute this will run
  8981. 6:13:34my app here and all of the code I'm
  8982. 6:13:37going to share guys in my description
  8983. 6:13:38from there you can execute. See guys
  8984. 6:13:40this is the user interface. I think this
  8985. 6:13:42is amazing right? My chat GPT has
  8986. 6:13:44created this user interface for me and
  8987. 6:13:46it has named it as research agent
  8988. 6:13:48because in the prompt I told this should
  8989. 6:13:50be the research uh research agent. So
  8990. 6:13:52that's why it has named like researcher
  8991. 6:13:54agent. Okay. Multi- aent AI system. Uh
  8992. 6:13:57four specialized AI agents collaborate
  8993. 6:13:59searching, scrapping, writing and
  8994. 6:14:01creating to deliver a polished research
  8995. 6:14:03uh report on a given topic. Amazing.
  8996. 6:14:05Right? Now here you can see uh here I
  8997. 6:14:08have the input option that means I can
  8998. 6:14:09pass any kinds of research topic. Even
  8999. 6:14:11it has also given some suggestion like
  9000. 6:14:13you can try with these are the example.
  9001. 6:14:15Okay, this is amazing. Now there is a
  9002. 6:14:16button. If I click on the button my
  9003. 6:14:19agent will be executing and these are
  9004. 6:14:20the pipeline I'm having inside my agent.
  9005. 6:14:22That means the first pipeline the search
  9006. 6:14:24agent. Second pipeline reser agent. Uh
  9007. 6:14:26third is the writer ch. Fourth is the
  9008. 6:14:28critic chain. And right now the starter
  9009. 6:14:30is waiting. Okay. Now let me try whether
  9010. 6:14:33it's working or not. So maybe what I can
  9011. 6:14:35do maybe I can uh copy the same example
  9012. 6:14:38or you can also write some other thing
  9013. 6:14:39if you want. Now simply run the research
  9014. 6:14:42pipeline.
  9015. 6:14:44Now see first of all my first agent is
  9016. 6:14:47working. Search agent is working. It is
  9017. 6:14:49searching with the help of tab API.
  9018. 6:14:51Let's see.
  9019. 6:14:58Done. Now my research agent is
  9020. 6:14:59scrapping. Sorry, reader agent is
  9021. 6:15:01scrapping the top resources from the
  9022. 6:15:03URL.
  9023. 6:15:12Now my writer agent is drafting the
  9024. 6:15:14entire report.
  9025. 6:15:16Okay. So step by step it is working.
  9026. 6:15:18Amazing. Right. The same things you can
  9027. 6:15:19also perform in your anti-gabit VS code
  9028. 6:15:21or Google cloud or charge GPT. You'll
  9029. 6:15:25see that it will also work step by step
  9030. 6:15:27using the agent mode. Right? So the same
  9031. 6:15:29thing we have developed here. Now see my
  9032. 6:15:31critic agent is reviewing the report
  9033. 6:15:36and that's how multi- aent system works.
  9034. 6:15:37Now see it's done. Now here you can see
  9035. 6:15:40the status is already done. All the
  9036. 6:15:42pipeline is completed successfully.
  9037. 6:15:43There is no error. That means amazing
  9038. 6:15:45beautiful user interface it has created.
  9039. 6:15:47Now just below you can see this is the
  9040. 6:15:49result even you can see the individual
  9041. 6:15:52uh actually execution let's say my
  9042. 6:15:55search result my search agent has
  9043. 6:15:58searched right what it has search you
  9044. 6:16:00will see see that it has got the URL and
  9045. 6:16:03this is the URL it has got the content
  9046. 6:16:05from medium the snippet that means the
  9047. 6:16:07introduction part then this is the title
  9048. 6:16:11okay title URL introduction part then
  9049. 6:16:13this is the title URL introduction part
  9050. 6:16:15okay that's how it is having five
  9051. 6:16:16information. Okay, five information.
  9052. 6:16:19Now, second agent that scrap the content
  9053. 6:16:21from the URL. Now, you can see this is
  9054. 6:16:23the extracted content from all the five
  9055. 6:16:25uh URL. Uh this is how it has extracted
  9056. 6:16:29okay and refined and this is the final
  9057. 6:16:32uh research report we got. Okay. On this
  9058. 6:16:35AGI development in next five year
  9059. 6:16:37introduction, key findings. So, it has
  9060. 6:16:39written all of this thing. Then
  9061. 6:16:40conclusion. Now, if you want to make it
  9062. 6:16:42more detailed, you can change in the
  9063. 6:16:43prompt itself. I think remember So here
  9064. 6:16:45is the prompt uh here is the prompt
  9065. 6:16:49in agent.py. So here you can uh increase
  9066. 6:16:52that particular section. Okay. If you
  9067. 6:16:54increase it will try to add that. Then
  9068. 6:16:56sources whatever sources it has referred
  9069. 6:16:58it also giving you the URL. You can see
  9070. 6:17:00one by one all of the URL it has given
  9071. 6:17:02you. Okay. Amazing. Now you can also
  9072. 6:17:06download it as a MD file. Okay. U my
  9073. 6:17:08chart GPT also added another button
  9074. 6:17:10here. I can also download as a MD file
  9075. 6:17:12if I want and I can open it up. Then
  9076. 6:17:15this is the critic feedback. So you can
  9077. 6:17:17see score got six out of 10. This is the
  9078. 6:17:20strength that means still uh uh sorry
  9079. 6:17:23this is the strength that means of this
  9080. 6:17:24particular report like the report
  9081. 6:17:26provides a clear timeline for a
  9082. 6:17:27development blah blah blah. It address
  9083. 6:17:29both technological and ethical
  9084. 6:17:31consideration. Still areas to
  9085. 6:17:34improvement are there you can improve.
  9086. 6:17:36These are the section maybe in the next
  9087. 6:17:38um prompt itself you can add these are
  9088. 6:17:40the point here. Okay, these are the
  9089. 6:17:42point here to improve that particular
  9090. 6:17:45response and uh this is the one verdict
  9091. 6:17:48uh line it has written. Okay, amazing.
  9092. 6:17:51Now let me try with another prompt. So
  9093. 6:17:53what I will do? So maybe I can ask like
  9094. 6:17:56um all latest AI agent in 2026.
  9095. 6:18:00This example run the resource pipeline.
  9096. 6:18:03again. My agent is working
  9097. 6:18:17now. Reader agent is tapping.
  9098. 6:18:28Now my writer agent is drafting the
  9099. 6:18:29report.
  9100. 6:18:48Critic is reviewing the report
  9101. 6:18:53and my agent has executed. Now this is
  9102. 6:18:55my search result. This is the scrap
  9103. 6:18:57content result. Okay, you can see here
  9104. 6:19:00and uh this is the final okay final
  9105. 6:19:02research report on latest AI agency
  9106. 6:19:042026. This is the report. This is the
  9107. 6:19:07sources you can download. Even this is
  9108. 6:19:09the critic feedback. Okay. Amazing. It's
  9109. 6:19:11working perfectly. Now if you want you
  9110. 6:19:13can also change the title. Uh then you
  9111. 6:19:15can also change this uh you can also
  9112. 6:19:17change this okay this content from this
  9113. 6:19:19team itself. you can go to the code and
  9114. 6:19:22maybe you can find out that section
  9115. 6:19:23where it has added um
  9116. 6:19:29so I think there is a
  9117. 6:19:32so the best part is that like you can
  9118. 6:19:34search okay so let's I'll copy this
  9119. 6:19:37and uh here I can search Ctrl Ftrl V
  9120. 6:19:46ah so here here itself you can change it
  9121. 6:19:48here okay Now
  9122. 6:19:53you can also change this title. Change
  9123. 6:19:56this title if you want. Let's say uh
  9124. 6:19:58here I think researcher agent. So I can
  9125. 6:20:01make it as
  9126. 6:20:03let's say research agent. I'll save it.
  9127. 6:20:08If I come here refresh now it will
  9128. 6:20:10become research agent. Okay that's how
  9129. 6:20:12you can change the title whatever you
  9130. 6:20:14want. Okay. Everything is possible but
  9131. 6:20:15I'll keep my researcher agent only.
  9132. 6:20:19So you just need to figure out where to
  9133. 6:20:20change this UI interface and you can
  9134. 6:20:23also change the color. Even if you want
  9135. 6:20:24you can also design this UI interface
  9136. 6:20:26with respect to your requirement. It's
  9137. 6:20:28completely fine. That means my agent is
  9138. 6:20:30working fine. We have already tested.
  9139. 6:20:31Now we'll commit the changes. Uh
  9140. 6:20:35agents
  9141. 6:20:37working and tested.
  9142. 6:20:43Now we'll try to deploy this agent.
  9143. 6:20:51So simply uh what I can do I can go to
  9144. 6:20:54my GitHub refresh.
  9145. 6:20:56Okay my agent is ready. Now if you want
  9146. 6:20:59you can also update the readmi file. So
  9147. 6:21:01nowadays updating readmi file is super
  9148. 6:21:03easy. Just open the agent inside your VS
  9149. 6:21:06code and try to mention
  9150. 6:21:09update the readme file for this
  9151. 6:21:16project
  9152. 6:21:18like a open source
  9153. 6:21:23repo.
  9154. 6:21:28Mention
  9155. 6:21:30how to
  9156. 6:21:32install
  9157. 6:21:36and
  9158. 6:21:38technologies
  9159. 6:21:40used here
  9160. 6:21:46if
  9161. 6:21:52architectures.
  9162. 6:21:54So now I'll send this prompt. So
  9163. 6:21:56automatically it will try to understand
  9164. 6:21:57my entire code code base all the code
  9165. 6:22:01all of the agents tool everything and it
  9166. 6:22:02will prepare the readme file for me okay
  9167. 6:22:05so you don't need to write manually
  9168. 6:22:06after generating you can customize okay
  9169. 6:22:08so let me quick do it quickly so that I
  9170. 6:22:10can update in my repo then I will show
  9171. 6:22:12you the deployment now see it is
  9172. 6:22:14evaluating see it is also working step
  9173. 6:22:17by step right first of all it is editing
  9174. 6:22:18the file evaluating the file that's how
  9175. 6:22:20it is running multiple agents in the
  9176. 6:22:22back end okay things are working like
  9177. 6:22:24that now see once it it needs any kinds
  9178. 6:22:26of human permission it will tell me I'll
  9179. 6:22:29give the permission again it will work
  9180. 6:22:31you can also give this kinds of human in
  9181. 6:22:33loop permission I will also show you in
  9182. 6:22:34future this kinds of thing now in the
  9183. 6:22:36readmi file see it has updated my readmi
  9184. 6:22:39now you can uh see here you can simply
  9185. 6:22:42open the preview and this is the update
  9186. 6:22:44okay this is the update you can see
  9187. 6:22:47amazing right now what I can do maybe I
  9188. 6:22:50can commit the changes
  9189. 6:22:54readme updated it
  9190. 6:22:57always try to update the readmi uh
  9191. 6:22:59because with the help of readmi file
  9192. 6:23:01user will be able uh I mean some other
  9193. 6:23:03people will be able to use your repo and
  9194. 6:23:06definitely whenever you are adding
  9195. 6:23:08project in your resume you have to
  9196. 6:23:09update the readmi in a proper github um
  9197. 6:23:12repository now see this is uh updated
  9198. 6:23:15now see this is this looks cool right
  9199. 6:23:17this looks like a like professional
  9200. 6:23:19project okay professional opensource
  9201. 6:23:21project you can see it has added all of
  9202. 6:23:23the features architectures
  9203. 6:23:25Okay. And then agent responsible
  9204. 6:23:27technology used prerequisite
  9205. 6:23:30installation process. Okay. Then uh get
  9206. 6:23:33your own API keys. How to get the API
  9207. 6:23:34keys? Uses streamly UI. Then project
  9208. 6:23:37folder structure workflow example output
  9209. 6:23:40contributing license acknowledgement and
  9210. 6:23:42supports. Amazing. Right? Now let's try
  9211. 6:23:44to deploy this project. So to deploy
  9212. 6:23:46this project either you can use u paid
  9213. 6:23:49google uh paid actually cloud services
  9214. 6:23:51like AWS, GCP, Azure or you can use any
  9215. 6:23:55uh other platform where you can uh
  9216. 6:23:57freely deploy this project. See there is
  9217. 6:24:00a platform called rendercloud. I think
  9218. 6:24:01previous project also I showed you this
  9219. 6:24:03render.com. So render.com also you can
  9220. 6:24:06uh deploy any kinds of AI application.
  9221. 6:24:08You can see first path to production for
  9222. 6:24:11the workflow you can deploy it here. But
  9223. 6:24:13the best part is that here you will be
  9224. 6:24:15getting a free instance. Okay, there you
  9225. 6:24:16can deploy the project. But although
  9226. 6:24:18this instance is like very low but still
  9227. 6:24:20I think for landing it is fine. But if
  9228. 6:24:22you want to uh professionally deploy
  9229. 6:24:24that time you have to take the
  9230. 6:24:25subscription. But in AWS GCP I don't
  9231. 6:24:27free I don't uh freely actually deploy.
  9232. 6:24:30We can't freely deploy there right? So
  9233. 6:24:31that's why we're using render. So first
  9234. 6:24:33of all you have to create an account in
  9235. 6:24:34render. I already have the account. So
  9236. 6:24:35I'll click on my dashboard.
  9237. 6:24:40Okay. So previously I already hosted
  9238. 6:24:43another application as you can see. Now
  9239. 6:24:45let me create a new web service.
  9240. 6:24:53Okay. Now I'll click on public git
  9241. 6:24:55repository and I'll just try to give my
  9242. 6:24:58repository link here. Then you have to
  9243. 6:25:01connect it.
  9244. 6:25:08Okay. Once it is done you can change the
  9245. 6:25:09name. By default it it has taken my
  9246. 6:25:11repository name. Everything would be
  9247. 6:25:14same. No need to change anything. Only
  9248. 6:25:16you have to give a start command here.
  9249. 6:25:18So to run a streaml app you have to give
  9250. 6:25:21this command.
  9251. 6:25:23Okay. Streamlitly run app.py server port
  9252. 6:25:25server address 00 and it will
  9253. 6:25:27automatically install my requirement.xt
  9254. 6:25:29whatever I'm having here. Okay. Once it
  9255. 6:25:31is done now I'll take the free plan. So
  9256. 6:25:33initially it will get 512 MB RAM and 0.1
  9257. 6:25:36CPU. This is enough for I think learning
  9258. 6:25:39but whenever you want to professionally
  9259. 6:25:41deploy it you can take the subscription
  9260. 6:25:43plan. Now you have to set the
  9261. 6:25:44environment variable because environment
  9262. 6:25:46variable it's not available in my
  9263. 6:25:48GitHub. So I have my open AI and uh this
  9264. 6:25:51table API both I'll add it here. So pi
  9265. 6:25:56give the value.
  9266. 6:26:09Okay. Now I'll add my another
  9267. 6:26:12environment variable which is
  9268. 6:26:15tabi.
  9269. 6:26:30Okay. Once it is done, now simply click
  9270. 6:26:32on deploy web service.
  9271. 6:26:37Now it will set up everything in that
  9272. 6:26:39particular instance. Maybe it will take
  9273. 6:26:41some time because we are using free
  9274. 6:26:42instance. Uh we'll wait once this
  9275. 6:26:45installation everything is complete. I
  9276. 6:26:46will come back.
  9277. 6:26:50Now see it is installing requirement
  9278. 6:26:52txt.
  9279. 6:26:54Let's wait get once this status is live.
  9280. 6:26:56I'll come back.
  9281. 6:27:41So guys, as you can see, my uh build is
  9282. 6:27:44successful and application is live. Now
  9283. 6:27:46I can copy this URL, open up my browser,
  9284. 6:27:48paste it and hit enter. Now this will
  9285. 6:27:51load your application.
  9286. 6:27:59So initially it may take some time. uh
  9287. 6:28:01you have to wait once this has loaded
  9288. 6:28:04then you will be able to use that.
  9289. 6:28:09So guys, as you can see, this is our
  9290. 6:28:11application is live. Now you can share
  9291. 6:28:12this URL with anyone. They can use it.
  9292. 6:28:15Now let's try. Maybe I can copy this
  9293. 6:28:17prompt
  9294. 6:28:19and I will test it.
  9295. 6:28:24See, it's working.
  9296. 6:28:38My
  9297. 6:28:40search agent is working right now.
  9298. 6:28:45Now reader agent is working.
  9299. 6:28:58Now writer agent is drafting the report.
  9300. 6:29:10and critic agent is reviewing the
  9301. 6:29:12report.
  9302. 6:29:22Okay, all of the execution is complete.
  9303. 6:29:24Now, here is the final result. You can
  9304. 6:29:26expand and see this is the search
  9305. 6:29:28result. This is the scrap content and
  9306. 6:29:30this is our final result we got. Okay.
  9307. 6:29:33Yeah. So this is the sources you can
  9308. 6:29:34download also critic feedback.
  9309. 6:29:36Everything is visible. So yes guys, I
  9310. 6:29:38think uh it's working fine perfectly.
  9311. 6:29:41There is no error. Uh we have
  9312. 6:29:42successfully deployed as well.
  9313. 6:29:44Congratulation. Now let me show you. If
  9314. 6:29:46I want to let's say delete the instance.
  9315. 6:29:48So how it can be done? So for this you
  9316. 6:29:50have to go to the settings
  9317. 6:29:53and just below there is option called
  9318. 6:29:56delete web service. Now you have to give
  9319. 6:29:58this command.
  9320. 6:30:03Now delete the web service.
  9321. 6:30:07Okay. Once you do that, you will see
  9322. 6:30:09that your web service will be deleted.
  9323. 6:30:10Okay.
  9324. 6:30:16So guys, I think you have seen the
  9325. 6:30:17entire uh deployment entire
  9326. 6:30:20implementation of this uh AI agent. We
  9327. 6:30:23have created the complete multi- aent
  9328. 6:30:25pipeline uh with the help of langin. Uh
  9329. 6:30:30definitely uh I think this is going to
  9330. 6:30:33be uh this is going to be actually uh
  9331. 6:30:36interesting project uh to you if you're
  9332. 6:30:38creating the agent for the first time.
  9333. 6:30:40Uh so this was uh the first
  9334. 6:30:42orchestration framework we have explored
  9335. 6:30:44so far. Don't worry uh we'll be
  9336. 6:30:46exploring all of the orchestration
  9337. 6:30:48framework one by one. Now in the next
  9338. 6:30:50video I'm going to tell you let's say
  9339. 6:30:53why we have to use the actual aentk
  9340. 6:30:55orchestration framework like lang graph
  9341. 6:30:56crewi okay or autogen why we can't use
  9342. 6:31:00uh lang chen okay what are the
  9343. 6:31:02limitation lang chains are having each
  9344. 6:31:04and everything I'm going to clarify so
  9345. 6:31:05guys I think you know uh we have already
  9346. 6:31:09uh implemented some AI agents with the
  9347. 6:31:11help of lang chain uh this was our first
  9348. 6:31:15orchestrator framework uh for building
  9349. 6:31:18uh GNI powered application but I told
  9350. 6:31:21you we can also use lang chain for
  9351. 6:31:24building these kinds of AI agents. So
  9352. 6:31:26there I have shown you uh single agents
  9353. 6:31:30implementation as well as the multi-
  9354. 6:31:32aents implementation. So if you haven't
  9355. 6:31:34uh checked that uh the link is given in
  9356. 6:31:36the description from there you can check
  9357. 6:31:38it out. So from this video itself guys
  9358. 6:31:42I'm going to start uh our actual uh
  9359. 6:31:47agentic AI orchestrator framework. The
  9360. 6:31:49first framework we'll be starting with
  9361. 6:31:51uh which is langraph.
  9362. 6:31:54So I think you have heard of about
  9363. 6:31:55langraph. It's a very famous and mostly
  9364. 6:31:58used framework in industry and uh
  9365. 6:32:01developer are using this framework okay
  9366. 6:32:04day by day in their life. So before
  9367. 6:32:07starting actually langraph first of all
  9368. 6:32:09I want to give you the idea behind uh
  9369. 6:32:12this langraph why langraph came in the
  9370. 6:32:15market and if you don't know langraph is
  9371. 6:32:17a product of langchen okay so langen
  9372. 6:32:20developer team has implemented this
  9373. 6:32:22langraph framework for building akai
  9374. 6:32:25application so first of all let's try to
  9375. 6:32:27understand why they have created this
  9376. 6:32:30framework for building these kinds of
  9377. 6:32:32aenti application uh although they are
  9378. 6:32:35having language Okay. Um I I think we
  9379. 6:32:38saw we can use langen for building some
  9380. 6:32:40of the agents. Okay. Some of the basic
  9381. 6:32:42level agents. But why we have to use the
  9382. 6:32:45langen? Okay. What was the purpose
  9383. 6:32:47behind to use this particular uh let's
  9384. 6:32:49say lang graph. Okay. First of all we'll
  9385. 6:32:51try to understand each and everything.
  9386. 6:32:54Uh then I'm going to start with our
  9387. 6:32:56langraph concept. Okay. So this video
  9388. 6:32:59will cover the uh detailed discussion be
  9389. 6:33:02behind actually langen versus langraph.
  9390. 6:33:05uh I will uh tell you I will show you
  9391. 6:33:07why we can't use actually langen when it
  9392. 6:33:10comes to complex actually workflow
  9393. 6:33:13complex uh uh agenti let's say
  9394. 6:33:16application we can't use langen uh
  9395. 6:33:18instead of that actually we have to use
  9396. 6:33:20langraph for that okay so I'm going to
  9397. 6:33:22show you each and every example so that
  9398. 6:33:24your understanding would be more clear
  9399. 6:33:26so make sure you watch this video till
  9400. 6:33:28the end guys now let's see what are the
  9401. 6:33:31things we're going to cover from this
  9402. 6:33:33video I'm going to give you the agenda
  9403. 6:33:35first of all then I will start with the
  9404. 6:33:37discussion. So guys as you can see uh
  9405. 6:33:41these are the things uh we'll be
  9406. 6:33:43discussing in this particular video. Uh
  9407. 6:33:46first of all uh I'm going to discuss
  9408. 6:33:48about the uh brief overview uh of
  9409. 6:33:51langen. So again uh the prerequisite for
  9410. 6:33:54this video is you have to know langen.
  9411. 6:33:56Okay, langchen uh understanding is
  9412. 6:33:59required and I already told you in my
  9413. 6:34:01YouTube channel I have created langchen
  9414. 6:34:04video. Uh again I'm going to add the
  9415. 6:34:06link in the description from there you
  9416. 6:34:08can check it out. So first of all uh
  9417. 6:34:10we'll understand um what is lang chain
  9418. 6:34:13how lang chain works uh what are the
  9419. 6:34:16application actually we can implement
  9420. 6:34:18with the help of langchen then we'll be
  9421. 6:34:21discussing about the lang graph uh we'll
  9422. 6:34:23understand why lang graph is required
  9423. 6:34:25and what is lang graph exactly then uh
  9424. 6:34:27we'll try to understand like uh the
  9425. 6:34:30difference between lang chain versus
  9426. 6:34:32lang graph uh what are the benefit we'll
  9427. 6:34:35be getting from the langraph okay and
  9428. 6:34:36what are the dis disadvantage we'll be
  9429. 6:34:38getting from langen and when to use what
  9430. 6:34:41kinds of framework definitely we'll try
  9431. 6:34:43to understand each and everything.
  9432. 6:34:45So uh guys uh here you can see guys uh
  9433. 6:34:48here is the langen um langen definition.
  9434. 6:34:53So if you see the langen definition uh
  9435. 6:34:56here langchen is an open-source library
  9436. 6:34:59uh designed to simplify the process of
  9437. 6:35:01building llm based applications. uh it
  9438. 6:35:04provides modular uh building blocks that
  9439. 6:35:07let you create uh sophisticated LLM
  9440. 6:35:10based workflows okay with this. So I
  9441. 6:35:13think uh you have already used langen uh
  9442. 6:35:15I mean um inside generative AI and there
  9443. 6:35:19we uh work with large language model and
  9444. 6:35:22mostly we implement some ALM based
  9445. 6:35:24application like uh chat bots then we
  9446. 6:35:28create RG system text generation system
  9447. 6:35:31okay uh uh retriever system we try to
  9448. 6:35:34create these are the things right so
  9449. 6:35:36guys as you can see lang chain uh
  9450. 6:35:38consist of multiple component the first
  9451. 6:35:41component is the model component. So
  9452. 6:35:43basically uh this model component gives
  9453. 6:35:46us a unified u actually interface to
  9454. 6:35:49interact with any kinds of large
  9455. 6:35:51language model provider. Let's say if
  9456. 6:35:53you want to connect with open AI LLM so
  9457. 6:35:57it is having the model component for
  9458. 6:35:59that. If you want to connect with
  9459. 6:36:01anropic
  9460. 6:36:03uh model so it has the model component
  9461. 6:36:05for that. Okay. If you want to connect
  9462. 6:36:07with any open source LLM like Llama,
  9463. 6:36:10okay, Mistral,
  9464. 6:36:13okay, everything is possible. So all
  9465. 6:36:15kinds of provider basically it supports
  9466. 6:36:18and it it will give you some kinds of
  9467. 6:36:21functionality so that you can connect
  9468. 6:36:22with. Okay. Then uh it is having
  9469. 6:36:25something called prom component. So what
  9470. 6:36:27is prom component exactly? So this prom
  9471. 6:36:29component helps you to engineer the
  9472. 6:36:31prompt. So let's say whenever we want to
  9473. 6:36:34give our custom prompt. Okay, custom
  9474. 6:36:36prompt, custom prompt. Then um if I want
  9475. 6:36:40to write actually different different um
  9476. 6:36:43prompt template. So everything is
  9477. 6:36:45possible here and all kinds of uh like u
  9478. 6:36:49prompting strategy prompting engineer we
  9479. 6:36:51can perform inside this pro prompt
  9480. 6:36:54component. Okay. So langent is having a
  9481. 6:36:55prompt uh functionality. With the help
  9482. 6:36:58of that we can play with the prompting
  9483. 6:37:00and I think you know especially in GNI
  9484. 6:37:02application prompting is super
  9485. 6:37:04important. Without prompt actually we
  9486. 6:37:06can't create a robust system uh because
  9487. 6:37:09if you're using very uh poor prompt
  9488. 6:37:12definitely whatever output you are
  9489. 6:37:14getting from the application it would be
  9490. 6:37:16definitely poor. But if you're using a
  9491. 6:37:19good prompt with a detailed uh
  9492. 6:37:21instruction that time you can get best
  9493. 6:37:23output from the application itself.
  9494. 6:37:25Okay. So langen provides all of them.
  9495. 6:37:28Then there is another important things
  9496. 6:37:29we are having inside langen which is
  9497. 6:37:31this retriever component. So this
  9498. 6:37:33basically helps you to fetch relevant
  9499. 6:37:35documents from a vector store. So I
  9500. 6:37:38think you know we use this for the RG
  9501. 6:37:40application rag application. So whenever
  9502. 6:37:43we create the rag application that time
  9503. 6:37:45this uh retriever component is super
  9504. 6:37:47important. So there we um there we use
  9505. 6:37:50something called vector databases and
  9506. 6:37:52inside vector databases we store all of
  9507. 6:37:55the documents as a chunk chunk of
  9508. 6:37:58vectors and whenever we require them so
  9509. 6:38:01we use retriever component for that to
  9510. 6:38:03fetch the information relevant
  9511. 6:38:05informations. Okay. So, yeah, I think uh
  9512. 6:38:08these are the some major components,
  9513. 6:38:09multiple components we're having inside
  9514. 6:38:11Langchen. Uh but the biggest offering of
  9515. 6:38:14Langchen is the chain. Okay. Uh this
  9516. 6:38:17this particular things chain. So without
  9517. 6:38:19chain actually uh it was uh very
  9518. 6:38:22difficult uh creating this kinds of um
  9519. 6:38:25this kinds of actually uh production
  9520. 6:38:28grade uh geni application because chain
  9521. 6:38:30is kinds of uh actually workflow uh it
  9522. 6:38:33it's actually sequential workflow. So
  9523. 6:38:36what is this chain exactly? Chain is
  9524. 6:38:38nothing but it's a um I mean workflow.
  9525. 6:38:41Uh basically here we uh create uh this
  9526. 6:38:45chain in a sequential order. Uh so if
  9527. 6:38:48you have already used languin I think
  9528. 6:38:49you know that let's say you have to
  9529. 6:38:51create first of all multiple uh block
  9530. 6:38:54okay let's say I have created a prompt
  9531. 6:38:57block then what I will do um I will take
  9532. 6:39:01another block called model okay then I
  9533. 6:39:04will take another block called let's say
  9534. 6:39:06output parser
  9535. 6:39:10parser then we'll try to connect this
  9536. 6:39:13chain together okay this chain together
  9537. 6:39:16so basically ally what uh will happen uh
  9538. 6:39:18first of all this prompt will go to the
  9539. 6:39:20model and model will generate some kinds
  9540. 6:39:22of output and this output we'll try to
  9541. 6:39:24see with the help of output pareter so
  9542. 6:39:26basically it's a uh it's actually
  9543. 6:39:28sequential workflow and we call it as a
  9544. 6:39:31chain so uh every block will give some
  9545. 6:39:34kinds of output and this output will
  9546. 6:39:36become the input from for the next next
  9547. 6:39:39block okay then again uh this block will
  9548. 6:39:42generate some kinds of output again this
  9549. 6:39:43will be uh going as an input to another
  9550. 6:39:46block. Okay, that's how you can create
  9551. 6:39:49actually um uh as many chain as you can.
  9552. 6:39:52Let's say you can create create
  9553. 6:39:53thousands uh blockchain. You can create
  9554. 6:39:56uh hundred of blockchain here. Okay. So
  9555. 6:39:58everything is possible u inside lang
  9556. 6:40:00chain. So this is the biggest benefit
  9557. 6:40:02we'll be getting from the lang chain. So
  9558. 6:40:04here you don't have any kinds of
  9559. 6:40:06restriction that means you have to only
  9560. 6:40:08create uh uh three blockchain or four
  9561. 6:40:10blockchain. Uh you can create as much
  9562. 6:40:12and as any as uh so here you can create
  9563. 6:40:16as much as block you can okay as much as
  9564. 6:40:19uh uh like um this chain you can okay
  9565. 6:40:23you have the flexibility here so that's
  9566. 6:40:25why this uh lang chain got like very
  9567. 6:40:28popularity and uh it was uh like uh very
  9568. 6:40:32easy for the developer for creating this
  9569. 6:40:34kinds of geni powered application. So as
  9570. 6:40:37you can see what you can build with the
  9571. 6:40:38langen. Uh so I already told you we can
  9572. 6:40:41implement like conversational workflow
  9573. 6:40:43like chat bots, text summarization app.
  9574. 6:40:46Okay. Then apart from that we can also
  9575. 6:40:48create uh translation system. Okay. All
  9576. 6:40:52kinds of NLP related um um I mean um uh
  9577. 6:40:56problem statement we can solve with the
  9578. 6:40:58help of this langen. Okay. We can
  9579. 6:40:59implement with the help of langen. Then
  9580. 6:41:01multi-step workflow it supports. So
  9581. 6:41:03let's say whenever I want to create any
  9582. 6:41:05kinds of mult um multi multi-step
  9583. 6:41:09workflows that time it is also possible
  9584. 6:41:11multi-step workflow means let's say um I
  9585. 6:41:15can give you one example let's say here
  9586. 6:41:16you given a topic okay you given a topic
  9587. 6:41:20then uh what you have done let's say you
  9588. 6:41:22generated a detail
  9589. 6:41:25okay detail report on that topic okay
  9590. 6:41:28once this detail report a topic
  9591. 6:41:30generated then again you took that and
  9592. 6:41:32you perform something called
  9593. 6:41:33summarization
  9594. 6:41:35summary okay so basically you are
  9595. 6:41:37running multi-step workflow here okay so
  9596. 6:41:39if I break down uh as a um let's say
  9597. 6:41:43chain here so what you are doing let's
  9598. 6:41:45say first of all you are taking a prompt
  9599. 6:41:49prompt uh related the topic so you are
  9600. 6:41:52passing it to the llm okay let's say you
  9601. 6:41:54are telling uh I have uh um or let's say
  9602. 6:41:58tell me about um tell me about actually
  9603. 6:42:02um large language model. Okay. Um you
  9604. 6:42:06just uh generate a detailed report on
  9605. 6:42:08that on the large language model in
  9606. 6:42:092026. So your uh this uh particular
  9607. 6:42:13component will try to give you uh the
  9608. 6:42:15output uh that means the detail report.
  9609. 6:42:18Then what you are taking uh again uh you
  9610. 6:42:21are uh creating another prompt. Okay.
  9611. 6:42:23You are creating another prompt. Then
  9612. 6:42:25you are telling uh now I need the
  9613. 6:42:27summary of this particular detail
  9614. 6:42:28report. Then again you are passing to
  9615. 6:42:30another LLM. Okay, another LLM and this
  9616. 6:42:33LLM is giving you some kinds of uh
  9617. 6:42:36output summary. Okay, output summary. So
  9618. 6:42:39basically you are running here
  9619. 6:42:41multi-step workflow. So here we are not
  9620. 6:42:43only using one large language model or
  9621. 6:42:45one prompting you can use multiple large
  9622. 6:42:47language model, multiple prompting,
  9623. 6:42:49multiple output parert. Okay, so that's
  9624. 6:42:51why I told you this chain can be created
  9625. 6:42:54uh as many as you can. Okay, and this is
  9626. 6:42:56the best uh uh things we got inside line
  9627. 6:42:59chain. Then uh the next thing we have
  9628. 6:43:02which is uh this RG application that
  9629. 6:43:05means rag application. So inside rag
  9630. 6:43:07application what we can do we can create
  9631. 6:43:09a external knowledge base okay knowledge
  9632. 6:43:13base for the LLM
  9633. 6:43:15and we we can connect our LLM there. So
  9634. 6:43:18basically if you are asking any kinds of
  9635. 6:43:20question if the question uh answer is
  9636. 6:43:23not available in the LLM itself. So what
  9637. 6:43:26it will do it will refer kinds of
  9638. 6:43:28database. Okay, we call it as a vector
  9639. 6:43:30database and this is the knowledge base
  9640. 6:43:32actually we try to connect the LLM
  9641. 6:43:34there. So LM will fetch the informations
  9642. 6:43:36from here. Uh and uh this uh process
  9643. 6:43:39actually we perform with the help of
  9644. 6:43:40this retr component. Okay. Then we uh
  9645. 6:43:44give the answer to the user. Okay. So
  9646. 6:43:46this is another things we can develop.
  9647. 6:43:48Then the last thing we can do on this uh
  9648. 6:43:51basic level agents creation. So we have
  9649. 6:43:53already seen um how we can implement AI
  9650. 6:43:56agents application with the help of
  9651. 6:43:58plankin. So there I showed you we can um
  9652. 6:44:01uh create a single agents as well as the
  9653. 6:44:03multi- aents. But uh here the problem is
  9654. 6:44:06that you can only create uh like very
  9655. 6:44:10simple um I mean workflow kinds of
  9656. 6:44:13agents but whenever it is having complex
  9657. 6:44:16uh architecture complex workflow that
  9658. 6:44:18time it would be difficult for you. I
  9659. 6:44:20will show you okay how what is the
  9660. 6:44:21difficult and if I want to implement
  9661. 6:44:23with the help of lang chain so what
  9662. 6:44:25would be what would be the biggest
  9663. 6:44:26challenge for you each and everything
  9664. 6:44:28I'm going to clarify so basically in the
  9665. 6:44:30basic label agents what we can do maybe
  9666. 6:44:33uh we can take a large language model
  9667. 6:44:36and here we can uh take some kinds of
  9668. 6:44:38tool okay tool access so whenever user
  9669. 6:44:42is giving any kinds of things any kinds
  9670. 6:44:45of input so this particular LLM will
  9671. 6:44:47have the connection uh with the tool And
  9672. 6:44:50it it can use the tool to get the um get
  9673. 6:44:53the answer whether you can use any kinds
  9674. 6:44:55of search tool or any kinds of tool you
  9675. 6:44:58can use here with respect to your task.
  9676. 6:45:00It will fetch the informations from the
  9677. 6:45:02tool and it will show the user. So
  9678. 6:45:04basically here what we have we have some
  9679. 6:45:07kinds of uh system that that system
  9680. 6:45:09connected with some tools. Okay. And
  9681. 6:45:11that tool will provide some realtime
  9682. 6:45:13informations to the agents so that it
  9683. 6:45:15can perform
  9684. 6:45:18it can perform some automated workflow.
  9685. 6:45:20Okay. So this is the thing and in multi-
  9686. 6:45:21aents we created multiple agents and uh
  9687. 6:45:24we combined them together so that
  9688. 6:45:26whenever I was assigning any task it was
  9689. 6:45:28working together. Okay. In a sequential
  9690. 6:45:30manner. So yeah guys uh these are the
  9691. 6:45:32things we can um actually implement uh
  9692. 6:45:34from this langen uh langen actually
  9693. 6:45:37framework. So guys now uh we'll take an
  9694. 6:45:40example um and we'll try to understand
  9695. 6:45:44uh why uh langen cannot be used whenever
  9696. 6:45:48we are building any kinds of agenti
  9697. 6:45:51application. So what would be the
  9698. 6:45:53biggest uh difficulties and challenges
  9699. 6:45:55uh if we are using lang chain for
  9700. 6:45:58building these kinds of agent
  9701. 6:45:59application uh we'll try to understand
  9702. 6:46:01in detail okay and why uh we have to use
  9703. 6:46:04lang graph uh we'll also try to
  9704. 6:46:07understand in detail okay so for this uh
  9705. 6:46:10I'm going to take the same example uh
  9706. 6:46:12the example I given you in my
  9707. 6:46:14introduction session uh where I
  9708. 6:46:17discussed about the agentic AI I think
  9709. 6:46:19probably this was the second session uh
  9710. 6:46:21you have to uh watch uh on my playlist.
  9711. 6:46:25So uh there I told you about a um
  9712. 6:46:28recruitment process uh agent. So
  9713. 6:46:32basically let's say if I am having uh um
  9714. 6:46:35if I'm having a job position and if I
  9715. 6:46:37want to uh if I want to let's say hire
  9716. 6:46:39someone so how I can utilize a agent.
  9717. 6:46:42Okay, how I can utilize an agent and how
  9718. 6:46:45this agent was working. Okay, I think I
  9719. 6:46:47given you a detailed introduction on
  9720. 6:46:50that. So what I have done uh that
  9721. 6:46:52particular example I have converted in a
  9722. 6:46:54flowchart. You can see this is a
  9723. 6:46:56detailed flowchart. So this flowchart uh
  9724. 6:46:58actually explains um uh each and
  9725. 6:47:01everything about that particular
  9726. 6:47:03application. Um so basically we call it
  9727. 6:47:05as a workflow. So this thing we call it
  9728. 6:47:08as a
  9729. 6:47:11workflow.
  9730. 6:47:13Okay workflow.
  9731. 6:47:15So don't try to relate this workflow
  9732. 6:47:17with the AI agents because there are
  9733. 6:47:19some difference between this workflow
  9734. 6:47:22and AI agents. So if you want to
  9735. 6:47:24understand this thing so what you can do
  9736. 6:47:27uh you can
  9737. 6:47:29um you can visit a website uh
  9738. 6:47:32entropic.com. So they have written a
  9739. 6:47:35blog about the building effectic AI
  9740. 6:47:37agents. So if you just go below so there
  9741. 6:47:40uh they have discussed uh about the
  9742. 6:47:42workflow and agents. Okay. So as you can
  9743. 6:47:44see um workflow are system where LLM and
  9744. 6:47:47tools are orchestrated through a
  9745. 6:47:49predefined code path. Okay. So as you
  9746. 6:47:52can see this workflow I showed you. So
  9747. 6:47:54this is kinds of predefined path and
  9748. 6:47:56every time whenever I will run my uh
  9749. 6:47:59let's let's say this particular block it
  9750. 6:48:01will it has to follow the same things.
  9751. 6:48:03Okay. But if I'm talking about the
  9752. 6:48:06agents, okay, agents as you can see,
  9753. 6:48:08agents on the other hand are the system
  9754. 6:48:10where LLM dynamically directs their own
  9755. 6:48:13process uh and tool uses, okay,
  9756. 6:48:16maintaining control over how they
  9757. 6:48:18accomplish a task. So I think you have
  9758. 6:48:20seen my first example I have given you
  9759. 6:48:22of the same requirement process uh uh
  9760. 6:48:25applic uh let's say system there my
  9761. 6:48:28agent was like kind of automated. So I
  9762. 6:48:31just need to give a prompt. Let's say I
  9763. 6:48:33want to hire a backend engineer. So all
  9764. 6:48:35the step actually it was performing
  9765. 6:48:37automatically. Okay. Sometimes it was
  9766. 6:48:39giving you some kinds of u uh uh let's
  9767. 6:48:42say uh human in loop that means u human
  9768. 6:48:46confirmation but every everything it was
  9769. 6:48:48automatically working. So it was
  9770. 6:48:51deciding what to do. It was
  9771. 6:48:52automatically selecting the tools. Okay.
  9772. 6:48:54And each and everything. But uh to make
  9773. 6:48:57you understand about uh this uh lang
  9774. 6:49:00chain uh langchen actually um uh agents
  9775. 6:49:03implementation
  9776. 6:49:05or let's say if I want to implement the
  9777. 6:49:08same uh that recruitment application
  9778. 6:49:10with the help of langin so what would be
  9779. 6:49:12the difficulties okay for that I created
  9780. 6:49:14this particular workflow so that I can
  9781. 6:49:15make you understand okay how it can be
  9782. 6:49:18done um so here you can see this is a
  9783. 6:49:20workflow uh so workflow means this is a
  9784. 6:49:23predefined path so you You can see some
  9785. 6:49:26kinds of condition looping. Okay, it is
  9786. 6:49:28available. Okay, as you can see but on
  9787. 6:49:30the other hand agent are actually
  9788. 6:49:32dynamically um changes everything
  9789. 6:49:34dynamically take the decisions um and it
  9790. 6:49:38actually basically dynamically controls
  9791. 6:49:40each and everything. Okay. So I think
  9792. 6:49:41you have understood what is workflow and
  9793. 6:49:43agents. Okay. So for example guys we'll
  9794. 6:49:46try to consider this particular
  9795. 6:49:47workflow. Now see let's try to
  9796. 6:49:50understand this workflow again. So first
  9797. 6:49:52of all what uh we were doing here. So
  9798. 6:49:55first of all we are starting this
  9799. 6:49:57workflow and starting actually we are
  9800. 6:49:59giving our first uh prompt which was
  9801. 6:50:01let's say I want to hire a backend
  9802. 6:50:02engineer. So what will happen that time
  9803. 6:50:06this particular request will go to this
  9804. 6:50:08hiring request.
  9805. 6:50:10Uh so this is kind of a python function
  9806. 6:50:13you can consider this is a python
  9807. 6:50:14function. So this uh request will go to
  9808. 6:50:17the hiring request. Uh so once it will
  9809. 6:50:19go to the hiring request. So what will
  9810. 6:50:21happen
  9811. 6:50:23uh it will uh create a job description
  9812. 6:50:25uh of that uh of that actually um um job
  9813. 6:50:29you are asking for. Let's say you have
  9814. 6:50:31given backend engineer. So what will
  9815. 6:50:33happen uh for uh backend engineer one
  9816. 6:50:36job description would be created. Okay,
  9817. 6:50:38one job description will be created. Uh
  9818. 6:50:41so let's say you are using some kinds of
  9819. 6:50:43tool here that tool will help you to
  9820. 6:50:45write that particular job description.
  9821. 6:50:47Then what it will do? it will try to
  9822. 6:50:49send to the next uh actually block you
  9823. 6:50:52can see called JD approved. So this is
  9824. 6:50:55another function. So this function let's
  9825. 6:50:57say has connection with another another
  9826. 6:50:58LLM. Okay. So this LLM what it will do
  9827. 6:51:02it will try to let's say verify this job
  9828. 6:51:04description. It will check whether this
  9829. 6:51:06is fine or not for this job job role. If
  9830. 6:51:08not fine so it will send no. Okay. If it
  9831. 6:51:11is sending no that means again you have
  9832. 6:51:13to create the job description. Okay. And
  9833. 6:51:16if actually this particular job JD uh
  9834. 6:51:20let's say block approved. So what will
  9835. 6:51:22happen? It will go to the next block.
  9836. 6:51:24Okay, it will go to the next block and
  9837. 6:51:27it will post the job description. So in
  9838. 6:51:29this case, let's say you are using some
  9839. 6:51:31other tools like uh LinkedIn API, no
  9840. 6:51:33API. Uh and with the help of this API,
  9841. 6:51:36you are posting the job on that
  9842. 6:51:38particular platform. Okay. Now it will
  9843. 6:51:41go to the next block. Let's say here it
  9844. 6:51:43will wait for 7 days. Okay. So this uh
  9845. 6:51:45this particular block will wait for 7
  9846. 6:51:47days. So after waiting for 7 days uh it
  9847. 6:51:50will u continuously monitor like how
  9848. 6:51:53many application you are receiving.
  9849. 6:51:56Okay. So now again it is it is going
  9850. 6:51:58through another condition. So let's say
  9851. 6:52:00if you got enough application then it
  9852. 6:52:02will perform the other step like short
  9853. 6:52:04list uh short listinguling conduct
  9854. 6:52:07interview and all. But let's say if
  9855. 6:52:09you're not getting enough application
  9856. 6:52:10let's say you are getting only two to
  9857. 6:52:11three application what will happen? It
  9858. 6:52:13will send you no and again it has to
  9859. 6:52:16modify the job description. Then again
  9860. 6:52:18let's say it will wait for uh 48 hours.
  9861. 6:52:21Okay. Then again this loop will be uh
  9862. 6:52:24jumped to back. Okay. U that means the
  9863. 6:52:26previous block again uh monitoring will
  9864. 6:52:29start and again it will check whether
  9865. 6:52:31you got enough application or not. If
  9866. 6:52:33you got enough application now let's say
  9867. 6:52:34you got uh 20 application this is
  9868. 6:52:36enough. That time short listing will be
  9869. 6:52:38happening. Short listing means let's see
  9870. 6:52:40it has some kinds of réumé parser tool.
  9871. 6:52:43So it will use that uh and it will uh uh
  9872. 6:52:46it will actually match the resume with
  9873. 6:52:49our actual job description and uh it
  9874. 6:52:52will short short list actually some of
  9875. 6:52:53the candidate let's say from 20
  9876. 6:52:55candidate it will it's like four to five
  9877. 6:52:57candidate then we'll try to schedule the
  9878. 6:52:59interview okay uh then we'll take this
  9879. 6:53:02interview okay manually take this
  9880. 6:53:03interview then again there there is
  9881. 6:53:05another condition block will come so if
  9882. 6:53:08let's say uh we selected the candidate
  9883. 6:53:11uh so what we'll do we'll try to send
  9884. 6:53:12offer letter and all but if we uh let's
  9885. 6:53:15say don't select the candidate so what
  9886. 6:53:17will happen when uh regret email will be
  9887. 6:53:19sent to the candidate let's say I'm
  9888. 6:53:21extremely sorry for that u actually we
  9889. 6:53:24are not uh uh we are we are not actually
  9890. 6:53:27hiding you because let's say you haven't
  9891. 6:53:29uh performed good in in the interview
  9892. 6:53:31okay this kinds of regret email we can
  9893. 6:53:33send otherwise we can send the offer
  9894. 6:53:35letter okay uh so in offer letter also
  9895. 6:53:38there are some condition let's say if
  9896. 6:53:39this offer letter is accepted that means
  9897. 6:53:42definitely will performing the
  9898. 6:53:43onboarding and other task but if this
  9899. 6:53:46operator is not accepted then again what
  9900. 6:53:48you will do you'll try to perform some
  9901. 6:53:50renegotiate okay let's say maybe I can
  9902. 6:53:53uh increase the uh I can increase the
  9903. 6:53:56package mode let's say initially I I u
  9904. 6:53:59let's say initially I offered uh uh 25
  9905. 6:54:02LPA but let's say this person has
  9906. 6:54:05rejected that so again I will
  9907. 6:54:06renegotiate that let's say I will give
  9908. 6:54:09you 30 30 LPA so that time actually this
  9909. 6:54:11person may prefer this particular
  9910. 6:54:14package. So it will accept he will
  9911. 6:54:16accept that then I'll perform the
  9912. 6:54:18onboarding process and all then we'll u
  9913. 6:54:20um I mean end this particular um
  9914. 6:54:23workflow. Okay. So that's how guys the
  9915. 6:54:25entire workflow is working and uh this
  9916. 6:54:27was the first example we have taken to
  9917. 6:54:29understand the AI agents and uh right
  9918. 6:54:31now we have seen as a workflow how I
  9919. 6:54:34mean things are working. Okay. Now let's
  9920. 6:54:36say you want to implement this uh system
  9921. 6:54:40with the help of langen. So how you can
  9922. 6:54:43implement this with the help of langen.
  9923. 6:54:45Okay. Because lang chain doesn't have
  9924. 6:54:48any kinds of conditional uh conditional
  9925. 6:54:51let's say u I mean uh workflow or
  9926. 6:54:53conditional related functionality or
  9927. 6:54:55looping functionality. Okay. So langen
  9928. 6:54:58doesn't have that. So first of all let
  9929. 6:55:00me tell you the challenges you will be
  9930. 6:55:02facing here if you're um if you're using
  9931. 6:55:04lang chain for this this one. Uh let me
  9932. 6:55:08show you. Yeah. So the see first
  9933. 6:55:10challenge you will be getting here which
  9934. 6:55:11is um uh conditional
  9935. 6:55:19branch.
  9936. 6:55:22Okay. So as you can see this particular
  9937. 6:55:24workflow is having u so many conditional
  9938. 6:55:27branch. Okay. So this is the first uh
  9939. 6:55:30challenges we'll be facing if you're
  9940. 6:55:31using langen because langen doesn't have
  9941. 6:55:33any kinds of conditional branch because
  9942. 6:55:35it works with respect to the chaining
  9943. 6:55:37concept. Okay, it it it kinds of
  9944. 6:55:40sequential chaining concept it will be
  9945. 6:55:42working it doesn't have any kinds of
  9946. 6:55:43conditional branch. Then the second
  9947. 6:55:47second challenge you'll be getting the
  9948. 6:55:49loops okay loops.
  9949. 6:55:52So as you can see
  9950. 6:55:54um sometimes it is performing the
  9951. 6:55:56looping. So that means this particular
  9952. 6:55:59things will continuously um happening.
  9953. 6:56:02Okay. If let's say you you you haven't
  9954. 6:56:04received enough job uh application. So
  9955. 6:56:06this process will again repeat. Okay. So
  9956. 6:56:08that means you are looping the
  9957. 6:56:10operation. Okay. Unless and until this
  9958. 6:56:12is not satisfied. So again this looping
  9959. 6:56:15concept is not available inside langen.
  9960. 6:56:17Okay. You can't uh create this looping
  9961. 6:56:20concept inside lang. This is not
  9962. 6:56:22possible. Now the third challenges
  9963. 6:56:24you'll be guessing um getting called
  9964. 6:56:27jump. Okay, jump. Now what is jump
  9965. 6:56:30exactly? Now you can see uh whenever
  9966. 6:56:32let's say I didn't get any enough
  9967. 6:56:33application. So this is telling no that
  9968. 6:56:36time we are modifying the job
  9969. 6:56:37description waiting for 48 hours then
  9970. 6:56:40again we are jumping back to my previous
  9971. 6:56:42block. Okay you can see monitor
  9972. 6:56:44application. Okay. So from here we are
  9973. 6:56:46jumping again here. So this is called
  9974. 6:56:48jump and this kinds of jump we can't do
  9975. 6:56:50inside lang chain. this is not possible.
  9976. 6:56:52Okay. So these are some uh biggest
  9977. 6:56:54challenges guys uh we will be facing
  9978. 6:56:57whenever we will be using langen for
  9979. 6:56:59developing this kinds of agent system.
  9980. 6:57:02Okay. Now let me show you um as a code
  9981. 6:57:06actually how it can be developed. Uh
  9982. 6:57:09let's say somehow you want to develop
  9983. 6:57:11this uh agents with the help of this
  9984. 6:57:13lang. Uh so now what would be the code
  9985. 6:57:16coding strategy? Okay. What would be the
  9986. 6:57:18problem in the coding? Let's try to
  9987. 6:57:20understand. So here I have actually uh
  9988. 6:57:24taken some code example uh and this is
  9989. 6:57:26the langen implementation as you can
  9990. 6:57:28see. So uh maybe I can open up my
  9991. 6:57:31diagram. Let me open the diagram guys.
  9992. 6:57:35H so this is the diagram. This is that
  9993. 6:57:37workflow. Okay. Now we'll try to
  9994. 6:57:39understand now with this code. Now as
  9995. 6:57:42you can see first of all here we are
  9996. 6:57:43preparing our prompt. Uh we need to hire
  9997. 6:57:45a software engineer for the back end uh
  9998. 6:57:47backend team. That means we are starting
  9999. 6:57:50this recruitment process, we are sending
  10000. 6:57:52the heading request. So as you can see
  10001. 6:57:56um before u uh before starting with
  10002. 6:58:00first of all I need some I need some
  10003. 6:58:02let's say um I need some um um I mean
  10004. 6:58:07important object like first of all I
  10005. 6:58:08need the LM object. So we are taking an
  10006. 6:58:11LLM as you can see um chat openai we are
  10007. 6:58:14taking let's say GPT4 then we are
  10008. 6:58:17creating the prompt template okay so
  10009. 6:58:20create a job description based on the
  10010. 6:58:22hiring request okay so whatever request
  10011. 6:58:25we are getting uh so let's say this
  10012. 6:58:27particular request we are getting uh we
  10013. 6:58:29are preparing a job description for that
  10014. 6:58:31okay this is this is a job description
  10015. 6:58:33prompt okay so to create this job
  10016. 6:58:35description we need a prompt so we are
  10017. 6:58:36preparing here then we are creating the
  10018. 6:58:39chain here as you can see JD chain is
  10019. 6:58:41equal to job prompt that means first of
  10020. 6:58:43all job prompt will come go to it will
  10021. 6:58:45go to the LLM lm will prepare a job
  10022. 6:58:47description okay job description then it
  10023. 6:58:51will uh uh it will be uh go to the
  10024. 6:58:54output parser and output parser will
  10025. 6:58:55give you the job description okay now
  10026. 6:58:58what we have to do guys we have to write
  10027. 6:58:59this particular uh things as a function
  10028. 6:59:02uh JD approved okay this is going to be
  10029. 6:59:04a simple Python function as you can see
  10030. 6:59:06so we have written a uh def uh approved
  10031. 6:59:10JD. So here we'll try to pass the JD
  10032. 6:59:13whatever JD we have uh prepared. Okay
  10033. 6:59:16I'll try to pass in this function and
  10034. 6:59:19this function will return see inside
  10035. 6:59:21that I haven't written the whole code I
  10036. 6:59:23just given you the highle idea let's say
  10037. 6:59:25if this job description is approved
  10038. 6:59:27based on some parameter then we'll try
  10039. 6:59:29to return approved otherwise we'll
  10040. 6:59:31reject it. Okay, as you can see we'll
  10041. 6:59:32try to approved otherwise we'll try to
  10042. 6:59:34send no. Okay, so here you can see um
  10043. 6:59:38once this particular job description is
  10044. 6:59:41approved then we have to pass to the uh
  10045. 6:59:43post job description. See as of now we
  10046. 6:59:46are considering
  10047. 6:59:49uh till here. Okay so this is the entire
  10048. 6:59:52workflow but I am not creating for the
  10049. 6:59:54entire workflow. So let's try to
  10050. 6:59:56consider u this part. Okay, this part we
  10051. 6:59:59we are implementing as of now with the
  10052. 7:00:00help of blank. Okay, I'm only
  10053. 7:00:02considering this part. So you can see
  10054. 7:00:06uh let me show you. Yeah. So you can see
  10055. 7:00:09the next function I have written for
  10056. 7:00:11post job description that means this
  10057. 7:00:13particular function. So it will take the
  10058. 7:00:16job description and let's say it has
  10059. 7:00:18some connection with uh some job portal
  10060. 7:00:21you have the API key like let's say
  10061. 7:00:22LinkedIn noy and it will use that and it
  10062. 7:00:25will post that particular job
  10063. 7:00:27description. Okay, so we have prepared
  10064. 7:00:29all of the helper and utility related
  10065. 7:00:31functionality. Now we have to work on
  10066. 7:00:33the actual logic building. So you can
  10067. 7:00:35see sometimes we have to run the loop.
  10068. 7:00:38Sometimes we have to uh go through the
  10069. 7:00:40condition. So these are the things we
  10070. 7:00:41have to do. But in langen this kinds of
  10071. 7:00:44functionality is not available. In
  10072. 7:00:45langen I think I told you this kinds of
  10073. 7:00:48conditional branching, looping, jumping
  10074. 7:00:49is not available. So for this what we
  10075. 7:00:52have to do? We have to write some manual
  10076. 7:00:54code. So let's say here we have written
  10077. 7:00:56the manual code. So first of all we have
  10078. 7:00:58taken two variable approved and job
  10079. 7:00:59description output. Okay. By default I
  10080. 7:01:01have created as a false and this is this
  10081. 7:01:03one is none. Okay. Now here you can see
  10082. 7:01:07in step five we are running a loop until
  10083. 7:01:10job description is approved. That means
  10084. 7:01:12this particular things. Okay. This
  10085. 7:01:13particular loop we'll be writing. So for
  10086. 7:01:15writing this loop I have taken a while
  10087. 7:01:17loop. Okay. While loop and I told uh
  10088. 7:01:20while not approved. Okay that means
  10089. 7:01:22unless and until this particular
  10090. 7:01:23approved parameter is true this loop
  10091. 7:01:25will be running. Then continuously what
  10092. 7:01:27we are doing we're u creating the job
  10093. 7:01:30description. Okay job description with
  10094. 7:01:32the help of this particular prompt user
  10095. 7:01:33is giving and we're sending to approved
  10096. 7:01:36job description that means this
  10097. 7:01:37particular function and unless and until
  10098. 7:01:40we are not getting approved from this
  10099. 7:01:41function this particular loop will be
  10100. 7:01:44continuously running. Okay, you can see
  10101. 7:01:45if not approved job des uh job not
  10102. 7:01:48approved uh regenerating again it will
  10103. 7:01:51come here again it will generate another
  10104. 7:01:52one again it will send to the uh this
  10105. 7:01:54particular function this loop will be
  10106. 7:01:56continuously running okay let's say uh
  10107. 7:01:59this particular job description is fine
  10108. 7:02:00we got approved then what we'll do in
  10109. 7:02:03the final step if it is approved then
  10110. 7:02:05we'll try to post this job description
  10111. 7:02:06with the help of this post JD function
  10112. 7:02:09okay so that's how we can implement this
  10113. 7:02:12system okay we can implement this system
  10114. 7:02:14uh And yeah, we are able to do that.
  10115. 7:02:16Okay, somehow we are able to do that.
  10116. 7:02:17But to implement this system, I think
  10117. 7:02:20one more thing you have observed which
  10118. 7:02:21is this uh extra code. Okay, which is
  10119. 7:02:24this manual coding. So let's say this
  10120. 7:02:26manual function we have created again.
  10121. 7:02:29Um
  10122. 7:02:30this uh this manual code we have
  10123. 7:02:33created. Okay, this manual code we have
  10124. 7:02:36created. So this is called actually blue
  10125. 7:02:40code.
  10126. 7:02:43Okay, glue code. So to implement this
  10127. 7:02:45project, we have to write okay so many
  10128. 7:02:49line of glue code. Now let's say you are
  10129. 7:02:51creating the entire workflow right now.
  10130. 7:02:53Let's say you are creating the entire
  10131. 7:02:54workflow right now. Just try to think
  10132. 7:02:56about to complete the entire recruitment
  10133. 7:02:58process how much glue code you have you
  10134. 7:03:00have to write here. Okay. And it's
  10135. 7:03:03recommended whenever you are creating
  10136. 7:03:05any kinds of production grade
  10137. 7:03:06application. So you have to avoid
  10138. 7:03:09writing this kinds of glue code. Okay.
  10139. 7:03:12you have to avoid to write this kind of
  10140. 7:03:14glue code, this kinds of manual coding.
  10141. 7:03:16Okay. So that's why in the market uh
  10142. 7:03:20they published different different
  10143. 7:03:21framework for different different kinds
  10144. 7:03:23of task. Okay. For agents also we can't
  10145. 7:03:26use langen because in langen we can
  10146. 7:03:30implement we can implement this kinds of
  10147. 7:03:32system. It's completely fine but for
  10148. 7:03:33this we have to write so many manual
  10149. 7:03:36coding so many glue code and this glue
  10150. 7:03:37code is not good for our application.
  10151. 7:03:40Okay. And again just try to think about
  10152. 7:03:42as a developer uh definitely uh it would
  10153. 7:03:45be very hectic task for you to write
  10154. 7:03:47that that much of glue code okay inside
  10155. 7:03:49your u uh codebase and just try to think
  10156. 7:03:52about how much your uh your code base
  10157. 7:03:55would be it would be huge codebase right
  10158. 7:03:56to manage this codebase like you have to
  10159. 7:03:59I mean uh you have to uh I mean take
  10160. 7:04:02care everything and we won't be do that
  10161. 7:04:05right so that's why guys we won't be
  10162. 7:04:08using this lang uh for building this
  10163. 7:04:11kinds of uh agentic workflow because if
  10164. 7:04:13you see this agentic workflow is not a
  10165. 7:04:15linear one it's a complex workflow right
  10166. 7:04:18it's a complex workflow when it comes
  10167. 7:04:20linear workflow that time it's
  10168. 7:04:22completely fine let's say there is no
  10169. 7:04:23condition there is no looping that time
  10170. 7:04:25easily we can use the training concept
  10171. 7:04:28and we can implement these things with
  10172. 7:04:30the help of langen okay but when it
  10173. 7:04:32comes this kinds of conditional uh
  10174. 7:04:35conditional branch looping jump that
  10175. 7:04:38time this lang is not recommend
  10176. 7:04:40recommended for that. Okay. So for this
  10177. 7:04:42we have to use some kinds of agentic
  10178. 7:04:45framework. Okay. Agentic framework it is
  10179. 7:04:48only for design for building this kinds
  10180. 7:04:50of complex workflow complex block. Okay.
  10181. 7:04:52And it has support with this kinds of
  10182. 7:04:54conditional branching looping jumping
  10183. 7:04:58all the functionalities it is having.
  10184. 7:04:59Okay. That's why Langchen team has
  10185. 7:05:02implemented another amazing framework
  10186. 7:05:05called Langraph. Okay. So they have
  10187. 7:05:08created one amazing framework called
  10188. 7:05:09langraph. So lang graph is a agentic AI
  10189. 7:05:12framework. Okay. With the help of that
  10190. 7:05:13you can create agents application. Okay.
  10191. 7:05:17So how much complex it doesn't matter.
  10192. 7:05:19You can implement all kinds of agents
  10193. 7:05:22application. And why this kinds of
  10194. 7:05:24framework is uh really good for building
  10195. 7:05:27agentic application because it works
  10196. 7:05:30works uh I mean with respect to the
  10197. 7:05:33nodes. Okay. I think you know graph is
  10198. 7:05:35all about nodes. Okay. You can create as
  10199. 7:05:38much as nodes you can then you can
  10200. 7:05:40connect those nodes all together. Then
  10201. 7:05:42you can also add the conditional
  10202. 7:05:44statement. You can add the looping in
  10203. 7:05:46the nodes. Okay, that means graph data
  10204. 7:05:49structure is a complex data structure.
  10205. 7:05:51It's not a linear data structure. If you
  10206. 7:05:53have already studied about this DSA
  10207. 7:05:55concept, I think you know that. So graph
  10208. 7:05:57data structure is a complex data
  10209. 7:05:59structure. It's a nonlinear data
  10210. 7:06:01structure. So here we can do anything.
  10211. 7:06:03Okay. So that's why uh this langraph is
  10212. 7:06:08got I mean this is like very uh very
  10213. 7:06:10powerful and popular framework when it
  10214. 7:06:13comes for building any kinds of agent
  10215. 7:06:15application and that's why langen team
  10216. 7:06:18has developed this kinds of system and
  10217. 7:06:19internally they're using uh langen only
  10218. 7:06:22okay internally they're using langen
  10219. 7:06:24only they have written some robust code
  10220. 7:06:26for that and with the help of that
  10221. 7:06:28actually they have built this lang graph
  10222. 7:06:30for us uh so that we can use this lang
  10223. 7:06:33graph for building AI agents
  10224. 7:06:36application. Okay,
  10225. 7:06:40I hope you understood. So as I told you
  10226. 7:06:43this lang graph works uh with the help
  10227. 7:06:45of nodes um because it has to create a
  10228. 7:06:47graph and to create a graph we have to
  10229. 7:06:49create a nodes. So if I now open the
  10230. 7:06:51workflow you can see uh I can clear yeah
  10231. 7:06:54so if I open the workflow as you can see
  10232. 7:06:56here each and every block is kinds of
  10233. 7:06:59nodes. Okay Lang graph will consider
  10234. 7:07:00each and every blocks uh as a node. So
  10235. 7:07:03let's say this hiding request it it
  10236. 7:07:05would be a node. So I can write here h.
  10237. 7:07:10So let's say this hiding request it's a
  10238. 7:07:13it's a node
  10239. 7:07:17padding request.
  10240. 7:07:31Okay. Now next we have this create job
  10241. 7:07:35description
  10242. 7:07:37j. So this is going to be another note.
  10243. 7:07:54This is going to be another node.
  10244. 7:07:58And then
  10245. 7:08:01we have
  10246. 7:08:04um
  10247. 7:08:06job approved. Okay, that means this
  10248. 7:08:08checking function.
  10249. 7:08:11So I can make it as job approved.
  10250. 7:08:15Now there is another node
  10251. 7:08:21called uh this post job description.
  10252. 7:08:28Okay, post.
  10253. 7:08:30I can make it as a post. Okay, so that's
  10254. 7:08:33how it will create the nodes.
  10255. 7:08:42Just a minute guys, let me fix it. Yeah,
  10256. 7:08:46nodes. Okay, now after creating the
  10257. 7:08:48nodes guys, what it will do? It will
  10258. 7:08:50draw the edges. Okay, edges means the
  10259. 7:08:53flow. Let's say this hiring request will
  10260. 7:08:56go to the job uh description that means
  10261. 7:09:00from here to here. Okay, this is called
  10262. 7:09:02ages. Okay, in langraph we call it as a
  10263. 7:09:05edges. Okay, you can see in the code
  10264. 7:09:07also I'll explain this code as well. U
  10265. 7:09:10but I I know that uh you you haven't uh
  10266. 7:09:13written any kinds of code in Langra but
  10267. 7:09:15it's completely fine. I'm going to teach
  10268. 7:09:16you how to write the code but as a high
  10269. 7:09:18level I'm going to make you understand
  10270. 7:09:20okay how things are working. Now this
  10271. 7:09:23job description will go to the uh job
  10272. 7:09:25approved. Okay, this block that means
  10273. 7:09:28this note. So again we'll create another
  10274. 7:09:30edge.
  10275. 7:09:31Okay, now this uh job approved will go
  10276. 7:09:34to the next uh next ed uh next actually
  10277. 7:09:37nodes which is post job description.
  10278. 7:09:40Post job description. Okay, so we have
  10279. 7:09:42drawn the edges. Okay, now we'll be
  10280. 7:09:44working on the conditional and looping.
  10281. 7:09:46Okay, now we we have to work on the
  10282. 7:09:48conditional and looping. Now to uh I
  10283. 7:09:50mean for better understanding maybe we
  10284. 7:09:52can see the code guys here. Uh so this
  10285. 7:09:55is the code implementation
  10286. 7:09:58uh of langraph. Let's say the same
  10287. 7:10:01workflow uh we can implement with with
  10288. 7:10:03the help of langraph. So you can see the
  10289. 7:10:05langraph implementation. So first of all
  10290. 7:10:07we are adding the nodes. Okay all of the
  10291. 7:10:09nodes one by one. First of all we are
  10292. 7:10:11adding hiring request this this nodes we
  10293. 7:10:14are getting these nodes. Okay. And uh
  10294. 7:10:16you can see uh we are giving the name as
  10295. 7:10:18well as we are giving a hiring request
  10296. 7:10:20object. Now you can ask what is this
  10297. 7:10:21hiring request object. This is nothing
  10298. 7:10:23but this is a simple python function as
  10299. 7:10:25you can see hiding request. Okay. So we
  10300. 7:10:28are um creating a simple Python
  10301. 7:10:30function. uh we are using LLM or we are
  10302. 7:10:34using some kinds of API here in that and
  10303. 7:10:36we are preparing a function and once
  10304. 7:10:38this function is ready we are giving the
  10305. 7:10:39object of that particular function in
  10306. 7:10:41the inside the nodes that means this
  10307. 7:10:43particular function will be uh created
  10308. 7:10:46as a node okay node inside langraph then
  10309. 7:10:49the next uh uh node we are adding create
  10310. 7:10:52uh job description job description again
  10311. 7:10:55create job description is another
  10312. 7:10:56function okay we are giving the object
  10313. 7:10:59here okay then we are creating
  10314. 7:11:01[clears throat] Next note which is check
  10315. 7:11:02approval that means this function. Okay.
  10316. 7:11:05So this is the function check approval.
  10317. 7:11:08Then next we are doing uh this uh post
  10318. 7:11:11job description that means this note
  10319. 7:11:13this note again this is the uh post
  10320. 7:11:17approval. What is post appro uh post
  10321. 7:11:19right? Post job description. Okay this
  10322. 7:11:20one this particular Python function.
  10323. 7:11:22Okay. So with the help of that we are
  10324. 7:11:24preparing all of this node one by one.
  10325. 7:11:26Now once node is created now I have to
  10326. 7:11:28draw the edges. Okay. Now we'll be
  10327. 7:11:30drawing the edges. So as you can see we
  10328. 7:11:32are drawing the edges. Uh so now see the
  10329. 7:11:34workflow. First of all uh hiding uh
  10330. 7:11:37request will go to the
  10331. 7:11:40uh create job description. So you can
  10332. 7:11:42see uh graph add age uh hiding request
  10333. 7:11:47will be connected with create job
  10334. 7:11:49description. That means here to here.
  10335. 7:11:52Okay. So the first one then the second
  10336. 7:11:55one. Okay. You want to connect this
  10337. 7:11:57particular edge. Now next is would be
  10338. 7:12:00create job description to check
  10339. 7:12:01approval. Create job description to
  10340. 7:12:04check approval. Okay. So here we have to
  10341. 7:12:06draw the edges. Okay. But in between you
  10342. 7:12:09can see
  10343. 7:12:11uh create job description to uh job
  10344. 7:12:14approval. Here we have a uh we have a
  10345. 7:12:17condition. Okay. If job is not approved
  10346. 7:12:21then it will again create a job
  10347. 7:12:22description. If it is approved then it
  10348. 7:12:25will post the job description. Okay. So
  10349. 7:12:26now we have to create this conditional
  10350. 7:12:28statement. It would be very easy for me
  10351. 7:12:30to create a conditional statement
  10352. 7:12:31because we are using this uh uh graph
  10353. 7:12:34structure. Okay. In line graph. Now you
  10354. 7:12:36can see in graph itself there is a
  10355. 7:12:38function called add conditional ages.
  10356. 7:12:40Okay. Now what would be the condition?
  10357. 7:12:43Condition would be depend on this check
  10358. 7:12:45approval function. That means this check
  10359. 7:12:46approval we have created. That means
  10360. 7:12:48this one. Okay. So if this check
  10361. 7:12:50approval returns no. Okay. If it is
  10362. 7:12:53returns no. Okay. not accepted again it
  10363. 7:12:56will create the job job description you
  10364. 7:12:57can see if it is not approved then
  10365. 7:12:59create the job job description it's a
  10366. 7:13:01loop back right but if it is approved
  10367. 7:13:03then it will go to the directly post ID
  10368. 7:13:05now you can see in next graph we are
  10369. 7:13:08again adding another edges post ID that
  10370. 7:13:10means from here to here from here to
  10371. 7:13:12here okay so that's how guys we can
  10372. 7:13:14easily implement this kinds of system
  10373. 7:13:16with the upline graph okay I hope you
  10374. 7:13:19got it and see like very easy it is
  10375. 7:13:21right but in my previous implementation
  10376. 7:13:23it was very hard for me and we have to
  10377. 7:13:25write so many line of glue code here but
  10378. 7:13:28here it is not required. Okay. So I hope
  10379. 7:13:31guys you have understood. So this is the
  10380. 7:13:33easiest example I can give um like uh
  10381. 7:13:36regarding this langen versus lang graph
  10382. 7:13:39and why people are using lang graph why
  10383. 7:13:41um it is recommended to use lang graph
  10384. 7:13:44uh like uh instead of using langen for
  10385. 7:13:46building this kinds of agentic workflow
  10386. 7:13:48now I think everything is clear in your
  10387. 7:13:50mind so that's why in this langraph
  10388. 7:13:53implementation you can either use
  10389. 7:13:55looping okay looping concept either use
  10390. 7:13:58branching concept this conditional
  10391. 7:14:01statement concept Okay, without writing
  10392. 7:14:03any kinds of glue code. Uh that's why it
  10393. 7:14:05is uh uh super powerful and recommended
  10394. 7:14:09and easily you can implement any kinds
  10395. 7:14:12of complex application complex agent
  10396. 7:14:15application with the help of this line
  10397. 7:14:17graph. Okay, because internally it is
  10398. 7:14:19using this nodding concept, graphing
  10399. 7:14:22concept. I hope it is clear guys. So
  10400. 7:14:25guys, now I'll be discussing about the
  10401. 7:14:27second challenges you will be getting
  10402. 7:14:29whenever you are using uh lang chain um
  10403. 7:14:34for this agentic AI application. So the
  10404. 7:14:36challenge name is uh handling state. So
  10405. 7:14:39let's try to understand what is state
  10406. 7:14:41exactly. So see state a kinds of uh meta
  10407. 7:14:44data uh we use whenever we execute the
  10408. 7:14:48entire workflow. So if I open the
  10409. 7:14:50workflow I think you have seen um these
  10410. 7:14:53are some uh important blocks we are
  10411. 7:14:55having. So every blocks will generate
  10412. 7:14:57some kinds of output and based on this
  10413. 7:14:59output actually we are deciding for the
  10414. 7:15:01next block. Let's say hiring request
  10415. 7:15:04will go to the job description. Job
  10416. 7:15:06description will generate job
  10417. 7:15:07description. Okay. Then job approved
  10418. 7:15:09will try to check whether this job
  10419. 7:15:11description is fine or not. If it is
  10420. 7:15:13fine. If this job description sends yes
  10421. 7:15:16then job post will be happening.
  10422. 7:15:18Otherwise uh if it sends no that means
  10423. 7:15:20again it will create a job description.
  10424. 7:15:23So in uh in every step guys you can see
  10425. 7:15:26we are generating some kinds of state
  10426. 7:15:28data okay state data. So if you just go
  10427. 7:15:30through this block I think you will
  10428. 7:15:32understand u uh why this block are
  10429. 7:15:35important and why the generated uh datas
  10430. 7:15:38are important because based on the data
  10431. 7:15:40we are making the decision for the next
  10432. 7:15:41block. So as you can see if I show you
  10433. 7:15:43this state. So let's say if this is our
  10434. 7:15:45goal hire a backend software engineer.
  10435. 7:15:47So first of all uh uh what will happen
  10436. 7:15:50these are the information will be stored
  10437. 7:15:52in the state memory that means the job
  10438. 7:15:54um description text would be available.
  10439. 7:15:57Then job approved or not this particular
  10440. 7:15:59status would be true or false. Job
  10441. 7:16:01posted or not this would be true or
  10442. 7:16:03false. How many applications you got?
  10443. 7:16:05Number of applications you have. Okay.
  10444. 7:16:08Shortlisted candidates name is offer
  10445. 7:16:10letter sent or not. Interview question
  10446. 7:16:12is prepared or not. Okay. So these kinds
  10447. 7:16:14of data you need to run the entire
  10448. 7:16:16workflow because this uh your agents
  10449. 7:16:19will try to refer this state okay state
  10450. 7:16:21data and it will decide okay what to do
  10451. 7:16:24next. Let's say uh you have run till
  10452. 7:16:26here let's say you have run till here
  10453. 7:16:29you have executed till here till
  10454. 7:16:30monitoring. So now right now your agent
  10455. 7:16:33is having this kinds of state data.
  10456. 7:16:35Let's say it know actually how many
  10457. 7:16:37application uh you you you have
  10458. 7:16:40currently okay it it it received
  10459. 7:16:42currently and how it will understand
  10460. 7:16:44because this information is available
  10461. 7:16:46inside state right so it it will solve
  10462. 7:16:48let's say five application came so far
  10463. 7:16:50so what it again it will do again it
  10464. 7:16:52will tell this is not enough just try to
  10465. 7:16:54modify the job description and again try
  10466. 7:16:57to monitor everything okay based on that
  10467. 7:16:59particular data it is deciding right so
  10468. 7:17:01this is super important so this is
  10469. 7:17:03called actually state And langen is
  10470. 7:17:05stateless. Okay, langshen doesn't have
  10471. 7:17:07any kinds of state related functionality
  10472. 7:17:10because you can see this particular
  10473. 7:17:12state would be stored as a key value
  10474. 7:17:14pair like a dictionary. Okay, but langen
  10475. 7:17:17langen doesn't give you any kinds of
  10476. 7:17:21um dictionary or key value pair storing
  10477. 7:17:25concept. Okay, that means langen is
  10478. 7:17:26completely stateless here. Okay, you
  10479. 7:17:30can't do it with the help of langen. You
  10480. 7:17:32can do it for this maybe what you have
  10481. 7:17:34to do you have to let's say whenever you
  10482. 7:17:36are starting the code at the very first
  10483. 7:17:38time you have to take a dictionary about
  10484. 7:17:40u name let's say state okay you are
  10485. 7:17:42taking a dictionary and uh you have to
  10486. 7:17:45manually like define these are the key
  10487. 7:17:47here manually define these are the key
  10488. 7:17:49and every after every execution you have
  10489. 7:17:52to manually update these are the value
  10490. 7:17:53here okay so that means you are again
  10491. 7:17:56writing the glue code here and this is
  10492. 7:17:58very trick task for you to manage all of
  10493. 7:18:00the state right so If I show you all of
  10494. 7:18:03the state because it's not a like a very
  10495. 7:18:05uh short state we are handling. If
  10496. 7:18:07you're creating the entire workflow just
  10497. 7:18:09try to think about how many state uh
  10498. 7:18:10that mean how many metadata will come
  10499. 7:18:12and every time you have up to date that
  10500. 7:18:14inside langen okay so this would be head
  10501. 7:18:16trick for you but inside uh this uh lang
  10502. 7:18:21graph okay if I'm using lang graph so
  10503. 7:18:24inside lang graph guys uh this concept
  10504. 7:18:28is available so lang graph is like
  10505. 7:18:30stateful
  10506. 7:18:32okay stateful if you're using lang graph
  10507. 7:18:34it is stateful because in lang graph We
  10508. 7:18:37create a nodes right? We create a nodes
  10509. 7:18:41and nodes will be having this kinds of
  10510. 7:18:47uh this kinds of actually state
  10511. 7:18:49connection. State connection means see
  10512. 7:18:53state connection means we can we can
  10513. 7:18:54create a state object. Okay, we can
  10514. 7:18:56create a state object inside langraph.
  10515. 7:19:00So state object.
  10516. 7:19:02So this state object can be created with
  10517. 7:19:04the help of pyic.
  10518. 7:19:06So I think I already taught you pyntic
  10519. 7:19:08in my playlist the same playlist you can
  10520. 7:19:10check that either you can create with
  10521. 7:19:12the help of type dict there is another
  10522. 7:19:15concept you can uh use it type dict.
  10523. 7:19:18Okay. So basically what you will do
  10524. 7:19:19you'll just try to define this kinds of
  10525. 7:19:21structure at the very beginning of your
  10526. 7:19:24application and in every nodes you will
  10527. 7:19:26try to provide this state access. Okay.
  10528. 7:19:29So what the node will do? So after every
  10529. 7:19:32node execution automatically these kinds
  10530. 7:19:35of data would be updated. Okay. These
  10531. 7:19:38kinds of data would be updated inside
  10532. 7:19:40the state. Okay. So let me show you
  10533. 7:19:42maybe uh you'll be clear enough.
  10534. 7:19:46So I think I showed you an example
  10535. 7:19:48right?
  10536. 7:19:51I showed you one example related this
  10537. 7:19:55yeah node concept. Yeah you can see we
  10538. 7:19:57are creating the node. Okay, we are
  10539. 7:19:59creating a node. So whenever you are
  10540. 7:20:02creating a node, it will have the access
  10541. 7:20:03to the state object. Okay, so let's say
  10542. 7:20:06whenever it is doing any kinds of um
  10543. 7:20:09execution, let's say it is generating
  10544. 7:20:10the job description. That time um in the
  10545. 7:20:14state there would be a section called
  10546. 7:20:15job description in a key, right? It will
  10547. 7:20:18try to update the job description.
  10548. 7:20:19Again, it will run to the next node job
  10549. 7:20:22approved. So whether job is approved or
  10550. 7:20:24not whether it is true or false again it
  10551. 7:20:27will try to update that particular
  10552. 7:20:28parameter because we are defining this
  10553. 7:20:31particular state with the help of this
  10554. 7:20:33pentic pentic or this state dict okay we
  10555. 7:20:36are doing that this kinds of structure
  10556. 7:20:39so that's why in the code itself if you
  10557. 7:20:41see the langraph implementation so every
  10558. 7:20:44time in the function itself we are
  10559. 7:20:45giving this kinds of state okay you can
  10560. 7:20:48see we are giving this kinds of state
  10561. 7:20:50okay and output it will also return you
  10562. 7:20:52some kinds of state okay because it is
  10563. 7:20:54updating in that particular um state
  10564. 7:20:57object okay so that's how this lang
  10565. 7:20:59graph handles this kinds of scenario
  10566. 7:21:01this kinds of stating scenario okay uh
  10567. 7:21:04but you now you can ask me in in lang
  10568. 7:21:06chain uh we have the memory concept
  10569. 7:21:08definitely right in lang chain we have
  10570. 7:21:10the memory
  10571. 7:21:12we can use the memory but memory you can
  10572. 7:21:15use for what for the conversational
  10573. 7:21:18workflow converation
  10574. 7:21:21okay you can store the conversation the
  10575. 7:21:23conversation you are doing with your
  10576. 7:21:24chatbot or whatever you can state the
  10577. 7:21:28you can store the conversation okay
  10578. 7:21:30conversation story but it doesn't
  10579. 7:21:33support any kinds of key value pair
  10580. 7:21:34storing this kind of stating concept is
  10581. 7:21:36it doesn't support you can store the
  10582. 7:21:38conversation you can use conversation
  10583. 7:21:40buffer memory for that but this kinds of
  10584. 7:21:42thing is not possible okay I hope it is
  10585. 7:21:45clear guys now guys let's talk about the
  10586. 7:21:48hard challenges uh we'll be facing um uh
  10587. 7:21:52which is eventdriven execution. Okay. So
  10588. 7:21:55what is this eventdriven execution? See
  10589. 7:21:57let's try to understand this one. So the
  10590. 7:22:00workflow we have uh seen here. So this
  10591. 7:22:02workflow can be executed in two way. Um
  10592. 7:22:05money is
  10593. 7:22:08uh let's say this is the workflow.
  10594. 7:22:12Okay. So this can be executed through
  10595. 7:22:14sequential manner.
  10596. 7:22:17Okay. And event driven
  10597. 7:22:21event driven. Okay. So let's try to
  10598. 7:22:24understand the sequential. So let's say
  10599. 7:22:27um sequential means let's say uh you are
  10600. 7:22:30implementing through the lang chain and
  10601. 7:22:31I think you know lang chain works in a
  10602. 7:22:33uh in a chain order that means in a
  10603. 7:22:35sequential order. So what I can do maybe
  10604. 7:22:40just a minute
  10605. 7:22:46or let's clear H. [clears throat]
  10606. 7:22:50So see in Lchen
  10607. 7:22:59in Lchen
  10608. 7:23:01you have created in a sequential order.
  10609. 7:23:03So let's say first of all you have given
  10610. 7:23:06a prompt
  10611. 7:23:08then you are passing this prompt to LLM
  10612. 7:23:11lm is giving a uh kinds of output again
  10613. 7:23:13you are preparing another prompt again
  10614. 7:23:16this output and prompt you are giving to
  10615. 7:23:17another LLM
  10616. 7:23:19okay LM then you are getting some kinds
  10617. 7:23:21of response here
  10618. 7:23:24response here right so this is called
  10619. 7:23:26actually sequential left to right you
  10620. 7:23:28can see left right it is happening so
  10621. 7:23:29this is a sequential order
  10622. 7:23:32sequential order it is following. Okay.
  10623. 7:23:35So, sequential order means this will
  10624. 7:23:38start and this will uh complete the
  10625. 7:23:41execution then it will be completed.
  10626. 7:23:42Okay. In between it is not pausing
  10627. 7:23:45anywhere. Okay. In between it is not
  10628. 7:23:47pausing anywhere. But if you see the
  10629. 7:23:49workflow inside workflow sometimes we
  10630. 7:23:52have to pause the execution. Okay. So
  10631. 7:23:55let's say if I give you example
  10632. 7:23:57let's say if I come here you can see so
  10633. 7:24:00whenever this workflow is running right
  10634. 7:24:01it is running the workflow it's
  10635. 7:24:03completely fine but here you can see it
  10636. 7:24:06is waiting for some manual trigger right
  10637. 7:24:08let's say it will uh wait for 7 days
  10638. 7:24:12after waiting for 7 days then what it
  10639. 7:24:14will do after posting the job
  10640. 7:24:16description it will wait for 7 days then
  10641. 7:24:18your monitoring application will be
  10642. 7:24:19started okay so here it is waiting for
  10643. 7:24:22some kinds of trigger Okay. So this
  10644. 7:24:25triggering concept is not available
  10645. 7:24:26inside that sequential execution. Okay.
  10646. 7:24:29It is not available inside langen.
  10647. 7:24:31Langen doesn't have any kinds of uh uh
  10648. 7:24:34this uh pausing option triggering
  10649. 7:24:36option. Okay. You can't do that.
  10650. 7:24:40Okay. But you can implement inside
  10651. 7:24:42langen. So for this what you have to do
  10652. 7:24:44let's say maybe you'll be creating this
  10653. 7:24:47part separately. Then you will wait for
  10654. 7:24:497 days. Okay. Let's say in some uh in
  10655. 7:24:52Python code you will be writing a
  10656. 7:24:54function that that function will try to
  10657. 7:24:56wait for seven days then again you will
  10658. 7:24:58run this particular uh this particular
  10659. 7:25:01let's say workflow okay so that means
  10660. 7:25:02you have to do it manually again you
  10661. 7:25:04have to write the glue code for that but
  10662. 7:25:06inside langraph okay inside lang graph
  10663. 7:25:09this kinds of concept is available this
  10664. 7:25:11eventdriven concept is available so
  10665. 7:25:13langen what it will do so automatically
  10666. 7:25:16because it has the state connection
  10667. 7:25:17right it has the state connection and
  10668. 7:25:19the state itself this uh metadata would
  10669. 7:25:22be available. You have to wait for 3
  10670. 7:25:23days. So in lang lang graph
  10671. 7:25:26automatically this particular
  10672. 7:25:27eventdriven option should be available.
  10673. 7:25:29So it will wait for the trigger. So once
  10674. 7:25:31this trigger is complete then it will
  10675. 7:25:32run the remaining workflow for you.
  10676. 7:25:35Okay. So this is another challenges
  10677. 7:25:37you'll be getting if you're using langin
  10678. 7:25:39for building this kinds of agentic
  10679. 7:25:42workflow. Okay. I hope you clear guys.
  10680. 7:25:45So guys uh next challenges uh you'll be
  10681. 7:25:48getting called fault tolerance. So what
  10682. 7:25:50is this fault tolerance? Fault tolerance
  10683. 7:25:52means let's say whenever we are running
  10684. 7:25:54these kinds of big workflow so
  10685. 7:25:56definitely there would be some kinds of
  10686. 7:25:57fault in your application. Okay, fault
  10687. 7:26:00in your application. Fault means let's
  10688. 7:26:02say sometimes for uh what happens? Let's
  10689. 7:26:04say you are executing the workflow.
  10690. 7:26:06Let's say here you are executing the
  10691. 7:26:09workflow uh at this particular workflow
  10692. 7:26:12is getting executed. This particular
  10693. 7:26:13block is executed. That time let's say
  10694. 7:26:15you are posting the job description to
  10695. 7:26:16the LinkedIn. Let's say uh that time
  10696. 7:26:19LinkedIn API is not working. So
  10697. 7:26:21definitely your application will stop
  10698. 7:26:23that time. Okay. So this is called
  10699. 7:26:24fault. Uh there is another fault. um
  10700. 7:26:28let's say you have deployed this
  10701. 7:26:30workflow in a server let's say AWS and
  10702. 7:26:33AWS got down so this is another fault so
  10703. 7:26:35that means this fault can be two types
  10704. 7:26:37one is small type
  10705. 7:26:41small type and one is big type okay in
  10706. 7:26:44small type uh what is happening you are
  10707. 7:26:47getting the fault in between let's say
  10708. 7:26:50in between the block let's say you are
  10709. 7:26:52not able to post the job in the LinkedIn
  10710. 7:26:54because LinkedIn API is down Okay,
  10711. 7:26:58big fault means let's say you are you
  10712. 7:27:00have hosted this workflow in AWS and AWS
  10713. 7:27:02got down that time your application will
  10714. 7:27:04crash. So what happens inside uh this uh
  10715. 7:27:08lang chain lang chain doesn't have any
  10716. 7:27:11kinds of fault tolerance functionality
  10717. 7:27:13integrated with it. That means if you're
  10718. 7:27:15creating a chain let's say you have
  10719. 7:27:16created this kinds of chain.
  10720. 7:27:19Okay. This kinds of chain. Okay. So how
  10721. 7:27:22chain executed? It executed in a
  10722. 7:27:23sequential order. Let's say here you you
  10723. 7:27:26break the chain. Okay. Let's say for a
  10724. 7:27:27reason let's say this is the post job
  10725. 7:27:30description. Let's say API is not
  10726. 7:27:32working. So that time it will break here
  10727. 7:27:34and all of the application will be break
  10728. 7:27:38okay break then whenever you will be uh
  10729. 7:27:41re-executing again it will reexecute
  10730. 7:27:43from the beginning okay from here it
  10731. 7:27:44will execute okay but already you have
  10732. 7:27:48done so many stuff before posting the
  10733. 7:27:50job description let's say your JD is
  10734. 7:27:51prepared everything is ready but if
  10735. 7:27:53you're running from beginning again it
  10736. 7:27:55will do everything then again it will
  10737. 7:27:57post the job description over the
  10738. 7:27:59LinkedIn that means it is not able to
  10739. 7:28:01resume from here okay it is not able to
  10740. 7:28:03resume from here. It is executing the
  10741. 7:28:05entire workflow again.
  10742. 7:28:07Okay. Inside uh lime chain, this is the
  10743. 7:28:10problem. Okay. Uh and let's say if your
  10744. 7:28:14server is getting down, AWS is getting
  10745. 7:28:16down also again you have to execute from
  10746. 7:28:18the beginning. But inside langraph uh
  10747. 7:28:21this fall tolerance functionality is
  10748. 7:28:23available. So basically what happens
  10749. 7:28:26let's say whenever you are creating this
  10750. 7:28:27kinds of workflow. Let's say this is
  10751. 7:28:29your workflow. Okay, this is your
  10752. 7:28:31workflow. So let's say you are coming
  10753. 7:28:33here and you you got you got some kinds
  10754. 7:28:37of error. Let's say your LinkedIn API is
  10755. 7:28:39not working that time it will give you
  10756. 7:28:42um one option called retry. Okay, retry.
  10757. 7:28:46So if you do the retry operation that
  10758. 7:28:48means from after some times from here
  10759. 7:28:51only your execution will start that
  10760. 7:28:53means it will go to the this node and
  10761. 7:28:54this node. Okay, it it doesn't have uh
  10762. 7:28:57has to come here from beginning and run
  10763. 7:28:59the entire workflow. Okay. And let's say
  10764. 7:29:02you have hosted over the AWS AWS got
  10765. 7:29:04shut down. And let's say you run till
  10766. 7:29:07here. There is some other workflow also
  10767. 7:29:10available. Let's say you run till here.
  10768. 7:29:11Okay. So whenever you again let's say uh
  10769. 7:29:14your AWS server uh fixed. Okay. And uh
  10770. 7:29:18it is running again. So again it will uh
  10771. 7:29:21continue from here. Again it will
  10772. 7:29:23continue from here. Again it doesn't
  10773. 7:29:25need to run from the beginning. So this
  10774. 7:29:27kinds of fall tolerance option is
  10775. 7:29:28available. And again this fault
  10776. 7:29:29tolerance uh how it is u I mean handling
  10777. 7:29:33with the help of the state concept state
  10778. 7:29:35concept because we are having the state
  10779. 7:29:37informations okay all of the state
  10780. 7:29:39information every time langraph will
  10781. 7:29:41take this snapshot of the state and it
  10782. 7:29:43will stored in a memory okay you can
  10783. 7:29:44also use a physical memory here if you
  10784. 7:29:47want some memory database you can use
  10785. 7:29:49and this state you can save inside a
  10786. 7:29:50memory so every time it will take a
  10787. 7:29:52snapshot of the state let's say what is
  10788. 7:29:54the current execution current execution
  10789. 7:29:56let's say post job description
  10790. 7:29:58Post job description. Let's say here
  10791. 7:30:00your uh uh let's say you got the fault.
  10792. 7:30:03Okay. So this kinds of state already
  10793. 7:30:06saved. Let's say before this post job
  10794. 7:30:09description everything is ready but
  10795. 7:30:10during post job description this is
  10796. 7:30:12failed. So what it will do again retry
  10797. 7:30:13from here again retry from here. It will
  10798. 7:30:16not run from the beginning. Okay. I hope
  10799. 7:30:18you got it. So that's why fall tolerance
  10800. 7:30:20is another challenges inside langen. So
  10801. 7:30:23guys, the next challenges uh and the
  10802. 7:30:26very important challenges you'll be
  10803. 7:30:28facing if you're using langen called
  10804. 7:30:30human in the loop or hittl
  10805. 7:30:32uh hl uh I think you know what is human
  10806. 7:30:35in loop uh human in the loop and why it
  10807. 7:30:38is required because I have given you the
  10808. 7:30:40same example and let's try to understand
  10809. 7:30:43from this workflow itself. So human in
  10810. 7:30:45the loop actually it depends upon the
  10811. 7:30:47human input. So uh basically you are not
  10812. 7:30:50giving the full access to the agent
  10813. 7:30:52instead of that some of the uh
  10814. 7:30:56restriction you are setting let's say
  10815. 7:30:57whenever it will create the job
  10816. 7:30:58description uh before posting the job
  10817. 7:31:02description it will ask for the approved
  10818. 7:31:04to the human let's say it is asking for
  10819. 7:31:05the approve to you if you approve that
  10820. 7:31:08then it will post this job description
  10821. 7:31:10okay or let's say here before sending
  10822. 7:31:14this uh conducting the interview it will
  10823. 7:31:15ask you uh whether uh you free or not?
  10824. 7:31:19Can I schedule the interview? So if you
  10825. 7:31:21give the access then it will like um
  10826. 7:31:24schedule the interview for you. Okay. So
  10827. 7:31:26this is called human in the loop and
  10828. 7:31:28this human in the loop functionality is
  10829. 7:31:29not available um default inside lang. Um
  10830. 7:31:33I mean you can't um take the human in uh
  10831. 7:31:36I mean human input in between the chain.
  10832. 7:31:39So let's say if you create a chain here.
  10833. 7:31:42Let's say this is your chain.
  10834. 7:31:47This is your chain right and in between
  10835. 7:31:50let's say you have to take a input from
  10836. 7:31:51the human okay you have to take the
  10837. 7:31:53input from the human
  10838. 7:31:55that time uh you can't actually uh I
  10839. 7:31:58mean uh use any kinds of default
  10840. 7:32:00functionality for that so maybe what you
  10841. 7:32:01can do in between maybe you can take a
  10842. 7:32:03input function and you can take the
  10843. 7:32:05input from the human but again uh this
  10844. 7:32:08will stop the chain here okay unless and
  10845. 7:32:10until you are not giving the input this
  10846. 7:32:11chain won't be executed or it will take
  10847. 7:32:13unnecessary computation and whenever it
  10848. 7:32:15is longterm Right? Long-term means uh
  10849. 7:32:17this kind of aentic system is long-term.
  10850. 7:32:19So user can give the input after 2 days
  10851. 7:32:22as well. Right? So that time I don't
  10852. 7:32:25want to necessarily compute uh I don't
  10853. 7:32:27want to necessarily use my computation.
  10854. 7:32:29Right? So this is another problem. So
  10855. 7:32:31maybe you can create this chain
  10856. 7:32:32separately this ch separately in between
  10857. 7:32:33you can ask the input and whenever user
  10858. 7:32:35will give the input then you can recont
  10859. 7:32:38this chain from here. Okay. But again
  10860. 7:32:39you have to take all of this state uh I
  10861. 7:32:42mean state data manually and you have to
  10862. 7:32:45copy here again. So again you have to
  10863. 7:32:46write some glue code there for that
  10864. 7:32:48right. But inside this uh lang graph
  10865. 7:32:51this human is loop already implemented.
  10866. 7:32:53Okay this is already the first class
  10867. 7:32:57citizen. Okay first class citizen inside
  10868. 7:33:00this lang graph. It is already uh
  10869. 7:33:03already available. Okay already
  10870. 7:33:05available. Even if you go to the uh
  10871. 7:33:07documentation of langraph uh there is a
  10872. 7:33:10separate section for that. Let me show
  10873. 7:33:12you. So this is the langraph
  10874. 7:33:13documentation. So you can see human in
  10875. 7:33:16the loop is available. So the human in
  10876. 7:33:18the loop um hittl
  10877. 7:33:22middleware wire lets you and human
  10878. 7:33:24oversight uh to agents to call when
  10879. 7:33:28model response an action that might
  10880. 7:33:30requires a review. For example, writing
  10881. 7:33:32to a file or execution SQL. Uh the um
  10882. 7:33:36middleware can pause execution and wait
  10883. 7:33:38a decision. Okay. So you can see this
  10884. 7:33:40particular option is available and they
  10885. 7:33:42have already integrated in their
  10886. 7:33:43functionality. Okay, human in the loop.
  10887. 7:33:45Okay, this is already available. We'll
  10888. 7:33:47definitely learn this in detail whenever
  10889. 7:33:49we'll uh learn the langen component. Uh
  10890. 7:33:51sorry, lang lang graph component. I will
  10891. 7:33:53try to learn each and everything. Okay,
  10892. 7:33:55I I hope this part is clear. That means
  10893. 7:33:57this is another challenges you'll be
  10894. 7:33:59getting uh if you're using langen. Okay,
  10895. 7:34:01and this is super important guys. If
  10896. 7:34:02you're is creating this kinds of
  10897. 7:34:04workflow, so this uh human in loop is
  10898. 7:34:06required there. Okay, I hope you clear.
  10899. 7:34:09Now let's talk about the next one which
  10900. 7:34:11is nested workflow. uh nested workflow
  10901. 7:34:14means see inside langraph you can run
  10902. 7:34:16the nested workflow. So whenever I'm
  10903. 7:34:19talking about lang graph I think you
  10904. 7:34:20know we can create actually complex
  10905. 7:34:25nodes here right it works as a node
  10906. 7:34:30okay you can create this kinds of node
  10907. 7:34:32okay now let's say a nested workflow
  10908. 7:34:36means the nodes you are creating
  10909. 7:34:38um inside this nodes you can create
  10910. 7:34:41another graph
  10911. 7:34:43let's say this node represents this
  10912. 7:34:45kinds of graph okay that means This node
  10913. 7:34:48itself it's a graph object. This is
  10914. 7:34:50called nested workflow. Okay, I I think
  10915. 7:34:53you get it. We call it as a subnote. So
  10916. 7:34:55there is a concept inside the
  10917. 7:34:57documentation. Let me show you.
  10918. 7:35:01Um this is the documentation. Uh you can
  10919. 7:35:05see if you see there is a concept called
  10920. 7:35:07sub sub node. So let's say this is your
  10921. 7:35:10uh node. This node itself should be a uh
  10922. 7:35:12another graph. Uh and you can use this
  10923. 7:35:15particular graph. Okay. So this is
  10924. 7:35:17called actually sub sub node concept and
  10925. 7:35:19we call it as a nested workflow and this
  10926. 7:35:21nested workflow is very much required
  10927. 7:35:23whenever you are creating this kinds of
  10928. 7:35:24system. So let's say if I'm talking
  10929. 7:35:26about a use case. So let's say if I'm
  10930. 7:35:29talking about this conduct interview
  10931. 7:35:31okay since said conduct interview uh
  10932. 7:35:33this thing is not like uh very easy to
  10933. 7:35:36implement because just try to think
  10934. 7:35:38about if I want to conduct the interview
  10935. 7:35:40first of all I have to prepare um set of
  10936. 7:35:43questions for each and every candidate
  10937. 7:35:46then I have to also
  10938. 7:35:49um uh take the interview let's say round
  10939. 7:35:50one round two round three okay I have to
  10940. 7:35:52track those informations so instead of
  10941. 7:35:54creating a single uh nodes here maybe I
  10942. 7:35:57and uh create it as a sub node. So this
  10943. 7:35:59will be connected with another nodes and
  10944. 7:36:01that uh sorry this will connected with
  10945. 7:36:04another workflow another graph and this
  10946. 7:36:06graph will try to uh let's say uh
  10947. 7:36:08prepare the interview questions for the
  10948. 7:36:09candidate or uh taken taken care by the
  10949. 7:36:12round one round two round three okay and
  10950. 7:36:14so on. So these kinds of complex uh
  10951. 7:36:17nodes whenever it is coming you can
  10952. 7:36:19simply handle with the help of this
  10953. 7:36:21nested workflow and this is very much
  10954. 7:36:23important whenever you are building any
  10955. 7:36:25kinds of uh multi- aent system. Okay, in
  10956. 7:36:29multi- aent system, this nested workflow
  10957. 7:36:31is required that time. But this uh
  10958. 7:36:33nested workflow functionality is not
  10959. 7:36:35available inside langen. Inside lang
  10960. 7:36:38actually we can't create this kinds of
  10961. 7:36:40sub nodes and all this is not possible.
  10962. 7:36:42Okay. So that's why uh you can call it
  10963. 7:36:45uh this is as a feature inside lang
  10964. 7:36:46graph as well. Now guys the last uh
  10965. 7:36:50challenges will be understanding which
  10966. 7:36:52is observable uh observability.
  10967. 7:36:55So basically uh what is observability
  10968. 7:36:59actually let's try to understand
  10969. 7:37:00observability refers to how easily you
  10970. 7:37:03can monitor debugs and understand what
  10971. 7:37:06your workflow is doing at the runtime.
  10972. 7:37:08So whenever we are running these kinds
  10973. 7:37:10of runtime so definitely we have to uh
  10974. 7:37:13continuously do the observation
  10975. 7:37:14otherwise what will happen uh sometimes
  10976. 7:37:17it will do some um let's say unexpected
  10977. 7:37:20uh task right let's say you have run
  10978. 7:37:23your um agents uh uh for the LinkedIn
  10979. 7:37:28ads okay so let's say it is running the
  10980. 7:37:30LinkedIn ads continuously and you will
  10981. 7:37:33end up with lots of cost that time right
  10982. 7:37:35let's say it's not necessary to run that
  10983. 7:37:38much of uh LinkedIn ads or that much of
  10984. 7:37:41budget right so that time uh if you're
  10985. 7:37:43not doing observations so definitely you
  10986. 7:37:46will end up with lots of cost uh so that
  10987. 7:37:48that that's why observability is
  10988. 7:37:50required but it's not like that we'll
  10989. 7:37:51sit there manually observe all of the
  10990. 7:37:54execution it's not like that so
  10991. 7:37:56definitely we have to use some automated
  10992. 7:37:57things that will continuously do the
  10993. 7:38:00observation continuously do the
  10994. 7:38:01monitoring uh and uh it will give me the
  10995. 7:38:04report okay so fortunately in lang chain
  10996. 7:38:08If I'm talking about Langshen, Langshen
  10997. 7:38:11has
  10998. 7:38:13um observability tool which is Langmith.
  10999. 7:38:17Okay, I think you heard about Langmith.
  11000. 7:38:19So, Langmith is a um like observation
  11001. 7:38:23tool with the help of Lang Langsmith. We
  11002. 7:38:25can continuously track the Lang Lang
  11003. 7:38:28chain actually pipeline Langchen chain.
  11004. 7:38:30So whatever lang chain um chain will be
  11005. 7:38:32executed all of the uh all of the
  11006. 7:38:35actually let's say parameter we can uh
  11007. 7:38:38we can actually monitor here in the lang
  11008. 7:38:40langismith will automatically monitor so
  11009. 7:38:42by default lang langismith um can
  11010. 7:38:44support this lang chain u monitoring
  11011. 7:38:47okay and don't worry we'll try to
  11012. 7:38:49understanding langismith as well
  11013. 7:38:50continuously uh sorry uh going forward
  11014. 7:38:53but what is the problem with the lang
  11015. 7:38:56chain uh if you're using langismith with
  11016. 7:38:58that uh see if you're implementing
  11017. 7:38:59writing this workflow with the help of
  11018. 7:39:01Langen. So definitely you have to write
  11019. 7:39:02lots of glue code. I already told you
  11020. 7:39:04right you have to write lots of glue
  11021. 7:39:05code but glue code cannot be uh
  11022. 7:39:08monitored with the help of lang.
  11023. 7:39:10Langismith only can monitor your lang
  11024. 7:39:12chain chain okay chain code or whatever
  11025. 7:39:15you are writing inside that but if
  11026. 7:39:17you're writing extra glue code you can't
  11027. 7:39:19actually uh you can't actually uh track
  11028. 7:39:22with the line speed this is not possible
  11029. 7:39:23but if I'm talking about lang graph if
  11030. 7:39:26I'm talking about lang graph okay lang
  11031. 7:39:28graph is having very strong connection
  11032. 7:39:31okay it is having very um strong
  11033. 7:39:33connection with lang
  11034. 7:39:37okay so that means whatever node
  11035. 7:39:39execution you are doing one by one all
  11036. 7:39:41of the node would be tracked in the lang
  11037. 7:39:44smmith okay langismith and you can see
  11038. 7:39:47each and everything okay so that's why
  11039. 7:39:49this langu as a observ observability
  11040. 7:39:52tool we'll be learning in this playlist
  11041. 7:39:54as well in detail I'll tell you how to
  11042. 7:39:56use the lang and all and how we can
  11043. 7:39:58perform the monitoring operation of our
  11044. 7:40:00agent each and everything we we'll also
  11045. 7:40:02try to understand here okay this is
  11046. 7:40:04super important and uh uh yeah I think
  11047. 7:40:06this is a good practice to add the
  11048. 7:40:08observability uh whenever you are
  11049. 7:40:10creating the application because there
  11050. 7:40:11you will get the enough understanding
  11051. 7:40:12about your workflow execution okay at
  11052. 7:40:15runtime this is super important so yes
  11053. 7:40:18guys we are done with uh all of the
  11054. 7:40:20challenges we have understood each and
  11055. 7:40:22everything in detail now we'll try to
  11056. 7:40:24conclude uh this video uh so before
  11057. 7:40:27concluding let me tell you few things so
  11058. 7:40:31guys so far we have understood uh about
  11059. 7:40:33the langraph and difference between lang
  11060. 7:40:36and lang graph um And I also uh showed
  11061. 7:40:41you the challenges actually we will be
  11062. 7:40:43facing. Okay. If you're using only
  11063. 7:40:46langen okay if you're not using lang
  11064. 7:40:48graph what would be the challenges. Now
  11065. 7:40:51you have pretty much u good
  11066. 7:40:53understanding about the langraph what
  11067. 7:40:54exactly the lang graph is. But again I
  11068. 7:40:56have given a definition you can see lang
  11069. 7:40:58graph is an orchestration framework that
  11070. 7:41:00enables you to build straightful
  11071. 7:41:02multi-step and event-driven workflow
  11072. 7:41:04using large language model. it uh it's
  11073. 7:41:07deals uh ideal for uh designing both
  11074. 7:41:11single agents and multi-agent
  11075. 7:41:12applications. Think of a langraph as a
  11076. 7:41:15flowchart engine for LLM. You define the
  11077. 7:41:18uh steps nodes. Okay, we call it as a
  11078. 7:41:20nodes how they are connected edges um
  11079. 7:41:23and uh and the logic that um governs the
  11080. 7:41:28transitions. Langraph takes care of
  11081. 7:41:30state management, conditional branching,
  11082. 7:41:32looping, pausing, resuming, fault
  11083. 7:41:34recovery feature uh feature essential
  11084. 7:41:37for building robust production grade AI
  11085. 7:41:39system. Okay. So I think you have seen I
  11086. 7:41:41have introduced so many um so many
  11087. 7:41:43actually strong terms here like uh this
  11088. 7:41:46uh edges branching looping pausing okay
  11089. 7:41:49fault recovery. So now I think this uh
  11090. 7:41:52these are the terms are clear because I
  11091. 7:41:54have already clarified these are the
  11092. 7:41:55terms then I given you the introduction.
  11093. 7:41:57So at the very beginning I could have
  11094. 7:41:59given you the introduction to this line
  11095. 7:42:01graph okay uh this kinds of uh
  11096. 7:42:03definition I can show you this uh this
  11097. 7:42:05uh actually page I can show you but uh
  11098. 7:42:08you won't be able to understand okay
  11099. 7:42:10what the langraph is and you that time
  11100. 7:42:12actually you are not familiar with these
  11101. 7:42:13are the concept so what I have done
  11102. 7:42:15actually I have clarified all the
  11103. 7:42:17concept now I have given you the
  11104. 7:42:18introduction okay I have given you uh I
  11105. 7:42:20have uh told you what is line graph
  11106. 7:42:22exactly okay now I think you are pretty
  11107. 7:42:24much uh clear with now let's try to
  11108. 7:42:26understand when to use what kinds of
  11109. 7:42:29framework. So use langen when you are
  11110. 7:42:31building simple linear workflow like
  11111. 7:42:33prompt chaining summarization or basic
  11112. 7:42:36retriever system chatbots okay these are
  11113. 7:42:38the things and use langraph when you use
  11114. 7:42:41case uh involves complex nonlinear
  11115. 7:42:44workflow that needs conditional paths
  11116. 7:42:46loops okay human in the loops concept
  11117. 7:42:49and multi- aent coordination and
  11118. 7:42:50asynchronous or even driven execution
  11119. 7:42:52okay so now I think guys uh you have the
  11120. 7:42:55understanding uh about uh this concept
  11121. 7:42:58like when to use what kinds of
  11122. 7:43:00framework. Uh so based on the problem
  11123. 7:43:02statement you can decide whether you
  11124. 7:43:04will be using the langen, whether you
  11125. 7:43:05will be using the langraph for that.
  11126. 7:43:07Okay. So now I think you have the enough
  11127. 7:43:09understanding on that. Now one more very
  11128. 7:43:12important things will be understanding
  11129. 7:43:13at the last uh so see people uh people
  11130. 7:43:17will uh I mean uh tell you like uh don't
  11131. 7:43:20use uh lang chain lang chain is like
  11132. 7:43:23deprecated and all okay so should we
  11133. 7:43:25still use lang chain or not? because
  11134. 7:43:27this kinds of question will definitely
  11135. 7:43:28come and uh through the entire video
  11136. 7:43:30actually I have given the appreciation
  11137. 7:43:31to the langraph instead of giving to the
  11138. 7:43:34langen okay but things is not like that
  11139. 7:43:37see still we have to use this langen
  11140. 7:43:40okay langen is required why because
  11141. 7:43:43langraph is built on top of langen okay
  11142. 7:43:46internally they're using langen only
  11143. 7:43:49okay uh then they have created this
  11144. 7:43:51langraph framework so it is basically
  11145. 7:43:53handling the complex workflow okay the
  11146. 7:43:56complex workflow uh by adding the
  11147. 7:43:58nodding concept but internally it is
  11148. 7:44:00using langen because if you see still
  11149. 7:44:04you need langen components like if you
  11150. 7:44:05want to load any kinds of llm you have
  11151. 7:44:07to use chat openi or any other open uh
  11152. 7:44:09let's say llm provider uh functionality
  11153. 7:44:12if you want to create a prompt uh so you
  11154. 7:44:14have to use the prompt template if you
  11155. 7:44:15want to create a retriever system you
  11156. 7:44:16have to use the retriever documents
  11157. 7:44:18loader tools etc okay these are the
  11158. 7:44:20things you will be only uh loading from
  11159. 7:44:22the langen not from the langraph okay I
  11160. 7:44:25think you get it And langraph handles
  11161. 7:44:26workflow orchestration while langchen
  11162. 7:44:28provides the building block for each
  11163. 7:44:30steps in the workflow. That means langen
  11164. 7:44:32is uh very important. Okay. But we can't
  11165. 7:44:36use langen to build the entire complex
  11166. 7:44:38workflow orchestration. Okay. We create
  11167. 7:44:41this orchestration. We create this
  11168. 7:44:42workflow orchestration with langraph.
  11169. 7:44:44But internally langraph uses some langen
  11170. 7:44:47building blocks like these are the
  11171. 7:44:48building blocks to uh work on that.
  11172. 7:44:50Okay. I hope this part is clear guys.
  11173. 7:44:53Okay. So guys uh I think uh you have uh
  11174. 7:44:57now clear and uh I mean enough amount
  11175. 7:45:00understanding on this langraph lang
  11176. 7:45:02chain uh you have got the detailed
  11177. 7:45:05introduction to the langraph uh and uh
  11178. 7:45:08don't worry I'm going to teach you the
  11179. 7:45:11uh teach you all of the component of the
  11180. 7:45:12langraph we'll be also building the
  11181. 7:45:14agents with that okay each and
  11182. 7:45:15everything we'll be covering um in this
  11183. 7:45:18uh course itself okay now in this video
  11184. 7:45:21I'm going to discuss uh some important
  11185. 7:45:24core component of langraph because uh
  11186. 7:45:27what I feel like uh before starting the
  11187. 7:45:30actual langraph concept first of all
  11188. 7:45:32let's try to understand the langraph
  11189. 7:45:34core component so once we have
  11190. 7:45:37understood the lang lang graph core
  11191. 7:45:39component it would be easy for us to
  11192. 7:45:42learn all of these component one by one
  11193. 7:45:44then we can combine all of them together
  11194. 7:45:46and we can build any kinds of agenti
  11195. 7:45:49application so guys as you can see uh
  11196. 7:45:52what is lang Lang graph lang graph is an
  11197. 7:45:54orchestration framework for building
  11198. 7:45:56intelligence stateful and multi-step L
  11199. 7:45:59workflows uh it enables advanced
  11200. 7:46:02features like parallelism loops
  11201. 7:46:05branching memory and resumeumability
  11202. 7:46:08making it ideal for agentic and
  11203. 7:46:10production grade AI applications and
  11204. 7:46:13lang models your logic as a graph of
  11205. 7:46:15nodes basically we call it as a task and
  11206. 7:46:18ages okay I think you saw there are some
  11207. 7:46:21uh ages we are drawing um in my previous
  11208. 7:46:24class right so uh we call it as a edges
  11209. 7:46:26we also call it as a routing instead of
  11210. 7:46:28a linear chain okay so in langen we used
  11211. 7:46:31to create a linear chain but here uh we
  11212. 7:46:34don't create the linear chain instead of
  11213. 7:46:36that we try to make everything as a
  11214. 7:46:38graph um and uh uh to make this graph we
  11215. 7:46:42use nodes and edges okay inside line
  11216. 7:46:44graph so let's say you are having a LA
  11217. 7:46:46markflow so let's say this is our L
  11218. 7:46:49markflow
  11219. 7:46:52Okay, this is our LM workflow and this
  11220. 7:46:54is called actually edges. Okay, this is
  11221. 7:46:56called actually edges
  11222. 7:47:00H. So let's say this is our LM workflow.
  11223. 7:47:03Okay, I'll tell you more about this LM
  11224. 7:47:05workflow. What is LM workflow is? LMA
  11225. 7:47:07workflow is nothing but um I told you
  11226. 7:47:10about the workflow, right? Workflow is
  11227. 7:47:11nothing but it's a uh it's a process of
  11228. 7:47:14executing a entire uh let's say
  11229. 7:47:16application, entire problem statement.
  11230. 7:47:18So basically we try to represent as a
  11231. 7:47:20workflow and inside that we use LLM
  11232. 7:47:23right. So that's why we call it as LM
  11233. 7:47:25workflows. So you can see um this is the
  11234. 7:47:28LM workflows. So here we pass any kinds
  11235. 7:47:31of input. Okay. And all of these you can
  11236. 7:47:35see node. Okay. This is called actually
  11237. 7:47:36node. This is called actually node. This
  11238. 7:47:39node can be called as a task. Okay. Task
  11239. 7:47:43basically let's say you are having you
  11240. 7:47:46are having a entire goal. Okay, entire
  11241. 7:47:48goal. So to achieve this goal, what you
  11242. 7:47:52have to do? We have to break down this
  11243. 7:47:53goal as a task. Okay, different
  11244. 7:47:55different subtask. And each of the
  11245. 7:47:57subtasks can be represented as a node.
  11246. 7:48:00Okay, in lang graph. So we try to
  11247. 7:48:02represent as a node. So this node will
  11248. 7:48:05perform all of the task. Let's say some
  11249. 7:48:07of the let's say the first node is
  11250. 7:48:09responsible for taking the input. Second
  11251. 7:48:12node is responsible let's say preparing
  11252. 7:48:14the prompt. Okay. Then third node is
  11253. 7:48:16responsible for calling the LLM. Okay,
  11254. 7:48:19that's how another node will be
  11255. 7:48:21responsible for calling a tool. That's
  11256. 7:48:22how it is defining a separate separate
  11257. 7:48:25task as a node. Okay, I hope you get it.
  11258. 7:48:28Now we also call it as a flowchart. We
  11259. 7:48:32also call it as a flowchart. As you if
  11260. 7:48:34you see this particular graph, this is
  11261. 7:48:36kinds of flowchart. Okay. Now you can
  11262. 7:48:39see inside lang graph we can perform
  11263. 7:48:42this parallelism looping branching
  11264. 7:48:45memory reasonability each and
  11265. 7:48:47everything. So if I'm talking about the
  11266. 7:48:48parallelism so lang graph can be also
  11267. 7:48:51executed in a parallel. Okay, let's say
  11268. 7:48:53here you are having
  11269. 7:48:56a a node. Here also you are having a
  11270. 7:48:57node. So both node can be executed
  11271. 7:49:00parallelly. Okay, both node can be
  11272. 7:49:02executed parallelly. Let's say you are
  11273. 7:49:04preparing a prompt template and here you
  11274. 7:49:06are calling the LM. Okay, so it's not
  11275. 7:49:08like that after preparing the prompt
  11276. 7:49:10template you will call the LM. Both you
  11277. 7:49:12can execute in parallel, right? That's
  11278. 7:49:13how there are so many problem statement
  11279. 7:49:16you can I mean um consider here. Okay.
  11280. 7:49:20Now it can also supports this looping
  11281. 7:49:22concept. Looping concept means let's say
  11282. 7:49:26sometimes let's say you are you are here
  11283. 7:49:28in this particular node. Let's say after
  11284. 7:49:30completing this node again you have to
  11285. 7:49:32go back. Okay again you have to go back
  11286. 7:49:35and uh again you will re-execute and
  11287. 7:49:37again you will try to send to the
  11288. 7:49:39another nodes. I think you remembered
  11289. 7:49:41our previous uh uh previous actually um
  11290. 7:49:45example I have given you that uh
  11291. 7:49:47interview uh interview agent AI uh I
  11292. 7:49:50think uh huh so interview uh interview
  11293. 7:49:53system okay that interview system what
  11294. 7:49:55happens let's say whenever u uh sorry
  11295. 7:49:58not interview that was actually
  11296. 7:50:00recruitment agent so that actually what
  11297. 7:50:03happened let's say if uh if let's say
  11298. 7:50:06your job description uh is not generated
  11299. 7:50:08properly so what it will again it will
  11300. 7:50:10go back and again it will regenerate. So
  11301. 7:50:12this is called actually looping right?
  11302. 7:50:14This is called actually looping. You're
  11303. 7:50:15performing the looping here. Then you
  11304. 7:50:17can also perform the branching
  11305. 7:50:18operation. Branching means the
  11306. 7:50:20condition. Let's say if this condition
  11307. 7:50:22is not true. Okay that means if if it is
  11308. 7:50:24not yes then it will go here. Okay
  11309. 7:50:28that's how you are creating branch here.
  11310. 7:50:29So this is called branching. Let's say
  11311. 7:50:32uh if uh you didn't get uh 20
  11312. 7:50:35applications again what you will do
  11313. 7:50:36again you will try to um like uh change
  11314. 7:50:39the job description and wait for the
  11315. 7:50:41application submission. So this is
  11316. 7:50:42called actually branching. So this
  11317. 7:50:44branching also can be supported. Then
  11318. 7:50:45memory. Memory means let's say each and
  11319. 7:50:48every nodes whatever it is generating
  11320. 7:50:50the output it would be stored inside a
  11321. 7:50:52memory. Okay. It will remember that
  11322. 7:50:54particular output and input as well.
  11323. 7:50:56This is called memory. Okay. Then uh
  11324. 7:50:58reasonability. Reasonability means let's
  11325. 7:51:01say I told you about the um about the
  11326. 7:51:03actually u problem okay problem means
  11327. 7:51:06let's say somehow your one of the uh
  11328. 7:51:09application got uh let's say got trouble
  11329. 7:51:12that means it got stopped let's say it
  11330. 7:51:14got stopped here only in this particular
  11331. 7:51:15node okay in this particular node it has
  11332. 7:51:17stopped so whenever you will uh
  11333. 7:51:20reinitialize the instance so instead of
  11334. 7:51:22running from the beginning it can resume
  11335. 7:51:25from here only it can continue from here
  11336. 7:51:27only this is called resumability
  11337. 7:51:29Okay. So that's why uh we uh call it as
  11338. 7:51:32a like a very powerful uh I mean
  11339. 7:51:35framework this particular langraph
  11340. 7:51:37because the way it is handling all of
  11341. 7:51:39the let's say task all of the um system
  11342. 7:51:43this is completely amazing right and
  11343. 7:51:45that's why uh we can't use the simple
  11344. 7:51:48lang chain here the linear chain here to
  11345. 7:51:51solve this kinds of complex workflow
  11346. 7:51:53that's why lang graph is required and
  11347. 7:51:55this is what actually your lang graph is
  11348. 7:51:57okay so basically here we will be
  11349. 7:51:59working with the nodes and edges okay to
  11350. 7:52:01make a graph okay instead of a linear
  11351. 7:52:04chain I hope you understood guys okay
  11352. 7:52:06now let's try to understand about the LM
  11353. 7:52:09workflow um in more detail uh so you can
  11354. 7:52:12see what is LM workflow first of all
  11355. 7:52:15let's try to understand so LM workflows
  11356. 7:52:18are step-by-step process using which we
  11357. 7:52:21can build a complex LLM applications
  11358. 7:52:24each steps in a workflow performs a
  11359. 7:52:26distinct task such as prompting ing
  11360. 7:52:29reasoning, tool calling, memory access
  11361. 7:52:31or decision making. Workflows can be
  11362. 7:52:33linear, parallel, branched or looped
  11363. 7:52:35allowing for a complex behavior like uh
  11364. 7:52:38retries, multi- aents communication or
  11365. 7:52:41two augmented reasoning and we'll be
  11366. 7:52:43discussing about some common workflows
  11367. 7:52:45as well. So the first workflow as you
  11368. 7:52:47can see this is the linear uh sequential
  11369. 7:52:49workflow. We can also call it as a
  11370. 7:52:51prompt chaining. So here what happens
  11371. 7:52:53let's say whenever we are giving any
  11372. 7:52:55kinds of input it will first of all go
  11373. 7:52:57to LLM. Okay, LM call because I'm
  11374. 7:53:01calling it as a LLM workflow and
  11375. 7:53:02definitely inside the workflow
  11376. 7:53:04definitely LLM call should be there.
  11377. 7:53:06Okay, LLM should be there that time we
  11378. 7:53:08can call it as LM workflows. Okay, if it
  11379. 7:53:10doesn't have any kinds of LLM that time
  11380. 7:53:12you can't call it as LM workflow. And
  11381. 7:53:14now inside a workflow there can be one
  11382. 7:53:17or multiple LM call. Okay, one or
  11383. 7:53:19multiple LM call. It's not like that you
  11384. 7:53:21have to only use one LM call or let's
  11385. 7:53:24say 5 LM call or 100 LM call. You can
  11386. 7:53:26use as many as LM you can inside a
  11387. 7:53:29workflow but make sure LM call should be
  11388. 7:53:32there otherwise we can't call it as LM
  11389. 7:53:34workflow. Okay. So let's say this is our
  11390. 7:53:36workflow. So first of all this input
  11391. 7:53:38will get this particular LLM. Then here
  11392. 7:53:40we are let's say doing a kinds of
  11393. 7:53:42verification whatever output we are
  11394. 7:53:45getting whether it is good or not. Okay.
  11395. 7:53:47If it is good then we are passing it to
  11396. 7:53:49the another LLM. Okay. for another task
  11397. 7:53:52then uh it will uh send an again to
  11398. 7:53:54another LM for another task then it will
  11399. 7:53:57uh give you some kinds of output okay
  11400. 7:53:59otherwise if this particular response is
  11401. 7:54:01not good then it will exit the
  11402. 7:54:03application okay so this is called
  11403. 7:54:04actually linear workflow uh you can
  11404. 7:54:06understand okay from this particular
  11405. 7:54:09so here you can understand uh this
  11406. 7:54:11particular concept from this uh workflow
  11407. 7:54:14itself okay I hope you cleared
  11408. 7:54:17now let's take an example to understand
  11409. 7:54:19this prompt chaining workflow So let's
  11410. 7:54:22say you are building uh you are building
  11411. 7:54:24an agent that agent will take a topic
  11412. 7:54:26okay topic name as an input okay so this
  11413. 7:54:29input should be a topic name topic name
  11414. 7:54:33and what it does it generates a complete
  11415. 7:54:36report on that particular topics okay so
  11416. 7:54:39I think previously you saw I created
  11417. 7:54:41these kinds of agents with the help of
  11418. 7:54:42langen so that I passed a topic and it
  11419. 7:54:44was preparing a detail uh detail
  11420. 7:54:47actually um scientific report on top of
  11421. 7:54:49that Okay. So, [snorts] first of all,
  11422. 7:54:51what you are doing, you are giving this
  11423. 7:54:53particular topic name uh to the first
  11424. 7:54:55LLM call and that means the first LLM
  11425. 7:54:58and this LLM will try to uh we will try
  11426. 7:55:02to generate something. Okay, we'll try
  11427. 7:55:04to generate something. Let's say this
  11428. 7:55:06particular LLM um has generate a draft
  11429. 7:55:09from this particular topic. Okay, so
  11430. 7:55:11let's say it has generated a draft.
  11431. 7:55:14Okay, draft. Now here you are doing a
  11432. 7:55:16verification. Let's say you are writing
  11433. 7:55:18a condition if this particular draft is
  11434. 7:55:21more than 5,000 word. Okay, it is more
  11435. 7:55:24than 5,000 word that time you are not
  11436. 7:55:26going to take. You simply uh exit the
  11437. 7:55:28application. Okay, you only take less
  11438. 7:55:29than 5,000 word. So if it is less than
  11439. 7:55:325,000 word then again what you will do
  11440. 7:55:33again you will pass to the allar LLM.
  11441. 7:55:36Let's say this LLM does the u review
  11442. 7:55:39operation. Okay, review operation that
  11443. 7:55:42means it will perform the review
  11444. 7:55:44operation. The draft you have prepared.
  11445. 7:55:46If review is completely fine, if it
  11446. 7:55:48pass, okay, then it will go to the next
  11447. 7:55:50LLM. This LLM will try to write this
  11448. 7:55:52particular draft in a file. Okay. Uh
  11449. 7:55:55write
  11450. 7:55:58okay write this particular draft in a
  11451. 7:56:00file. Then you will get the output.
  11452. 7:56:02Okay. So this is the example you can
  11453. 7:56:04consider about the prom chaining. Okay.
  11454. 7:56:06So inside prompt chaining what you are
  11455. 7:56:07doing? You are trying to break down a
  11456. 7:56:09task. Okay. Um and you are trying to
  11457. 7:56:12solve it. Okay. Step by step. This is
  11458. 7:56:14called prom chaining. Now let's try to
  11459. 7:56:16understand about the another uh LM
  11460. 7:56:19workflow which is routing. Okay. So this
  11461. 7:56:22is another kinds of LM workflow. Um uh
  11462. 7:56:25this is called routing. Routing means
  11463. 7:56:27here you are getting an input and you
  11464. 7:56:29are using a LM um definitely LLM call.
  11465. 7:56:33But this LLM call we are considering as
  11466. 7:56:35a router. Router means it will basically
  11467. 7:56:38route uh route the route the task. Okay.
  11468. 7:56:42route the task to different different
  11469. 7:56:43LLM. Okay, as you can see, let's say
  11470. 7:56:45this is LLM 1, this is LM2, this is LLM
  11471. 7:56:473. Okay, and here we are getting the
  11472. 7:56:49output. So let's say you are building a
  11473. 7:56:52customer uh support application. Let's
  11474. 7:56:55say for the tech company. So there you
  11475. 7:56:57are getting different different let's
  11476. 7:56:58say customer questions. Let's say uh you
  11477. 7:57:01are getting related um let's say you are
  11478. 7:57:03running an ad tech company. Uh you are
  11479. 7:57:05let's say getting the question related
  11480. 7:57:07about your service. Okay. The service
  11481. 7:57:09you usually provide uh let's say
  11482. 7:57:11whatever course you provide. Okay.
  11483. 7:57:13Whatever let's say content you are
  11484. 7:57:16providing this kinds of service people
  11485. 7:57:18are asking about. So let's say the first
  11486. 7:57:20LM we we just let's say defined this
  11487. 7:57:25service task to the first LM that means
  11488. 7:57:27the prompt we have written here. So this
  11489. 7:57:29particular LM will try to only handle
  11490. 7:57:32about our service. Okay. Service related
  11491. 7:57:33query. So let's say this is the service
  11492. 7:57:36uh service lm. Okay. Now the next let's
  11493. 7:57:39say t uh next let's say um uh I mean um
  11494. 7:57:43task which is uh about our um
  11495. 7:57:47about our let's say what I can say um
  11496. 7:57:52or let's try to consider about a
  11497. 7:57:54technical query
  11498. 7:57:56technical query
  11499. 7:58:01technical query okay technical query
  11500. 7:58:03means let's say people are having a
  11501. 7:58:04doubt related Python or machine learning
  11502. 7:58:08deep learning whatever. So this
  11503. 7:58:09particular LM will try to handle that.
  11504. 7:58:11Let's say this is the tech LLM. Okay.
  11505. 7:58:13Now there is another LM. This LLM will
  11506. 7:58:15try to give you the interview related
  11507. 7:58:17help. Okay. Interview preparation
  11508. 7:58:20related help. Let's say you want to
  11509. 7:58:22prepare for the interview. So uh this
  11510. 7:58:25particular LM will try to handle the
  11511. 7:58:28interview related task. Now whenever any
  11512. 7:58:31kinds of student is giving the input
  11513. 7:58:33let's say student asking about the
  11514. 7:58:35services okay the service we usually
  11515. 7:58:37provide in the DS with BP okay D with BP
  11516. 7:58:40whatever service we provide he's asking
  11517. 7:58:43for now what this LM router okay LLM
  11518. 7:58:46call router will do it will
  11519. 7:58:47automatically understand about your
  11520. 7:58:49questions and it will decide when to
  11521. 7:58:51send this where to send your question
  11522. 7:58:54whether it has to send to the LM call uh
  11523. 7:58:57sorry uh service service LLM whether it
  11524. 7:58:59has to say uh send to the tech lm or
  11525. 7:59:01whether it has to send to the interview
  11526. 7:59:02lm. So definitely this is kinds of
  11527. 7:59:04service related query it it will send to
  11528. 7:59:07the service LLM here. Okay. And service
  11529. 7:59:09LM will try to give you the response and
  11530. 7:59:11you will see the output. Now let's say
  11531. 7:59:12someone is asking about the technical
  11532. 7:59:14query. Let's say he is getting uh Python
  11533. 7:59:17uh function error. So that time LM
  11534. 7:59:19router will understand okay now I have
  11535. 7:59:21to send to the tech lm. TechM will give
  11536. 7:59:23you the output and you will be able to
  11537. 7:59:24see the output. Now there is another
  11538. 7:59:26let's say question you are getting
  11539. 7:59:27related interview. Your LM router will
  11540. 7:59:29send to the interview LLM and you will
  11541. 7:59:31be getting the output. Okay. So this is
  11542. 7:59:33called actually routing workflow.
  11543. 7:59:34Routing LM workflow. This kinds of
  11544. 7:59:37workflow we can easily create inside the
  11545. 7:59:38line graph. Okay. So definitely we'll
  11546. 7:59:40try to also discuss about that. Now
  11547. 7:59:42let's try to understand about the next
  11548. 7:59:44workflow which is uh paraly um par uh
  11549. 7:59:48parallelization.
  11550. 7:59:50Inside parallelization actually what we
  11551. 7:59:52can do we can execute uh the task in
  11552. 7:59:55parallel. So let's try to understand uh
  11553. 7:59:58this particular concept as well. As you
  11554. 7:59:59can see, let's say here we are getting
  11555. 8:00:01the input and some multiple LM call is
  11556. 8:00:04happening. Okay, let's say LM 2, LM 1,
  11557. 8:00:06LMU 2 and LM3. Then we are performing
  11558. 8:00:09the aggregator operation, then we're
  11559. 8:00:10getting the output. Okay. So if I'm
  11560. 8:00:12giving you a realtime example, let's say
  11561. 8:00:15uh I'm a YouTuber definitely I just try
  11562. 8:00:17to upload my content to the YouTube and
  11563. 8:00:20by default YouTube also
  11564. 8:00:23YouTube also use internally this uh um I
  11565. 8:00:26mean AI related uh functionality. Okay.
  11566. 8:00:30So with the help of AI actually it u
  11567. 8:00:32what it do it it try to let's say uh do
  11568. 8:00:36the verification check of your content.
  11569. 8:00:38Let's say the content we're uploading to
  11570. 8:00:40the YouTube. Okay. Okay, let's say I
  11571. 8:00:41have recorded a video. Okay, I have
  11572. 8:00:43recorded a video. So, first of all, you
  11573. 8:00:45will upload that video and it's not like
  11574. 8:00:47that YouTube will directly take that
  11575. 8:00:49video and uh it will allow you to
  11576. 8:00:51publish. First of all, it will do some
  11577. 8:00:53uh verification.
  11578. 8:00:55Okay, verification.
  11579. 8:00:57Verification means let's say it can be
  11580. 8:01:00multiple layer verification. The first
  11581. 8:01:01is let's say whether it is any uh
  11582. 8:01:05unappropriate content or not.
  11583. 8:01:11appropriate content or not. Then it will
  11584. 8:01:13check whether it is sexual content or
  11585. 8:01:16not. Then it will check whether this
  11586. 8:01:18content is uh having any kinds of uh any
  11587. 8:01:22kinds of let's say abusive or not. Okay.
  11588. 8:01:25So this kinds of let's say multiple
  11589. 8:01:27layer verification it will do. Now here
  11590. 8:01:29what we can do for each of the
  11591. 8:01:32verification maybe we can use different
  11592. 8:01:34different task different different let's
  11593. 8:01:36say LLM call for that. Let's say the
  11594. 8:01:38first one is responsible for checking
  11595. 8:01:41unappropriate
  11596. 8:01:43okay unappropriate verification. Second
  11597. 8:01:46one let's say it is responsible for
  11598. 8:01:49sexual verification and third one is
  11599. 8:01:51responsible for let's say um abusive
  11600. 8:01:55verification. Now it's not like that
  11601. 8:01:57after checking this unappropriate
  11602. 8:01:59verification you have to do the sexual
  11603. 8:02:00verification or after checking the
  11604. 8:02:01sexual sexual verification you have to
  11605. 8:02:04check for abive verification. It's not
  11606. 8:02:05like that. All of the checks are
  11607. 8:02:08independent here. Okay. So instead of
  11608. 8:02:10running sequentially, you can run in
  11609. 8:02:12parallel. So parallelly all of the check
  11610. 8:02:14will done. Okay. Once you will get all
  11611. 8:02:16of the um let's say check check uh let's
  11612. 8:02:19say ratings and answer. Then we'll try
  11613. 8:02:21to aggregate them together. Okay. Let's
  11614. 8:02:23say it will give you some kinds of
  11615. 8:02:25rating. Let's say it has given you 9.5
  11616. 8:02:27out of 10. Okay. That means this video
  11617. 8:02:29is good. It it has also given you let's
  11618. 8:02:31say 9.6 around 10. Okay. It has also
  11619. 8:02:34given you 9.5 around 10. Then you are
  11620. 8:02:36combining all of them together. You are
  11621. 8:02:38making the average and let's say there
  11622. 8:02:40is a condition uh there is a average
  11623. 8:02:42threshold. Let's say if this threshold
  11624. 8:02:43is matching that time you will try to
  11625. 8:02:45accept this video otherwise you'll try
  11626. 8:02:47to reject the video then you are getting
  11627. 8:02:49the output here. Okay. So that's how
  11628. 8:02:51this parallelization
  11629. 8:02:53will be working and uh this kinds of
  11630. 8:02:55workflow also we can easily create uh
  11631. 8:02:57inside our langraph as well. Okay. Now
  11632. 8:03:00the next uh workflow let's try to
  11633. 8:03:02understand which is this orchestrator
  11634. 8:03:05workflow. Okay. So this is uh this is
  11635. 8:03:07the same kinds of uh I mean paralleliz
  11636. 8:03:10uhization actually workflow as you can
  11637. 8:03:13see we are also taking all of the result
  11638. 8:03:16and we are also doing the aggregator
  11639. 8:03:18operation and we're getting the output
  11640. 8:03:20but the only difference is uh let's uh
  11641. 8:03:23let's try to discuss about
  11642. 8:03:25so in this workflow uh as you can see um
  11643. 8:03:29before this uh uh before this particular
  11644. 8:03:32section there is another section we have
  11645. 8:03:35which is orchestrator. Okay,
  11646. 8:03:36orchestrator is uh another you can say
  11647. 8:03:38lm um lm uh call. So basically this is
  11648. 8:03:42the main okay lead uh lead actually um
  11649. 8:03:47uh lead nodes this particular nodes will
  11650. 8:03:49decide uh a particular task it is
  11651. 8:03:53getting uh so what to assign whether it
  11652. 8:03:55will assign to the llm 1, llm 2 and lm
  11653. 8:03:583. Okay, it will basically decide but if
  11654. 8:04:00you see the previous one the
  11655. 8:04:02parallelization one. So basically here
  11656. 8:04:04we are uh uh setting the task. Let's say
  11657. 8:04:07here we are assigning the task. Let's
  11658. 8:04:08say LM uh one will get the task related
  11659. 8:04:11unappropriate content. LM will get the
  11660. 8:04:13task related uh let's say uh sexual
  11661. 8:04:16content and LLM3 will try to get the
  11662. 8:04:19task related abive content. We defining
  11663. 8:04:21the task but here there is no task
  11664. 8:04:23nature. Okay. So basically your
  11665. 8:04:25orchestrator will decide where to set
  11666. 8:04:27this particular task. Okay. So uh based
  11667. 8:04:30on the orchestrator uh it will define
  11668. 8:04:32let's say it can define to llm 1 lm 2
  11669. 8:04:35and lm 33 okay it doesn't matter but it
  11670. 8:04:37will decide okay which one would be
  11671. 8:04:38appropriate for this particular task
  11672. 8:04:40then once we are getting this we are
  11673. 8:04:42again doing the synthesizer that means
  11674. 8:04:44aggregating and we're getting the output
  11675. 8:04:46okay so your orchestrator can also
  11676. 8:04:48define this particular task to only lm1
  11677. 8:04:50okay or let's say it can define the task
  11678. 8:04:52to lm1 and lm3 it doesn't matter okay
  11679. 8:04:55based on the task it will decide it can
  11680. 8:04:57either give to the uh let's multiple LM
  11681. 8:05:00either it can give it to the one LM.
  11682. 8:05:01Okay. So this is called actually
  11683. 8:05:02orchestrator workflow. I hope you get
  11684. 8:05:04it. Okay. So this is the similar kinds
  11685. 8:05:06of your parallelization. Now the next
  11686. 8:05:08workflow you are having this evaluator
  11687. 8:05:11optimizer.
  11688. 8:05:12Okay. So what this evaluator optimizer?
  11689. 8:05:15So I think by the workflow itself you
  11690. 8:05:17can understand uh the uh actual uh
  11691. 8:05:21example. Okay. How this will work. So
  11692. 8:05:23basically it has one LM call generator.
  11693. 8:05:26Okay. LM call generator. uh this
  11694. 8:05:28particular uh section and it it is
  11695. 8:05:31having another one called LM call
  11696. 8:05:33evaluator. Okay. So basically whatever
  11697. 8:05:35input you are getting giving first of
  11698. 8:05:37all LM this LM call is generating this
  11699. 8:05:40particular output then you are sending
  11700. 8:05:42to the LM call evaluator and it is
  11701. 8:05:44checking okay it is checking uh whether
  11702. 8:05:47it is good or not. Okay whether it is
  11703. 8:05:49good or not and if it is not good it
  11704. 8:05:51will reject and with the reject it will
  11705. 8:05:54also give some kinds of feedback like
  11706. 8:05:55what to update next. Okay. So this will
  11707. 8:05:58get again uh this particular LM call
  11708. 8:06:00generator the rejection parameter as
  11709. 8:06:02well as the feedback. Based on the
  11710. 8:06:04feedback again it will try to based on
  11711. 8:06:06the feedback again it will try to
  11712. 8:06:07generate. Okay. Again it will try to
  11713. 8:06:08send to the LM call evaluator. Okay.
  11714. 8:06:11Then if it is good then it will accept
  11715. 8:06:12and you'll see the output. Okay. And
  11716. 8:06:14this particular loop will be
  11717. 8:06:15continuously happening unless and until
  11718. 8:06:17this LLM uh call evaluator will accept
  11719. 8:06:20your content. Okay. So I think you know
  11720. 8:06:22that in our uh that uh recruitment agent
  11721. 8:06:26I told you about the job description
  11722. 8:06:27right. So let's say one of the LM will
  11723. 8:06:30generate the job description here. Let's
  11724. 8:06:31say this is this is uh generating the
  11725. 8:06:34job description and another LM you're
  11726. 8:06:36using for verifying the job description
  11727. 8:06:38whether it is perfect or not. If not
  11728. 8:06:40perfect it will give you some kinds of
  11729. 8:06:41rejection and the feedback. Again it
  11730. 8:06:43will try to generate the job
  11731. 8:06:44description. Again it will send and if
  11732. 8:06:46job description is fine then it will
  11733. 8:06:47accept it um that particular job
  11734. 8:06:49description. Okay. I hope you get it
  11735. 8:06:51guys. So guys, I have shown you I think
  11736. 8:06:55uh five workflows here. 1 2 3 4 and
  11737. 8:07:01five. Okay. So five different LLM
  11738. 8:07:03workflows I have explained here. And
  11739. 8:07:04don't worry I'm going to um I'm going to
  11740. 8:07:07cover these are the workflow in this
  11741. 8:07:09particular playlist itself. Okay. We'll
  11742. 8:07:12try to see all of the workflow one by
  11743. 8:07:13one. Now the very important concept
  11744. 8:07:16we'll try to understand about the um
  11745. 8:07:20langraph uh components okay we'll try to
  11746. 8:07:22understand lang graph core uh components
  11747. 8:07:25uh which is graph nodes and edges okay
  11748. 8:07:28although I've given you the highle
  11749. 8:07:30overview in my previous video what is
  11750. 8:07:31graph nodes and edges but still we'll
  11751. 8:07:33try to understand this particular
  11752. 8:07:35concept in detail so for this here what
  11753. 8:07:38I'm going to do I'm going to take an
  11754. 8:07:40example I'm going to take a problem
  11755. 8:07:42statement and this problem statement
  11756. 8:07:44we'll try to uh define as a graph okay
  11757. 8:07:47define as a workflow then we'll try to
  11758. 8:07:49understand these are the concept so guys
  11759. 8:07:52uh as you can see here I have taken an
  11760. 8:07:54example um so let's say here we want to
  11761. 8:07:57create a system uh that generate a uh SE
  11762. 8:08:01topic okay I think you know about SE uh
  11763. 8:08:04so whenever you are let's say going for
  11764. 8:08:09any big uh universities
  11765. 8:08:12uh so basically you have to submit
  11766. 8:08:15there. Okay. Uh bas based on the topic.
  11767. 8:08:18So let's say uh what it does it uh
  11768. 8:08:20collects the student uh SE submissions
  11769. 8:08:24and it evaluates in parallel on depth of
  11770. 8:08:27analysis, language quality and clarity
  11771. 8:08:30of thoughts based on the combined score.
  11772. 8:08:33It either gives the feedback for the
  11773. 8:08:35improvement or approach that I see.
  11774. 8:08:37Okay. So to build this particular system
  11775. 8:08:40first of all we have to uh break down
  11776. 8:08:42the task okay let's say this is the
  11777. 8:08:44entire goal okay this is the entire goal
  11778. 8:08:46of our system now to achieve this goal
  11779. 8:08:48we have to define uh a set of task okay
  11780. 8:08:51the let's say first task what it would
  11781. 8:08:53be so let's say this particular system
  11782. 8:08:55will first of all generate a se right
  11783. 8:08:57the uh first of all we have to generate
  11784. 8:08:59a topic so system generate a relevant uh
  11785. 8:09:03UPS style as topic and uh present in uh
  11786. 8:09:08pres present it to us to the student
  11787. 8:09:10let's say uh you are giving UPSC exam
  11788. 8:09:13that time let's say the this particular
  11789. 8:09:15essay topic you have to prepare okay
  11790. 8:09:17then you have to collect the SE from the
  11791. 8:09:19student so student write and submits the
  11792. 8:09:21SE based on the generated topics okay
  11793. 8:09:24you you will try to collect that after
  11794. 8:09:26collecting uh your system will evaluate
  11795. 8:09:28the SE okay parallel evaluation block
  11796. 8:09:30because here we will be evaluating based
  11797. 8:09:32on the analysis language quality clarity
  11798. 8:09:35of thought so All of the checks we are
  11799. 8:09:38doing, all of the evaluation checks we
  11800. 8:09:39are doing based on the language, based
  11801. 8:09:41on the um language quality, then
  11802. 8:09:44analysis, okay, clarity of thought, we
  11803. 8:09:46are checking each and everything. Okay.
  11804. 8:09:48So after getting the evaluation report,
  11805. 8:09:50we are aggregating the results. Let's
  11806. 8:09:52say the combined the three scores and
  11807. 8:09:53generate the total scores. Uh let's say
  11808. 8:09:55we got the three scores all together.
  11809. 8:09:57Then we combined them and we got one
  11810. 8:09:59average score and we matched with the
  11811. 8:10:01threshold. Now here there is another uh
  11812. 8:10:04task you can see conditional routing. So
  11813. 8:10:06based on the total score either you will
  11814. 8:10:08uh accept that particular
  11815. 8:10:11SC otherwise you will give the feedback
  11816. 8:10:13let's say again you have to update this
  11817. 8:10:15particular SC. Okay. So then then you
  11818. 8:10:17can see we are uh our next is the give
  11819. 8:10:20feedback based on the uh conditional
  11820. 8:10:22routing that means aggregating results
  11821. 8:10:24we are giving the feedback and there is
  11822. 8:10:26another option we have kept. Let's say
  11823. 8:10:27if user wants to uh give the uh revision
  11824. 8:10:30version of that particular AC, they will
  11825. 8:10:31be able to do that. Then at the last
  11826. 8:10:33we'll try to show the success uh message
  11827. 8:10:35to the um student. Okay. If your if
  11828. 8:10:39their essay is good, then we'll try to
  11829. 8:10:40congratulate them. Okay. So this is the
  11830. 8:10:42entire let's say um problem. Now if I
  11831. 8:10:45want to uh if I want to represent with
  11832. 8:10:47the help of lang graph. So first of all
  11833. 8:10:49we have to make it as a graph. Okay. I
  11834. 8:10:51think you know lang graph um make every
  11835. 8:10:54let's say problem statement as a graph
  11836. 8:10:56as a workflow. Okay. So basically it
  11837. 8:10:58will represent as a graph after
  11838. 8:11:01representing as a graph then what it
  11839. 8:11:04will do it will try to uh take all of
  11840. 8:11:07this task as a node. Okay all of the
  11841. 8:11:09task as a node then it will connect the
  11842. 8:11:11edges let's say after uh which node
  11843. 8:11:15another node would be executed. Okay
  11844. 8:11:17this particular connection will be do
  11845. 8:11:19doing with the help of edges. So for
  11846. 8:11:20this I have already prepared a um graph.
  11847. 8:11:23Let me show you. Let's say this is our
  11848. 8:11:25uh line graph graph we have prepared.
  11849. 8:11:27Okay. So you can see uh whatever problem
  11850. 8:11:30statement I have showed you here. So I
  11851. 8:11:31have just represent as a graph. First of
  11852. 8:11:33all it will generate a topic. So this is
  11853. 8:11:35the first you can see this is the first
  11854. 8:11:40uh first task right. Let me just write
  11855. 8:11:43here this is the first task.
  11856. 8:11:46Okay. because we broken down our entire
  11857. 8:11:50goal as a task and generate topic was
  11858. 8:11:52one of the task and this task we
  11859. 8:11:54represented as a node okay this is
  11860. 8:11:56called actually node each and every
  11861. 8:11:58block is a node here okay now this is
  11862. 8:12:00another task as you can see right AC
  11863. 8:12:02right as means you can also let's say
  11864. 8:12:05take the from the student okay user will
  11865. 8:12:08upload that student will upload that
  11866. 8:12:10then after uploading you are doing the
  11867. 8:12:12evaluation here okay so this uh this
  11868. 8:12:15evaluation is also another task another
  11869. 8:12:17node. So this is also node this is uh
  11870. 8:12:19this is also node this is another node
  11871. 8:12:21this is another node this is another
  11872. 8:12:22node so here we are let's say evaluating
  11873. 8:12:24with the with respect to the clarity of
  11874. 8:12:26thought depth of analysis lang base then
  11875. 8:12:28we're getting some kinds of score here
  11876. 8:12:29okay let's say we are getting some kinds
  11877. 8:12:31of score let's say this this one is
  11878. 8:12:33given you 9.5 this one is given you 9.8
  11879. 8:12:35need this one is giving you 8.5. Okay,
  11880. 8:12:38based on that we are doing the final
  11881. 8:12:39evaluation. We are aggregating the
  11882. 8:12:41results. Let's say our threshold is 9.5
  11883. 8:12:45and after combining all of these we are
  11884. 8:12:47getting uh 9.5 or greater than 9.5 then
  11885. 8:12:50that time what I will do I'll just try
  11886. 8:12:52to simply give the success message to
  11887. 8:12:53these students. Okay, let's say I will
  11888. 8:12:56congratulate them otherwise I will give
  11889. 8:12:58the feedback. Let's say this is another
  11890. 8:13:00another node. In this particular node
  11891. 8:13:02I'll give the feedback. So in the
  11892. 8:13:03feedback itself I'll tell what to update
  11893. 8:13:06otherwise they can also resubmit that
  11894. 8:13:08particular hy to me. Okay. So this is
  11895. 8:13:10the entire representation and you can in
  11896. 8:13:12the representation itself you can see
  11897. 8:13:14this is the entire graph. Okay. This is
  11898. 8:13:15the entire langraph graph and each of
  11899. 8:13:18the task is a node. Okay. Each of the
  11900. 8:13:20task is a node and the connection you
  11901. 8:13:22can see this particular connection this
  11902. 8:13:23is called edge. Okay. This edge is
  11903. 8:13:25represents after generate topics write a
  11904. 8:13:28will execute. After write a this uh
  11905. 8:13:31evaluation uh let's say nodes will
  11906. 8:13:33execute. After evaluation this final
  11907. 8:13:35evaluator node will execute. Okay. Then
  11908. 8:13:38either it will go to this access nodes
  11909. 8:13:40either it will go to the feedback nodes.
  11910. 8:13:41Okay. This is called ages. This is
  11911. 8:13:42called connection. Okay. So if you
  11912. 8:13:44understand this thing guys it will be
  11913. 8:13:46very easy for you to create any kinds of
  11914. 8:13:48langraph graph for you. Okay. And you
  11915. 8:13:51can represent any kinds of problem
  11916. 8:13:52statement in a graph. Okay. I hope you
  11917. 8:13:54clear guys. So guys, now we'll be uh
  11918. 8:13:57discussing about the next uh line graph
  11919. 8:13:59component which is state. So I think you
  11920. 8:14:02know already about this state. I have
  11921. 8:14:04given you the state overview in my
  11922. 8:14:06previous video. But let's try to
  11923. 8:14:07understand. So as you can see in lang
  11924. 8:14:09graph state um it is the shared memory
  11925. 8:14:12that follows through uh your workflows.
  11926. 8:14:15It holds all the data being passed
  11927. 8:14:18between nodes as your graph runs. Okay,
  11928. 8:14:21as your graph runs. So as you can see uh
  11929. 8:14:23this is uh how your uh state looks like.
  11930. 8:14:27So this is a kinds of u like python
  11931. 8:14:31object okay python uh kinds of
  11932. 8:14:33dictionary object it is having the key
  11933. 8:14:35key and value pair either you can create
  11934. 8:14:37this with help of pentic okay pentic
  11935. 8:14:41uh library with uh inside python either
  11936. 8:14:43you can also create it as a type dict
  11937. 8:14:46okay type dict both you can use to
  11938. 8:14:49define this particular state uh memory.
  11939. 8:14:51So I think you know that uh to run a LM
  11940. 8:14:54workflow let's say this is our complete
  11941. 8:14:56LM workflow we need this kinds of state
  11942. 8:14:58that means some metadata informations
  11943. 8:15:01because each of the nodes will generate
  11944. 8:15:04some kinds of output and that particular
  11945. 8:15:07output will take uh taken by another
  11946. 8:15:09nodes okay let's say this generate topic
  11947. 8:15:12will generate some kinds of topic okay
  11948. 8:15:14topic name so this topic name will go to
  11949. 8:15:16the next node which is this right a
  11950. 8:15:19because uh on top of that your um essay
  11951. 8:15:22will be written right so that means
  11952. 8:15:23whatever topic uh this particular node
  11953. 8:15:26is generating this should be stored in
  11954. 8:15:28this state memory and the next node
  11955. 8:15:31let's say this write as a we'll take
  11956. 8:15:33that particular topic and it will write
  11957. 8:15:34that content as well so after writing
  11958. 8:15:36this content this content would be also
  11959. 8:15:39saved in the state memory so you can see
  11960. 8:15:40there is another section called text
  11961. 8:15:42topic okay then we are uh evaluating the
  11962. 8:15:45scores and all of these uh scores would
  11963. 8:15:48be saved in this uh this uh uh statement
  11964. 8:15:51memory. You can see they have this
  11965. 8:15:52score, language score, clarity score. So
  11966. 8:15:54after this score, you will perform the
  11967. 8:15:55final evaluation. Okay. So totally score
  11968. 8:15:57would be also saved. Then you will be
  11969. 8:15:59giving the feedback. This feedback will
  11970. 8:16:00be al also saved. Then evaluation round
  11971. 8:16:02it will also save. Okay. So that means
  11972. 8:16:05uh to execute the entire nodes to
  11973. 8:16:07execute the entire workflow you need
  11974. 8:16:09this particular state. And this state is
  11975. 8:16:11a shared okay it's a shared memory. As
  11976. 8:16:13you can see it's a shared memory. Shared
  11977. 8:16:15memory means each of the nodes will take
  11978. 8:16:17this particular state as an input. Okay.
  11979. 8:16:20Each each of the node will take this
  11980. 8:16:22particular state as an input. All of the
  11981. 8:16:24node okay all of the node will take this
  11982. 8:16:25particular state and after taking it
  11983. 8:16:28once it will generate some output this
  11984. 8:16:30output will be instantly updated in that
  11985. 8:16:32particular state. Okay, that's why this
  11986. 8:16:34state is mutable as well. Okay, mutable.
  11987. 8:16:37Mutable means you can change it any time
  11988. 8:16:39and after exe uh every execution this
  11989. 8:16:43state would be uh saved. Okay, because
  11990. 8:16:46this is completely dynamic and this is
  11991. 8:16:49required guys. Okay, without that
  11992. 8:16:51actually um you can't create any kinds
  11993. 8:16:53of agent application inside line graph.
  11994. 8:16:56Okay, this state is required.
  11995. 8:16:58So yes, I think you have understood and
  11996. 8:17:00uh whenever we'll try to um uh create
  11997. 8:17:03these kinds of uh uh application
  11998. 8:17:06definitely we'll uh define this state at
  11999. 8:17:08the very beginning either we can use p
  12000. 8:17:10identicular we can use type dict for
  12001. 8:17:12that okay and we'll try to define this
  12002. 8:17:14state and for your problem statement you
  12003. 8:17:16have to define the state like what are
  12004. 8:17:18the variable you'll be keeping here what
  12005. 8:17:21data uh you you feel like okay this
  12006. 8:17:24should be updated to run your entire
  12007. 8:17:26agents okay this thing will try to uh
  12008. 8:17:28define at the very beginning. Now let's
  12009. 8:17:30try to understand the next uh component
  12010. 8:17:33of lang graph which is reducer. So what
  12011. 8:17:36is reducer exactly? Uh so reducer in the
  12012. 8:17:39lang graph defines how updates from
  12013. 8:17:41nodes are applied to the shared state.
  12014. 8:17:44Each key in the state can have its own
  12015. 8:17:47reducer which determines whether new
  12016. 8:17:50data uh replaces, merges or adds to the
  12017. 8:17:52existing value. So if you see this
  12018. 8:17:55reducer is very close to your state.
  12019. 8:17:57Okay, this is very close to the state.
  12020. 8:17:59That means whenever you are defining the
  12021. 8:18:01state that time reducer will come to the
  12022. 8:18:03picture. Okay, so let me give you one
  12023. 8:18:05example. Uh see as of now what we are
  12024. 8:18:08doing let's say whatever we are getting
  12025. 8:18:10the data from each and every nodes we
  12026. 8:18:14are directly updating in the state
  12027. 8:18:15memory. Okay, I think you know that and
  12028. 8:18:17this state is a shared uh shared uh
  12029. 8:18:20actually memory and it it is accessible
  12030. 8:18:23to all of the nodes here. Let's say this
  12031. 8:18:24nodes will also take this state. These
  12032. 8:18:26nodes will also take this states. Okay,
  12033. 8:18:27all of the nodes will take this state
  12034. 8:18:28and it will update in real time. That
  12035. 8:18:31means every time the value uh you are
  12036. 8:18:33changing here it is replacing okay let's
  12037. 8:18:35say previously you you generated a topic
  12038. 8:18:38let's say topic a so again whenever you
  12039. 8:18:40will second time execute that this topic
  12040. 8:18:42will replace that means the previous
  12041. 8:18:43topic will be removed okay that that
  12042. 8:18:45means we are replacing the value that's
  12043. 8:18:47how depth score language score clarity
  12044. 8:18:50score acetics okay so all of the
  12045. 8:18:53parameter you are changing every time
  12046. 8:18:54and your previous uh information you are
  12047. 8:18:56losing but let's say sometimes
  12048. 8:18:59uh let me give you first of One example
  12049. 8:19:01let's say you are creating an
  12050. 8:19:02application okay you are uh you are
  12051. 8:19:05building an application that application
  12052. 8:19:07let's say um takes two number so let me
  12053. 8:19:10just give you the workflow let's say
  12054. 8:19:14takes two number a and b after that it
  12055. 8:19:17perform the sum operation okay then
  12056. 8:19:20whatever sum you get okay it perform the
  12057. 8:19:24multiply operation with three okay then
  12058. 8:19:27it shows the result
  12059. 8:19:30result. Let's say this is your
  12060. 8:19:31application. Now in this application,
  12061. 8:19:32what would be the state? If you consider
  12062. 8:19:34state, so state would be first of all
  12063. 8:19:37the first number.
  12064. 8:19:39First number,
  12065. 8:19:43okay, first number should be state then
  12066. 8:19:45second number
  12067. 8:19:49then the result.
  12068. 8:19:53Okay. So this this is this is your
  12069. 8:19:55state. So what will happen? Let's say
  12070. 8:19:57you are giving two number. First number
  12071. 8:19:58is five, second number is six. And if
  12072. 8:20:01you do the sum operation, what would be
  12073. 8:20:02the result? It would be 11. Okay, 11.
  12074. 8:20:06But if you see you are multiplying by
  12075. 8:20:08three. Okay, if you multiply by three,
  12076. 8:20:10so what will happen? This result will be
  12077. 8:20:12replaced. That means previously it was
  12078. 8:20:14uh previously it was 11. Now I'll rub
  12079. 8:20:17this 11. Initially after summing the
  12080. 8:20:20result is 11. Now you have to multiply
  12081. 8:20:22by 3. So if you multiply by 3 that means
  12082. 8:20:24this 11 will be replaced by 33. Okay
  12083. 8:20:28that means this 11 is not there anymore.
  12084. 8:20:30Okay, this is changed completely. But in
  12085. 8:20:33some application, let's say uh let me
  12086. 8:20:36give you another example. I will
  12087. 8:20:39rub this. Now, let's say you are
  12088. 8:20:41creating a chatbot.
  12089. 8:20:43You're creating a chatbot.
  12090. 8:20:46In the chatbot, what you are doing? You
  12091. 8:20:47are doing the conversation uh to the uh
  12092. 8:20:50AI uh your conversation to the uh
  12093. 8:20:53application. Let's say this is your app.
  12094. 8:20:56Okay, this is your app and you are doing
  12095. 8:20:57the conversation. So in this uh
  12096. 8:20:59application what would be the state?
  12097. 8:21:01State state it would be the let's say
  12098. 8:21:03message the message we are sending or
  12099. 8:21:05message we are getting from the um
  12100. 8:21:08application. So initially let's say you
  12101. 8:21:10have given hi
  12102. 8:21:13I am bi
  12103. 8:21:16okay let's say this is your message. So
  12104. 8:21:17this message would be saved here. Let's
  12105. 8:21:19say hi,
  12106. 8:21:23I am BP. Okay. Now let's say second time
  12107. 8:21:25you have given uh I like
  12108. 8:21:29football.
  12109. 8:21:31Okay. Now this message will be replaced.
  12110. 8:21:33Okay. Let's say this this will removed
  12111. 8:21:35and it will replace by I like
  12112. 8:21:40football.
  12113. 8:21:41Okay. Football.
  12114. 8:21:43Now if you ask what is my name? So that
  12115. 8:21:47time um let's say your nodes won't be
  12116. 8:21:50able to uh get get your name because
  12117. 8:21:52this this name is already removed okay
  12118. 8:21:54from the state memory. Now you only have
  12119. 8:21:57I like football okay this is the
  12120. 8:21:58problem. So in this case if you're using
  12121. 8:22:01only state without reducer that time it
  12122. 8:22:03will replace that but if you're using
  12123. 8:22:05reducer okay inside reducer you can
  12124. 8:22:08define whether you have to okay you have
  12125. 8:22:12to replace the data or merge the data or
  12126. 8:22:15add the data. So in this case maybe we
  12127. 8:22:17can add the data. So that means my
  12128. 8:22:18previous message would be also there.
  12129. 8:22:20Let's say I am bi
  12130. 8:22:24after giving a comma maybe I can add the
  12131. 8:22:26second message. That's how continuously
  12132. 8:22:28all of the messages would be saved here.
  12133. 8:22:30Either you can merge, either you can
  12134. 8:22:32replace, everything can be defined with
  12135. 8:22:33the help of this reducer. Okay. So that
  12136. 8:22:35means the reducer in langraph defines
  12137. 8:22:37how updates from nodes are applied to
  12138. 8:22:39the shared state. Okay. That means
  12139. 8:22:41whenever you are creating the state that
  12140. 8:22:43time you can define all of the state
  12141. 8:22:46data you are preparing, right? Whether
  12142. 8:22:47it should be addable, it should be
  12143. 8:22:49mergible or it should be replaceable.
  12144. 8:22:51Okay. So in this case let's say we have
  12145. 8:22:53defined this particular state. So in the
  12146. 8:22:55feedback section you can see we have
  12147. 8:22:57given add. Add means instead of uh let's
  12148. 8:23:00say replacing the feedback it will
  12149. 8:23:03continuously add. Let's say this is our
  12150. 8:23:04example I showed you. So in this example
  12151. 8:23:06let's say the feedback we are getting.
  12152. 8:23:08So this feedback should be definitely
  12153. 8:23:09saved in the state memory. So next time
  12154. 8:23:11whenever it is executing okay it will
  12155. 8:23:14see that particular feedback the
  12156. 8:23:15previous feedback then it will give the
  12157. 8:23:16new feedback otherwise what will happen
  12158. 8:23:18the same feedback continuously it might
  12159. 8:23:19give right? So that's why it should be
  12160. 8:23:21addable. Okay, it should be addable
  12161. 8:23:23inside state memory. So this is the work
  12162. 8:23:25of reducer and definitely we'll also
  12163. 8:23:28learn um by a project okay uh in this
  12164. 8:23:31particular playlist there I'll try to
  12165. 8:23:32use this reducer concept as well with
  12166. 8:23:34the state. So there this part would be
  12167. 8:23:36more clear. So I think guys now you got
  12168. 8:23:38it what is the reducer? So reducer only
  12169. 8:23:40can be used whenever you are using the
  12170. 8:23:42state concept inside the line graph.
  12171. 8:23:44Okay now I think it is clear. So guys
  12172. 8:23:46now we'll be understanding the last
  12173. 8:23:49concept of this lang graph which is lang
  12174. 8:23:51graph execution model. So what is this
  12175. 8:23:53lang graph execution model means that
  12176. 8:23:56means uh the way it is executing the
  12177. 8:23:59graph because I think you know lang
  12178. 8:24:01graph internally defines uh your problem
  12179. 8:24:04statement as a graph. It creates the
  12180. 8:24:06nodes then uh it creates the edges. Okay
  12181. 8:24:10that's how basically it executes
  12182. 8:24:12everything. So what is the execution
  12183. 8:24:15process of this particular graph? Okay,
  12184. 8:24:17this is called actually execution model.
  12185. 8:24:19So lang graph internally follows uh one
  12186. 8:24:23amazing execution uh model strategy
  12187. 8:24:26which is u let me show you which is
  12188. 8:24:30actually google uh pragle. Okay, pragle.
  12189. 8:24:33So what is Google pragle? Google pragle
  12190. 8:24:34is a system for large scale graph
  12191. 8:24:36processing. Uh so basically uh they have
  12192. 8:24:39published this particular research long
  12193. 8:24:41uh uh long ago that time actually they
  12194. 8:24:44showed if you are having a large scale
  12195. 8:24:46graph okay that time how it can be
  12196. 8:24:48processed okay so internally lang graph
  12197. 8:24:50uses the same technique uh for executing
  12198. 8:24:53this kinds of graph
  12199. 8:24:56because if you see the langraph uh
  12200. 8:24:58actually graph uh whenever you are
  12201. 8:25:00creating very big workflow that time
  12202. 8:25:02this graph would be also big and to
  12203. 8:25:04process this to execute this you have to
  12204. 8:25:06follow that pragle strategy. Okay. Now
  12205. 8:25:09this is the strategy guys. As you can
  12206. 8:25:11see here I have already defined all of
  12207. 8:25:13the uh execution process. So first of
  12208. 8:25:16all what happens uh if you see here
  12209. 8:25:18first of all it defines uh the graph.
  12210. 8:25:21Okay. So whenever you are giving any
  12211. 8:25:23problem statement uh it it will define
  12212. 8:25:25the graph. So whenever it will define
  12213. 8:25:27the graph first of all it will define
  12214. 8:25:29the state schema that I showed you
  12215. 8:25:32showed you about the schema right uh
  12216. 8:25:33state schema. uh either you can uh do it
  12217. 8:25:36with the help of pentic with the help of
  12218. 8:25:38uh type dict okay you can you you just
  12219. 8:25:40need to define this schema after that
  12220. 8:25:43you have to prepare the node and edges
  12221. 8:25:45okay so this node and this edge
  12222. 8:25:47connection okay so fun uh and what is
  12223. 8:25:50node actually this node is nothing but
  12224. 8:25:52it's a simple python function okay it's
  12225. 8:25:55a python function only if you can write
  12226. 8:25:56a python function if you can write a
  12227. 8:25:58python code you can just define any
  12228. 8:26:00kinds of node okay because each of the
  12229. 8:26:02nodes is responsible for a specific task
  12230. 8:26:04And this task you are solving inside
  12231. 8:26:06this Python function only. Okay, that's
  12232. 8:26:08it. And what is edges? Which node
  12233. 8:26:10connects to uh which okay that means
  12234. 8:26:12this particular ages will be connecting
  12235. 8:26:14to another nodes. Okay, like the
  12236. 8:26:16execution flow like after this node
  12237. 8:26:18which node would be executed. So once
  12238. 8:26:20you have defined this particular graph
  12239. 8:26:23then next step you will do the
  12240. 8:26:24compilation. So here we'll do the
  12241. 8:26:27compile. Compile operation compile means
  12242. 8:26:28let's say you have created a uh graph.
  12243. 8:26:30Let's say this is your graph. Okay, this
  12244. 8:26:32is your graph and this is the age
  12245. 8:26:34connection and let's say you created
  12246. 8:26:35another node but this node doesn't have
  12247. 8:26:37any kinds of connection. Okay, so after
  12248. 8:26:39doing the compilation you will be able
  12249. 8:26:41to understand okay this node doesn't
  12250. 8:26:43have any kinds of connection that means
  12251. 8:26:45there's some problem with the graph.
  12252. 8:26:46Okay, otherwise what will happen? Our
  12253. 8:26:47entire agentic system will be okay uh
  12254. 8:26:50terminated. So that's why after defining
  12255. 8:26:52the graph we have to do the compilation
  12256. 8:26:54to checks the graph structure and
  12257. 8:26:56prepared prepares for the execution.
  12258. 8:26:58Okay. Then the uh third thing we'll be
  12259. 8:27:00doing the invocation operation. So
  12260. 8:27:02invocation operation that means uh
  12261. 8:27:04whatever first node we have prepared
  12262. 8:27:06we'll try to do the invoke operation
  12263. 8:27:07with our initial state. The state we are
  12264. 8:27:10preparing we'll try to pass to this uh
  12265. 8:27:12pass to this initial actually nodes and
  12266. 8:27:14this initial nodes what it will do it
  12267. 8:27:16will take this uh state and it will
  12268. 8:27:18execute and it will generate some kinds
  12269. 8:27:20of output and this output would be also
  12270. 8:27:22updated in the state. Okay. So once it
  12271. 8:27:25has updated to the state then this state
  12272. 8:27:27will go to the another function okay
  12273. 8:27:29another another nodes and this node
  12274. 8:27:31would be also initialized that that
  12275. 8:27:33means activated okay so after giving
  12276. 8:27:35this initial state this node would be
  12277. 8:27:38activated and once you get some kinds of
  12278. 8:27:40output from this node then it will pass
  12279. 8:27:42to the next one the next one would be
  12280. 8:27:44activated okay so this is called
  12281. 8:27:46actually invocation okay you can see
  12282. 8:27:47langraph sends the initial state as a
  12283. 8:27:50message to the entity of nodes okay then
  12284. 8:27:53once it gets this particular particular
  12285. 8:27:55uh let's say uh uh output and whenever
  12286. 8:27:58it activates okay we call it as a super
  12287. 8:28:01step begins okay execution process uh in
  12288. 8:28:03rounds that means uh it's not like that
  12289. 8:28:05manually you have to uh I mean initiate
  12290. 8:28:08uh and invoke all of the nodes one by
  12291. 8:28:10one so once you invoke the first one
  12292. 8:28:13okay the remaining one will be
  12293. 8:28:15automatically executed because it is
  12294. 8:28:17getting the output and after getting the
  12295. 8:28:18output this will go to the input to the
  12296. 8:28:20next node and next node would be uh
  12297. 8:28:23activated Okay, this is called actually
  12298. 8:28:25super begins. Super step begins. Okay,
  12299. 8:28:27lang lang graph call it as a super step
  12300. 8:28:28begins. That means all of the nodes
  12301. 8:28:30would be activated that time. That means
  12302. 8:28:32you can see message passing and node
  12303. 8:28:34activation. The messages are passed to
  12304. 8:28:36the downstream nodes via edges. So that
  12305. 8:28:38means whatever output you are getting
  12306. 8:28:39from the first node, it will go via this
  12307. 8:28:42edges to the second node. Then it will
  12308. 8:28:44be activating one by one. Okay. So this
  12309. 8:28:45is called super step begins. Okay. And
  12310. 8:28:48with the help of that it perform the
  12311. 8:28:50message parsing and node activation. And
  12312. 8:28:52the last step which is nothing but uh
  12313. 8:28:54nothing but the halting conditions. So
  12314. 8:28:56execution stop when all uh no nodes are
  12315. 8:28:59activated and no messes are in transit.
  12316. 8:29:02That means if all of the node has been
  12317. 8:29:03activated and no message are uh let's
  12318. 8:29:06say in transit that time this particular
  12319. 8:29:08condition would be stop and your graph
  12320. 8:29:11would be also stop. Yeah. So this is
  12321. 8:29:13called actually the spreel a system for
  12322. 8:29:15large scale graph execution process and
  12323. 8:29:18langraph follow the same strategy
  12324. 8:29:20whenever they execute their graph. Okay.
  12325. 8:29:22So yes guys I think you have understood
  12326. 8:29:24all of the concept about the uh lang
  12327. 8:29:28graph all of the component about the
  12328. 8:29:29langraph. Now it would be easy for you
  12329. 8:29:31to uh code in langraph whenever we try
  12330. 8:29:34to write the code whenever we'll create
  12331. 8:29:36the agents that time you won't be having
  12332. 8:29:38any kinds of confusion you won't be
  12333. 8:29:40having any kinds of problem related each
  12334. 8:29:42of the components we have discussed so
  12335. 8:29:45guys so far we have uh discussed about
  12336. 8:29:48the theoretical aspect of agentic AI uh
  12337. 8:29:52as well as I have already given you the
  12338. 8:29:55in-depth understanding about the uh
  12339. 8:29:58langraph components and all. Now it's
  12340. 8:30:01time to start the practical uh
  12341. 8:30:04exploration. So from this video onward
  12342. 8:30:07guys uh we'll be working on the uh
  12343. 8:30:09practical part of the langraph. So uh
  12344. 8:30:12first of all we'll be starting with the
  12345. 8:30:14very uh basic workflow uh inside
  12346. 8:30:17langraph which is uh sequential
  12347. 8:30:19workflow. I think I have already told
  12348. 8:30:21you about that. First actually workflow
  12349. 8:30:23the workflow name is sequential
  12350. 8:30:25workflow. Okay, sequential means uh this
  12351. 8:30:27will run um uh in a step-by-step uh
  12352. 8:30:30let's say manner. Okay, this is called
  12353. 8:30:32sequent sequential workflow. So, it
  12354. 8:30:34doesn't have any kinds of looping. It
  12355. 8:30:36doesn't have any kinds of conditional
  12356. 8:30:37branching. Okay, it doesn't have
  12357. 8:30:39anything. Only uh it will be working as
  12358. 8:30:42a sequence manner. Uh so we call it as a
  12359. 8:30:45sequential workflow. Okay. So for this
  12360. 8:30:47guys uh first of all uh we'll be
  12361. 8:30:49installing the langraph. Okay. In inside
  12362. 8:30:51our system. So to install the langraph
  12363. 8:30:54guys you can visit this langraph
  12364. 8:30:56documentation. So there uh you will be
  12365. 8:30:58getting uh all kinds of actually
  12366. 8:31:00tutorial how to install okay how to
  12367. 8:31:03create your first agent. So each and
  12368. 8:31:04everything they have already given. So
  12369. 8:31:06see if you want to install this langraph
  12370. 8:31:08you can use the pip command either you
  12371. 8:31:10can use uv okay so let's use pep as of
  12372. 8:31:13now maybe in future I will also show you
  12373. 8:31:15how to use the uv package manager as
  12374. 8:31:17well. So you just need to run pip
  12375. 8:31:19install lang graph. So this lang graph
  12376. 8:31:21would be installed inside your system.
  12377. 8:31:23So for this let's open up our local
  12378. 8:31:25folder and here I'm going to just open
  12379. 8:31:28up my visual code studio
  12380. 8:31:33h
  12381. 8:31:35and I will also open up my terminal
  12382. 8:31:37here.
  12383. 8:31:40Okay. So the first thing guys uh here
  12384. 8:31:43I'm going to create a file called readmi
  12385. 8:31:47md and inside that I'm going to mention
  12386. 8:31:50um all of the command you need to
  12387. 8:31:53execute uh to install this uh lang graph
  12388. 8:31:56to create your virtual environment and
  12389. 8:31:58everything. So if you want to create the
  12390. 8:32:00virtual environment you have to execute
  12391. 8:32:02this command called cond createen
  12392. 8:32:07n okay then you can give the name of the
  12393. 8:32:10environment I will give let's say lang
  12394. 8:32:12graph
  12395. 8:32:16test okay python
  12396. 8:32:20you can specify the python version
  12397. 8:32:21python is equal to 3.11
  12398. 8:32:24and hyphen y okay so this is the command
  12399. 8:32:27first of all you have to execute this
  12400. 8:32:28command want to create a virtual
  12401. 8:32:29environment then you'll be installing
  12402. 8:32:31this line graph. Okay. Now you have to
  12403. 8:32:33activate this environment. After that
  12404. 8:32:35you'll be installing the
  12405. 8:32:38requirements. We have to install pyener
  12406. 8:32:43requirement.txt.
  12407. 8:32:45Okay. So these are the command guys you
  12408. 8:32:47have to uh follow first of all. So let's
  12409. 8:32:49create this requirement.xt
  12410. 8:32:51here.
  12411. 8:32:52H. So inside that let's mention our line
  12412. 8:32:55graph package.
  12413. 8:33:01Okay. Lang graph. So apart from lang
  12414. 8:33:03graph uh you need to install some other
  12415. 8:33:05library as well like you need this lang
  12416. 8:33:09chain open ai. Okay. So we are using
  12417. 8:33:12this langchen openai because uh I'll be
  12418. 8:33:14using my openai uh large language model
  12419. 8:33:18but if you want you can also use any
  12420. 8:33:19other model um from any other provider.
  12421. 8:33:22Let's say you can use open router, you
  12422. 8:33:24can use gro API, okay, you can use
  12423. 8:33:27gemini API, anything you can use. It's
  12424. 8:33:29completely up to you. It's a very easy
  12425. 8:33:31things. You just need to uh change this
  12426. 8:33:33model provide at that time. Okay. So
  12427. 8:33:35with me, I am having my open API key.
  12428. 8:33:37That's why I'll be using this one. Okay.
  12429. 8:33:39And if you want to use openi API, so
  12430. 8:33:41that time you have to install this
  12431. 8:33:43langen openi because I told you langraph
  12432. 8:33:46uh doesn't work actually independently
  12433. 8:33:48internally. It is uses langen. Okay. And
  12434. 8:33:51uh for all the model u let's say loading
  12435. 8:33:54creating the prompt template we need the
  12436. 8:33:56langen okay still langen is required
  12437. 8:33:58then uh I also need pythonb
  12438. 8:34:02for the environment management okay now
  12439. 8:34:04guys uh you have to install this
  12440. 8:34:06requirement txt file but before that I
  12441. 8:34:09told you you have to create the
  12442. 8:34:10environment so try to copy the first
  12443. 8:34:12command and execute from your terminal
  12444. 8:34:15so this will create the environment okay
  12445. 8:34:17for you but for me this environment is
  12446. 8:34:19already available I'll activate the
  12447. 8:34:21environment. So can't activate langraph
  12448. 8:34:23test. Yeah. So you can see this is
  12449. 8:34:26already available. But if you don't have
  12450. 8:34:28just try to create it first of all then
  12451. 8:34:30just execute this requirement command.
  12452. 8:34:33It will install everything. So for me it
  12453. 8:34:34is already satisfied because I installed
  12454. 8:34:36previously. Okay. Now once it is done
  12455. 8:34:39now what I'm going to do guys um let me
  12456. 8:34:41just tell you about the sequential
  12457. 8:34:43workflow. Okay. Uh what is the workflow
  12458. 8:34:46we'll be creating here. See here I'm
  12459. 8:34:48going to create a very simple uh
  12460. 8:34:50workflow without using any kinds of LLM.
  12461. 8:34:52Uh I'll also show you how to use uh LLM
  12462. 8:34:56um how to create the LM workflow as
  12463. 8:34:58well. Don't worry but this is our first
  12464. 8:35:00workflow we are creating inside Lang
  12465. 8:35:02graph and we don't know how to code
  12466. 8:35:03inside Lang graph right so to understand
  12467. 8:35:05the workflow first of all we'll be
  12468. 8:35:07creating a very simple workflow without
  12469. 8:35:09using any kinds of LLM. Then I'm also
  12470. 8:35:12going to show you how to use the LLM as
  12471. 8:35:13well. Okay. So guys uh now let's see uh
  12472. 8:35:16what workflow we'll be creating first of
  12473. 8:35:18all. So here you can see uh we'll be
  12474. 8:35:21creating a sequential workflow uh and
  12475. 8:35:23the workflow is temperature conversion
  12476. 8:35:26workflow. Okay. So here it doesn't have
  12477. 8:35:29any kinds of LLM. As you can see this is
  12478. 8:35:31a simple workflow we have created
  12479. 8:35:33without using any kinds of LLM. So
  12480. 8:35:35basically this workflow what it will do
  12481. 8:35:37it will
  12482. 8:35:39convert actually Celsius temperature to
  12483. 8:35:42Fahrenheit. Okay. This is the only work
  12484. 8:35:44this workflow will do. And if we convert
  12485. 8:35:48this workflow in a graph. So this will
  12486. 8:35:50look like that. So as you can see we
  12487. 8:35:52have taken the start node then convert
  12488. 8:35:55temperature node and the end node. So
  12489. 8:35:57start and end would be common for all
  12490. 8:35:59the workflow you'll be creating uh with
  12491. 8:36:01the help of this langraph. This is a
  12492. 8:36:04dummy nodes you can say because langraph
  12493. 8:36:06understands okay workflow starts from
  12494. 8:36:08here and it it uh ends actually here.
  12495. 8:36:11Okay. And basically it takes the input
  12496. 8:36:13uh to the like other nodes as well. And
  12497. 8:36:17this will also have a state right state
  12498. 8:36:19is a shared memory and this is a mutable
  12499. 8:36:23u let's say object you can create this
  12500. 8:36:25uh state with the help of pentic either
  12501. 8:36:28you can use type dict okay anything you
  12502. 8:36:29can um use it. So basically the state I
  12503. 8:36:33have to share to all of the node so that
  12504. 8:36:35it can take the data and it can update
  12505. 8:36:37the data as well in real time. So you
  12506. 8:36:41can see uh in this particular workflow
  12507. 8:36:44the only function I have to write this
  12508. 8:36:46conversion function temperature
  12509. 8:36:47conversion function. So user will give
  12510. 8:36:49Celsius uh temperature and I'll try to
  12511. 8:36:52convert it to the Fahrenheit. Then this
  12512. 8:36:54uh uh this Fahrenheit output would be
  12513. 8:36:56show uh shows shows as an output. Okay.
  12514. 8:36:59So you can see for this we have created
  12515. 8:37:02we have taken a node convert temperature
  12516. 8:37:04and this node would be a simple Python
  12517. 8:37:06function. in that particular Python
  12518. 8:37:08function what I will do I'll just try to
  12519. 8:37:10I'll just try to uh write u um the uh
  12520. 8:37:14code related conversion uh temperature
  12521. 8:37:17conversion and whatever output we'll try
  12522. 8:37:19to get we'll try to update in this
  12523. 8:37:21particular state so here in this
  12524. 8:37:22particular variable we'll try to update
  12525. 8:37:24that let's say whatever uh temperature
  12526. 8:37:26user will give this is in Celsius so
  12527. 8:37:28this will save inside this particular
  12528. 8:37:30state uh let's object and whatever I'll
  12529. 8:37:33try to convert right uh in the
  12530. 8:37:35Fahrenheit this one I'll try to save it
  12531. 8:37:37here. Okay. Then whenever I'll try to
  12532. 8:37:39show the output. So from here I'll try
  12533. 8:37:41to read and I'll show the output here.
  12534. 8:37:43So this is a simple workflow guys. Uh we
  12535. 8:37:45have to create and this state is a
  12536. 8:37:47shared memory. So this will go to the
  12537. 8:37:49all of the uh all of the nodes. Okay.
  12538. 8:37:52One by one and the complete you can see
  12539. 8:37:54this diagram this workflow this is
  12540. 8:37:56called actually graph. Okay I hope you
  12541. 8:37:58cleared. Now let's try to code inside
  12542. 8:38:00lang graph. So what I'm going to do, I'm
  12543. 8:38:02going to open up my uh So let's create a
  12544. 8:38:06file here.
  12545. 8:38:07I'm going to create a file.
  12546. 8:38:14I'm going to name it as
  12547. 8:38:19one temperature conversion workflow
  12548. 8:38:22NB. Okay. So here I have taken the
  12549. 8:38:25Jupyter notebook file guys because here
  12550. 8:38:27I'm not creating any kinds of end to end
  12551. 8:38:29project. I'm just explaining the
  12552. 8:38:31concept. Uh that's why I think this
  12553. 8:38:34notebook uh format would be uh great fit
  12554. 8:38:37for that because I will also show you
  12555. 8:38:39the uh workflow in a diagram. Okay. And
  12556. 8:38:42this diagram I can't uh I can't actually
  12557. 8:38:46uh show you inside Py file. That's why I
  12558. 8:38:48have taken this file notebook file. So
  12559. 8:38:51let's select our environment line test.
  12560. 8:38:53Yeah. So first of all uh what you have
  12561. 8:38:56to do guys you have to uh import some
  12562. 8:38:58library.
  12563. 8:39:00So here let me comment. First of all you
  12564. 8:39:03have to import
  12565. 8:39:06some library. Okay. So you have to
  12566. 8:39:08import uh this line graph. So from lang
  12567. 8:39:12graph
  12568. 8:39:14dotg graph.
  12569. 8:39:16Okay you have to import state graph.
  12570. 8:39:20Okay you have to import state graph. If
  12571. 8:39:22you check the documentation as well. So
  12572. 8:39:25here also they are doing the same thing
  12573. 8:39:26from lang graph they're importing state
  12574. 8:39:28graph then start and end. Okay this is a
  12575. 8:39:31dummy nodes I already told you this will
  12576. 8:39:33be common for all the uh workflow you'll
  12577. 8:39:36be creating with the help of this line
  12578. 8:39:37graph. Okay. So let's try to import
  12579. 8:39:39them.
  12580. 8:39:41H so state graph then I need start
  12581. 8:39:46I need start
  12582. 8:39:48then I need
  12583. 8:39:52end.
  12584. 8:39:57So here state graph is the function with
  12585. 8:39:59the help of that we create the graph.
  12586. 8:40:01Okay, entire graph it will be creating
  12587. 8:40:03basically uh this helps to create the
  12588. 8:40:06graph as well as uh to add the state uh
  12589. 8:40:08inside our graph. Okay, now let me
  12590. 8:40:11import them. Yeah, so import is
  12591. 8:40:13successful. Uh that means we have
  12592. 8:40:15already installed this langraph and we
  12593. 8:40:17are able to import uh everything. Okay,
  12594. 8:40:19then I also need to import this type
  12595. 8:40:22dict from typing. So from typing.
  12596. 8:40:27So first of all I'm going to show you
  12597. 8:40:30how we can create the state with the
  12598. 8:40:31help of this type dict uh typed dict
  12599. 8:40:34actually module u from python then later
  12600. 8:40:37on I'm also going to show you how we can
  12601. 8:40:39create this uh state with the help of
  12602. 8:40:41pientic okay pientic is another uh
  12603. 8:40:44python framework with the help of that
  12604. 8:40:45you can also create the state so let's
  12605. 8:40:47import
  12606. 8:40:49typed dict
  12607. 8:40:52this one now let me import all of them
  12608. 8:40:56now the first thing Guys, I have to uh
  12609. 8:40:58initialize the state uh state object.
  12610. 8:41:01Okay, state is important. Uh without
  12611. 8:41:04state actually we can't uh create the
  12612. 8:41:06graph. Then after creating the state
  12613. 8:41:08we'll be creating the entire graph.
  12614. 8:41:10First of all, we'll be um uh creating
  12615. 8:41:12the nodes all the nodes. Then after that
  12616. 8:41:15uh we'll be uh we'll be creating the
  12617. 8:41:17ages as well. Okay. So this is called
  12618. 8:41:19ages. Ages means this is the connection.
  12619. 8:41:21Let's say after uh which node uh which
  12620. 8:41:24node would be executed. Okay. This is
  12621. 8:41:26the connection. So this edges should be
  12622. 8:41:28also created. Okay. And if we uh create
  12623. 8:41:30all of them uh this will be uh this will
  12624. 8:41:32become a graph. Okay. So now let's try
  12625. 8:41:35to define the state here. Uh so here
  12626. 8:41:38maybe I can comment
  12627. 8:41:40define
  12628. 8:41:43state
  12629. 8:41:46H. So for this problem I told you state
  12630. 8:41:49would be uh two state. Okay. uh one is
  12631. 8:41:53temperature Celsius and temperature
  12632. 8:41:55Fahrenheit. So let's try to define that.
  12633. 8:41:57So for this I'll write a class.
  12634. 8:42:01Okay, I'll write a class.
  12635. 8:42:03I'm I'm going to name this class as a
  12636. 8:42:06temperature
  12637. 8:42:09state.
  12638. 8:42:12Okay. And I'm going to inherit uh this
  12639. 8:42:15uh class with this type dict uh function
  12640. 8:42:18we have imported. Okay. Now basically
  12641. 8:42:21you are telling this class uh um like
  12642. 8:42:24this class right now can store uh any
  12643. 8:42:27kinds of data as a key value pair. Okay.
  12644. 8:42:30Now the first key should be the
  12645. 8:42:32temperature
  12646. 8:42:34temp Celsius.
  12647. 8:42:37Okay. And uh you can mention the data
  12648. 8:42:39type as well. What should be the data
  12649. 8:42:41type for this particular u uh variable.
  12650. 8:42:45So basically uh Celsius should be in a
  12651. 8:42:47float uh data type. I think you know
  12652. 8:42:49that it can't be integer. It should be
  12653. 8:42:51float. That's why I told uh it is a
  12654. 8:42:54float. Okay, float data type. Then you
  12655. 8:42:57have to write another variable called
  12656. 8:43:01temperature Fahrenheit. So this should
  12657. 8:43:03be also a float type data. Okay. So this
  12658. 8:43:06will become our state. Okay. This will
  12659. 8:43:08become our state and this state we'll be
  12660. 8:43:10using inside our nodes. Okay. All of the
  12661. 8:43:12nodes we'll be creating. Yeah. Now this
  12662. 8:43:15state is also ready. Now let's work on
  12663. 8:43:17this graph. So here what I'm going to do
  12664. 8:43:20uh here let's say I'm going to comment
  12665. 8:43:25define
  12666. 8:43:28okay define and
  12667. 8:43:32compile
  12668. 8:43:34graph I think you know after defining
  12669. 8:43:36the graph you have to compile I told you
  12670. 8:43:38the graph execution process right in my
  12671. 8:43:41previous video as well
  12672. 8:43:44so to define the graph I told you first
  12673. 8:43:46of all you have to use this state graph
  12674. 8:43:47of uh function you have to create a
  12675. 8:43:50object of that. So let's uh create a
  12676. 8:43:54object called graph. Then I'm going to
  12677. 8:43:57initialize state graph and inside that
  12678. 8:43:58you have to pass the state the state you
  12679. 8:44:01have created. This is the state
  12680. 8:44:02temperature state. Okay. So basically
  12681. 8:44:05this will take the state. Now see what
  12682. 8:44:08is happening if you're using the state
  12683. 8:44:09graph object right state graph
  12684. 8:44:11functionality and if you're passing the
  12685. 8:44:13state inside that uh so basically this
  12686. 8:44:16particular function will try to provide
  12687. 8:44:18the state to all of the nodes okay
  12688. 8:44:20automatically one by one you don't need
  12689. 8:44:22to manually provide that okay so this is
  12690. 8:44:24the main benefit here so that's why
  12691. 8:44:26we're using the state graph state graph
  12692. 8:44:28u basically takes this uh state object
  12693. 8:44:31and it provides to all of the nodes okay
  12694. 8:44:33one by one now uh we I have defined our
  12695. 8:44:38graph here.
  12696. 8:44:40So this is called definition
  12697. 8:44:43of the graph. Define your graph.
  12698. 8:44:50Define your graph. Now next I have to
  12699. 8:44:54add the nodes
  12700. 8:45:02nodes to your graph to the graph. So to
  12701. 8:45:06add the nodes guys you just need to
  12702. 8:45:08write graph dot add nodes
  12703. 8:45:12okay add nodes then you have to provide
  12704. 8:45:15the nodes name okay nodes name at the
  12705. 8:45:18very first time you have to give the
  12706. 8:45:19nodes name let's say if you see my nodes
  12707. 8:45:22here okay if you see my nodes here so
  12708. 8:45:28I have only one nodes which is this uh
  12709. 8:45:31convert temperature right I have only
  12710. 8:45:33one nodes which is convert temperature
  12711. 8:45:35now I Ask me start and ed ends is also a
  12712. 8:45:38node right but this is a dummy node this
  12713. 8:45:40thing you don't need to create it
  12714. 8:45:42separately okay so whenever you are uh
  12715. 8:45:45defining the ages okay that time you
  12716. 8:45:47will mention that let's say uh after
  12717. 8:45:49start uh after start this convert
  12718. 8:45:53temperature node would be connected okay
  12719. 8:45:54this is called actually connection
  12720. 8:45:56that's why we call it as a um like uh
  12721. 8:45:58dummy nodes we don't need to create
  12722. 8:46:00separately here okay we don't need to
  12723. 8:46:02add separately here so by default your
  12724. 8:46:05uh lang graph adds that and we just need
  12725. 8:46:07to uh we just need to connect this
  12726. 8:46:10particular nodes to our actual nodes.
  12727. 8:46:12Okay, this is the fun here. Now let me
  12728. 8:46:14first of all create none I'm going to
  12729. 8:46:16explain okay how it works. So first of
  12730. 8:46:18all here I have to add our nodes. So
  12731. 8:46:20here I only have one nodes which is
  12732. 8:46:22convert temperature. So maybe I can just
  12733. 8:46:24give a name. I'll give let's say convert
  12734. 8:46:28okay convert
  12735. 8:46:31temp. You can give any name it's up to
  12736. 8:46:33you. But make sure uh the name you are
  12737. 8:46:35giving here the same name you use for
  12738. 8:46:38creating that particular function. Okay.
  12739. 8:46:40Now this will take that uh convert
  12740. 8:46:43temperature function object. Okay. This
  12741. 8:46:45will take this convert temperature
  12742. 8:46:47function object and I told you every
  12743. 8:46:48node takes a function and this function
  12744. 8:46:50is nothing but it's a Python simple
  12745. 8:46:52function. Okay. Now let's try to create
  12746. 8:46:53this convert temperature function
  12747. 8:46:55individually here. So what I'm going to
  12748. 8:46:57do, I'm going to uh simply
  12749. 8:47:01um come here. So basically this is our
  12750. 8:47:03first node.
  12751. 8:47:12So now let's write the function. So def
  12752. 8:47:15convert temperature. So this will take a
  12753. 8:47:18state.
  12754. 8:47:19Okay, this will take a state. What is
  12755. 8:47:22this state? This temperature state.
  12756. 8:47:25And this will return uh also the state I
  12757. 8:47:29told you every time this state would be
  12758. 8:47:32the input and each and every nodes will
  12759. 8:47:36return some kinds of output. This output
  12760. 8:47:38should be also state okay the updated
  12761. 8:47:40state. So that's why I have to uh I have
  12762. 8:47:43to give this um blueprint that uh this
  12763. 8:47:47function takes uh state uh state as an
  12764. 8:47:50input and it also returns the state.
  12765. 8:47:52Okay, this temperature state only. So
  12766. 8:47:54that's how you can give the blueprint of
  12767. 8:47:56a function. Okay. Now inside that first
  12768. 8:47:59of all I'll take the Celsius data
  12769. 8:48:01whatever data user will provide. So here
  12770. 8:48:04I'll just write Celsius.
  12771. 8:48:07Celsius okay is equal to this Celsius
  12772. 8:48:10should be available inside state. Okay.
  12773. 8:48:12So we are calling state and we are
  12774. 8:48:14extracting the Celsius only because this
  12775. 8:48:17is a dictionary right now and you know
  12776. 8:48:19how to work with the dictionary right?
  12777. 8:48:21uh so we are working in a same then
  12778. 8:48:23after that we'll try to convert uh we'll
  12779. 8:48:26try to convert this to the Fahrenheit so
  12780. 8:48:28I've already written the code let me
  12781. 8:48:29show you
  12782. 8:48:31so here we are converting to the
  12783. 8:48:34Fahrenheit okay you can see Celsius to
  12784. 8:48:37Fahrenheit and if you want to see how to
  12785. 8:48:39convert Celsius to Fahrenheit you can go
  12786. 8:48:42to Google
  12787. 8:48:44you can search here so you will see the
  12788. 8:48:47formula okay so this is the formula so
  12789. 8:48:49we are replicating the same formula here
  12790. 8:48:52you can see we are replicating the self
  12791. 8:48:53same formula we are first of all
  12792. 8:48:55multiplying this Celsius uh with uh 9
  12793. 8:48:58out of five then we are adding 32 with
  12794. 8:49:01that so once we get this Fahrenheit we
  12795. 8:49:03have to also we have to also update the
  12796. 8:49:06state memory right we have to also
  12797. 8:49:08update the state memory because we have
  12798. 8:49:09taken a variable called temperature
  12799. 8:49:11Fahrenheit now whatever Fahrenheit we
  12800. 8:49:13got we have to update inside this
  12801. 8:49:15particular state right so for this
  12802. 8:49:18uh that's how we can update because this
  12803. 8:49:19is a dictionary right this dictionary.
  12804. 8:49:21So I'm uh just adding this particular
  12805. 8:49:23new value to this variable to this key.
  12806. 8:49:26Right? So here we're using round
  12807. 8:49:27function because if it is a float type
  12808. 8:49:30uh data so after point there would be
  12809. 8:49:33too many number but I'm not taking too
  12810. 8:49:35too many number. I'm only taking last
  12811. 8:49:37two uh digit okay after after the point.
  12812. 8:49:40Now once it is done I'm going to simply
  12813. 8:49:42return this state. So return this state.
  12814. 8:49:46Okay that's it. So this is our simple
  12815. 8:49:48python function we have created. Okay.
  12816. 8:49:50Now this function can convert any kinds
  12817. 8:49:53of Celsius data to Fahrenheit and we are
  12818. 8:49:55updating the state here. Okay, that's
  12819. 8:49:57it. Now this particular function will
  12820. 8:50:00object will come here. So that's how
  12821. 8:50:02guys we have created our first node. We
  12822. 8:50:04have added our first node. Now see this
  12823. 8:50:06node has added. Okay. Now you have to
  12824. 8:50:10create this edges. Okay. You have to
  12825. 8:50:11create it create this edges that that
  12826. 8:50:13means the connection the flow of
  12827. 8:50:14execution. So for this let's do that. So
  12828. 8:50:18here I'm going to comment add edges
  12829. 8:50:23to the graph. So first of all you have
  12830. 8:50:25to
  12831. 8:50:28add the first edges. Now see this start
  12832. 8:50:30node will come here. Okay. Now see so
  12833. 8:50:33here I'll just write start and convert
  12834. 8:50:36them. Just try to see this uh graph. See
  12835. 8:50:39now I'm telling this start node would be
  12836. 8:50:41connected to the convert them. Okay,
  12837. 8:50:43that means this is the connection we are
  12838. 8:50:44making right now because from here it
  12839. 8:50:46will start and it will go go to the
  12840. 8:50:48convert temperature. See here we're
  12841. 8:50:50doing start to convert temperature.
  12842. 8:50:52Okay, now I will add the second graph
  12843. 8:51:00sorry second edge add is now convert
  12844. 8:51:03them to end. Now you can see uh so
  12845. 8:51:05basically let me just show you. See
  12846. 8:51:08first of all we connect it here right
  12847. 8:51:11that means this connection this
  12848. 8:51:13connection we have built start to
  12849. 8:51:15convert temperature now convert
  12850. 8:51:17temperature to end okay that means this
  12851. 8:51:19particular edge we are getting right now
  12852. 8:51:21this edge is already created start to
  12853. 8:51:23convert them now convert them to end
  12854. 8:51:25okay particular uh this this edge we are
  12855. 8:51:27getting uh this edge is already created
  12856. 8:51:30now we are doing it here so you can see
  12857. 8:51:32convert them to end okay I hope you
  12858. 8:51:34clear guys now once this is done then
  12859. 8:51:37you will compiling the graph. So compile
  12860. 8:51:41the graph. So you just need to write
  12861. 8:51:44uh graph
  12862. 8:51:47dot compile.
  12863. 8:51:49Okay. And this returns you the workflow.
  12864. 8:51:52So maybe I can store inside a variable
  12865. 8:51:59workflow. Okay. Now let's compile.
  12866. 8:52:05So compilation is also done. Now we'll
  12867. 8:52:08simply execute the graph.
  12868. 8:52:17Execute the graph.
  12869. 8:52:24Now guys, we'll try to execute the
  12870. 8:52:26graph. So to execute the graph uh first
  12871. 8:52:28of all you have to take the initial
  12872. 8:52:31state that means the input uh which is
  12873. 8:52:34the uh Celsius okay Celsius uh um
  12874. 8:52:38temperature. So here what I can do I can
  12875. 8:52:42create a variable. I'm going to name it
  12876. 8:52:44as you can also call it as input state
  12877. 8:52:47or initial state. Okay, it's up to you.
  12878. 8:52:50But I have named it as initial state
  12879. 8:52:52because this this will become my initial
  12880. 8:52:53state. Okay, the first state which is
  12881. 8:52:55nothing but the uh temperature Celsius,
  12882. 8:52:58right? So initial state. So temperature
  12883. 8:53:00Celsius I'm giving let's say 28.5.
  12884. 8:53:03Now this thing we'll try to provide to
  12885. 8:53:05the workflow. So I have created my
  12886. 8:53:08workflow
  12887. 8:53:10workflow dot invoke. Now you can perform
  12888. 8:53:13the invoke operation because this is a
  12889. 8:53:15lang graph object. Inside that I'm going
  12890. 8:53:17to pass my initial state and this will
  12891. 8:53:19uh return you the final state. Okay,
  12892. 8:53:22final state that means the output.
  12893. 8:53:25Final state and this final state I'm
  12894. 8:53:27going to simply print it here. Okay,
  12895. 8:53:30done. Now let's uh see whether it is
  12896. 8:53:33working or not. Now see if I execute.
  12897. 8:53:34Now see initially we have given 28.5
  12898. 8:53:38this is the Celsius temperature. Now the
  12899. 8:53:41final state is uh temp temperature
  12900. 8:53:43Fahrenheit 83
  12901. 8:53:46uh 3. Okay you can also try with Google
  12902. 8:53:50let's say if I'm giving Celsius now see
  12903. 8:53:54Celsius is uh 28.5
  12904. 8:53:56and you are getting 83.3
  12905. 8:54:00you can see 83.3 that means it's working
  12906. 8:54:02fine right? So we are able to execute
  12907. 8:54:04our first graph guys. Okay, we are able
  12908. 8:54:07to create our first graph and this is
  12909. 8:54:09completely working fine. See there is no
  12910. 8:54:12problem. Now if you want to see this
  12911. 8:54:14graph as a uh image you can also do
  12912. 8:54:17that. That that means you can visualize
  12913. 8:54:18this particular graph. This is very
  12914. 8:54:20interesting things I found in langraph.
  12915. 8:54:22So let me just comment here. Okay
  12916. 8:54:24visualize
  12917. 8:54:27graph.
  12918. 8:54:28So I found this code inside this
  12919. 8:54:30langraph documentation.
  12920. 8:54:33Yeah. So here we are using this ipython
  12921. 8:54:36display um and we are importing this
  12922. 8:54:38image function. Inside that we are just
  12923. 8:54:41giving workflow.get graph. Okay.
  12924. 8:54:43Basically this will get the graph and we
  12925. 8:54:45are drawing this particular graph as a
  12926. 8:54:46mar mermaid png. Okay. So mermaid is a
  12927. 8:54:50kinds of uh you can talk about it's a
  12928. 8:54:53flowchart. Okay flowchart style. You can
  12929. 8:54:55search on Google mermaid flowchart or
  12930. 8:54:58simply search for mermaid. You will see
  12931. 8:55:00that. Uh okay. Mermaid flowchart.
  12932. 8:55:06Yeah. See, so this will give you this
  12933. 8:55:07kinds of flowchart. Okay. Now let me
  12934. 8:55:09show you.
  12935. 8:55:11If I execute,
  12936. 8:55:14see guys, you are getting the flowchart.
  12937. 8:55:16Now see this flowchart and this
  12938. 8:55:18flowchart. Just try to tell me whether
  12939. 8:55:21you are able to see this is same or not.
  12940. 8:55:23Okay, this is same right. So you can see
  12941. 8:55:27start then it is going to the convert
  12942. 8:55:29temperature.
  12943. 8:55:31then it is uh giving you the final
  12944. 8:55:34output that means the end nodes. Okay,
  12945. 8:55:36amazing. So guys, congratulation. We
  12946. 8:55:39have created our first workflow, first
  12947. 8:55:41uh line graph graph and this is
  12948. 8:55:43completely working fine. So guys, now
  12949. 8:55:45what we'll do, we'll just try to uh
  12950. 8:55:48update uh the workflow we have created.
  12951. 8:55:50Let's say this is our workflow. Uh so
  12952. 8:55:53here we are only converting the
  12953. 8:55:55temperature to the Fahrenheit. Now what
  12954. 8:55:57I have done, I created another workflow.
  12955. 8:55:59So this is the sim similar workflow only
  12956. 8:56:01I have added a new node here you can
  12957. 8:56:04see. So the node name is label weather.
  12958. 8:56:07So what this label weather will do let's
  12959. 8:56:09say the fahrenheit temperature we are
  12960. 8:56:12getting uh we'll just try to label that
  12961. 8:56:15label means let's say if this fahrenheit
  12962. 8:56:18temperature is less than 50 that time
  12963. 8:56:21weather status is cold. Okay. If let's
  12964. 8:56:23say Fahrenheit temperature is it is uh
  12965. 8:56:26less than equal 50 and less than equal
  12966. 8:56:29uh 77 that time it is mild. Okay. If it
  12967. 8:56:32is less than 95 uh then that time it is
  12968. 8:56:36hot. And if it is not all of them that
  12969. 8:56:39means it is extreme heat. Okay. So this
  12970. 8:56:41kinds of labeling I want to do. So for
  12971. 8:56:44this I have created another node here.
  12972. 8:56:47I'll I'll be writing another node here.
  12973. 8:56:48this particular node will try to um try
  12974. 8:56:52to uh figure out the weather status.
  12975. 8:56:55Okay, it will try to figure out the
  12976. 8:56:56weather status whether the weather is
  12977. 8:56:58hot, cold, mild. Okay, or extreme hot
  12978. 8:57:01etc. Right? And uh to create this
  12979. 8:57:04particular uh graph guys, I need another
  12980. 8:57:07state called weather status because uh
  12981. 8:57:10these nodes will return the label right
  12982. 8:57:13whether it is hot, cold, mild or
  12983. 8:57:15anything. So this particular data I have
  12984. 8:57:18to also save in the state that's why I
  12985. 8:57:19have taken another variable called
  12986. 8:57:21weather status here. But previously this
  12987. 8:57:23was missing here. Okay. Now let's try to
  12988. 8:57:25update this. So what I'm going to do I'm
  12989. 8:57:27going to open up my code again. So see
  12990. 8:57:29here I'll add another nodes. Okay. I'll
  12991. 8:57:31add another nodes here.
  12992. 8:57:34Yeah.
  12993. 8:57:36Let's say the node name is
  12994. 8:57:40uh label weather. Okay. And it will take
  12995. 8:57:42a function Python function called level
  12996. 8:57:44weather. So now let's write this
  12997. 8:57:46function. So after this function maybe I
  12998. 8:57:48can write it here.
  12999. 8:57:51So def label weather. So this will take
  13000. 8:57:54this state as an input.
  13001. 8:57:59Okay. And it will also return this state
  13002. 8:58:01as an output.
  13003. 8:58:04State as an output. Okay. So already I
  13004. 8:58:07got the suggestion code from my uh from
  13005. 8:58:11my co-pilot. Let me show you the code I
  13006. 8:58:14have written.
  13007. 8:58:16So this is the code. Okay. Now let me
  13008. 8:58:20also
  13009. 8:58:23comment here.
  13010. 8:58:26Let's say this is for
  13011. 8:58:29label
  13012. 8:58:34weather
  13013. 8:58:37condition. This is our second note.
  13014. 8:58:39Okay. So now what what we are doing the
  13015. 8:58:42Fahrenheit temperature we are getting
  13016. 8:58:44we're taking it from the state okay we
  13017. 8:58:46are pulling the Fahrenheit from the
  13018. 8:58:47state instead of Celsius
  13019. 8:58:50uh because I want to check with respect
  13020. 8:58:53to the Fahrenheit okay I want to check
  13021. 8:58:55with respect to Fahrenheit you can also
  13022. 8:58:56do it with the help of Celsius as well
  13023. 8:58:59Celsius temperature as well you can also
  13024. 8:59:00label that but I want to do it with the
  13025. 8:59:02help of Fahrenheit I want to I want to
  13026. 8:59:03only show you the output we are getting
  13027. 8:59:06whether we can use it inside this
  13028. 8:59:08particular node or not okay that's why
  13029. 8:59:09I'm using is uh temperature um finite
  13030. 8:59:14then after that I'm checking if finite
  13031. 8:59:15is less than 50 that time uh weather
  13032. 8:59:18status should be cold we are updating
  13033. 8:59:21this
  13034. 8:59:23state okay there should be another
  13035. 8:59:24variable called weather status and right
  13036. 8:59:28now this status should be hot cold mild
  13037. 8:59:30so I can consider this should be a
  13038. 8:59:31string type data okay now let me execute
  13039. 8:59:34this node yeah now you can see this
  13040. 8:59:36weather starter should be cold if it is
  13041. 8:59:40less than and equal 50 or less than 73
  13042. 8:59:4377 that time the weather status should
  13043. 8:59:45be mild. If it is uh less than 77 and
  13044. 8:59:49less than 95 this should be hot
  13045. 8:59:51otherwise it should be extreme heat.
  13046. 8:59:53Okay. So this is our uh uh this is our
  13047. 8:59:56logic we have written inside this label
  13048. 8:59:58weather function and we are returning
  13049. 8:59:59the state. Okay. Now let me execute. Now
  13050. 9:00:02what I'm going to do just execute from
  13051. 9:00:05the beginning one one more time just to
  13052. 9:00:07show you the output.
  13053. 9:00:10H. So the node add is done. Now we'll
  13054. 9:00:12try to add the edges. Okay. Now we'll
  13055. 9:00:15add the edges. That means after convert
  13056. 9:00:18temperature, this will go to the label
  13057. 9:00:19weather. Okay. So here I'm going to
  13058. 9:00:21write
  13059. 9:00:22um
  13060. 9:00:24see uh start start uh convert
  13061. 9:00:28temperature. Okay, that means this part
  13062. 9:00:29is done. Now I have to work on this
  13063. 9:00:32part. Convert temperature to level
  13064. 9:00:34weather. So here I have to write
  13065. 9:00:37convert temperature to level weather.
  13066. 9:00:39Okay. Now label weather to end. Now here
  13067. 9:00:43I just need to light right level weather
  13068. 9:00:47to end. Okay. Now I think you have
  13069. 9:00:49understood this particular edge
  13070. 9:00:50connection. Okay this like very amazing
  13071. 9:00:53right and if you understand this edge
  13072. 9:00:55connection just trust me you can create
  13073. 9:00:56any kinds of workflow inside langraph.
  13074. 9:00:58Okay that's why I'm showing you this
  13075. 9:01:00easy workflow at the very beginning. Now
  13076. 9:01:02once it is done, now let's try to
  13077. 9:01:04compile the graph again. Then I will
  13078. 9:01:08execute
  13079. 9:01:10the graph. This only takes the uh
  13080. 9:01:12temperature Celsius input.
  13081. 9:01:15H uh so you can see temperature Celsius
  13082. 9:01:18this 28.5 we are getting the Fahrenheit
  13083. 9:01:21and based on the Fahrenheit result we
  13084. 9:01:24are seeing that weather status is hot
  13085. 9:01:26right now. We can check if it is 83
  13086. 9:01:28right
  13087. 9:01:3083 that means here this condition is
  13088. 9:01:32matching here okay that means this
  13089. 9:01:34particular condition is hot right now
  13090. 9:01:37okay now if I visualize this graph now
  13091. 9:01:39see another node is added which is level
  13092. 9:01:41weather now this uh this graph and this
  13093. 9:01:45graph I think you can match okay great
  13094. 9:01:49guys so yes this was the first uh
  13095. 9:01:53sequential uh sequential actually
  13096. 9:01:56workflow we have created without using
  13097. 9:01:58any kinds of large language model. So
  13098. 9:02:01now I'm going to show you how we can
  13099. 9:02:03create sequential workflow uh with the
  13100. 9:02:05help of large language model as well. So
  13101. 9:02:08guys uh now we'll be creating a LLM
  13102. 9:02:11workflow. Uh previously the workflow I
  13103. 9:02:13showed you uh this workflow I have
  13104. 9:02:15created this is a non-LM based workflow.
  13105. 9:02:17Uh here I'm not using any kinds of LLM.
  13106. 9:02:19Okay. uh with the help of simple python
  13107. 9:02:21function simple python logic I was
  13108. 9:02:24handling everything now let's say you
  13109. 9:02:25want to use llm okay llm inside the
  13110. 9:02:28workflow so how to create the workflow
  13111. 9:02:31for that let's try to understand and see
  13112. 9:02:33here our main goal is to learn the lang
  13113. 9:02:36graph uh like workflow creation the
  13114. 9:02:39problem statement I'm taking uh it might
  13115. 9:02:41be very simple uh you can think about
  13116. 9:02:43okay this this thing I can create with
  13117. 9:02:45the help of simple python function only
  13118. 9:02:47but why we are writing that much line of
  13119. 9:02:49code. Okay. So our intention is to learn
  13120. 9:02:52the um lang graph workflow. Okay. How we
  13121. 9:02:55can use the lang graph? How we can
  13122. 9:02:56create the workflow? How we can create
  13123. 9:02:58the node edges. Okay. Each and
  13124. 9:03:00everything this idea I'm giving you.
  13125. 9:03:01Okay. So problem statement doesn't
  13126. 9:03:03matter. You can use any kinds of problem
  13127. 9:03:04statement. So after learning this simple
  13128. 9:03:07concept so later on whenever we'll be
  13129. 9:03:09creating the actual agents or big
  13130. 9:03:12project. So this concept will help us a
  13131. 9:03:14lot. Right? So that's why we are um uh
  13132. 9:03:17explaining this concept with the help of
  13133. 9:03:18simple workflow. Now here I'm going to
  13134. 9:03:21take another uh very simple workflow
  13135. 9:03:23guys for the LM workflow. So here what
  13136. 9:03:26I'm going to do uh here this is the uh
  13137. 9:03:29workflow. This is the graph you can see.
  13138. 9:03:31So basically this will have the start
  13139. 9:03:33and end nodes definitely because this is
  13140. 9:03:35common. So the only one nodes I'll be
  13141. 9:03:37creating here the LMQA nodes. Okay. So
  13142. 9:03:39LMQA means what it will perform. So
  13143. 9:03:41basically user will give some of the
  13144. 9:03:43question and this lm will uh answer that
  13145. 9:03:46particular question and this will return
  13146. 9:03:48you the answer only this simple
  13147. 9:03:50operation will be doing okay in this
  13148. 9:03:52particular workflow. So for this what
  13149. 9:03:55should be the state? The state should be
  13150. 9:03:56definitely the question whatever
  13151. 9:03:58question user is giving and whatever
  13152. 9:04:00answer we are getting from the LLM this
  13153. 9:04:02should be another state. Okay. So this
  13154. 9:04:05state should be passed to all of the
  13155. 9:04:06nodes and it will real time update that
  13156. 9:04:09and our uh uh workflow would be ended.
  13157. 9:04:12So this is the simple uh graph guys. Now
  13158. 9:04:15let's try to implement this graph with
  13159. 9:04:17the help of lang graph. So for this I
  13160. 9:04:19have already prepared a notebook as you
  13161. 9:04:21can see simple keyway LA workflow. So
  13162. 9:04:23let me open it up and uh to run this uh
  13163. 9:04:26um um code guys you need this file
  13164. 9:04:30because in the env I have mentioned my
  13165. 9:04:32openi API key because here we are using
  13166. 9:04:34large language model and I'm using openi
  13167. 9:04:37large language model but if you want to
  13168. 9:04:38use any other large language model you
  13169. 9:04:40can use it completely fine for this you
  13170. 9:04:42can change the API key here. So this is
  13171. 9:04:44the uh code guys. This is the notebook I
  13172. 9:04:46have prepared. Now this is this looks
  13173. 9:04:49same as per your previous uh notebook.
  13174. 9:04:51Only the things I have added the llm
  13175. 9:04:53functionality here. Now first of all you
  13176. 9:04:55have to import some necessary library.
  13177. 9:04:57So see you can see we are importing the
  13178. 9:04:59same uh state graph start ends from the
  13179. 9:05:02langraph graph. Then one additional
  13180. 9:05:04package we're importing langchen peni
  13181. 9:05:07chat opi. I told you if I want to use
  13182. 9:05:09any kinds of uh let's say large language
  13183. 9:05:12model or whatever I have to still use
  13184. 9:05:15langen because langraph doesn't have
  13185. 9:05:17direct functionality so that
  13186. 9:05:19functionality can load any kinds of llm
  13187. 9:05:21okay so it has to use this langen to
  13188. 9:05:23load the large language model so here
  13189. 9:05:25one more thing you are also learning how
  13190. 9:05:27we can use langen along with the lang
  13191. 9:05:28graph okay so this is the concept so we
  13192. 9:05:31are importing chat open a let's say if
  13193. 9:05:32you're using any other other provider if
  13194. 9:05:34you're using grock or open router inside
  13195. 9:05:36langen it is available you simply you
  13196. 9:05:38can open it up. Then we are also
  13197. 9:05:40importing type dict just to create the
  13198. 9:05:42state and the load envadment
  13199. 9:05:45variable.
  13200. 9:05:48Now the first step we are loading the
  13201. 9:05:49environment variable this env. For this
  13202. 9:05:52we are calling this load env. So if it
  13203. 9:05:54is returns two. Okay first of all I have
  13204. 9:05:57to import this. Now I'll execute. Now if
  13205. 9:06:00it if it returns to that means this env
  13206. 9:06:03file is present and inside that we have
  13207. 9:06:04the uh key right. It has loaded
  13208. 9:06:07successfully. Now we'll try to define
  13209. 9:06:09the large language model. Okay. So here
  13210. 9:06:10we are creating a model object and we
  13211. 9:06:12are calling the chat openi. So by
  13212. 9:06:14default I think it loads a model. Okay.
  13213. 9:06:16Uh I think GPT 3.5 turbo model it will
  13214. 9:06:19load. You can also change the model
  13215. 9:06:21parameter. If you want to use any other
  13216. 9:06:22model like GPT 5 or 4 you can easily do
  13217. 9:06:25that. But I will take the default model.
  13218. 9:06:27It's completely fine for me. Okay. So I
  13219. 9:06:28got my model object. Now here you can
  13220. 9:06:30change with any model object. Either you
  13221. 9:06:32are using grock uh either you can using
  13222. 9:06:34open router Gemini anything you can use.
  13223. 9:06:37Now we have to create this state. Okay,
  13224. 9:06:40this state we have to create and I told
  13225. 9:06:41you to create this workflow I need u
  13226. 9:06:45this these two state question and
  13227. 9:06:46answer. So this thing I'll be creating
  13228. 9:06:48right now. You can see I have written a
  13229. 9:06:50class I named it as LLM state and again
  13230. 9:06:53I'm inheriting with the help of type
  13231. 9:06:54dict. Now we can store the data as a
  13232. 9:06:57question uh key value pair. Now the
  13233. 9:06:59first state you can see this is the
  13234. 9:07:00question and the data type should be
  13235. 9:07:02string because usually uh whatever
  13236. 9:07:05question we are writing this is kinds of
  13237. 9:07:06string type data and answer also this is
  13238. 9:07:09a string type data okay we are
  13239. 9:07:10preferring the state now once uh state
  13240. 9:07:12preparation is done now we'll be
  13241. 9:07:15creating the nodes but before uh showing
  13242. 9:07:17you the nodes u logic I will show you
  13243. 9:07:20the graph definition so you can see guys
  13244. 9:07:22uh we are creating the state graph and
  13245. 9:07:24we are passing the state the state we
  13246. 9:07:26have created this state then After that
  13247. 9:07:29we are adding the nodes. Okay. The first
  13248. 9:07:31node we have added the LM QA. Okay. Now
  13249. 9:07:33this LLM QA we have to write. Okay. This
  13250. 9:07:35LLM QA we have to write. So this this is
  13251. 9:07:37this should be a simple Python function.
  13252. 9:07:39Inside that we'll perform the LLM call.
  13253. 9:07:41So see LM QA this is the function we are
  13254. 9:07:44writing. This will take this state as an
  13255. 9:07:45input and return the state as an output.
  13256. 9:07:48Now whatever question user is giving I
  13257. 9:07:52am taking it from the state. Then I'm
  13258. 9:07:54preparing a prompt. Answer the following
  13259. 9:07:56questions. We are giving the questions.
  13260. 9:07:57Then this particular prompt I'm just
  13261. 9:07:59giving to the model. We're just doing
  13262. 9:08:01model.info giving the prompt and
  13263. 9:08:03whatever content it is giving me. I'm
  13264. 9:08:05just extracting in the answer and this
  13265. 9:08:07answer I'm updating in the state memory
  13266. 9:08:09again. Okay. So you can see it is having
  13267. 9:08:11the answer key. I'm updating the value
  13268. 9:08:13there and we're returning the state.
  13269. 9:08:15Okay. Now let's execute.
  13270. 9:08:21Now once our node is added now we'll be
  13271. 9:08:24working on the edges. We'll try to
  13272. 9:08:25connect the edges. Now if you see the
  13273. 9:08:27graph so see first of all start node
  13274. 9:08:29will connect to the lm QA. So we are
  13275. 9:08:32connecting that start to lm QA. Then LLM
  13276. 9:08:35QA will be connected to the end. You can
  13277. 9:08:37see then add LLM QA to end. Okay. And I
  13278. 9:08:42told you start and end is a default node
  13279. 9:08:44inside Langraph. You don't need to
  13280. 9:08:46manually add that. This is a dummy node.
  13281. 9:08:48Okay. So only we'll be calling whenever
  13282. 9:08:50we'll be adding the edges. So once it is
  13283. 9:08:52done we'll try to compile the graph.
  13284. 9:08:54Let's compile. Okay, now everything is
  13285. 9:08:57ready. Now we can execute the graph. So
  13286. 9:08:59we are preparing the initial state which
  13287. 9:09:00is nothing but the question. Let's say
  13288. 9:09:02here I'm giving a question who is the
  13289. 9:09:04creator of Python and uh the workflow we
  13290. 9:09:07have created. We are just doing the
  13291. 9:09:08inbing operation. We are giving the
  13292. 9:09:09initial state and we are getting the
  13293. 9:09:11final state output. Then we are just
  13294. 9:09:13returning the answer. So I'm asking a
  13295. 9:09:16question which is the creator of Python.
  13296. 9:09:18Now let's see.
  13297. 9:09:20So see the Python was created by Guido
  13298. 9:09:23Van Rosrom in the late '9s80s. Okay,
  13299. 9:09:261980s. So it's working fine. Okay, you
  13300. 9:09:28can give any other question as well. It
  13301. 9:09:30will work. Now let's try to visualize
  13302. 9:09:32the graph. So here I will execute this
  13303. 9:09:34code. This code is common. Now see this
  13304. 9:09:36is uh the graph. You can see start LMQA
  13305. 9:09:39and ends. Okay, amazing. So this is the
  13306. 9:09:42actually LM workflow we have created. So
  13307. 9:09:44previously we created without uh nonLM
  13308. 9:09:47workflow. Now we have created LM based
  13309. 9:09:49workflow. Okay, I hope you get it. So
  13310. 9:09:51that's how guys, if you want to use any
  13311. 9:09:53kinds of large language model inside the
  13312. 9:09:55workflow, you can uh define it like
  13313. 9:09:57that. Okay, now we'll be learning
  13314. 9:09:59another uh amazing concept. I I think I
  13315. 9:10:02told you in my previous video as well
  13316. 9:10:04called prom chaining. Promching means
  13317. 9:10:06you can use multiple LM calls. See here
  13318. 9:10:09I'm using only one LM call, right? One
  13319. 9:10:11LM call. But if you want to use multiple
  13320. 9:10:13LM call, that is also possible. So we'll
  13321. 9:10:16be learning in the pom uh we'll be
  13322. 9:10:18learning this concept in the prom
  13323. 9:10:19chaining. Okay. So I'm going to create
  13324. 9:10:20another notebook. There I'm going to
  13325. 9:10:22show you how we can perform the prom
  13326. 9:10:24chaining operation. That means one uh
  13327. 9:10:26LLM answer you are getting. You can pass
  13328. 9:10:28this answer to another LM to get another
  13329. 9:10:30response. Okay, this is also possible
  13330. 9:10:31here. Let me show you that part as well.
  13331. 9:10:33So guys, now I'll explain about this
  13332. 9:10:36prom training. Uh this is another
  13333. 9:10:38sequential workflow. So in our previous
  13334. 9:10:41uh workflow, we did the single LLM call.
  13335. 9:10:44That means uh user was giving any kinds
  13336. 9:10:46of question and it was generating the
  13337. 9:10:48answer. But let's say you want to do
  13338. 9:10:50multiple LM call that means uh after one
  13339. 9:10:52LM call that output you want to use for
  13340. 9:10:55another LM okay as an input. This is
  13341. 9:10:57called prompt chaining. So for an
  13342. 9:11:00example let me just uh tell you see here
  13343. 9:11:03what I'm going to do. I'm going to let's
  13344. 9:11:05say uh create a blog generator. Okay
  13345. 9:11:08blog generator from a topic. So here
  13346. 9:11:11let's say user will give a topic name.
  13347. 9:11:13Okay. So this will generate a blog.
  13348. 9:11:16Okay, block blog for that. But this
  13349. 9:11:18block I'm not going to generate
  13350. 9:11:19directly. Instead of that what I'm going
  13351. 9:11:21to do first of all I'm going to take
  13352. 9:11:22this topic name. Then I'm going to pass
  13353. 9:11:25to LLM. Okay, I'm going to pass to LLM.
  13354. 9:11:29And this LLM will try to generate the
  13355. 9:11:31outline. Okay, outline for the block. So
  13356. 9:11:34let's say this will generate the
  13357. 9:11:36outline. Okay, outline of the block from
  13358. 9:11:39this LLM. And whatever outline I will
  13359. 9:11:41give uh get from this LLM, I'll pass to
  13360. 9:11:43another LLM. Okay. And this LLM will try
  13361. 9:11:46to
  13362. 9:11:48take this topic as well as this outline
  13363. 9:11:50and it will generate the block.
  13364. 9:11:54Okay. And we'll be getting the final
  13365. 9:11:56block as an output. Okay. At the last.
  13366. 9:11:58So this is the workflow and this is
  13367. 9:12:00called actually prompt chaining concept.
  13368. 9:12:03Okay. Prompt chaining concept. Basically
  13369. 9:12:05whatever output we are getting from a
  13370. 9:12:07first large bank model we are passing it
  13371. 9:12:09to the second LLM as an input and we are
  13372. 9:12:11getting a final output. That means we
  13373. 9:12:13are calling multiple LM call here. This
  13374. 9:12:14is called prompt shading concept. Okay.
  13375. 9:12:16So this workflow we'll try to create
  13376. 9:12:18right now. Now see guys I have already
  13377. 9:12:20created this uh graph. Okay. Uh I've
  13378. 9:12:23already created this workflow as you can
  13379. 9:12:24see. So start and end would be common.
  13380. 9:12:26So here I have to create two nodes. One
  13381. 9:12:28is the create outline. That means
  13382. 9:12:30whatever input I'll be getting. That
  13383. 9:12:32means uh the topic. So first of all I'll
  13384. 9:12:35generate outline and this outline as
  13385. 9:12:37well as the topic I'll send to another
  13386. 9:12:39nodes which is create block. This will
  13387. 9:12:41generate the blog and I'll be getting
  13388. 9:12:43the final block as an output. Okay. And
  13389. 9:12:45what should be the state for this
  13390. 9:12:46particular uh workflow? First of all the
  13391. 9:12:49title that means the blog title. Okay.
  13392. 9:12:51Then whatever outline it will generate
  13393. 9:12:53this outline as well. And whatever
  13394. 9:12:55content that means the blog will be
  13395. 9:12:57getting this should be another state.
  13396. 9:12:59Okay. So that means three state will be
  13397. 9:13:00available for this particular uh
  13398. 9:13:02workflow for this particular graph.
  13399. 9:13:04Okay. Now let's try to represent in the
  13400. 9:13:06lang graph code. So for this I have
  13401. 9:13:08created another notebook as you can see
  13402. 9:13:10prompt chaining workflow. So let's open
  13403. 9:13:12it up. So this is the notebook. So again
  13404. 9:13:14this is the same uh as per your previous
  13405. 9:13:16notebook I created. First of all we have
  13406. 9:13:18to import all the necessary libraries.
  13407. 9:13:21You can see we are importing state graph
  13408. 9:13:22start ends chat open. Okay. Then type d
  13409. 9:13:26load env. Then we'll be loading the env
  13410. 9:13:28uh env file to load the opinion API key.
  13411. 9:13:32Then we'll be defining the large
  13412. 9:13:33language model. Then we'll be creating
  13413. 9:13:36the state and uh this state name I have
  13414. 9:13:39uh named it as blog state. And again I'm
  13415. 9:13:41doing the inheritant inheritance
  13416. 9:13:43operation with the help of this type
  13417. 9:13:45dict. Now we are preparing the state.
  13418. 9:13:47State means the title, outline and the
  13419. 9:13:49content. Okay. Three state we are
  13420. 9:13:50taking. H now before creating the nodes
  13421. 9:13:54first of all let me show you the graph
  13422. 9:13:57okay see here we are creating the graph
  13423. 9:14:00state graph and we are passing the state
  13424. 9:14:02and first of all we are adding the nodes
  13425. 9:14:04okay so the first nodes we are adding
  13426. 9:14:06for the create outline now let me show
  13427. 9:14:08you this create outline function so this
  13428. 9:14:10is the create outline function so this
  13429. 9:14:11will take this state as an uh input and
  13430. 9:14:14uh return you the state as an output
  13431. 9:14:17okay so whatever title user is giving
  13432. 9:14:19first of all I'm taking the title And
  13433. 9:14:21here I'm preparing a prompt generate a
  13434. 9:14:23detail outline for the blog uh for a
  13435. 9:14:26blog on the topic. So then we are
  13436. 9:14:28passing it to the LLM. LM is giving the
  13437. 9:14:30outline. This outline we are saving
  13438. 9:14:31inside the state. Okay, inside outline
  13439. 9:14:33variable then we are returning the
  13440. 9:14:35state. Then after that if you show if
  13441. 9:14:37you see I'm adding another nodes okay
  13442. 9:14:40called generate blog. Now whatever
  13443. 9:14:43outline I got and title I got I will
  13444. 9:14:45pass to this particular function. You
  13445. 9:14:47can see uh it will take from this state
  13446. 9:14:50the title as well as the outline. Then
  13447. 9:14:51I'm preparing another prompt. This
  13448. 9:14:53prompt is telling write a detailed blog
  13449. 9:14:55on the title. Okay, using the following
  13450. 9:14:57outline. The outline we are getting as
  13451. 9:14:58well as the title we are using here.
  13452. 9:15:00Then we are passing it to the LLM. Okay,
  13453. 9:15:02again we're doing the LM call. Whatever
  13454. 9:15:04LM is generating, I'm just storing in
  13455. 9:15:06the content. That means this is the
  13456. 9:15:08final block. Okay, I'm storing inside
  13457. 9:15:09this content uh content state. Okay, so
  13458. 9:15:13it is done. Now you can see we are
  13459. 9:15:15adding both of the nodes one by one. So
  13460. 9:15:18this uh nodes is added create outline
  13461. 9:15:20and uh create blocks. Now I have to
  13462. 9:15:22create the edges. Now to create the
  13463. 9:15:24edges guys here you can see I'm creating
  13464. 9:15:26the edges. First of all age would be
  13465. 9:15:28created. Start to create outline. You
  13466. 9:15:31can see start to create outline. Then
  13467. 9:15:34create outline to create block.
  13468. 9:15:38Create outline to create block. Okay.
  13469. 9:15:40Then create block to end. create block
  13470. 9:15:44to end. Okay, then we are doing the
  13471. 9:15:45compile operation.
  13472. 9:15:48Then now we'll execute the graph. So
  13473. 9:15:50here as initial state we are giving the
  13474. 9:15:52title. Okay, we are giving a title let's
  13475. 9:15:54say raise of AI in India. Let's say this
  13476. 9:15:56is our uh title and I want to generate
  13477. 9:15:59outline and then block. Now we are
  13478. 9:16:01giving into the workflow. We are doing
  13479. 9:16:03the blocking operation and we are
  13480. 9:16:04getting the final state as an output.
  13481. 9:16:09See
  13482. 9:16:15it is doing multiple LM call that's why
  13483. 9:16:17it's taking some time. First of all it
  13484. 9:16:19will invoke first LLM then the second
  13485. 9:16:22LM. Right now see here we are getting
  13486. 9:16:24the output. So this is the title based
  13487. 9:16:26on the title we are getting the outline
  13488. 9:16:28and also we have a content final content
  13489. 9:16:31I think somewhere content is also there.
  13490. 9:16:33Uh we can see uh here. So final state uh
  13491. 9:16:37first of all I want to see the outline.
  13492. 9:16:39So this is the outline. Okay, it has
  13493. 9:16:40prepared. Now if I want to show you the
  13494. 9:16:44content that means the blog. So this is
  13495. 9:16:46the blog guys. Okay, I'm getting. So
  13496. 9:16:48this is called prompt shading concept.
  13497. 9:16:50Now if I want to show you the
  13498. 9:16:53graph. So this is the graph. You start
  13499. 9:16:55create outline then it will go to the
  13500. 9:16:57generate block create block then hands.
  13501. 9:17:00Okay, I hope you got it guys. Okay, so
  13502. 9:17:02that's how guys we can create any kinds
  13503. 9:17:04of sequential workflow. Either you can
  13504. 9:17:06create a nonLM based, either you can
  13505. 9:17:08create LLM based, either you can create
  13506. 9:17:10prompt chaining based, anything you can
  13507. 9:17:12create only you just need to know how to
  13508. 9:17:14uh how to define these uh nodes and this
  13509. 9:17:18particular connection. Okay, age
  13510. 9:17:19connection if you can understand this
  13511. 9:17:21concept you can just trust me you can
  13512. 9:17:24create any kinds of workflow okay inside
  13513. 9:17:26lang graph. Now I think by end of this
  13514. 9:17:29video it is uh very much clear how we
  13515. 9:17:31can create any kinds of sequential
  13516. 9:17:32workflow inside lang graph. Okay don't
  13517. 9:17:34worry I'm also going to show you uh like
  13518. 9:17:37complex workflow as well like parallel
  13519. 9:17:38workflow. Okay there are lots of
  13520. 9:17:39workflow we saw right we'll be learning
  13521. 9:17:42each of them don't need to worry but
  13522. 9:17:44before starting that complex workflow
  13523. 9:17:46first of all I've given you the
  13524. 9:17:47sequential workflow. uh I think uh now
  13525. 9:17:50you have enough understanding how to
  13526. 9:17:52code inside langraph at least right now
  13527. 9:17:54I think these are the syntax won't be
  13528. 9:17:55confusion to you right like what is a
  13529. 9:17:58node what is ajs okay so so far we have
  13530. 9:18:00learned so many theoretical concept now
  13531. 9:18:02we have seen the practical
  13532. 9:18:04implementation
  13533. 9:18:05and all of this code and everything
  13534. 9:18:07would be available in the description
  13535. 9:18:09from there you can uh download and you
  13536. 9:18:11can uh try in your system and one more
  13537. 9:18:14exercise you can perform let's say this
  13538. 9:18:16prom training u we have
  13539. 9:18:19Maybe you can add another node for the
  13540. 9:18:21evalu evaluation for this block. Let's
  13541. 9:18:23say the blog you are generating whether
  13542. 9:18:25this is good or bad. You can uh take
  13543. 9:18:28another LLM. You can take another nodes
  13544. 9:18:30and you can evaluate that and you can
  13545. 9:18:31also uh print the evaluation result.
  13546. 9:18:34Let's say it needs the feedback or not
  13547. 9:18:37or it is completely fine. This kinds of
  13548. 9:18:39result you can also uh print. Okay, that
  13549. 9:18:42means you you have to take another state
  13550. 9:18:43here and whatever result you are getting
  13551. 9:18:45you can also show the result here. Okay,
  13552. 9:18:47after you can see uh content maybe you
  13553. 9:18:51can uh print another result which is
  13554. 9:18:53evaluator result. Okay. Now the best
  13555. 9:18:56part is of this state is you you can
  13556. 9:18:58access all of the output. Okay. All of
  13557. 9:19:00the output input any time. Let's say we
  13558. 9:19:02have generated uh these three uh three
  13559. 9:19:05things right? Uh title, outline and
  13560. 9:19:07content and it is accessible anytime.
  13561. 9:19:09Okay. This is the final state. From the
  13562. 9:19:11fin from the final state you can access
  13563. 9:19:15um any kinds of state. Let's you can
  13564. 9:19:17access title, outline, content or if
  13565. 9:19:19you're adding the evaluator you can
  13566. 9:19:21access it anytime. Okay. So yes that's
  13567. 9:19:23it guys. So yes uh this is all about
  13568. 9:19:26from this video. I hope you got it. Now
  13569. 9:19:28in the next video guys we'll be uh we'll
  13570. 9:19:30be learning uh some other workflow as
  13571. 9:19:33well. Okay like uh parallel workflow
  13572. 9:19:35we'll be also learning conditional
  13573. 9:19:37workflow, iterative workflow. Okay, all
  13574. 9:19:38the workflow we'll try to cover one by
  13575. 9:19:40one. So guys uh we are continuing with
  13576. 9:19:42our uh complete agenti course and as you
  13577. 9:19:46know we started uh learning our first
  13578. 9:19:49orchestration framework which is
  13579. 9:19:51langraph and in our previous video I
  13580. 9:19:54have already showed you how we can build
  13581. 9:19:56sequential workflow inside langraph. So
  13582. 9:20:00if I open up my um previous uh like uh
  13583. 9:20:04materials. So there I already showed you
  13584. 9:20:07about the sequential workflow and I
  13585. 9:20:08think you know how sequential workflow
  13586. 9:20:10works. Basically it will work as a
  13587. 9:20:12step-by-step manner. Okay. First of all
  13588. 9:20:14let's say this node then this node then
  13589. 9:20:16this node okay that's how it will
  13590. 9:20:17execute okay as a sequence. So if I uh
  13591. 9:20:20show you see I created a nonlm based
  13592. 9:20:23workflow and lm workflow uh then prompt
  13593. 9:20:26chaining workflow. So as you can see u
  13594. 9:20:29after executing this node this node
  13595. 9:20:31would be executed. Okay then you will be
  13596. 9:20:32getting the output. So this is a
  13597. 9:20:34sequential order. Now we'll try to
  13598. 9:20:36understand this uh parallel workflow
  13599. 9:20:39like how parallel workflow works and
  13600. 9:20:42we'll also try to uh write the code
  13601. 9:20:45inside langraph. And uh here is the
  13602. 9:20:47example guys. The first example I'm
  13603. 9:20:48going to show you the employee analytics
  13604. 9:20:51workflow. Okay. So this is the example I
  13605. 9:20:52have taken. uh I already told you just
  13606. 9:20:55don't um I mean don't focus on the
  13607. 9:20:57problem statement I I have taken some of
  13608. 9:21:00the problem statement uh easy problem
  13609. 9:21:01statement so that I can make you
  13610. 9:21:03understand these are the workflow so
  13611. 9:21:04later on we'll be building some amazing
  13612. 9:21:06ANTI application completely end to end
  13613. 9:21:09so you can see guys uh here uh this is
  13614. 9:21:12the parallel workflow uh graph as you
  13615. 9:21:15can see uh so you you can see the
  13616. 9:21:17difference between the sequential and
  13617. 9:21:20the parallel sequential means uh After
  13618. 9:21:23executing this node, this node will be
  13619. 9:21:25executing. That means the output you are
  13620. 9:21:28getting from this particular node, you
  13621. 9:21:30are passing this particular output to
  13622. 9:21:32the next node and this node is taking
  13623. 9:21:34that um output as an input. Then it is
  13624. 9:21:36executing. Okay, that means um you have
  13625. 9:21:40to wait okay um you have to wait till
  13626. 9:21:42this node just complete the execution
  13627. 9:21:45then this node will start. But in
  13628. 9:21:47parallel workflow um it's not like that.
  13629. 9:21:51Each of the nodes are independent that
  13630. 9:21:53means you can execute them
  13631. 9:21:55independently. Okay, simultaneously you
  13632. 9:21:57can execute all of the node and you can
  13633. 9:22:00get the output. So for this I have taken
  13634. 9:22:02one amazing example called employee
  13635. 9:22:04analytics workflow. So basically what
  13636. 9:22:06we'll do here we'll just try to take
  13637. 9:22:08some employee data. So here I already
  13638. 9:22:10created the state as you can see I have
  13639. 9:22:12already defined the state for this
  13640. 9:22:14particular demo. So as you can see let's
  13641. 9:22:16say this is our employee state and you
  13642. 9:22:17know what is a state right? state is a
  13643. 9:22:20uh a shared memory uh inside our graph,
  13644. 9:22:22right? And it will pass to all of the
  13645. 9:22:25nodes. So you can see these are the data
  13646. 9:22:28we'll be taking from the user. Okay,
  13647. 9:22:30let's see employee name, monthly salary,
  13648. 9:22:33working days and completed projects.
  13649. 9:22:35Okay, based on that what we'll do, we'll
  13650. 9:22:37just try to calculate the bonus of the
  13651. 9:22:40employee, uh yearly salary of the
  13652. 9:22:42employee and the project evaluation. Ev
  13653. 9:22:44evaluation means the project is
  13654. 9:22:46excellent. uh let's say project work is
  13655. 9:22:48excellent or average okay we'll try to
  13656. 9:22:50mark that now you can see u to do that I
  13657. 9:22:54don't need to wait for any of the node
  13658. 9:22:57here let's say I don't need to wait for
  13659. 9:22:59this bonus to calculate the yearly
  13660. 9:23:01salary then I don't need to wait for
  13661. 9:23:04project evaluation for this calculate
  13662. 9:23:07yearly salary okay I don't need to wait
  13663. 9:23:08for each and every nodes here because
  13664. 9:23:11each and every nodes are independent the
  13665. 9:23:13task I have taken you can see this is
  13666. 9:23:15completely independent task So instead
  13667. 9:23:17of running this in a sequential manner
  13668. 9:23:20so I can follow this par parallel
  13669. 9:23:22workflow. Okay. So that I can execute
  13670. 9:23:25them in parallel and I can quickly
  13671. 9:23:27complete my task. Okay. Otherwise if you
  13672. 9:23:30if you are running in sequential order
  13673. 9:23:32you have to wait for the previous node
  13674. 9:23:34to be executed. Okay. But here it's not
  13675. 9:23:36like that. This is completely
  13676. 9:23:37independent. Then after uh getting all
  13677. 9:23:40of this uh information what we'll do
  13678. 9:23:42guys we'll just try to give a summary.
  13679. 9:23:45uh summary means let's say the employee
  13680. 9:23:47name their salary yearly salary project
  13681. 9:23:51evaluation calculated bonus we'll just
  13682. 9:23:53try to return a string complete uh
  13683. 9:23:55detail summary string and we'll just try
  13684. 9:23:57to end the graph okay so this is a
  13685. 9:23:58simple problem statement I have taken
  13686. 9:24:00again I told you guys uh don't uh just
  13687. 9:24:03focus on the problem statement uh just
  13688. 9:24:05to make you understand I have taken this
  13689. 9:24:07problem statement the main intention you
  13690. 9:24:08have to learn this workflow okay how we
  13691. 9:24:10can build this workflow so first of all
  13692. 9:24:12we'll try to learn this nonLM based
  13693. 9:24:14workflow So here I'm not going to use
  13694. 9:24:15any kinds of LLM. Uh then after learning
  13695. 9:24:18this nonLM based workflow, the next one
  13696. 9:24:20I'm going to take the LM workflow. Okay.
  13697. 9:24:23So both we'll be learning. No need to
  13698. 9:24:25worry. Now let's start the coding inside
  13699. 9:24:27Langraph. So what I'm going to do guys,
  13700. 9:24:29I'm going to simply
  13701. 9:24:31um create a
  13702. 9:24:34I'm going to simply create a file here.
  13703. 9:24:37I'm going to name it as four
  13704. 9:24:40um employee data analytics. Okay.
  13705. 9:24:42Employee
  13706. 9:24:53analytics
  13707. 9:24:58workflow.
  13708. 9:25:06I'm going to create a notebook file.
  13709. 9:25:10Perfect. So here I'll take the code cell
  13710. 9:25:12and I will select the kernel. Uh so
  13711. 9:25:14previously I created this environment. I
  13712. 9:25:16think you remember we'll try to select
  13713. 9:25:18that as well. H fine. Now guys the first
  13714. 9:25:22thing what you have to do I think you
  13715. 9:25:24remember the first thing you have to
  13716. 9:25:26import all of the necessary library. So
  13717. 9:25:28maybe what I can do I can refer my
  13718. 9:25:30previous notebook and I can just import
  13719. 9:25:34all of the necessary library. I need um
  13720. 9:25:37I need this one right? this uh line
  13721. 9:25:41graph state graph and start and end. So
  13722. 9:25:44I'll try to import the this as well as I
  13723. 9:25:46need this uh typing
  13724. 9:25:49to create this uh state. Okay, I need
  13725. 9:25:52this particular type dict. Now let's
  13726. 9:25:54import it. H now the second thing guys
  13727. 9:25:58you have to define the state. Okay, if
  13728. 9:25:59you uh if you see that let's say the
  13729. 9:26:02previous example also uh so this is LM
  13730. 9:26:04workflow. But if I open my previous
  13731. 9:26:06example, let's say this one I created,
  13732. 9:26:08right? This is the non LLM based
  13733. 9:26:10workflow. Uh then second thing you have
  13734. 9:26:12to define the state and uh for this uh
  13735. 9:26:15example guys what should be the state.
  13736. 9:26:17So this is the state I already prepared.
  13737. 9:26:19First of all uh these are the state
  13738. 9:26:20we'll be taking from the u user and
  13739. 9:26:24these are the state we'll be uh we'll be
  13740. 9:26:26just calculating. Okay we'll be updating
  13741. 9:26:27basically let's say this calculate uh
  13742. 9:26:30yearly salary. We'll try to calculate
  13743. 9:26:32the yearly salary and we'll try to
  13744. 9:26:33update in the inside this particular
  13745. 9:26:34state. Then bonus okay we'll update
  13746. 9:26:37inside this uh state then project
  13747. 9:26:39evaluation we update inside this project
  13748. 9:26:41status and summary whatever summary we
  13749. 9:26:44are getting we'll also update here okay
  13750. 9:26:46and all of the data type I have also
  13751. 9:26:47mentioned you can see employee name
  13752. 9:26:49should be string data type monthly
  13753. 9:26:51salary should be integer working days uh
  13754. 9:26:53it should be also integer completed
  13755. 9:26:55project it should be integer that means
  13756. 9:26:57the number of project employee has
  13757. 9:26:59completed yearly salary this is also
  13758. 9:27:01integer bonus amount also integer
  13759. 9:27:03project status okay uh this status I
  13760. 9:27:06will let's say tell excellent average
  13761. 9:27:08okay so this should be a string and
  13762. 9:27:09summary also should be a string okay so
  13763. 9:27:11this is the data type now let's uh try
  13764. 9:27:13to um just write same uh uh state uh
  13765. 9:27:17inside our notebook I'm going to just
  13766. 9:27:19close this other file
  13767. 9:27:21so
  13768. 9:27:23this is the state guys okay you can see
  13769. 9:27:25the same state we have prepared here and
  13770. 9:27:27I just named it as employee state and I
  13771. 9:27:29inherited with type tic because I can
  13772. 9:27:32store my data as a key value pair okay I
  13773. 9:27:34think I have already disced test
  13774. 9:27:35previously. Okay, this thing. So, I'm
  13775. 9:27:37not going to repeat again. Now, uh my
  13776. 9:27:40state is done. Now, I'll just need to uh
  13777. 9:27:43create the graph. Now, let's try to
  13778. 9:27:45create the graph. So, we'll try uh
  13779. 9:27:48create the graph. You can see we are
  13780. 9:27:49using a state graph. And inside that we
  13781. 9:27:51are passing our state. Okay. Employee
  13782. 9:27:53state. Now, we have to add the nodes.
  13783. 9:27:55Okay. Now, how many nodes we are having?
  13784. 9:27:57Uh 1 2 3. Okay. And last, we have
  13785. 9:28:00another nodes called summary. And start
  13786. 9:28:02and end. You don't need to take it
  13787. 9:28:03because this is a default node inside
  13788. 9:28:05langraph. This is a dummy node. So first
  13789. 9:28:07of all let's try to create this um uh
  13790. 9:28:10this one this um calculate bonus or you
  13791. 9:28:16can create any of them because this is
  13792. 9:28:18completely independent right uh you are
  13793. 9:28:19not uh I mean uh you you don't need to
  13794. 9:28:22worry about the like order because this
  13795. 9:28:24is not a sequential one you can create
  13796. 9:28:26any of them any of them. Okay. So first
  13797. 9:28:28of all let's create uh this calculate
  13798. 9:28:30yearly salary. So here I'm going to add
  13799. 9:28:33a node.
  13800. 9:28:38So this is the node guys. Graph add
  13801. 9:28:40nodes. I named it as calculate early
  13802. 9:28:42salary and the same name I used for this
  13803. 9:28:44particular function. Okay. And this is
  13804. 9:28:47going to be a python function. We'll
  13805. 9:28:48just try to write the function. Okay.
  13806. 9:28:50Just give me some time. So like that
  13807. 9:28:52I'll also define for all of these nodes
  13808. 9:28:55one by one. Uh the next one I'm going to
  13809. 9:28:57create for
  13810. 9:28:59uh calculate bonus and project
  13811. 9:29:01evaluation.
  13812. 9:29:04Yeah. So calculate bonus this one and
  13813. 9:29:06the project evaluation. Project
  13814. 9:29:08evaluation. Okay. So all of the nodes I
  13815. 9:29:10have created only the last node I have
  13816. 9:29:12to create this summary.
  13817. 9:29:14Now let's also create the summary.
  13818. 9:29:18Summary. Okay. My node uh creation is
  13819. 9:29:22done. Now I'll write these are the
  13820. 9:29:23function one by one. So I'll come here.
  13821. 9:29:27So here I will comment
  13822. 9:29:29uh this is our node one and the function
  13823. 9:29:31name is calculate yearly salary. Okay.
  13824. 9:29:33Now let's define a function def uh
  13825. 9:29:36calculate yearly salary
  13826. 9:29:40and uh this will uh take this uh
  13827. 9:29:42employee state uh as an input because
  13828. 9:29:45every nodes takes this uh state. I think
  13829. 9:29:47you remember okay every node takes this
  13830. 9:29:49state. Okay. And also return a state
  13831. 9:29:52right. So we are we are giving this type
  13832. 9:29:54hint here. So let's try to write write
  13833. 9:29:57the logic here. Uh so first of all we'll
  13834. 9:29:59try to calculate the yearly salary. So
  13835. 9:30:01how to calculate the yearly salary? I
  13836. 9:30:03think you know that we have the monthly
  13837. 9:30:04salary. So what I can do uh I can just
  13838. 9:30:07multiply by 12. So this will give me the
  13839. 9:30:09yearly salary and multi salary I have
  13840. 9:30:12inside the state. You can see the
  13841. 9:30:13monthly salary I have inside the state.
  13842. 9:30:15So once it is done I'm going to update
  13843. 9:30:17the yearly salary where in my state
  13844. 9:30:19again. You can see we are updating this
  13845. 9:30:21yearly salary in this state. Then we are
  13846. 9:30:23returning the state. You know that every
  13847. 9:30:26nodes return the state. Okay, we are
  13848. 9:30:28returning the state. It's completely
  13849. 9:30:29fine, right? We have written the first
  13850. 9:30:31uh first nodes. Now like that we'll also
  13851. 9:30:34write the second nodes uh state nodes
  13852. 9:30:37doine. We have to execute this cell. Now
  13853. 9:30:40let's execute. Okay, now it's working
  13854. 9:30:42fine. Now the second node guys, we have
  13855. 9:30:44to write for the calculate bonus for
  13856. 9:30:48this one. Uh let's write this function
  13857. 9:30:56def calculate bonus. This will also take
  13858. 9:31:00um
  13859. 9:31:02this will also take uh employee uh state
  13860. 9:31:06that means the state and also return the
  13861. 9:31:08state. Okay. And here we'll try to
  13862. 9:31:10calculate the bonus. So you can see we
  13863. 9:31:13whatever um
  13864. 9:31:16so what I can do I can calculate the
  13865. 9:31:19bonus based on the monthly salary
  13866. 9:31:23monthly salary so I'll just try to
  13867. 9:31:25multiply by two okay see here I'm not
  13868. 9:31:29calculating the exact bonus yet just try
  13869. 9:31:31to think about just I'm adding some
  13870. 9:31:33bonus uh based on the monthly slid of
  13871. 9:31:35that particular employee okay and after
  13872. 9:31:37that we are adding this bonus amount uh
  13873. 9:31:39inside the state then we are returning
  13874. 9:31:41this state. Okay, it's done. Now we'll
  13875. 9:31:44try to create the next one which is uh
  13876. 9:31:46project evaluation
  13877. 9:31:51node three project evaluation def
  13878. 9:31:54project evaluation this will also take
  13879. 9:31:56the state as an input and return the
  13880. 9:31:57state as an output. So here I can just
  13881. 9:32:00write a logic. So let's say this is the
  13882. 9:32:02logic. I can write simple logic. If uh
  13883. 9:32:06let's say the completed project amount
  13884. 9:32:08is more than five. So that time I can
  13885. 9:32:11just give the status excellent otherwise
  13886. 9:32:14I'll just try to tell it's average one.
  13887. 9:32:16Okay. Now I'll update this project
  13888. 9:32:19status. Then I will return the status.
  13889. 9:32:21Okay. So yeah this is our notes we have
  13890. 9:32:23uh prepared. Now uh once it is done the
  13891. 9:32:27at the last I will add this summary
  13892. 9:32:28notes as well. Now let's add the summary
  13893. 9:32:30note. So inside summary I'm just going
  13894. 9:32:33to return all of the summary. That's it.
  13895. 9:32:38So ref summary.
  13896. 9:32:43So here I will just initialize the
  13897. 9:32:46summary. Let's say this is the entire
  13898. 9:32:48summary text. I've taken the f string
  13899. 9:32:50and I'm just joining the string all
  13900. 9:32:52together. employee employee name then
  13901. 9:32:55has a yearly salary of yearly salary a
  13902. 9:33:00bonus of bonus amount project status is
  13903. 9:33:03the project status okay that mean this
  13904. 9:33:05is a complete string I'm just writing
  13905. 9:33:06and updating and returning it okay
  13906. 9:33:09that's it now let me execute yeah my all
  13907. 9:33:11of the nodes are prepared now what I
  13908. 9:33:14have to do guys uh we have already
  13909. 9:33:15created all of the nodes that means
  13910. 9:33:17nodes is created now we have to add the
  13911. 9:33:20edges okay this is called edges now we
  13912. 9:33:21have to do the edge connecting
  13913. 9:33:22connection. Now let's try to do the edge
  13914. 9:33:24connection.
  13915. 9:33:25So for this I think you know that we use
  13916. 9:33:28this
  13917. 9:33:30add edge uh uh addage function inside
  13918. 9:33:33lang graph. So here I can comment h. So
  13919. 9:33:36first of all try to see how we are going
  13920. 9:33:38to connect the edges. You can see from
  13921. 9:33:41start it is connecting to calculate
  13922. 9:33:44bonus. It is connecting to calculate
  13923. 9:33:47yearly salary. It is connected to
  13924. 9:33:49project evaluation. Okay, that means
  13925. 9:33:52simultaneously you can see it is having
  13926. 9:33:54three connection. Okay, with calculate
  13927. 9:33:56bonus, uh calculate yearly salary and
  13928. 9:33:58project evaluation. So what I'm going to
  13929. 9:34:00do, I'm going to do the same thing.
  13930. 9:34:01First of all, I'm going to add this
  13931. 9:34:04start with calculate yearly salary. Then
  13932. 9:34:07I'm going to add with my calculate
  13933. 9:34:10bonus. Then I'm going to add with
  13934. 9:34:13project evaluation.
  13935. 9:34:15Okay, I'm going to add with project
  13936. 9:34:17evaluation. Now just try to um relate
  13937. 9:34:20you can see start is connected with
  13938. 9:34:22yearly salary calculate bonus and
  13939. 9:34:23project evaluation. Okay. So these are
  13940. 9:34:25the connection I have already made. You
  13941. 9:34:27can see these are the connection I have
  13942. 9:34:28already made. Now this connection is
  13943. 9:34:31complete. Now I have to build this
  13944. 9:34:32connection. Okay. That means now um
  13945. 9:34:36calculate bonus is connected to the
  13946. 9:34:37summary. Yearly salary also connected to
  13947. 9:34:40the summary. Project evaluation is also
  13948. 9:34:42connected to the summary. Okay. That
  13949. 9:34:43means I have to build this connection.
  13950. 9:34:44Now let's do that. So here what I'm
  13951. 9:34:46going to do
  13952. 9:34:48I'm going to write uh calculate yearly
  13953. 9:34:51salary it is connected to summary
  13954. 9:34:53calculate yearly salary it is connected
  13955. 9:34:55to summary okay then calculate bonus it
  13956. 9:34:59is also connected to the summary and uh
  13957. 9:35:02project evaluation this is also
  13958. 9:35:04connected to the summary okay project
  13959. 9:35:06evaluation this is also connected to the
  13960. 9:35:08summary and summary is connected to the
  13961. 9:35:10end now let's add another edge
  13962. 9:35:14H summary is connected to the end. Now
  13963. 9:35:17just try to relate. Okay, just trust me
  13964. 9:35:20if you can understand this one just the
  13965. 9:35:23age connection at the node creation you
  13966. 9:35:25can build any kinds of workflow inside
  13967. 9:35:27langraph. Okay, any kinds of workflow
  13968. 9:35:29you can create. So I hope guys you got
  13969. 9:35:31it. Okay, I hope guys you got it how we
  13970. 9:35:33have made this connection. Okay, and
  13971. 9:35:36this is a independent connection. This
  13972. 9:35:38is a independent connection. Nobody uh I
  13973. 9:35:41mean none of the nodes is dependent on
  13974. 9:35:44another nodes. Okay. So that's why we
  13975. 9:35:46call it as a parallel workflow. Now let
  13976. 9:35:48me show you for this. First of all we
  13977. 9:35:50have to compile the workflow. Let's
  13978. 9:35:52compile. Okay. Now I'll compile the
  13979. 9:35:55workflow. Now you can just see the
  13980. 9:35:57workflow graph. See if you're using uh
  13981. 9:36:00this Jupyter notebook you don't need to
  13982. 9:36:02write uh this extra code for that.
  13983. 9:36:05uh I think in the recent update u they
  13984. 9:36:07have uh automatically done this one in
  13985. 9:36:10the cell itself. So previously I used
  13986. 9:36:12this code to draw this graph but right
  13987. 9:36:15now you don't need to do that. If you
  13988. 9:36:17just print this workflow you'll
  13989. 9:36:18automatically see this particular uh
  13990. 9:36:20graph. Okay. Now see guys this is the
  13991. 9:36:23graph and this is our parallel um
  13992. 9:36:27parallel workflow we have created. Now
  13993. 9:36:29just try to relate this graph. Okay. Now
  13994. 9:36:31you can see start and it is connected
  13995. 9:36:33with all of the nodes independently
  13996. 9:36:35connected. Then whatever um result we
  13997. 9:36:39are getting we are just returning the
  13998. 9:36:40summary and we're ending the graph.
  13999. 9:36:42Okay. So this is the parallel workflow.
  14000. 9:36:44Now let's try to execute. So what I'm
  14001. 9:36:46going to do I'm going to uh initialize
  14002. 9:36:50my initial state and what should be the
  14003. 9:36:52initial state. These are the uh state
  14004. 9:36:54should be the initial one because we'll
  14005. 9:36:56be taking these are the data from the
  14006. 9:36:57user. So let's define that.
  14007. 9:37:01So this is our initial state. You can
  14008. 9:37:03see I'm taking the employee name. Um
  14009. 9:37:05then monthly salary. So I'm going to
  14010. 9:37:07take my name. Let's say I'm the
  14011. 9:37:09employee. This is the monthly salary.
  14012. 9:37:11This is the working days. And this is
  14013. 9:37:12the completed project. Okay. Now we'll
  14014. 9:37:14just try to run this workflow.
  14015. 9:37:17Run the workflow. So we're just running
  14016. 9:37:20this workflow dot invok. We are giving
  14017. 9:37:22the initial state and we're getting the
  14018. 9:37:24result. Now execute. Okay. Now see guys
  14019. 9:37:28here we are getting one output. The
  14020. 9:37:30output is add key employee name can
  14021. 9:37:32receive only one value per step. Use an
  14022. 9:37:35annotated key to handle multiple uh
  14023. 9:37:38value. Now you can ask me why we are
  14024. 9:37:41getting the error. Okay, why we are
  14025. 9:37:43getting this error? Because everything
  14026. 9:37:45is fine so far, right? Everything is
  14027. 9:37:47fine so far. But why we're getting the
  14028. 9:37:49error? See the reason I showed you this
  14029. 9:37:52error? Actually, I could have fixed it
  14030. 9:37:54previously, but I showed you this error
  14031. 9:37:56so that you can relate the difference
  14032. 9:37:57between the sequential workflow and uh
  14033. 9:38:01this um this uh parallel workflow. Okay,
  14034. 9:38:05if you can understand this, I think you
  14035. 9:38:07won't be having any kinds of problem.
  14036. 9:38:09See what is happening. If I show you my
  14037. 9:38:12workflow again, so this is my workflow.
  14038. 9:38:15See here we created the state, right? We
  14039. 9:38:18created this state and we are passing
  14040. 9:38:20the state to the all of these nodes. But
  14041. 9:38:22if you just observe uh if you just
  14042. 9:38:24deeply observe what is happening
  14043. 9:38:26whenever we are passing this uh state uh
  14044. 9:38:29to all of the nodes what is happening to
  14045. 9:38:31calculate the bonus what I'm using okay
  14046. 9:38:34to calculate the bonus what I'm using
  14047. 9:38:36I'm using this uh initial state that
  14048. 9:38:39means whatever data user is passing I'm
  14049. 9:38:40I'm using that so to calculate this I
  14050. 9:38:43think I was using this um monthly salary
  14051. 9:38:46only right I was using the monthly
  14052. 9:38:47salary and I was updating this value
  14053. 9:38:52wire
  14054. 9:38:53in this particular section
  14055. 9:38:56that means this boner bonus amount
  14056. 9:38:58variable would be changed okay after
  14057. 9:39:01running this state this particular
  14058. 9:39:03variable would be changed I'm not
  14059. 9:39:04changing these are the variable right
  14060. 9:39:06that means the monthly salary is remain
  14061. 9:39:08same I'm not changing it anywhere that
  14062. 9:39:10means the employee name I'm also not
  14063. 9:39:11changing working days also I'm not
  14064. 9:39:13changing completed project also I'm not
  14065. 9:39:16changing right I'm only changing these
  14066. 9:39:18are the variable here but these are the
  14067. 9:39:20variable remains same common right so
  14068. 9:39:23wherever you are passing the state
  14069. 9:39:25everywhere it is updating here only not
  14070. 9:39:27here okay so that's why in parallel
  14071. 9:39:30workflow whenever you are giving this
  14072. 9:39:32simultaneously to all of the nodes okay
  14073. 9:39:35so this nodes uh actually
  14074. 9:39:39conflicts each other conflicts each
  14075. 9:39:40other means there is no update so it
  14076. 9:39:43conflicts like uh whether the value we
  14077. 9:39:45are getting here this is correct for
  14078. 9:39:46this nodes or not whether the value we
  14079. 9:39:49are getting here this is correct correct
  14080. 9:39:50for these nodes or not. Okay, that means
  14081. 9:39:52it conflicts inside because we are
  14082. 9:39:55returning the entire state. Here you can
  14083. 9:39:56see we are returning the entire state.
  14084. 9:39:58Although we are not updating this at the
  14085. 9:40:00state but still we are returning the
  14086. 9:40:02entire state that means the entire state
  14087. 9:40:04will go to the another node. Okay, that
  14088. 9:40:06means the entire state will go to the
  14089. 9:40:08another node. Although we are not doing
  14090. 9:40:10any kinds of update but we are returning
  14091. 9:40:11the state. Okay, it's not recommended.
  14092. 9:40:13So whenever you are creating the
  14093. 9:40:14parallel workflow you have to make sure
  14094. 9:40:18only the update you are doing inside the
  14095. 9:40:20variable that particular variable or
  14096. 9:40:22that particular state you have to return
  14097. 9:40:23only okay let's say in this case let me
  14098. 9:40:26just give you an example let's say in
  14099. 9:40:28this case we are only calculating what
  14100. 9:40:31we are only calculating the yearly
  14101. 9:40:32salary so instead of returning all the
  14102. 9:40:34state together what I'm going to do only
  14103. 9:40:36I'm going to return the yearly salary
  14104. 9:40:38okay because this is a parallel one I
  14105. 9:40:41don't need to like wait for my employee
  14106. 9:40:44name monthly salary these are the things
  14107. 9:40:45right whatever update I'm just doing
  14108. 9:40:47I'll just only try to return that so
  14109. 9:40:49instead of uh this uh update what I'm
  14110. 9:40:52going to do guys I'm going to only
  14111. 9:40:54return
  14112. 9:40:57I'm going to only return
  14113. 9:41:01uh yearly salary
  14114. 9:41:05see I'm going to only return the yearly
  14115. 9:41:07salary we have calculated we are only
  14116. 9:41:08returning that because at the end uh
  14117. 9:41:11this is this is a dictionary. Okay, this
  14118. 9:41:13this nodes returns a dictionary. Okay,
  14119. 9:41:14we have to return a dictionary somehow.
  14120. 9:41:16Now I don't need to give this time type
  14121. 9:41:18time type time type time type time type
  14122. 9:41:18time type time type time type time type
  14123. 9:41:18time type time type int. Okay, this is
  14124. 9:41:19not required because we are not
  14125. 9:41:20returning the entire employee state.
  14126. 9:41:22Okay, now I'm going to just remove it.
  14127. 9:41:24So only it will take the state and
  14128. 9:41:26whatever update it will do inside the
  14129. 9:41:28state and that state will only return
  14130. 9:41:30not any other state. Okay, not any other
  14131. 9:41:33state only the updated one it will
  14132. 9:41:34return. So for this I'll uh update for
  14133. 9:41:36all the nodes I have done. So let's say
  14134. 9:41:39here
  14135. 9:41:40uh I was
  14136. 9:41:43uh updating the bonus amount. So I'll
  14137. 9:41:45only return the bonus amount and this
  14138. 9:41:47thing is not required.
  14139. 9:41:52Okay. Now for this project evaluation
  14140. 9:41:55also I'll do the same thing.
  14141. 9:42:00Return the project status. This thing is
  14142. 9:42:02not required.
  14143. 9:42:04Now for summary also
  14144. 9:42:07we'll do the same thing.
  14145. 9:42:16This is not required. Okay. So let me
  14146. 9:42:19check everything is fine or not. Yeah,
  14147. 9:42:21everything is fine. Now let me execute
  14148. 9:42:22from the beginning.
  14149. 9:42:26Now our workflow is created.
  14150. 9:42:29Now we'll
  14151. 9:42:31uh now we'll just try to invoke this
  14152. 9:42:33workflow. Now see it's working. Now if I
  14153. 9:42:35print the result
  14154. 9:42:38see we are getting the final result. So
  14155. 9:42:40this is the employee name, monthly
  14156. 9:42:41salary, working days, completed project,
  14157. 9:42:44yearly salary. So see we got the
  14158. 9:42:46calculated yearly salary. Then bonus
  14159. 9:42:49amount project status excellent because
  14160. 9:42:52the completed project is seven and our
  14161. 9:42:55logic was if it is more than five right
  14162. 9:42:57more than an equal five that means it is
  14163. 9:42:59excellent you are getting the excellent
  14164. 9:43:01here and here's the summary but summary
  14165. 9:43:04is giving a function so let me check
  14166. 9:43:10okay so this should be summary text I'm
  14167. 9:43:13just returning the function only right
  14168. 9:43:15the nodes only so this should be a um
  14169. 9:43:18this this variable. Now I think this
  14170. 9:43:20should work.
  14171. 9:43:26H now we are getting the summary.
  14172. 9:43:28Employee BP has yearly salary of that
  14173. 9:43:31amount. Bonus uh bonus is that amount
  14174. 9:43:33and project status is excellent. Okay.
  14175. 9:43:36So this is our uh uh parallel workflow
  14176. 9:43:39guys we have created and I hope you
  14177. 9:43:41understood. Okay. Okay, I hope you
  14178. 9:43:43understood and uh this particular
  14179. 9:43:45concept also you understood why we don't
  14180. 9:43:47need to return the entire state inside
  14181. 9:43:50parallel workflow. If you're creating
  14182. 9:43:52the sequential workflow, it's completely
  14183. 9:43:54fine. You can return the entire state
  14184. 9:43:56that time. Okay, you can return the
  14185. 9:43:57entire state that time. But whenever you
  14186. 9:44:00are creating the parallel workflow, make
  14187. 9:44:01sure only the state you are changing,
  14188. 9:44:05just try to uh return those state only.
  14189. 9:44:08Okay, not the entire state. Okay, you
  14190. 9:44:10don't need to do like that because uh
  14191. 9:44:13internally it will do the conflict
  14192. 9:44:14operation because we can't pass
  14193. 9:44:16simultaneously to all of the nodes the
  14194. 9:44:19same state. Okay, this is not possible.
  14195. 9:44:21So in every state that should be that
  14196. 9:44:23should uh should be updated. Okay, state
  14197. 9:44:26should be updated. But here you can see
  14198. 9:44:28it is not getting updated. Okay, after
  14199. 9:44:30going to the every state, every nodes it
  14200. 9:44:33is not going to be updated. Okay, that's
  14201. 9:44:34why this is going to be conflicted. So
  14202. 9:44:37we have to update it somehow. So that's
  14203. 9:44:39why we only are returning these are the
  14204. 9:44:41state which is getting updated. Get it?
  14205. 9:44:43Yeah. So this is the concept guys and
  14206. 9:44:45this is our first non nonLM based
  14207. 9:44:48workflow we have created and this is the
  14208. 9:44:49parallel workflow. It is executing as
  14209. 9:44:52parallel. Okay. Now we'll try to create
  14210. 9:44:55another workflow. Uh we'll use the LLM
  14211. 9:44:58and we'll call as a LM parallel
  14212. 9:45:00workflow. Now let's try to see how we
  14213. 9:45:02can uh create this LLM based parallel
  14214. 9:45:05workflow guys. So guys, so far we have
  14215. 9:45:08created uh this nonLM based parallel
  14216. 9:45:11workflow. Uh we have already seen the
  14217. 9:45:13example how it can be done. Now I'm
  14218. 9:45:16going to show you how we can create LLM
  14219. 9:45:18based parallel workflow. Now we'll try
  14220. 9:45:20to integrate LLM with that. And for this
  14221. 9:45:23example uh I'm going to take uh this
  14222. 9:45:26particular demo called SA workflow. So I
  14223. 9:45:28think you remember uh in my introductory
  14224. 9:45:31session whenever I was giving you the
  14225. 9:45:33introduction about the langraph I used
  14226. 9:45:36one example called essay okay essay
  14227. 9:45:38writing example so there there I created
  14228. 9:45:40a system I created a workflow that
  14229. 9:45:42workflow takes an essay as an input and
  14230. 9:45:45it does uh the evaluation based on some
  14231. 9:45:47parameter like uh it checks the um it uh
  14232. 9:45:52depth analysis then language uh
  14233. 9:45:55evaluation then uh um like research of
  14234. 9:45:58thought evaluation. Okay, based on that
  14235. 9:46:01uh it returns you uh some kinds of
  14236. 9:46:03feedback as well as the score and we get
  14237. 9:46:06the final evaluation then we conclude
  14238. 9:46:08that right. So these kinds of things I
  14239. 9:46:10think I uh already discussed about my uh
  14240. 9:46:13this session. Okay. Uh this is the
  14241. 9:46:15number seven video I have already
  14242. 9:46:16discussed. You can go through that uh if
  14243. 9:46:18you want to understand about that
  14244. 9:46:20particular workflow. But again I'm going
  14245. 9:46:22to um show you the workflow here. I
  14246. 9:46:24already created the workflow. I'm going
  14247. 9:46:25to discuss it here. And uh you can also
  14248. 9:46:27see what is essay. Essay is a like uh
  14249. 9:46:30it's a short non-frictional
  14250. 9:46:32piece of writing that presents a
  14251. 9:46:34specific argument analysis or personal
  14252. 9:46:36point of view on a particular subject.
  14253. 9:46:38Okay. So basically whenever you um
  14254. 9:46:41attend any kinds of uh let's say uh
  14255. 9:46:44exams or you if you are studying in a
  14256. 9:46:47university any kinds of university that
  14257. 9:46:48uh so these are the essay writing you
  14258. 9:46:50will be getting there. Okay. So this is
  14259. 9:46:52a kinds of research topic you can talk
  14260. 9:46:54about. So what I'm going to do I'm going
  14261. 9:46:56to take this same example uh here to
  14262. 9:47:00make you understand this LM based
  14263. 9:47:01workflow because here we'll be utilizing
  14264. 9:47:03the LLM to analyze is the essay right
  14265. 9:47:05and we'll also do the marking and all.
  14266. 9:47:07So this is the workflow. This is the
  14267. 9:47:09graph guys. Uh we we I have created as
  14268. 9:47:11you can see start and end nodes would be
  14269. 9:47:14common and these are the nodes we'll be
  14270. 9:47:15creating. Uh evaluate analysis nodes.
  14271. 9:47:18That means uh whatever essay topic will
  14272. 9:47:20be giving right. Uh essay will be giving
  14273. 9:47:22it will try to evaluate the analysis
  14274. 9:47:24whether the analysis section is good or
  14275. 9:47:26not. It will evaluate and it will give
  14276. 9:47:27you two things. Okay. This is this will
  14277. 9:47:29give you two things. Uh just let me
  14278. 9:47:32write down
  14279. 9:47:33what I can do. I can take a screenshot.
  14280. 9:47:40I can take a screenshot and I'll open up
  14281. 9:47:42my board.
  14282. 9:47:46So now let me tell you
  14283. 9:47:52so let's say you are giving a essay
  14284. 9:47:54here. You are giving a
  14285. 9:47:58essay here. Okay. That that means the
  14286. 9:48:01entire essay essay text you are giving.
  14287. 9:48:03So basically first of all we'll be
  14288. 9:48:04running this uh evaluate analysis. So
  14289. 9:48:07this evaluate analysis will try to
  14290. 9:48:08analyze the entire essay. It will this
  14291. 9:48:10it will give you two things. The first
  14292. 9:48:12one is the uh feedback.
  14293. 9:48:16Okay
  14294. 9:48:17feedback feedback of the essay and
  14295. 9:48:21second one is the score.
  14296. 9:48:23This will give you a score. Uh let's out
  14297. 9:48:26of 10 it will give you some kinds of
  14298. 9:48:27score. Then next nodes we have writing
  14299. 9:48:30for the evaluate language. Let's say you
  14300. 9:48:32are using English language, right? So,
  14301. 9:48:35how is your grammatical uh let's say uh
  14302. 9:48:38I mean uh grammatical arrangement or if
  14303. 9:48:41you are following the right grammaticals
  14304. 9:48:44structure or not and uh what is the
  14305. 9:48:46words you are using. So this kinds of
  14306. 9:48:48language related evaluation will perform
  14307. 9:48:50then again this will give you a
  14308. 9:48:51feedback.
  14309. 9:48:54Okay. And this will also give you a
  14310. 9:48:55score out of 10 right then we'll just
  14311. 9:48:58perform another analysis. This is the
  14312. 9:49:00like uh uh thought analysis. Thought
  14313. 9:49:03analysis means the thought thought of on
  14314. 9:49:06top of this essay. Okay. Uh so here this
  14315. 9:49:08will also give you a feedback
  14316. 9:49:12and the score.
  14317. 9:49:15Okay. That means every nodes we are
  14318. 9:49:17getting two two things feedback score.
  14319. 9:49:20Feedback is score feedback is score.
  14320. 9:49:21Okay. Then we'll pass this feedback
  14321. 9:49:24score uh uh feedback and score all of
  14322. 9:49:26the feedback and score from all of the
  14323. 9:49:28nodes. Let's say this is node one, this
  14324. 9:49:29is node two, this is node three to
  14325. 9:49:31another nodes called final evaluator. So
  14326. 9:49:33that means this will evaluate based on
  14327. 9:49:35all of the feedback. Let's say this is
  14328. 9:49:37feedback one, this is feedback two, this
  14329. 9:49:38is feedback three. So it will take all
  14330. 9:49:40of the feedback then it will give you
  14331. 9:49:41the final feedback.
  14332. 9:49:43Final feedback,
  14333. 9:49:47okay, or evaluation. Then it will take
  14334. 9:49:50all of this code, okay? All of this
  14335. 9:49:52code. And this will return you the
  14336. 9:49:54average score of that. Okay, average
  14337. 9:49:57final score of that. Okay, so this is
  14338. 9:50:00how actually we'll be uh implementing
  14339. 9:50:02this particular essay. Then once it is
  14340. 9:50:03done, we'll try to end this particular
  14341. 9:50:06uh end this particular but um graph.
  14342. 9:50:09Okay, now if I get back to my workflow,
  14343. 9:50:12I think now you are getting right and to
  14344. 9:50:14make this workflow I need these state.
  14345. 9:50:16Okay, I already prepared the state as
  14346. 9:50:18you can see. I need this state. I named
  14347. 9:50:20it as assay state and I inherited with
  14348. 9:50:22type dict and first of all I need to
  14349. 9:50:24take the essay and essay should be
  14350. 9:50:25string right this is a variable then
  14351. 9:50:28language feedback that means uh here so
  14352. 9:50:30evaluate uh language this will basically
  14353. 9:50:32do the language uh language evaluation
  14354. 9:50:35and whatever feedback we'll be getting
  14355. 9:50:36we'll try to save inside language
  14356. 9:50:38feedback then it will also give you uh
  14357. 9:50:40this will also give you um another score
  14358. 9:50:44right uh that means the uh language
  14359. 9:50:46score so instead of storing inside a
  14360. 9:50:48single var variable. So what I'm doing?
  14361. 9:50:50So here you can see I have taken another
  14362. 9:50:52variable called individual score. Okay.
  14363. 9:50:55And here I use this annotated list
  14364. 9:50:58integer operator add. So I think you can
  14365. 9:51:01call this uh call this concept right. So
  14366. 9:51:03this is called actually reducer. I
  14367. 9:51:05already talked about the reducer here uh
  14368. 9:51:07in my um demo whenever I was explaining
  14369. 9:51:10about the langraph core component there
  14370. 9:51:12I talked about the reducer. So if you
  14371. 9:51:14haven't watched that video guys please
  14372. 9:51:15try to watch because this is important
  14373. 9:51:17without that actually you won't be able
  14374. 9:51:18to understand what is reducer exactly.
  14375. 9:51:20So reducer uh will help us to uh replace
  14376. 9:51:24add and merge the uh like data inside
  14377. 9:51:28the state. So uh by default it will
  14378. 9:51:30replace everything. I think so far
  14379. 9:51:32whatever state we have created it was
  14380. 9:51:34replacing every time right but as you
  14381. 9:51:36can see from each and every nodes from
  14382. 9:51:39each and every nodes we are getting some
  14383. 9:51:41score. Okay, let's say if I'm only
  14384. 9:51:43taking one let's say score variable. So
  14385. 9:51:46what will happen? So whenever I'll get
  14386. 9:51:48this score from here, let's say I got 12
  14387. 9:51:50uh sorry I got let's say 8. Then from
  14388. 9:51:54this particular nodes I'm I get another
  14389. 9:51:56score from this particular node I get
  14390. 9:51:58another score. Let's say this is 8.5. So
  14391. 9:52:00what I will do this 8.5 8 would be
  14392. 9:52:02replaced by 8.5. So that means I will
  14393. 9:52:04lose my previous score of that evaluate
  14394. 9:52:06analysis. Right? Then let's say this
  14395. 9:52:08this node has generated another one.
  14396. 9:52:10Okay, let's say 9.5. So again, it will
  14397. 9:52:13replace by 9.5. So I lose my previous
  14398. 9:52:15like uh score, right? But I need all of
  14399. 9:52:17this code to make the average. So I need
  14400. 9:52:20this score as well. I need this score as
  14401. 9:52:23well. I need this score as well. That
  14402. 9:52:24means I need to keep inside a
  14403. 9:52:27dictionary. Let's say the first score
  14404. 9:52:29I'm getting eight. Second score I'm
  14405. 9:52:31getting 8.5. The third score I'm getting
  14406. 9:52:339.5. I'll store all of the score from
  14407. 9:52:36all of the nodes. Okay, inside a list.
  14408. 9:52:39Then I'm going to create a average of
  14409. 9:52:40that particular score. And this is going
  14410. 9:52:42to be my final evaluation. Okay. And for
  14411. 9:52:45this we are using this operator do add
  14412. 9:52:47here. Okay. You can see we are using
  14413. 9:52:49operator do add here. And we are using
  14414. 9:52:51annotated. Okay. I think you know what
  14415. 9:52:53is annotated. Whenever I want to use
  14416. 9:52:55reducer, right? I have to use this
  14417. 9:52:57annotated. And here we are mentioning
  14418. 9:52:59that should be a list of integer. Okay.
  14419. 9:53:01There should be a list of integer. That
  14420. 9:53:03means I want to uh I want to uh let's
  14421. 9:53:06say store uh store list of integer here.
  14422. 9:53:09So here I have taken a float value but
  14423. 9:53:10you can consider I want to uh you can
  14424. 9:53:13also like give it as float value here.
  14425. 9:53:15Let's say sometimes uh score should be
  14426. 9:53:17also um float value 8.5 7.5 but I told I
  14427. 9:53:21need only integer type uh like feedback
  14428. 9:53:24okay integer type score. So that's why
  14429. 9:53:26given list of integer and operator dot
  14430. 9:53:29add that means I want to perform reducer
  14431. 9:53:31reducer what operation add operation
  14432. 9:53:34that means instead of replacing it will
  14433. 9:53:35every time add all of the score so
  14434. 9:53:37whatever score I'm going going to get
  14435. 9:53:39from my evaluator analysis I'll store it
  14436. 9:53:41here okay apart apart from the feedback
  14437. 9:53:43then from evaluator language also I'm
  14438. 9:53:46going to add the score from uh evaluate
  14439. 9:53:48thoughts whatever feedback score I'm
  14440. 9:53:50getting I will also try to add there
  14441. 9:53:51okay so that's how you can see for all
  14442. 9:53:54of the nodes I have indiv individual
  14443. 9:53:56variable. So you can see language
  14444. 9:53:58feedback I have one variable then
  14445. 9:54:00evaluate of thought that means uh uh
  14446. 9:54:04this one
  14447. 9:54:06clarity feedback okay uh this is uh
  14448. 9:54:08clarity of thought you can consider and
  14449. 9:54:10the full name is clarity of thought we
  14450. 9:54:12have taken a variable called clarity
  14451. 9:54:14feedback so basically this feedback will
  14452. 9:54:16store here then we have evaluator
  14453. 9:54:19analysis that means the analysis
  14454. 9:54:20feedback it will store here okay that
  14455. 9:54:22means language analysis then evaluate
  14456. 9:54:26thoughts. Okay, clarity of thoughts.
  14457. 9:54:28Then the overall feedback. That means
  14458. 9:54:30from final evolution also we are getting
  14459. 9:54:31a feedback. From final evaluation also
  14460. 9:54:34we are getting a feedback. So this
  14461. 9:54:35feedback will store inside overall
  14462. 9:54:37feedback. Okay. And final evalution will
  14463. 9:54:41give you another uh score which is
  14464. 9:54:43average score. And for average score we
  14465. 9:54:45have kept another separate variable
  14466. 9:54:47called average score. And this should be
  14467. 9:54:48a float value. Okay. And for individual
  14468. 9:54:52uh score we are getting we are storing
  14469. 9:54:54inside this particular list. Okay,
  14470. 9:54:56individual score this should be a list
  14471. 9:54:58and we are performing the reducer add
  14472. 9:55:00operation. Okay, now I think you got it
  14473. 9:55:02how we created this particular state.
  14474. 9:55:05Okay, how we created this particular
  14475. 9:55:06state. Now I think this is pretty much
  14476. 9:55:08clear guys
  14477. 9:55:10and to understand this reducer concept I
  14478. 9:55:12will suggest you go through this uh
  14479. 9:55:14recording. Okay, lang core component you
  14480. 9:55:15will try to understand okay how reducer
  14481. 9:55:17works. So yeah, I think our uh uh our uh
  14482. 9:55:21state is ready. Everything is ready. Now
  14483. 9:55:23we can start working on that. But one
  14484. 9:55:25more issue we'll be having which is this
  14485. 9:55:27u uh output format. Okay, that means I
  14486. 9:55:31need a structure output from my LLM.
  14487. 9:55:33That means every nodes will return
  14488. 9:55:35feedback and score feedback and score
  14489. 9:55:37feedback and score. And we are using LLM
  14490. 9:55:38and you know LLM is unstructured uh uh
  14491. 9:55:41data generator. Okay, we won't be
  14492. 9:55:43getting this kinds of feedback score
  14493. 9:55:45every time. Let's say if you're adding
  14494. 9:55:47by the prompt I need a feedback and
  14495. 9:55:49score only let's say it will run five
  14496. 9:55:51times maybe in six times it will give
  14497. 9:55:53you some other parameter as well that
  14498. 9:55:55time your code will crash right so to
  14499. 9:55:57make our output stack chart so I taught
  14500. 9:56:00you about uh I already taught you about
  14501. 9:56:02this pyantic right so you can see
  14502. 9:56:04pyantic for AI agents I've already taken
  14503. 9:56:07a class on that so you just need to go
  14504. 9:56:09through this pantic because we'll be
  14505. 9:56:11using pentipic concept to get the
  14506. 9:56:13structured output from my lm Okay. Now
  14507. 9:56:16let's try to show you how it can be
  14508. 9:56:17done. So what I'm going to do here I'm
  14509. 9:56:19going to create another um another file.
  14510. 9:56:23So I'm going to name it as
  14511. 9:56:26pipe
  14512. 9:56:30as a workflow.
  14513. 9:56:39I'm going to select my environment.
  14514. 9:56:43So first of all I will import all of the
  14515. 9:56:45necessary library.
  14516. 9:56:47So I need this state graph start end
  14517. 9:56:50okay from lang graph. Then I also need
  14518. 9:56:55openi model because here I'm going to
  14519. 9:56:58use llm and for lm I'm going to use
  14520. 9:57:00openi model. You can use any model. Okay
  14521. 9:57:02it's up to you. You can use gemini gro
  14522. 9:57:05provider any kinds of model you can use.
  14523. 9:57:07But I already have the open API key
  14524. 9:57:09yesterday. I already collect uh
  14525. 9:57:10collected. I think remember okay that's
  14526. 9:57:12why I'm using that then uh okay I'm
  14527. 9:57:15going to close this
  14528. 9:57:17then I need this uh load env to load my
  14529. 9:57:21involvement variable because inside
  14530. 9:57:23environment variable I I have my API key
  14531. 9:57:25then I need um
  14532. 9:57:28these are the
  14533. 9:57:32these are the import as well from typing
  14534. 9:57:34I'm importing this type dict and
  14535. 9:57:35annotated why annotated because you know
  14536. 9:57:37that uh to make this reducer Okay, I
  14537. 9:57:41need this annotated. Okay, annotated is
  14538. 9:57:43required. Uh and it is available inside
  14539. 9:57:45this typing. We are importing annotated
  14540. 9:57:47and we are using pientic. So from
  14541. 9:57:49pientic we are importing base model
  14542. 9:57:53and field and you have to install
  14543. 9:57:56pientic for this. Uh let me install
  14544. 9:57:58pientic.
  14545. 9:58:04Pentic
  14546. 9:58:06I'll install this specific version of
  14547. 9:58:08the piantic. Now let me
  14548. 9:58:12uh activate my environment.
  14549. 9:58:20Then let's install the requirements
  14550. 9:58:22again.
  14551. 9:58:32Okay. Done. Now I'll come here. Now you
  14552. 9:58:35can use this pi identic. So from identic
  14553. 9:58:37I'm importing base model and field and
  14554. 9:58:39what this base model field does guys I
  14555. 9:58:41already discussed in this session please
  14556. 9:58:42go through that okay I'm not going to
  14557. 9:58:44repeat again so this session will give
  14558. 9:58:45you the entire entire idea about pi
  14559. 9:58:47identity okay why it is required and
  14560. 9:58:50operator for this add operation that
  14561. 9:58:53means for the reducer okay uh operation
  14562. 9:58:56dot add operator do add we have to write
  14563. 9:58:58it here so once it is done now let me
  14564. 9:59:00import all of the package yeah so it's
  14565. 9:59:04working fine now first of all we'll try
  14566. 9:59:06to load put the involvement variable.
  14567. 9:59:10Yeah. Then we'll prepare the model.
  14568. 9:59:14So here I'll take GPT4 mini. Okay. This
  14569. 9:59:17model. This is our LM. Now you can
  14570. 9:59:21perform the invoke operation if you want
  14571. 9:59:24directly. But if you perform the invoke
  14572. 9:59:26operation right now, so what will
  14573. 9:59:27happen? Uh this will uh give you
  14574. 9:59:29unstructured output. But I need what? I
  14575. 9:59:32need only this uh feedback and score.
  14576. 9:59:34Okay. Okay, I need feedback score uh
  14577. 9:59:36from this uh model. Okay, whatever essay
  14578. 9:59:39I'll give you um I'll I'll give to this
  14579. 9:59:42uh model, it will give me feedback and
  14580. 9:59:44score. So I have to make the structure.
  14581. 9:59:46So how to make the structure? For this
  14582. 9:59:48we'll be using the pyic. So here I have
  14583. 9:59:51created one pentic class.
  14584. 9:59:54So this is the pentic class. So the name
  14585. 9:59:58of the pyic class is evaluation schema.
  14586. 10:00:01Uh and we are inheriting with the base
  14587. 10:00:03model. Okay, the base model we have
  14588. 10:00:04imported here, we have inherited and
  14589. 10:00:08here is the pentic syntax. Okay, this
  14590. 10:00:11syntax I already taught you in that
  14591. 10:00:12session. So this should be uh string and
  14592. 10:00:14this should be integer and here I have
  14593. 10:00:16given the field. So in the field I'm
  14594. 10:00:18telling detail feedback for for the
  14595. 10:00:22essay and for score I've given a
  14596. 10:00:25description score out of 10. uh so this
  14597. 10:00:28is the greater than and this is the
  14598. 10:00:30lesser than okay greater than zero and
  14599. 10:00:32lesser than 10 so this should be the
  14600. 10:00:34score so this that's how you can make
  14601. 10:00:36the structured output from any kinds of
  14602. 10:00:38given lm okay now uh to make the
  14603. 10:00:43structured uh model what I'm going to do
  14604. 10:00:46simply I'm going to just add this uh add
  14605. 10:00:51the schema to the model so for this you
  14606. 10:00:53have to call the model dot with
  14607. 10:00:56structure output there is a function
  14608. 10:00:57function called with structured output I
  14609. 10:00:58think
  14610. 10:01:02with structured output inside that you
  14611. 10:01:04have to pass this class okay this pentic
  14612. 10:01:07class now this will set um uh into the
  14613. 10:01:10model that means whenever you will
  14614. 10:01:12generate any kinds of output this will
  14615. 10:01:14have two things one is the feedback is
  14616. 10:01:16the score okay now I'll store inside
  14617. 10:01:19another variable called structured model
  14618. 10:01:21now this is going to be my structured
  14619. 10:01:23model object okay now every time I'm
  14620. 10:01:25call this I'm going to call this model.
  14621. 10:01:27Okay, not this model. This model will
  14622. 10:01:28give you unstructured output, but this
  14623. 10:01:30model will give you the structured
  14624. 10:01:31output. Okay, now let me execute
  14625. 10:01:36and see whether everything is fine or
  14626. 10:01:38not. H now if you want to test guys, so
  14627. 10:01:40maybe I can show you. So I'll give a
  14628. 10:01:42essay here.
  14629. 10:01:44So this is one essay I generated from
  14630. 10:01:46chart GPT. You can see this is essay I
  14631. 10:01:49generated from chart GPT Europe in the
  14632. 10:01:52age of AI, the regulatory super power.
  14633. 10:01:55So what I'm going to do, I'm going to
  14634. 10:01:57pass this asset to this structured model
  14635. 10:02:00with a prompt.
  14636. 10:02:03So this is the prompt uh I have written.
  14637. 10:02:05Evaluate the language quality of the
  14638. 10:02:08following essay and provide a feedback
  14639. 10:02:11and assign a score out of 10. Okay, I'm
  14640. 10:02:12giving the essay text here and right now
  14641. 10:02:15I'm calling the structured model, not
  14642. 10:02:16the model only. Okay, structured
  14643. 10:02:18model.invoke and I'm passing the prompt.
  14644. 10:02:20Now this will give you the result.
  14645. 10:02:24Okay, result I stored inside result
  14646. 10:02:26variable. Now let's execute.
  14647. 10:02:38Yeah. Now if I print this result,
  14648. 10:02:44you'll see that it will have two
  14649. 10:02:46parameter. One is the feedback. Okay.
  14650. 10:02:48Feedback of the essay and another one is
  14651. 10:02:51the score. Okay, see I got this code.
  14652. 10:02:54You can also extract it if you want. So
  14653. 10:02:56you just simply need to write result dot
  14654. 10:03:00feedback.
  14655. 10:03:04Okay, you'll get the feedback and if you
  14656. 10:03:06want this code, you can call
  14657. 10:03:08result.core.
  14658. 10:03:10Okay, this this code you got. I hope you
  14659. 10:03:13got it guys. Okay, that's with the pyic
  14660. 10:03:15you can um you can get the structured
  14661. 10:03:17output from any large than case model.
  14662. 10:03:19Okay, this is very much important.
  14663. 10:03:22Now we'll try to start writing our uh
  14664. 10:03:25this workflow. Now first of all let's
  14665. 10:03:26prepare this state. So already state is
  14666. 10:03:29given. I'm going to just replicate the
  14667. 10:03:30same state here.
  14668. 10:03:33So this is our state
  14669. 10:03:36essay state. So we giving the essay
  14670. 10:03:38language feedback test analysis feedback
  14671. 10:03:40clarity of clarity feedback overall
  14672. 10:03:42feedback individual scores and this is
  14673. 10:03:44uh reducer uh reducer concept you're
  14674. 10:03:47using. Basically this should be a list
  14675. 10:03:48of score. Okay. and it will add every
  14676. 10:03:50time and the average score. Now let's
  14677. 10:03:53initialize that.
  14678. 10:03:55Now we'll write our our graph. Let's
  14679. 10:03:58prepare the graph.
  14680. 10:04:01Yeah. So we have given this state to
  14681. 10:04:03this graph. Okay. Now we'll try to add
  14682. 10:04:08the nodes. So first of all I will add
  14683. 10:04:10this node, this node, this node. Okay.
  14684. 10:04:13And the final evalation node. Total four
  14685. 10:04:15nodes I have to add. Let's add it. Um I
  14686. 10:04:19have already prepared all of the node
  14687. 10:04:24add node.
  14688. 10:04:30So yeah you can see we're adding the
  14689. 10:04:31nodes. First of all we're adding the
  14690. 10:04:33evaluation evaluate language. Okay
  14691. 10:04:36evaluate language this node. Then we are
  14692. 10:04:38adding evaluate analysis this node. Then
  14693. 10:04:42we are giving evaluate thoughts this
  14694. 10:04:44node. Okay. Then last final evaluation.
  14695. 10:04:47final evalation. Okay, my node is done.
  14696. 10:04:50Now we have to uh create these are the
  14697. 10:04:52Python function one by one. Let's create
  14698. 10:04:54quickly.
  14699. 10:05:04So here I'm going to just create it
  14700. 10:05:06quickly. First of all I'm going to
  14701. 10:05:07create this function evaluate language.
  14702. 10:05:11So I already created let me show you.
  14703. 10:05:15Yeah. So evalute language this will take
  14704. 10:05:17this state as an input and here you can
  14705. 10:05:19see uh I'm using llm and for this I
  14706. 10:05:22prepared a prompt. So here I'm telling
  14707. 10:05:24evaluate the language quality of the
  14708. 10:05:26following essay and provide a feedback
  14709. 10:05:27and assign a score out of 10 and we're
  14710. 10:05:29giving the state uh sorry essay from the
  14711. 10:05:32state. Okay and we are calling this
  14712. 10:05:34structured model that means the
  14713. 10:05:36structured model we have prepared here
  14714. 10:05:38this model. Okay, instead of this model,
  14715. 10:05:40so structured model, so this model will
  14716. 10:05:42give you two things. One is the
  14717. 10:05:43feedback, one is the score. So the
  14718. 10:05:46feedback we're storing inside language
  14719. 10:05:47feedback. That means this particular
  14720. 10:05:49variable because we are evaluating the
  14721. 10:05:51language here. That's why feedback will
  14722. 10:05:52go to the language feedback. And the
  14723. 10:05:54score we are getting we are storing
  14724. 10:05:56inside individual score and this is um
  14725. 10:05:59like uh reducer type that means we are
  14726. 10:06:01adding inside a list. So that's why you
  14727. 10:06:04can see individual score output score.
  14728. 10:06:06Okay, that means the first code will
  14729. 10:06:08save here. That means let's say
  14730. 10:06:10uh what I'm going to do
  14731. 10:06:16see
  14732. 10:06:17that means um from here uh evaluate
  14733. 10:06:21language right I think it is evaluate
  14734. 10:06:23language uh evaluate language so that
  14735. 10:06:26means we are executing this note so this
  14736. 10:06:28node will give you two things one is the
  14737. 10:06:29feedback
  14738. 10:06:32one is the score okay so feedback I
  14739. 10:06:35already stored inside my feedback um
  14740. 10:06:39feedback um uh feedback state that means
  14741. 10:06:43here language feedback now score okay
  14742. 10:06:45score what I'm doing because I created
  14743. 10:06:47an individual feedback variable okay uh
  14744. 10:06:50so here let me show you
  14745. 10:06:52maybe I can take a screenshot
  14746. 10:07:06so Here you remember I created this
  14747. 10:07:10individual score variable. So basically
  14748. 10:07:11this is a list. Okay. This should be a
  14749. 10:07:13list. This should be a list. Okay. And
  14750. 10:07:16we added our first score which is this
  14751. 10:07:20uh evaluate language. Let's say it has
  14752. 10:07:21given you eight. Okay. Then there would
  14753. 10:07:24be a comma
  14754. 10:07:26done. Okay. Now I will write for the
  14755. 10:07:29next nodes which is evaluate analysis.
  14756. 10:07:32Okay. because I already executed uh I
  14757. 10:07:35already created this node evaluate
  14758. 10:07:36language this will give you feedback and
  14759. 10:07:38it's code I already got it and instead
  14760. 10:07:40of returning all the state we are
  14761. 10:07:41returning the updated one only because
  14762. 10:07:44in my previous example I showed you if
  14763. 10:07:46you're creating parallel workflow you
  14764. 10:07:48don't need to return the entire state
  14765. 10:07:50instead of that only you just you just
  14766. 10:07:52need to return the updated state okay
  14767. 10:07:54otherwise there would be a conflict
  14768. 10:07:56problem okay yeah so now let me define
  14769. 10:07:59this node now once it is done I'll
  14770. 10:08:02define Find the next note which is the
  14771. 10:08:05depth of analysis. Evaluate analysis.
  14772. 10:08:08This will take the state and here we are
  14773. 10:08:10giving the prompt again. Evaluate the
  14774. 10:08:12depth of analysis of the following essay
  14775. 10:08:13and provide a feedback and assign a
  14776. 10:08:16score out of 10. And we are giving the
  14777. 10:08:17essay and this will uh pass to the
  14778. 10:08:19structured model. This will give you two
  14779. 10:08:21things. One is the feedback. So this
  14780. 10:08:22feedback I'm storing inside analysis
  14781. 10:08:24feedback. that means here in this
  14782. 10:08:27particular variable and it is giving you
  14783. 10:08:29the individual score and we are uh
  14784. 10:08:32storing this uh score in the individual
  14785. 10:08:34score that means here okay this is a
  14786. 10:08:37list so like let's say this has given
  14787. 10:08:39you uh again eight okay this will store
  14788. 10:08:42here okay that's how we are storing now
  14789. 10:08:47this is also done now we'll write for
  14790. 10:08:50the next one which is
  14791. 10:08:53clarity of thought analysis is evaluate
  14792. 10:08:55clarity clarity of thought. Again, this
  14793. 10:08:57will take the state as an input. We are
  14794. 10:08:59defining the prompt. Evaluate the
  14795. 10:09:00clarity of the thought of the following
  14796. 10:09:02essay and provide a feedback analysis
  14797. 10:09:04and assign a score out of 10. Okay,
  14798. 10:09:06we're giving the essay and we are
  14799. 10:09:09passing it to the structured model
  14800. 10:09:14and this will give you two things. One
  14801. 10:09:15is the feedback. So feedback I'm storing
  14802. 10:09:17inside clarity feedback in this uh
  14803. 10:09:20variable and the score we are getting
  14804. 10:09:22we're storing inside individual score.
  14805. 10:09:24Okay, that means here then again it will
  14806. 10:09:27get give you another score. Let's say
  14807. 10:09:29you got uh nine here. Okay, so that's
  14808. 10:09:32how your individual score will form,
  14809. 10:09:35right? And now we have all of the score
  14810. 10:09:37from all of the nodes. Now we'll try to
  14811. 10:09:39make the average one. Okay, later on.
  14812. 10:09:42Now it's done. You can see uh we are
  14813. 10:09:44also returning uh these two things
  14814. 10:09:46clarity of uh clarity feedback and
  14815. 10:09:47individual scores and this will become
  14816. 10:09:49my next node. Now we have to work on the
  14817. 10:09:53uh final node which is final evaluation.
  14818. 10:09:56Now let's also write that
  14819. 10:10:00this is our final evaluation nodes.
  14820. 10:10:02Again this will take the state as an
  14821. 10:10:04input and again we are preparing a
  14822. 10:10:06prompt based on the following feedbacks.
  14823. 10:10:08Uh create a summarized feedback. Okay.
  14824. 10:10:10Now here we are passing all of the
  14825. 10:10:12feedback one by one. That means this
  14826. 10:10:14feedback, this feedback, this feedback.
  14827. 10:10:16Okay. This feedback, this feedback, this
  14828. 10:10:18feedback. Three feedback we are giving.
  14829. 10:10:20language feedback
  14830. 10:10:22then depth of analysis feedback clarity
  14831. 10:10:24of thought feedback and I'm just uh
  14832. 10:10:28telling the model give me a overall
  14833. 10:10:30feedback and right now I only need a
  14834. 10:10:32feedback I know I don't need any kinds
  14835. 10:10:34of score okay so that's why I'm using
  14836. 10:10:37the original model instead of working on
  14837. 10:10:40the structured model I'm now invoking
  14838. 10:10:43the original model because I only need
  14839. 10:10:45the feedback that's why I'm invoking on
  14840. 10:10:48the original model I'm giving giving
  14841. 10:10:50this prompt and whatever content it is
  14842. 10:10:52generating I'm just storing inside
  14843. 10:10:53overall feedback. Okay. Now I have to
  14844. 10:10:56calculate the average um average score.
  14845. 10:10:58Okay. And how to calculate the average
  14846. 10:11:00score? Because I already have the all of
  14847. 10:11:02this score, right? All of this score as
  14848. 10:11:04a list. Now you can see from this state
  14849. 10:11:07I'm extracting the individual score.
  14850. 10:11:09Okay, individual score uh because this
  14851. 10:11:12is a list. Okay. Now we are calculating
  14852. 10:11:14the length of this uh uh uh like list
  14853. 10:11:18and how many uh like let's say variable
  14854. 10:11:21uh how many value we are having we are
  14855. 10:11:23just doing the dividing operation. Okay
  14856. 10:11:25first of all we are doing the sum
  14857. 10:11:26operation you can see. So how to
  14858. 10:11:28calculate average? First of all you will
  14859. 10:11:29do the sum operation. You will do the
  14860. 10:11:31sum operation 8 + 8 + 9. Okay then
  14861. 10:11:34you'll just try to divide with the
  14862. 10:11:36number of uh item you have. Let's say we
  14863. 10:11:38have three here. Now whatever output you
  14864. 10:11:40will be getting this is your average.
  14865. 10:11:42Okay. So we are calculating the average
  14866. 10:11:43like that. First of all we are summing
  14867. 10:11:46all the value. Then we are dividing with
  14868. 10:11:48length of the uh item we are having
  14869. 10:11:50inside the list. Then this is going to
  14870. 10:11:52be your average score and we are
  14871. 10:11:54returning the overall feedback and
  14872. 10:11:56average score. So overall feedback we
  14873. 10:11:57are storing inside this variable overall
  14874. 10:12:00feedback and the average score we are
  14875. 10:12:02storing this average. Okay average score
  14876. 10:12:04here. That's it.
  14877. 10:12:07Okay. Now all of the function we have
  14878. 10:12:09created. Now we have to add the nodes.
  14879. 10:12:11Now let's try to refer this graph and
  14880. 10:12:13add the nodes. Now see whenever you are
  14881. 10:12:15adding the nodes first of all you can
  14882. 10:12:17see start would be connected to the
  14883. 10:12:18evaluate analysis evaluate language
  14884. 10:12:20evaluate of thoughts. Let's add that
  14885. 10:12:29addages.
  14886. 10:12:35Yeah. So you can see start is connected
  14887. 10:12:37with evaluate language, evaluate
  14888. 10:12:39analysis, evaluate thoughts, evaluate
  14889. 10:12:42analysis, evaluate language, evaluate
  14890. 10:12:43thoughts. Okay, that means these are the
  14891. 10:12:45connection we have built. Now evaluate
  14892. 10:12:48analysis is connected with final
  14893. 10:12:49evaluation. Evaluate language is
  14894. 10:12:51connected with uh final evaluation and
  14895. 10:12:53evalu evaluate thought is connected to
  14896. 10:12:55final evaluation. Now I have to make
  14897. 10:12:57this connection. Now let me do that.
  14898. 10:13:01See evaluate language is connected to
  14899. 10:13:04the final evaluation. Evaluate analysis
  14900. 10:13:05is connected to the final evaluation.
  14901. 10:13:07Evaluate at heart is connected to the
  14902. 10:13:09final evaluation. That means this
  14903. 10:13:10connection is also done. Now final
  14904. 10:13:12evaluation is connected to the end.
  14905. 10:13:17Now final evaluation is connected to the
  14906. 10:13:19end. Okay. Now we have to compile the
  14907. 10:13:21graph.
  14908. 10:13:25Done. Now if you print the workflow.
  14909. 10:13:29So that's how your workflow looks like.
  14910. 10:13:31And now you can verify this workflow and
  14911. 10:13:33this workflow. Okay. These are same. Now
  14912. 10:13:37I need to uh invoke this workflow. So
  14913. 10:13:40for this let's prepare another essay.
  14914. 10:13:43So I generated another ay from my chart
  14915. 10:13:45GPT. So this is another essay. I named
  14916. 10:13:48it as ay 2. Okay. So this is in test
  14917. 10:13:50state in the age of AI then
  14918. 10:13:52infrastructure and capital super power.
  14919. 10:13:55So I'm going to invoke it right now with
  14920. 10:13:57my workflow.
  14921. 10:13:59So let's do that.
  14922. 10:14:02So first of all here I have prepared the
  14923. 10:14:04initial state and I have given my SA
  14924. 10:14:06okay then we are involving the workflow
  14925. 10:14:09and this will return you the result
  14926. 10:14:29done now we'll print this result.
  14927. 10:14:33See here you have all of the data. So
  14928. 10:14:35this is the essay. This is the language
  14929. 10:14:37feedback you got. This is the analysis
  14930. 10:14:39feedback feedback you got. This is the
  14931. 10:14:40clarity feedback you got. This is the
  14932. 10:14:42overall feedback you got. This is the
  14933. 10:14:44individual scores for from all of the
  14934. 10:14:46nodes. Okay. And this is the average
  14935. 10:14:48score. I hope you get it guys. See
  14936. 10:14:52amazing right? So that's how we can
  14937. 10:14:54create any kinds of LLM based parallel
  14938. 10:14:57workflow. Uh now I think it is pretty
  14939. 10:14:59much clear and the only things is that
  14940. 10:15:03you have to understand the connection
  14941. 10:15:05you have to understand this graph and
  14942. 10:15:07the state. Okay the state you will be
  14943. 10:15:08using here and when to use this u
  14944. 10:15:12reducer when to use the pantic you have
  14945. 10:15:15to understand
  14946. 10:15:17uh by seeing the problem statement. So
  14947. 10:15:20here two things you have learned um I
  14948. 10:15:23just used in this particular practical
  14949. 10:15:25demo. One is the pientic how to use
  14950. 10:15:28pientic to get the structured output.
  14951. 10:15:30Okay. Then another one this reducer. So
  14952. 10:15:34reducer we already uh saw right uh in
  14953. 10:15:37the concept understanding now we
  14954. 10:15:40practically applied this reducer as
  14955. 10:15:42well. Okay in the lang lang graph. So
  14956. 10:15:44yes guys uh this is all about uh that's
  14957. 10:15:47how we can create any kinds of parallel
  14958. 10:15:48workflow. Now in the next video I'm
  14959. 10:15:51going to teach you some other workflow
  14960. 10:15:53like conditional, iterative. Okay, each
  14961. 10:15:56and everything we'll try to discuss then
  14962. 10:15:58we'll also implement some amazing uh
  14963. 10:16:01practical project. Okay, agent project.
  14964. 10:16:03Okay, in our previous video I have
  14965. 10:16:06already discussed about uh parallel
  14966. 10:16:08workflows like how parallel workflow
  14967. 10:16:10works and uh we already did the coding
  14968. 10:16:13as well with the help of lang graph. Uh
  14969. 10:16:16now let's try to understand this
  14970. 10:16:17conditional workflows and this
  14971. 10:16:19conditional workflows would be more
  14972. 10:16:21interesting because if you have already
  14973. 10:16:23uh let's say learned programming
  14974. 10:16:25language you know that inside
  14975. 10:16:26programming language we have something
  14976. 10:16:28called a condition right so based on
  14977. 10:16:30this a condition we uh handle any kinds
  14978. 10:16:33of conditional based scenario so the
  14979. 10:16:35same thing you can do inside langraph as
  14980. 10:16:38well whenever you are having a workflow
  14981. 10:16:40this is having some kinds of condition
  14982. 10:16:42you can handle this kinds of scenario
  14983. 10:16:43with the help of this conditional
  14984. 10:16:45workflows. Okay. So, make sure you watch
  14985. 10:16:48this video till the end. Don't miss
  14986. 10:16:50anything. And if you found this content
  14987. 10:16:52useful, guys, please try to subscribe to
  14988. 10:16:54my channel and hit the like. Uh just uh
  14989. 10:16:57hit the like guys because like is
  14990. 10:16:58required if you like the session. So, uh
  14991. 10:17:01it will be uh it will be reaching to all
  14992. 10:17:03the people out there so that they can
  14993. 10:17:05also find this kinds of content and
  14994. 10:17:08please try to share this video with your
  14995. 10:17:09friends and family. So, first of all,
  14996. 10:17:11let me give you the idea about
  14997. 10:17:12conditional workflows. Then I will also
  14998. 10:17:14show you how we can code with the help
  14999. 10:17:16of lang graph. How we can implement this
  15000. 10:17:18conditional workflow with the help of
  15001. 10:17:19lang graph. So here also I'm going to uh
  15002. 10:17:22take two kinds of example. I'm going to
  15003. 10:17:24take the first example nonlm based
  15004. 10:17:27conditional workflows. First of all I'm
  15005. 10:17:28going to show you the nonlm based
  15006. 10:17:30workflows. Then after that I'm also
  15007. 10:17:32going to show you the lm based
  15008. 10:17:33workflows. Okay. Both we're going to
  15009. 10:17:35cover here. So if you see here um this
  15010. 10:17:38is the conditional workflows guys. So
  15011. 10:17:40this is uh similar to the uh parallel
  15012. 10:17:43workflows. I think you already studied
  15013. 10:17:45about parallel workflows. Okay. So let
  15014. 10:17:47me show you. So previously I already
  15015. 10:17:48discussed about this parallel workflows,
  15016. 10:17:50right? So in uh parallel workflows what
  15017. 10:17:52happens if you give a task. So basically
  15018. 10:17:56here we are having multiple nodes and
  15019. 10:17:58all of the nodes would be executed
  15020. 10:18:00independently. That means it will
  15021. 10:18:02execute uh it will be executed in
  15022. 10:18:04parallel. Okay. Altogether it will be
  15023. 10:18:06executing. Then whatever result I was
  15024. 10:18:08getting, I was just aggregating and u
  15025. 10:18:12showing the results. Okay. But inside
  15026. 10:18:14this conditional workflow, this is uh um
  15027. 10:18:17little bit different. Let me show you.
  15028. 10:18:19So inside conditional workflow, what
  15029. 10:18:21will happen? See here also we are having
  15030. 10:18:23multiple nodes. Okay. Uh in parallel but
  15031. 10:18:26these are actually condition. Okay.
  15032. 10:18:28These are actually condition. That means
  15033. 10:18:30let's say uh let's say whatever content
  15034. 10:18:33we are sending. So first of all it will
  15035. 10:18:35analyze that after doing the analyze it
  15036. 10:18:38will perform a conditional statement
  15037. 10:18:41that means if this content is good let's
  15038. 10:18:44say it will approve that particular post
  15039. 10:18:47if it is let's say uh if is let's say
  15040. 10:18:51needs any human review that time it will
  15041. 10:18:55send it to the human review okay and it
  15042. 10:18:58if it is having any kinds of problem
  15043. 10:19:00that time it will directly reject the
  15044. 10:19:01post that means here you are checking
  15045. 10:19:03the condition based on the condition you
  15046. 10:19:05are executing one of the node. Okay, you
  15047. 10:19:07are not executing all of the node. You
  15048. 10:19:10are only executing one of the node.
  15049. 10:19:12Okay, let's say
  15050. 10:19:15this node can be executed based on the
  15051. 10:19:17condition or this note can be executed
  15052. 10:19:19based on the condition or this node can
  15053. 10:19:21be executed based based on the
  15054. 10:19:23condition. Okay, based on that you are
  15055. 10:19:25ending the entire graph. But here it's
  15056. 10:19:27not like that. Here you are executing
  15057. 10:19:28all the node togethers. Okay, in
  15058. 10:19:30parallel you are executing then you are
  15059. 10:19:32aggregating the results and you are
  15060. 10:19:33showing that. But here it's not like
  15061. 10:19:35that. This is working as a a fields
  15062. 10:19:37condition. Okay, so let me show you. See
  15063. 10:19:40here basically we'll just write a
  15064. 10:19:42condition. Okay, let's say here the
  15065. 10:19:44problem statement. First of all I'm
  15066. 10:19:45going to show you u this is actually
  15067. 10:19:48content moderation system. This is the
  15068. 10:19:50nonlm based workflow. First of all I'm
  15069. 10:19:52going to create then after that I'm also
  15070. 10:19:54going to show you how to create the LMB
  15071. 10:19:56based workflow. So here basically we'll
  15072. 10:19:57be creating a content moderation system
  15073. 10:19:59for a social media platform. It
  15074. 10:20:02processes a user text post and evaluate
  15075. 10:20:05it for spam and conditionally allowed it
  15076. 10:20:08to be published. Okay, published either
  15077. 10:20:12flagged for the human review. If it is
  15078. 10:20:15uh need any kinds of human review it
  15079. 10:20:16will try to send to the human review or
  15080. 10:20:18it will automatically reject that
  15081. 10:20:20particular post. That means here we'll
  15082. 10:20:22be uh basically deciding this kinds of
  15083. 10:20:25statement based on the condition. Okay,
  15084. 10:20:28condition we'll first of all check the
  15085. 10:20:29content. Whatever content user will
  15086. 10:20:32post, whatever text user will post,
  15087. 10:20:33we'll try to check that. Okay, before
  15088. 10:20:35checking that we'll try to first of all
  15089. 10:20:36format the post. Format the post means I
  15090. 10:20:38will show a message. Okay, I will show a
  15091. 10:20:41message like let's say this is the user
  15092. 10:20:43he has posted this uh this this
  15093. 10:20:45particular content. After that we'll
  15094. 10:20:47analyze that, right? Analyze that. So
  15095. 10:20:49this analyze function will try to
  15096. 10:20:52analyze whether this is uh this is uh
  15097. 10:20:55this particular post I can directly post
  15098. 10:20:56or not if it doesn't have any kinds of
  15099. 10:20:58violation or not or either if user is
  15100. 10:21:02completely new to my platform okay first
  15101. 10:21:04of all I have to send this post for the
  15102. 10:21:07review okay either if it is having any
  15103. 10:21:10kinds of uh violation related post I'll
  15104. 10:21:12just try to reject that particular post
  15105. 10:21:14okay so this is the condition so
  15106. 10:21:16basically here you are sending uh you
  15107. 10:21:18are handling this kinds condition. If
  15108. 10:21:20else condition,
  15109. 10:21:24if else condition, okay, if else
  15110. 10:21:27condition, if this uh post is fine, you
  15111. 10:21:30are approving that. Okay, if it is uh uh
  15112. 10:21:34like uh uh if it uh
  15113. 10:21:39or if user is completely new user, okay,
  15114. 10:21:43new user, you are sending for the human
  15115. 10:21:45review or else you are rejecting the
  15116. 10:21:47post. that means there is there is a
  15117. 10:21:49violation problem. Okay. So this is a
  15118. 10:21:52conditional based workflow. Now I think
  15119. 10:21:54you got it. What is the difference
  15120. 10:21:55between this conditional workflows and
  15121. 10:21:58the parallel workflows. Okay. And to
  15122. 10:22:00implement this workflows guys I need a
  15123. 10:22:02state. So I already prepared the state.
  15124. 10:22:03As you can see I named it as moderation
  15125. 10:22:06state and I inherited with the type dict
  15126. 10:22:08and here I have taken some of the
  15127. 10:22:10variable. So the first one I have taken
  15128. 10:22:12for the post content that means whatever
  15129. 10:22:14text user will pass I'll try to save it
  15130. 10:22:17here. post content and this should be a
  15131. 10:22:18string type data. Then uh user
  15132. 10:22:21reputation. This is also userable pass.
  15133. 10:22:24User reputation means either user is a
  15134. 10:22:26uh registered user or he's the new user.
  15135. 10:22:29Okay. Let's say if user reputation is
  15136. 10:22:31equal to is equal to let's say um let's
  15137. 10:22:34say the user is uh the user is let's say
  15138. 10:22:38trusted user. Okay. Trusted user means
  15139. 10:22:40this is uh this user is already
  15140. 10:22:42registered user. Okay. So that time I'll
  15141. 10:22:45uh not send this post for the review.
  15142. 10:22:47Okay, this post uh won't be going for
  15143. 10:22:50the review because the review I I will
  15144. 10:22:52only learn uh I mean I will only execute
  15145. 10:22:54whenever the user is completely new to
  15146. 10:22:56my platform. Okay, so this this uh
  15147. 10:22:59statement will uh store here and this is
  15148. 10:23:01going to be also string type data. Then
  15149. 10:23:03formatted post. So whatever content user
  15150. 10:23:06will give give us first of all we'll try
  15151. 10:23:08to format that particular post. Format
  15152. 10:23:10means I will give a message. Let's say
  15153. 10:23:13um let's say user says this is the post.
  15154. 10:23:17Okay, that that kind of like uh I'm
  15155. 10:23:19going to just give a message then
  15156. 10:23:22content flag. Content flag means u here
  15157. 10:23:25is the content flag. Basically all of
  15158. 10:23:26the condition whether this should be
  15159. 10:23:28approved or whether this should be
  15160. 10:23:31rejected or whether this should be uh
  15161. 10:23:34flagged for the human review. Okay. So
  15162. 10:23:36these kinds of condition I'll try to
  15163. 10:23:39save inside content flag and this is
  15164. 10:23:40also going to be a string because here
  15165. 10:23:42I'm going to store uh either approved
  15166. 10:23:44either review either reject post okay
  15167. 10:23:46that's why it's going to uh it's going
  15168. 10:23:48to be string then result the final
  15169. 10:23:50result okay final result means whether
  15170. 10:23:52the post has been approved uh that mean
  15171. 10:23:55uh it will give a message right let's
  15172. 10:23:56say post automatically approved or post
  15173. 10:23:59flagged for the human review or post or
  15174. 10:24:01already rejected okay these kinds of
  15175. 10:24:03methods I want to show at the last
  15176. 10:24:04that's why I have taken another variable
  15177. 10:24:06called result and this is also going to
  15178. 10:24:07be a string. Okay, I hope you got it
  15179. 10:24:09guys. Now let's try to code inside lang
  15180. 10:24:12graph how we can uh create this graph
  15181. 10:24:14how we can create this workflow. So I
  15182. 10:24:16think you already get it. First of all I
  15183. 10:24:18have to create some of the nodes. Okay,
  15184. 10:24:20this node, this node, this node, this
  15185. 10:24:22node, this node. Okay, then I'll try to
  15186. 10:24:23do the edge connection and I will show
  15187. 10:24:25you how we can uh handle this kinds of
  15188. 10:24:27conditional workflow as well with the
  15189. 10:24:29help of this
  15190. 10:24:31um this langraph. Okay, this can be also
  15191. 10:24:34um discussed in this particular video.
  15192. 10:24:36Now, let me create a file first of all
  15193. 10:24:38here. So, I'm going to create a file.
  15194. 10:24:45I'm going to create a new file. I'm
  15195. 10:24:47going to name it as
  15196. 10:24:49six content moderation workflow. PY NB.
  15197. 10:24:54Okay, this is a notebook file. So, I'll
  15198. 10:24:57take a code cell and here also I'll take
  15199. 10:24:58the kernel H.
  15200. 10:25:01So the first thing guys I have to import
  15201. 10:25:03the necessary library and I I think you
  15202. 10:25:05know that uh what are the library we
  15203. 10:25:08need right so let's import so I need
  15204. 10:25:12this uh uh state graph start end from
  15205. 10:25:14lang graph graph and type date let's
  15206. 10:25:17import them then after that we have to
  15207. 10:25:20create this state right so the same
  15208. 10:25:22state I'm going to create here
  15209. 10:25:26so this is the state
  15210. 10:25:28I have taken the post contain user
  15211. 10:25:30reputation
  15212. 10:25:31Then uh formatted post content flag and
  15213. 10:25:33result.
  15214. 10:25:37So first of all now I'm going to uh
  15215. 10:25:41create the graph. Okay. Then after
  15216. 10:25:42creating the graph we'll try to add all
  15217. 10:25:44of the nodes. Now let's create the
  15218. 10:25:45graph.
  15219. 10:25:49So graph is equal to state graph. Then I
  15220. 10:25:50have given my state moderation state.
  15221. 10:25:53Then after that we'll just try to add
  15222. 10:25:55the nodes.
  15223. 10:25:57add the nodes.
  15224. 10:26:01Okay, first of all, I'm going to add my
  15225. 10:26:04first nodes which is uh this one format
  15226. 10:26:07post. Let's add that
  15227. 10:26:12format post and this function I have to
  15228. 10:26:14write. Okay, this format post Python
  15229. 10:26:16function I have to write separately.
  15230. 10:26:18Then the next uh nodes I have to write
  15231. 10:26:22this uh analyze content.
  15232. 10:26:25Analyze content. Okay. I have give given
  15233. 10:26:28the same name. Then the next node I have
  15234. 10:26:32to create approve post.
  15235. 10:26:37Then next node I have to create flag for
  15236. 10:26:40review.
  15237. 10:26:44Then next po uh node I have to create
  15238. 10:26:46this reject post.
  15239. 10:26:50Okay. Now let me check whether I have
  15240. 10:26:52any node or not. No, it's completely
  15241. 10:26:54fine. I have created all the nodes. Now
  15242. 10:26:56we have to create all of these node one
  15243. 10:26:58by one. So first of all let's create the
  15244. 10:27:00format post.
  15245. 10:27:03Uh see inside formatted post I'm not
  15246. 10:27:07going to do anything. This is the nonLM
  15247. 10:27:09based workflow. So I'm going to just
  15248. 10:27:11write a simple Python code here. So
  15249. 10:27:13basically whatever um let's say user is
  15250. 10:27:15passing input user is passing. Let's say
  15251. 10:27:17user is passing post content and user
  15252. 10:27:19reputation. So I just created a
  15253. 10:27:21formatted string here. So here I told
  15254. 10:27:24user uh reputation. Okay that means
  15255. 10:27:26let's say user is trusted user. So here
  15256. 10:27:28trusted user will come. That means user
  15257. 10:27:30trusted user says post content. That
  15258. 10:27:33means whatever post he's giving this
  15259. 10:27:35particular post it will show here. Let's
  15260. 10:27:36say user has given uh one post uh check
  15261. 10:27:39out this amazing new product and buy
  15262. 10:27:41now. Okay. So this will show here inside
  15263. 10:27:43a uh this f string. Okay. Then after
  15264. 10:27:46that we are just returning this
  15265. 10:27:48particular formatted post. Okay.
  15266. 10:27:50Formatted because we created this
  15267. 10:27:52formatted post and whatever formatted
  15268. 10:27:53output we are generating right we'll
  15269. 10:27:55just try to store in the formatted post
  15270. 10:27:57string. Okay we are storing uh storing
  15271. 10:27:59here and we're returning it. And why we
  15272. 10:28:01are not returning the enter state guys?
  15273. 10:28:04Because in my previous uh previous video
  15274. 10:28:07I already told you about right I
  15275. 10:28:09whenever I created the parallel workflow
  15276. 10:28:10that time I told you uh if you are
  15277. 10:28:13having this kinds of scenario um that
  15278. 10:28:16time don't use the entire state uh
  15279. 10:28:19returning concept instead of that uh
  15280. 10:28:21whatever state you are changing only
  15281. 10:28:22just try to return those state okay this
  15282. 10:28:24is a good practice okay instead of
  15283. 10:28:26returning the whole one because here you
  15284. 10:28:29are not changing inside that okay after
  15285. 10:28:31the execution node execution you are not
  15286. 10:28:33changing inside this particular variable
  15287. 10:28:36you are only changing inside that right
  15288. 10:28:37that's why don't return the entire state
  15289. 10:28:39instead of whatever state you are uh
  15290. 10:28:42changing only just try to return that
  15291. 10:28:44okay I hope you got it so this is our
  15292. 10:28:45first node we have created now let's
  15293. 10:28:47create the next one called uh this
  15294. 10:28:51analyze content okay now analyze content
  15295. 10:28:53would be very simple uh see here I just
  15296. 10:28:57written a simple condition so see here
  15297. 10:29:01I'm giving my state And whatever post
  15298. 10:29:04content we are having first of all we're
  15299. 10:29:06doing the lower operation. Okay
  15300. 10:29:10lower operation then after that we are
  15301. 10:29:14checking the condition. So as you can
  15302. 10:29:16see if spam in the content or buy now in
  15303. 10:29:19the content. See here we are only
  15304. 10:29:20considering uh this particular post
  15305. 10:29:23would be rejected based on some like
  15306. 10:29:25parameter whether it should be a spam
  15307. 10:29:27whether it should be buy now. If user is
  15308. 10:29:29giving this kinds of word in the text
  15309. 10:29:31itself, I'm going to directly reject
  15310. 10:29:33that particular content. Okay? Because
  15311. 10:29:35this is a condition I mean non-LM based
  15312. 10:29:37one. So that's why I I just taken uh
  15313. 10:29:40like manual verification. But whenever
  15314. 10:29:41it would be LM based that time it would
  15315. 10:29:43be more robust. Okay. But just for your
  15316. 10:29:45understanding I kept this particular
  15317. 10:29:46easy example. So that's why I only
  15318. 10:29:49considered two word. One is spam one is
  15319. 10:29:51buy now. Okay. If it is present in the
  15320. 10:29:53content I'm going to directly reject
  15321. 10:29:55that particular content. So flag would
  15322. 10:29:56be rejected. If the state reputation if
  15323. 10:30:00is equal to is equal to new user that
  15324. 10:30:02means I told you if user reputation is
  15325. 10:30:04equal to is equal to new user that means
  15326. 10:30:06he is the completely new user on my
  15327. 10:30:08platform first of all I'll review this
  15328. 10:30:10particular post okay I'll send it for
  15329. 10:30:12the review or else I'm going to approve
  15330. 10:30:15the post let's say if it it doesn't have
  15331. 10:30:17any kinds of spam content or it doesn't
  15332. 10:30:20need any kinds of review that means this
  15333. 10:30:21content is fine I'm going to approve
  15334. 10:30:23that okay that's why in the s block the
  15335. 10:30:25flag is equal to approved then whatever
  15336. 10:30:28uh flag we are getting based on the
  15337. 10:30:29condition we are just storing inside
  15338. 10:30:31content flag okay here we are storing
  15339. 10:30:33that and we are returning this
  15340. 10:30:34particular state okay I hope you got it
  15341. 10:30:37now the next one I have to create for
  15342. 10:30:39this approved post
  15343. 10:30:43okay approved post so this will
  15344. 10:30:44basically return this approved message
  15345. 10:30:47uh result is equal to post published
  15346. 10:30:49successfully to the timeline and result
  15347. 10:30:51is equal to result so we are storing
  15348. 10:30:53inside result okay now we'll do it for
  15349. 10:30:55the same uh for the flag review and
  15350. 10:30:58reject post as well. Now here also I'm
  15351. 10:31:02going to just return the message for
  15352. 10:31:03flag for review post sent uh to the
  15353. 10:31:07human moderation uh queue okay for the
  15354. 10:31:09review and we are updating the result
  15355. 10:31:12okay and here you can see uh we don't
  15356. 10:31:14need to store all of the like uh result
  15357. 10:31:18here because this is not required
  15358. 10:31:20because this is a conditional workflow.
  15359. 10:31:22So either one of the node would be
  15360. 10:31:24executed it it should not be executed
  15361. 10:31:26all of the node right like that okay so
  15362. 10:31:29previously it was executing all of the
  15363. 10:31:30node and I was uh I was collecting all
  15364. 10:31:33of the ratings okay and I was storing
  15365. 10:31:35inside a list that's why I I uh I used
  15366. 10:31:38actually reducer concept here but here
  15367. 10:31:40reducer concept is not required because
  15368. 10:31:42here either one of the node would be
  15369. 10:31:44executed and I only need to save one
  15370. 10:31:46particular result okay that's why this
  15371. 10:31:48is completely uh string type okay I
  15372. 10:31:51haven't taken any kinds of reducer type
  15373. 10:31:54here. Okay, every time it will uh
  15374. 10:31:57replace that.
  15375. 10:31:59Then the next one I have for the reject
  15376. 10:32:01post.
  15377. 10:32:03Reject post. So as you can see uh post
  15378. 10:32:06automatically deleted due to the policy
  15379. 10:32:07violation and we are updating the
  15380. 10:32:09result. That's it. So let's execute this
  15381. 10:32:11one. Execute this one.
  15382. 10:32:19And I'll execute this one also. Execute
  15383. 10:32:22this one. Okay. Once it is done, now uh
  15384. 10:32:26I have to
  15385. 10:32:28I have to um do the age connection.
  15386. 10:32:31Okay. So first of all, let's do the age
  15387. 10:32:33connection. Then I will show you how we
  15388. 10:32:35can uh handle the conditional scenario.
  15389. 10:32:37So here let's try to do the age
  15390. 10:32:39connection.
  15391. 10:32:41Add
  15392. 10:32:42the edges. So first of all you can see
  15393. 10:32:45the age connection would be start to
  15394. 10:32:47formatted post. Okay, let's try to do
  15395. 10:32:49that.
  15396. 10:32:51Start to formatted post.
  15397. 10:32:55Okay, then the next one, formatted post
  15398. 10:32:57to analyze content.
  15399. 10:33:03Formatted post to analyze content. Okay.
  15400. 10:33:05Then after that uh what we have
  15401. 10:33:11uh we have um we have uh this
  15402. 10:33:14connection. Okay. But this connection
  15403. 10:33:16will build up um based on the condition
  15404. 10:33:19either uh analyze content will return uh
  15405. 10:33:24this particular output to the approved
  15406. 10:33:26post or flag review post or rejected
  15407. 10:33:27post. Okay. Now this conditional
  15408. 10:33:30statement will come come into picture.
  15409. 10:33:32Okay. Now this conditional statement
  15410. 10:33:33will come into picture. So let's say if
  15411. 10:33:35I'm not adding the condition if I'm
  15412. 10:33:37directly just let's say this these nodes
  15413. 10:33:39are not there. I'm directly just adding
  15414. 10:33:41this um analyze content to the end.
  15415. 10:33:45Analyze content to the end.
  15416. 10:33:52Analyze content
  15417. 10:33:55to the
  15418. 10:33:58and okay. Now if I compile the graph and
  15419. 10:34:02if I show you the workflow
  15420. 10:34:09again not
  15421. 10:34:19okay uh there should not be any
  15422. 10:34:21quotation that's why it's coming the
  15423. 10:34:23error now if execute this workflow is
  15424. 10:34:25created now if I show you the workflow
  15425. 10:34:27now see the workflow look Next lab.
  15426. 10:34:31So this is the workflow right now.
  15427. 10:34:34Okay. But I created the nodes already,
  15428. 10:34:36right? So if I let's say um comment is
  15429. 10:34:39at the node. Now if I execute,
  15430. 10:34:42see
  15431. 10:34:45this will look like that. So start
  15432. 10:34:47formatted post then analyze content and
  15433. 10:34:50end. Okay. Uh let's say these are the
  15434. 10:34:53nodes are not there. Okay. But now I
  15435. 10:34:55have to create this node because uh I
  15436. 10:34:57have to handle the condition statement.
  15437. 10:34:58Now let's uh uncomment that.
  15438. 10:35:01Now here I'll just try to add the
  15439. 10:35:03condition. Now I'll remove this one.
  15440. 10:35:04Okay. Now here only you have to add the
  15441. 10:35:06condition. Now see if you want to add a
  15442. 10:35:10condition. Okay. If you want to add a
  15443. 10:35:12condition, so you have to use this
  15444. 10:35:14function
  15445. 10:35:18add conditional age. Okay. There is a
  15446. 10:35:21function inside graph called add
  15447. 10:35:22conditional edge. inside that you have
  15448. 10:35:25to you have to give a
  15449. 10:35:28uh you have to give a function object
  15450. 10:35:31okay condition function object okay
  15451. 10:35:33condition function object and you have
  15452. 10:35:35to provide from where to it will go to
  15453. 10:35:37the conditional function let's say you
  15454. 10:35:40can see condition will start after this
  15455. 10:35:42analyze content okay so here I'll just
  15456. 10:35:44write
  15457. 10:35:46analyze content okay analyze content
  15458. 10:35:52Yeah.
  15459. 10:35:54Now from analyze content it will either
  15460. 10:35:56go to the
  15461. 10:35:58it will either go to the approved post
  15462. 10:36:00flag for review or rejected post. Okay.
  15463. 10:36:02Now I have to write this conditional
  15464. 10:36:04function. Now separately I have to
  15465. 10:36:06create another function.
  15466. 10:36:09Let me show you the function. So this is
  15467. 10:36:11the function guys. Okay. This is the
  15468. 10:36:14function. Now we have to import this
  15469. 10:36:16literal. Okay. Literal from this typing.
  15470. 10:36:21Okay. Now see whenever you are writing
  15471. 10:36:24any kinds of condition this code would
  15472. 10:36:25be common. See I have named this
  15473. 10:36:27function as check condition and it will
  15474. 10:36:29also take this state okay and it will
  15475. 10:36:32return
  15476. 10:36:33uh it will return the nodes. Okay you
  15477. 10:36:37can see we are giving the nodes name
  15478. 10:36:39analyze content approved. Okay sorry
  15479. 10:36:43approved post flag for review and reject
  15480. 10:36:46post. That means these are the node
  15481. 10:36:47approve post flag for review reject
  15482. 10:36:49post. Okay, because these are my node
  15483. 10:36:51name, right? So this function basically
  15484. 10:36:53what happens? See this function takes
  15485. 10:36:55this state and it returns either one of
  15486. 10:36:57this particular node. Okay, based on the
  15487. 10:36:59condition. Now let's try to see the
  15488. 10:37:01condition.
  15489. 10:37:02See if my state flag I already
  15490. 10:37:05calculated the state flag guys here
  15491. 10:37:06right if it is if it is uh let's say
  15492. 10:37:09approved that means my approved post
  15493. 10:37:13approved post node would be written that
  15494. 10:37:15means this node would be written that
  15495. 10:37:17means that time only this node would be
  15496. 10:37:19executed not these are the nodes okay
  15497. 10:37:21then
  15498. 10:37:24if uh my content flag is equal to review
  15499. 10:37:26that means only flag for review will be
  15500. 10:37:28executed that means if my flag post is
  15501. 10:37:32equal L2 is equal to uh let's say
  15502. 10:37:35uh review that means this this
  15503. 10:37:37particular node would be executed not
  15504. 10:37:38these two nodes then if uh either none
  15505. 10:37:43of them then rejected post post would be
  15506. 10:37:45written that means if it is not approved
  15507. 10:37:48post and flag for review then reject
  15508. 10:37:50node would be executed okay neect node
  15509. 10:37:52would be returned so this is the logic
  15510. 10:37:53we have written here that's why we are
  15511. 10:37:55using this literal literal means you can
  15512. 10:37:58return the node object here okay you can
  15513. 10:38:00return the node object Okay, that's why
  15514. 10:38:02we have to give this particular syntax
  15515. 10:38:04and this syntax uh basically uh
  15516. 10:38:06recommended by langraph. If you check
  15517. 10:38:08the langraph documentation, you will see
  15518. 10:38:10that they have also uh given the same
  15519. 10:38:12thing. Okay, so this is the condition
  15520. 10:38:14function you have to write whenever you
  15521. 10:38:16want to use this kinds of conditional
  15522. 10:38:18edges. Okay, if you want to handle this
  15523. 10:38:20kinds of conditional scenario that time
  15524. 10:38:22you have to write this kinds of
  15525. 10:38:23function. Now this function object you
  15526. 10:38:25have to just provide here. Okay, after
  15527. 10:38:27this analyze content, you have to
  15528. 10:38:29provide this kind uh this this function
  15529. 10:38:31object check condition. That's it. Okay,
  15530. 10:38:34now what will happen after analyze
  15531. 10:38:36content? This particular uh connection
  15532. 10:38:39would be either with this particular
  15533. 10:38:42node or with this particular node or
  15534. 10:38:44with this particular node. Okay, but you
  15535. 10:38:45don't know which one because it will
  15536. 10:38:47check the condition based on the
  15537. 10:38:49condition which condition will match it
  15538. 10:38:51will go to that particular node. Okay,
  15539. 10:38:53that's why we have written the
  15540. 10:38:54condition. Okay, I hope you got it. Now
  15541. 10:38:57this connection is also done. This
  15542. 10:38:59connection is also done. Now it will uh
  15543. 10:39:01do the connection either one of them.
  15544. 10:39:03Okay, now you have to make this kinds of
  15545. 10:39:05connection. That means approve post will
  15546. 10:39:07be connected to the end. Flag for review
  15547. 10:39:09will connect to the end and reject post
  15548. 10:39:11will also connect to the end. Okay, now
  15549. 10:39:13let's do uh do this connection. So here
  15550. 10:39:16I will
  15551. 10:39:19just do the connection. So this is the
  15552. 10:39:20connection. You can see approved post is
  15553. 10:39:23connected to the end. Then flag for
  15554. 10:39:26review which is also connected to the
  15555. 10:39:27end.
  15556. 10:39:29Okay. Then uh reject post will be also
  15557. 10:39:31connected to the end. Then we are
  15558. 10:39:33compiling the graph. Now if I execute
  15559. 10:39:36the graph uh okay check condition is not
  15560. 10:39:39defined because I have to execute this
  15561. 10:39:40function.
  15562. 10:39:42Uh lit is not defined. Okay sorry I have
  15563. 10:39:45to also import it first of all. Then I
  15564. 10:39:49will execute.
  15565. 10:39:51Then I will compile the graph. After
  15566. 10:39:54that now let me show you the workflow.
  15567. 10:39:56Now see guys this workflow and this
  15568. 10:39:58workflow is same. Okay I hope you got it
  15569. 10:40:01guys how we are handling this kinds of
  15570. 10:40:04conditional scenario. Okay, I know I
  15571. 10:40:07hope you already got it right. Only the
  15572. 10:40:10change is that
  15573. 10:40:12you have to use this kind use this
  15574. 10:40:15function add conditional edges and this
  15575. 10:40:17add conditional ages takes the uh
  15576. 10:40:19previous connection. Okay, previous
  15577. 10:40:21connection and it takes the condition uh
  15578. 10:40:24condition function because condition
  15579. 10:40:26function will decide uh after that which
  15580. 10:40:29node should be connected. Okay, either
  15581. 10:40:31approved post, either flag post, either
  15582. 10:40:33rejected post. Okay, but it should not
  15583. 10:40:35be executed all together. It would be
  15584. 10:40:37only executed either one of them based
  15585. 10:40:39on the condition. This is what we have
  15586. 10:40:41done guys. Now let me check this
  15587. 10:40:43workflow. So I'll invoke this workflow.
  15588. 10:40:46First of all, let's define initial
  15589. 10:40:48state.
  15590. 10:40:49So this is our initial state. So first
  15591. 10:40:52of all, I've given the post content.
  15592. 10:40:53Check out this amazing new product and
  15593. 10:40:56buy now. And then I've given the user
  15594. 10:40:57reputation. Let's say this is the
  15595. 10:40:59trusted user already registered user.
  15596. 10:41:01Then we're invoking the workflow and
  15597. 10:41:03this workflow will give me a result
  15598. 10:41:08result. Okay. Now if I print this result
  15599. 10:41:12now see guys this is the post user has
  15600. 10:41:15given user reputation is trusted user
  15601. 10:41:17and we are formatting that particular
  15602. 10:41:20uh post. So you can see user trusted
  15603. 10:41:22user says check this amazing product buy
  15604. 10:41:25now. Content flag is rejected. Okay. Why
  15605. 10:41:28it is rejected? because it is having buy
  15606. 10:41:30now and we already did the condition
  15607. 10:41:32check here
  15608. 10:41:35uh buy now by now here. So if uh buy now
  15609. 10:41:39is present in the content it would be
  15610. 10:41:40rejected. Okay. So that's why
  15611. 10:41:44uh you can see content flag is rejected
  15612. 10:41:47and result is also post automatically
  15613. 10:41:49deleted due to the policy violation.
  15614. 10:41:51Okay. Now let's say here I'm not giving
  15615. 10:41:53this by now. By now I will remove it.
  15616. 10:41:56Now if I execute the workflow again. Now
  15617. 10:41:58see uh right now it is approved because
  15618. 10:42:00it doesn't have any kinds of violation.
  15619. 10:42:02Uh again user is trusted user so it
  15620. 10:42:04doesn't need any kinds of approval.
  15621. 10:42:06Okay. Uh it doesn't need any kinds of
  15622. 10:42:08review that's why directly approved and
  15623. 10:42:10post published successfully. Okay. Now
  15624. 10:42:12let's say user is new user.
  15625. 10:42:18New user. Okay. Now see although this uh
  15626. 10:42:22um I mean content is fine but still it
  15627. 10:42:25will uh okay I have to execute
  15628. 10:42:30then result huh so although see although
  15629. 10:42:32this uh content is fine but still it is
  15630. 10:42:35waiting for the review because I have to
  15631. 10:42:37first of all check the user because this
  15632. 10:42:39is uh he is not registered in my
  15633. 10:42:41platform that's why it is uh going for
  15634. 10:42:44the review and you can see post sent to
  15635. 10:42:46the human moderation P okay I hope you
  15636. 10:42:48got it That's how this conditional
  15637. 10:42:50workflow is working. Okay, that's how
  15638. 10:42:53this conditional uh conditional workflow
  15639. 10:42:55is working. So whatever message you are
  15640. 10:42:57giving based on that it is first of all
  15641. 10:42:58checking the condition. Okay, after
  15642. 10:43:00checking the condition it is executing
  15643. 10:43:02either one of this particular node.
  15644. 10:43:04Okay, not all the nodes altogether. I
  15645. 10:43:06hope you got it guys. So this is what
  15646. 10:43:08our nonLM based workflow. Now let's try
  15647. 10:43:11to discuss the LM based workflow as
  15648. 10:43:13well. So guys, so far we have seen the
  15649. 10:43:15nonLM based workflow, conditional
  15650. 10:43:18workflows and I showed you how it works,
  15651. 10:43:20right? How we can handle the conditional
  15652. 10:43:22scenario. Now let's try to learn the LLM
  15653. 10:43:25based conditional workflows. Okay, now
  15654. 10:43:27we'll be uh using large language model.
  15655. 10:43:29But previously I didn't use any kinds of
  15656. 10:43:31large language model here. Okay,
  15657. 10:43:32everything I handled manually. So see if
  15658. 10:43:35I u um first of all explain the problem
  15659. 10:43:39statement we're going to uh create here.
  15660. 10:43:41So this is going to be a um review reply
  15661. 10:43:45system. Review reply system means let's
  15662. 10:43:47say here uh user will give a review.
  15663. 10:43:50Okay, user will give a review and what
  15664. 10:43:53we have to do we have to uh give a reply
  15665. 10:43:56to that particular review. Now review
  15666. 10:43:58can be anything whether it should be a
  15667. 10:44:01positive review, it should be a negative
  15668. 10:44:02review. Let's say uh we are working we
  15669. 10:44:06are working in a uh [clears throat] tech
  15670. 10:44:07company right we are uh selling a
  15671. 10:44:09product let's say we have created a
  15672. 10:44:11software right so in that software uh uh
  15673. 10:44:15let's say I I have uh made a
  15674. 10:44:18subscription plan and some of the user
  15675. 10:44:19have taken their subscription okay now
  15676. 10:44:22definitely they will be using your
  15677. 10:44:23product and uh based on the product
  15678. 10:44:25actually they will uh give some kinds of
  15679. 10:44:28uh like um I mean review right on on
  15680. 10:44:30your product and uh as a let's say
  15681. 10:44:34company owner what you have to do
  15682. 10:44:36definitely you have to take take care
  15683. 10:44:38about the um uh user review okay
  15684. 10:44:40whatever user is giving the review uh
  15685. 10:44:43you have to take care if they are giving
  15686. 10:44:44the positive review that means it's
  15687. 10:44:46completely fine your product is amazing
  15688. 10:44:48okay you don't need to change inside
  15689. 10:44:49your product but if they're getting some
  15690. 10:44:53if they're giving some negative review
  15691. 10:44:55that means if they're having some of the
  15692. 10:44:56issue definitely you have to handle
  15693. 10:44:57their issue right so you just think in
  15694. 10:44:59that way so basically user will give a
  15695. 10:45:01review. First of all, what we'll do is
  15696. 10:45:03just try to check the sentiment of that
  15697. 10:45:05review whether uh this is a positive
  15698. 10:45:08review or whether this is a negative
  15699. 10:45:10review. And whenever I want to do this
  15700. 10:45:12uh sentiment uh check, right? So
  15701. 10:45:14definitely I have to use a large
  15702. 10:45:15language model here. So here I'm I'll be
  15703. 10:45:18using a large language model. And this
  15704. 10:45:20large language model either will return
  15705. 10:45:22the positive,
  15706. 10:45:24either it will uh return the negative.
  15707. 10:45:26That means this is also a structured
  15708. 10:45:28output. And if I want to get the
  15709. 10:45:29structured output guys, what I have to
  15710. 10:45:31do? I have to use the pientic. I already
  15711. 10:45:33uh showed you in my previous lecture as
  15712. 10:45:35well whenever I created that parallel
  15713. 10:45:37workflow that time I also told you with
  15714. 10:45:39the help of pientic uh you can uh get
  15715. 10:45:42the structured output. Okay, you have to
  15716. 10:45:43just create a schema and you have to
  15717. 10:45:45provide the schema to the model and
  15718. 10:45:46model will work in uh uh in that way and
  15719. 10:45:49for this you have to learn the pyic and
  15720. 10:45:51pyic video I already have in my
  15721. 10:45:52playlist. Please try to check that.
  15722. 10:45:54Okay. So this particular node will
  15723. 10:45:57return either positive or negative based
  15724. 10:45:59on the review I will be using a large
  15725. 10:46:01lang based model. Large lang based model
  15726. 10:46:02will uh uh like uh analyze that uh
  15727. 10:46:05analyze the sentiment and based on that
  15728. 10:46:08it will give me positive either
  15729. 10:46:09negative. Okay. If it is positive so see
  15730. 10:46:11here your condition statement is
  15731. 10:46:13working. If let's say this particular
  15732. 10:46:16sentiment is positive that means I'll
  15733. 10:46:17generate a positive response. Okay
  15734. 10:46:19positive reply to the customer. Okay.
  15735. 10:46:22But if it is negative, if this review is
  15736. 10:46:25negative, sentiment is negative. So
  15737. 10:46:27again, I'm running another node called
  15738. 10:46:29run diagnosis. Okay. So what this run
  15739. 10:46:32diagnosis will do? Basically I want to
  15740. 10:46:35uh analyze this particular review uh in
  15741. 10:46:39little more depth because I want to
  15742. 10:46:42understand what is the uh what is the
  15743. 10:46:44issue they are having. Okay. What is
  15744. 10:46:46their main concern? I have to analyze
  15745. 10:46:48that. That's why I will be running
  15746. 10:46:49another nodes called run diagnosis. So
  15747. 10:46:52this run diagnosis will return three
  15748. 10:46:53things. One is the issue type. First of
  15749. 10:46:55all, it will return the issue type. What
  15750. 10:46:56is the issue related? Whether the issue
  15751. 10:46:58is coming from UI uh UX okay or whether
  15752. 10:47:02it is coming from performance or whether
  15753. 10:47:05it is kinds of bugs or whether they need
  15754. 10:47:07any kinds of support or any other
  15755. 10:47:08things. Okay. I have to understand the
  15756. 10:47:10issue type. Then I have to understand
  15757. 10:47:11the tone whether they're angry,
  15758. 10:47:13frustrated, disappointed or calm. Okay.
  15759. 10:47:15I have to understand the user. Then I
  15760. 10:47:17have to understand their urgency.
  15761. 10:47:19whether this urgency is low, medium or
  15762. 10:47:21high. Okay, based on that definitely I
  15763. 10:47:23have to uh take the actions. Okay,
  15764. 10:47:26otherwise I can't sell my product
  15765. 10:47:28anymore. Right then once I got these are
  15766. 10:47:30the let's say issue type based on that
  15767. 10:47:33okay I will be generating a reply
  15768. 10:47:36negative uh like reply to that
  15769. 10:47:39particular user let's say I'll tell okay
  15770. 10:47:41you are getting this kinds of UI related
  15771. 10:47:43problem you you you are very angry okay
  15772. 10:47:46and your urgency is high so definitely
  15773. 10:47:48uh we'll our team will look into that
  15774. 10:47:50immediately or if it is low uh so you
  15775. 10:47:53just wait for 3 to two days I will look
  15776. 10:47:55into that okay so this kinds of reply
  15777. 10:47:57will try to generate Okay, I hope you
  15778. 10:47:58got it this workflow. Uh now you can see
  15779. 10:48:01here this is the workflow. This is a
  15780. 10:48:03conditional workflow but we'll be
  15781. 10:48:04solving with the help of llm. Okay, so
  15782. 10:48:06we will be ling l we'll be using the lm
  15783. 10:48:09uh two u uh two times here. So in this
  15784. 10:48:12particular nodes and here also we'll be
  15785. 10:48:13using the llm to run this diagnosis I
  15786. 10:48:15need another llm. Okay, with help of llm
  15787. 10:48:17we'll try to generate these are the
  15788. 10:48:19structure and again this should be a
  15789. 10:48:21structured output. Okay. So every time
  15790. 10:48:23whenever I run this nodes run diagnosis
  15791. 10:48:25node LM will return three things issue
  15792. 10:48:27type, tone and urgency again I have to
  15793. 10:48:29use pientic for that. Okay. Pentic for
  15794. 10:48:32that we'll be creating a schema and
  15795. 10:48:34we'll generate this structure output.
  15796. 10:48:36Okay. So this is what we'll be
  15797. 10:48:37implementing guys right now. And for
  15798. 10:48:38this whatever state I need I already
  15799. 10:48:40created the state as you can see I named
  15800. 10:48:42it as review state inherited with type
  15801. 10:48:44dict. So first of all whatever review
  15802. 10:48:46user will give me I will store in the
  15803. 10:48:47review and this should be a string and
  15804. 10:48:49our this node will try to find the
  15805. 10:48:51sentiment okay sentiment of the review.
  15806. 10:48:54So either it would be a positive or
  15807. 10:48:56negative. You can either create it as a
  15808. 10:48:58string. Either you can create it as a
  15809. 10:48:59literal type. In literal type you can
  15810. 10:49:01mention uh because this is a category
  15811. 10:49:02right? Either it would be a positive or
  15812. 10:49:04negative. It kinds of category. So
  15813. 10:49:06that's why we have taken this literal
  15814. 10:49:07type. You can also take a string type.
  15815. 10:49:09It will also work. Okay. I have taken
  15816. 10:49:10literal type. So positive and negative.
  15817. 10:49:12Okay. Sentiment should be positive or
  15818. 10:49:13negative. And uh diagnosis. So diagnosis
  15819. 10:49:16will return three things. That means uh
  15820. 10:49:19tone type, tone and angry. Okay. So this
  15821. 10:49:22this should this structure should be a
  15822. 10:49:24dictionary type you can see this is the
  15823. 10:49:25key this is the value this is the key
  15824. 10:49:26this is the value right so that's why I
  15825. 10:49:28have taken this should be a dictionary
  15826. 10:49:29type and the response whatever response
  15827. 10:49:32I'll try to generate whether I should
  15828. 10:49:33I'll generate a positive response or
  15829. 10:49:35negative response it will come here and
  15830. 10:49:36this again this should be a string type
  15831. 10:49:38okay I hope you got it now we can start
  15832. 10:49:40coding inside lang graph guys okay so
  15833. 10:49:43what I'll do guys I'll create another
  15834. 10:49:44file here
  15835. 10:49:46let's create another file
  15836. 10:49:49I'm going to name it as Seven
  15837. 10:49:53uh
  15838. 10:49:56review workflow
  15839. 10:50:01review
  15840. 10:50:06workflow
  15841. 10:50:07dot ip yv
  15842. 10:50:11I'll take the code cell select the
  15843. 10:50:14kernel
  15844. 10:50:16fine so the first thing guys what I have
  15845. 10:50:18to do I have to import all the necessary
  15846. 10:50:20libraries so let's port and here we'll
  15847. 10:50:21be using LLM. So again I'm going to use
  15848. 10:50:23my uh open AI model. I already have the
  15849. 10:50:26API key inside my env. So you just also
  15850. 10:50:29need to generate API key. Okay. You can
  15851. 10:50:31either use any other model as well. It's
  15852. 10:50:33completely fine. Uh
  15853. 10:50:36yeah. Then after that uh I need uh this
  15854. 10:50:39uh typing
  15855. 10:50:42type dict and literal from typing. Then
  15856. 10:50:45I also need to load this env. For this I
  15857. 10:50:47need this load env.
  15858. 10:50:50And I also need to import the pi dantic.
  15859. 10:50:52Okay, because I have to generate a
  15860. 10:50:53structured output. So pi dantic I need
  15861. 10:50:56best model and field. So please try to
  15862. 10:50:58see in my uh playlist guys this tutorial
  15863. 10:51:01is already there. So here is the
  15864. 10:51:03playlist guys complete aentici course
  15865. 10:51:05and here is the pentic video. Please try
  15866. 10:51:08to go ahead with this pyic you'll try to
  15867. 10:51:09understand. Okay and previously I also
  15868. 10:51:13discussed about this uh uh sequential
  15869. 10:51:15workflow and parallel workflow. Okay
  15870. 10:51:17that this concept you have to also
  15871. 10:51:19understand. Okay, if you're
  15872. 10:51:20understanding this um uh conditional
  15873. 10:51:23workflow because each of the workflow is
  15874. 10:51:26uh something is like connected with each
  15875. 10:51:29other that means if you can understand
  15876. 10:51:32uh our workflow then you can relate with
  15877. 10:51:35another workflow. Okay. So that's why
  15878. 10:51:37this is required and the way I have
  15879. 10:51:39structured this course course right step
  15880. 10:51:41by step this is interconnected between
  15881. 10:51:44so if you missed out the previous
  15882. 10:51:45sessions so I think it would be a little
  15883. 10:51:47bit confusing okay for the current
  15884. 10:51:49session so that's why I'm telling you
  15885. 10:51:51just try to go ahead with the previous
  15886. 10:51:52session yeah
  15887. 10:51:55so yeah so after that I'll first of all
  15888. 10:51:57load the environment variable
  15889. 10:52:03okay now let's initialize the model LLM
  15890. 10:52:06model. So here I have taken GPT photo
  15891. 10:52:08mini. Yeah. Now I told you I have to
  15892. 10:52:12generate this uh I have to create this
  15893. 10:52:14uh structure. So yeah. So I told you
  15894. 10:52:18this fine sentiment nodes will give you
  15895. 10:52:21two things either positive or negative.
  15896. 10:52:23Okay. For this I'll create a a
  15897. 10:52:25structured output and for run diagnosis
  15898. 10:52:28node I'll create a structured output.
  15899. 10:52:29That means it will generate three
  15900. 10:52:30things. One is issue type, tone and
  15901. 10:52:32urgency. Right? So for this let's try to
  15902. 10:52:35write this pyic class.
  15903. 10:52:38So this is the first class I have
  15904. 10:52:40written for the sentiment.
  15905. 10:52:43Okay. So basically this will uh return
  15906. 10:52:46two uh uh two things positive or
  15907. 10:52:48negative based on the
  15908. 10:52:50review. Okay. So this is going to be my
  15909. 10:52:53first uh actually structured output from
  15910. 10:52:55my LLM. Okay. So maybe I can show you.
  15911. 10:52:58So let's create a object
  15912. 10:53:01of a model.
  15913. 10:53:04Yeah. So let's say structured model uh
  15914. 10:53:06is equal to model dot with structured
  15915. 10:53:07output I have given the sentiment
  15916. 10:53:09schema. Now see if I show you the
  15917. 10:53:11output.
  15918. 10:53:13Let's say I have generated uh structured
  15919. 10:53:15model. Now if I give any kinds of
  15920. 10:53:18uh if I give any kinds of let's say
  15921. 10:53:20prompt here
  15922. 10:53:23let's say this is the prompt. What is
  15923. 10:53:24the sentiment of the following review?
  15924. 10:53:26This software is too good. Okay. Now
  15925. 10:53:28I'll give it to my model. Now see here
  15926. 10:53:32I'm not using the direct model. I'm
  15927. 10:53:34giving my structured model. Okay. Now
  15928. 10:53:36I'm doing the invok operation and I'm
  15929. 10:53:38only getting the sentiment.
  15930. 10:53:40Now see
  15931. 10:53:43see positive it will either return
  15932. 10:53:45positive or negative. Now let's say here
  15933. 10:53:47I've give two bat. Now this will return
  15934. 10:53:51me negative. Okay. So this is the
  15935. 10:53:53structured output and if you want to get
  15936. 10:53:55this kinds of output you have to use the
  15937. 10:53:56py okay schema for that. So the same
  15938. 10:53:59thing I'll also write for my diagnosis
  15939. 10:54:03uh node.
  15940. 10:54:05So this is for my diagnosis node. Okay.
  15941. 10:54:08So again I'm inheriting with the base
  15942. 10:54:09model of the pentic and here I have
  15943. 10:54:11written the issue type tone and urgency.
  15944. 10:54:14So this uh node will return this three
  15945. 10:54:16thing issue type. Now here I have given
  15946. 10:54:18some of the hint like I need uh issue
  15947. 10:54:20type should be UIX performance bug
  15948. 10:54:22support and others. Here I have given
  15949. 10:54:24the field description the category of
  15950. 10:54:26the issue mentioned in the review. Then
  15951. 10:54:28tone, angry, frustrated, disappointed,
  15952. 10:54:30clam, the emotion, tone expressed by the
  15953. 10:54:32user. Urgency, low, medium, high. How
  15954. 10:54:36urgent to uh or critical the issue
  15955. 10:54:39appears to be. Okay. So this thing I
  15956. 10:54:41have discussed in my pentic uh uh class.
  15957. 10:54:44Okay. So I already talked about what is
  15958. 10:54:47this um literal, what is this field,
  15959. 10:54:50what is the description, each and
  15960. 10:54:52everything I have already discussed.
  15961. 10:54:53Okay. So this is another structured
  15962. 10:54:55output we have created. Okay. Now you
  15963. 10:54:57can also test for this you can create
  15964. 10:54:58another uh another model. So let's say I
  15965. 10:55:03have named this model as structured
  15966. 10:55:05model to model uh uh with structured
  15967. 10:55:08output and we are giving the diagnosis
  15968. 10:55:10schema here and this is going to be my
  15969. 10:55:12another object. Okay. Okay. I'm getting
  15970. 10:55:14an output. Okay. I have to execute this
  15971. 10:55:16one. Now I'll execute. Now see this is
  15972. 10:55:19working. Now you can also give a prompt
  15973. 10:55:21and you can
  15974. 10:55:23uh you can uh basically uh do the
  15975. 10:55:26analysis. Let's say
  15976. 10:55:29uh now I'll call this model.
  15977. 10:55:32Okay. Uh structured model 2. Now I'm
  15978. 10:55:34giving the same prompt. Now I want to
  15979. 10:55:37see the
  15980. 10:55:39uh output.
  15981. 10:55:42Now see uh issue type is other tone is
  15982. 10:55:45disappointed. U is medium. Okay. So this
  15983. 10:55:47is returning three things. Okay, I hope
  15984. 10:55:49you got it. Now, uh what I'm going to
  15985. 10:55:52do, I'm going to simply um
  15986. 10:55:56um create the
  15987. 10:55:58um state. Okay, now I have to prepare
  15988. 10:56:00the state. So, let's define the state,
  15989. 10:56:02the same state.
  15990. 10:56:04So, this is the state review state uh
  15991. 10:56:06review, sentiment, uh diagnosis and uh
  15992. 10:56:09response.
  15993. 10:56:11It's done. Now, I'll define the nodes.
  15994. 10:56:17Okay, I have given my state here. Now
  15995. 10:56:20add the nodes.
  15996. 10:56:25So now see the node connection. Uh see
  15997. 10:56:27the nodes how many nodes you are having.
  15998. 10:56:29Find sentiment then you have positive
  15999. 10:56:32response. You have brand diagnosis. You
  16000. 10:56:34have negative response. Okay these are
  16001. 10:56:35the nodes. Let's add one by one.
  16002. 10:56:40So these are the note find sentiment
  16003. 10:56:42positive response run diagnosis and
  16004. 10:56:44negative response. Okay. Okay. Now I
  16005. 10:56:45have to create these other function one
  16006. 10:56:47by one. Okay. So let's create
  16007. 10:56:51uh
  16008. 10:56:53first of all I'll create find sentiment.
  16009. 10:56:57So this is the function. This is the
  16010. 10:56:59note find sentiment. It will take the
  16011. 10:57:01state and here I have given a prompt for
  16012. 10:57:03the following review. Please uh find out
  16013. 10:57:06the sentiment and here we are giving the
  16014. 10:57:08review. Uh review is present inside our
  16015. 10:57:10state. Okay. And here we are getting the
  16016. 10:57:12sentiment from the model and we are
  16017. 10:57:14calling the structured model that means
  16018. 10:57:15the first model and first model I think
  16019. 10:57:17returns the only the sentiment whether
  16020. 10:57:18positive or negative. Okay, we're
  16021. 10:57:20getting the sentiment and we're updating
  16022. 10:57:21the sentiment and we're returning this
  16023. 10:57:23particular sentiment only. Okay, instead
  16024. 10:57:24of returning the whole state then
  16025. 10:57:28uh I'm going to write the next nodes
  16026. 10:57:31which is uh
  16027. 10:57:33positive response.
  16028. 10:57:38Positive response. Okay. So again it is
  16029. 10:57:40taking the state and we are preparing
  16030. 10:57:42the prompt. Write a warm thank you
  16031. 10:57:44message in response uh uh to this
  16032. 10:57:47review. So we are giving the review also
  16033. 10:57:49kindly ask user to leave feedback on our
  16034. 10:57:52website. Let's see that means if uh the
  16035. 10:57:54review is completely positive other time
  16036. 10:57:56I want to just give a thank you message
  16037. 10:57:58to the user. Okay. And I will tell also
  16038. 10:58:00just please leave a feedback to the
  16039. 10:58:02website. Then once it is done we are
  16040. 10:58:04giving to the model and see we are not
  16041. 10:58:06using any structured model here. we are
  16042. 10:58:08giving the main model because why here I
  16043. 10:58:11don't need any kinds of structured
  16044. 10:58:12output because it will only generate
  16045. 10:58:14some kinds of thank you message okay and
  16046. 10:58:16I don't need any kinds of structured
  16047. 10:58:17output that's why I'm giving the
  16048. 10:58:19original model and whatever content it
  16049. 10:58:21is returning I'm just uh saving inside
  16050. 10:58:23my response okay done now next thing I
  16051. 10:58:28have to create my diagnosis
  16052. 10:58:33run diagnosis
  16053. 10:58:35so this is the run diagnosis again it is
  16054. 10:58:37taking the state and here I preparing
  16055. 10:58:38the prompt diagnosis this negative
  16056. 10:58:40review we are giving the review uh
  16057. 10:58:42return issue type tone and urgency so we
  16058. 10:58:45are executing this structure to model
  16059. 10:58:49okay and basically this will return this
  16060. 10:58:51three things and whenever we are getting
  16061. 10:58:53we are updating my uh diagnosis you can
  16062. 10:58:57see we're updating the diagnosis because
  16063. 10:58:58diagnosis type is dictionary and this is
  16064. 10:59:00also a dictionary type output okay we
  16065. 10:59:03are doing that
  16066. 10:59:06now once it is I'll do it for my next
  16067. 10:59:09one. Uh negative response.
  16068. 10:59:13Negative response. So we are passing the
  16069. 10:59:15state. Then uh we are taking the
  16070. 10:59:19diagnosis. Okay. Then we are preparing
  16071. 10:59:21the prompt. You are a supportive
  16072. 10:59:22assistant. You uh the user had a issue
  16073. 10:59:25type then tone then urgency. Based on
  16074. 10:59:30that just write a empa uh empathetic
  16075. 10:59:33helpful resolution message. and we are
  16076. 10:59:36involving the actual model and whatever
  16077. 10:59:39response we are getting we are updating
  16078. 10:59:40the response. Okay. So that's how we are
  16079. 10:59:42getting all of the node one by one. Now
  16080. 10:59:44my node is ready. Now what I have to do
  16081. 10:59:46guys I have to
  16082. 10:59:48um make the age connection. Now let's do
  16083. 10:59:51the edge connection.
  16084. 10:59:55So add ages with condition H. So first
  16085. 10:59:59[clears throat] of all the connection
  16086. 11:00:00should be start to find sentiment.
  16087. 11:00:04Start to find sentiment.
  16088. 11:00:06Okay, start to find sentiment then you
  16089. 11:00:09have to uh take the conditional is right
  16090. 11:00:12now because either it will go to the
  16091. 11:00:14positive response either it will go to
  16092. 11:00:15the uh run diagnosis. Okay. So here
  16093. 11:00:18we'll just write the condition right
  16094. 11:00:20now. Uh
  16095. 11:00:24yeah so this is the conditional edges.
  16096. 11:00:27So see it will uh start from fun uh find
  16097. 11:00:32sentiment and either it will connect to
  16098. 11:00:34the positive either it will connect to
  16099. 11:00:35the negative. So that's why we have
  16100. 11:00:37taken the find sentiment. Now we have to
  16101. 11:00:39write the check sentiment function. I
  16102. 11:00:41think previous also we have created a
  16103. 11:00:43conditional function right and this
  16104. 11:00:44conditional function is return uh
  16105. 11:00:46returning your notes based on the
  16106. 11:00:48condition either it will return this
  16107. 11:00:49note, this node or this node. Okay,
  16108. 11:00:51we'll write the same thing here. So
  16109. 11:00:52let's write this function. Uh very
  16110. 11:00:55simple function that's I told you this
  16111. 11:00:57code would be common everywhere whenever
  16112. 11:00:59you are using conditional based
  16113. 11:01:00workflow. So see this is the function I
  16114. 11:01:02have written check statement uh
  16115. 11:01:05sentiment it will take the state and it
  16116. 11:01:07will return the uh nodes either positive
  16117. 11:01:11response node. Okay either positive
  16118. 11:01:13response node either run diagnosis node
  16119. 11:01:16that means this run diagnosis node.
  16120. 11:01:18Okay, based on the condition now where
  16121. 11:01:20I'll check the condition in the
  16122. 11:01:22sentiment. If the sentiment is positive,
  16123. 11:01:24I'll return the positive node, positive
  16124. 11:01:26response node. Okay, that means this
  16125. 11:01:27node will be return or if it is
  16126. 11:01:30negative, I'll return this run diagnosis
  16127. 11:01:33node. That means this node would be
  16128. 11:01:34written. Okay, I hope you got it guys.
  16129. 11:01:37So that's why we have to give this
  16130. 11:01:39particular function here. Now this
  16131. 11:01:40function will decide which node should
  16132. 11:01:42be called. Okay, so once it is done, now
  16133. 11:01:45let's say this connection is done. Okay,
  16134. 11:01:47now this connection is done. Now I have
  16135. 11:01:48to make the other connection. Now what
  16136. 11:01:50will happen?
  16137. 11:01:52Uh this uh positive will connect to the
  16138. 11:01:55end. Then run diagnosis will connect to
  16139. 11:01:58the negative response and negative
  16140. 11:01:59response will connect to the end. Okay.
  16141. 11:02:01We'll try to make this connection right
  16142. 11:02:02now.
  16143. 11:02:05So this is the connection.
  16144. 11:02:08Yeah. So you can see positive response
  16145. 11:02:09is connected to the end. Then run
  16146. 11:02:13diagnosis will connected to the negative
  16147. 11:02:15response. Okay. If let's say diagnosis
  16148. 11:02:17run successfully, we got the issue type,
  16149. 11:02:19tone and urgency, we'll connect to the
  16150. 11:02:21negative. We'll generate the negative
  16151. 11:02:23response and negative response will
  16152. 11:02:24connect it to the end. It is uh
  16153. 11:02:26connected to the end. Okay, I hope you
  16154. 11:02:28got the connection. Now let's uh define
  16155. 11:02:30the workflow. Compile the workflow.
  16156. 11:02:34Compile the workflow. Now let's execute.
  16157. 11:02:36Done. Now if I show you the workflow.
  16158. 11:02:41So this is the workflow guys. Now this
  16159. 11:02:43workflow and this workflow is same. You
  16160. 11:02:45can check uh find sentiment positive,
  16161. 11:02:48run diagnosis negative and okay
  16162. 11:02:50completely fine. Now let's uh invoke
  16163. 11:02:53this workflow.
  16164. 11:02:57So what I can do
  16165. 11:02:59I can give a positive
  16166. 11:03:03positive uh uh positive review first of
  16167. 11:03:06all.
  16168. 11:03:08So I will generate from chat JP. I'll
  16169. 11:03:10just tell generate a
  16170. 11:03:15Write a positive
  16171. 11:03:21review for a
  16172. 11:03:25tech software
  16173. 11:03:31in short.
  16174. 11:03:36Okay. Now I'll copy this and what I'm
  16175. 11:03:39going to do I'm going to add inside my
  16176. 11:03:43initial state.
  16177. 11:03:51So let me define my initial state.
  16178. 11:04:04So in the review itself I'll try to
  16179. 11:04:06write my
  16180. 11:04:17Now let's invoke the workflow
  16181. 11:04:25and this will give me the result.
  16182. 11:04:32Now I'll print the result.
  16183. 11:04:36Now see this uh this is the review and
  16184. 11:04:39the sentiment is positive and response
  16185. 11:04:42is also positive. Their username thank
  16186. 11:04:44you for your wonderful field uh uh here
  16187. 11:04:48to that our software made such a
  16188. 11:04:49positive. Okay, your kinds of word means
  16189. 11:04:51a lot blah blah blah and also please uh
  16190. 11:04:54give a review in inside our website.
  16191. 11:04:57Okay, now let's give a negative response
  16192. 11:05:00as well. Now I'll generate another one.
  16193. 11:05:03Now uh negative review.
  16194. 11:05:16Now what I can do? I can copy the same
  16195. 11:05:18code
  16196. 11:05:22only. I'll just change this preview.
  16197. 11:05:35So I will invoke the result uh workflow
  16198. 11:05:39and print the result.
  16199. 11:05:57Okay, now we are getting the negative.
  16200. 11:06:00You can see this uh sentiment is
  16201. 11:06:01negative and diagnosis we got. Issue
  16202. 11:06:04type is performance, tone is frustrated,
  16203. 11:06:06urgency is high and this is the uh
  16204. 11:06:08negative response we're writing. We are
  16205. 11:06:11here to help you with the performance
  16206. 11:06:12issue. Hi user blah blah blah. Okay. So
  16207. 11:06:15amazing that means it's working fine.
  16208. 11:06:17Okay. And I think you got how we have
  16209. 11:06:19created the entire workflow with the
  16210. 11:06:21help of this conditional workflow.
  16211. 11:06:24Get it? So now I think you can create
  16212. 11:06:26any kinds of conditional workflow either
  16213. 11:06:28it is non LLM based or LM based it
  16214. 11:06:30doesn't matter you can create it only
  16215. 11:06:32you just need to understand this
  16216. 11:06:34conditional connection okay if you
  16217. 11:06:35understand this conditional connection
  16218. 11:06:38then you will be able to create any
  16219. 11:06:39kinds of conditional workflow. So guys
  16220. 11:06:42in this video I'll be discussing about
  16221. 11:06:45the last workflows uh inside langraph
  16222. 11:06:48which is iterative workflows. So far I
  16223. 11:06:51have discussed about uh sequential
  16224. 11:06:53workflows, parallel workflows,
  16225. 11:06:55conditional workflows. Okay, each and
  16226. 11:06:57everything I have already covered. If
  16227. 11:06:59you haven't checked those videos, uh it
  16228. 11:07:01is already available inside my playlist.
  16229. 11:07:03Uh I have given the link in the
  16230. 11:07:05description from there you can check it
  16231. 11:07:07out. So uh this is going to be a very
  16232. 11:07:10important and interesting workflows guys
  16233. 11:07:12inside Langraph because with the help of
  16234. 11:07:14iterative workflows you can perform the
  16235. 11:07:17looping operation. So let's say whenever
  16236. 11:07:19you are performing any task and uh if
  16237. 11:07:21you feel like uh this uh task needs some
  16238. 11:07:24more improvement you can continuously
  16239. 11:07:27actually perform the looping operation
  16240. 11:07:29with the help of this iterative
  16241. 11:07:30workflows. So we'll try to understand
  16242. 11:07:32this one. So if you found my uh content
  16243. 11:07:36useful guys and if you are really
  16244. 11:07:38learning okay from this particular
  16245. 11:07:40playlist uh I would like to request you
  16246. 11:07:42please try to subscribe to my channel
  16247. 11:07:44and hit the like and please try to share
  16248. 11:07:46this with your friends and family. So if
  16249. 11:07:48you are supporting me guys if you are
  16250. 11:07:50supporting my channel I'll be getting
  16251. 11:07:52more motivation to bring this kinds of
  16252. 11:07:54content. So if you uh see guys uh here
  16253. 11:07:58is the iterative workflows we'll be
  16254. 11:08:00discussing about. So previously I
  16255. 11:08:03already discussed about all the
  16256. 11:08:04workflows um I told you about uh inside
  16257. 11:08:08langraph like sequential workflows you
  16258. 11:08:11have understood the LLM non LLM based
  16259. 11:08:13okay then I have discussed about the
  16260. 11:08:16parallel workflows then I discussed
  16261. 11:08:18about the conditional workflows okay now
  16262. 11:08:20we'll try to understand this iterative
  16263. 11:08:22workflows so you can see this is the uh
  16264. 11:08:26iterative workflows graph I already
  16265. 11:08:28created this particular graph so guys to
  16266. 11:08:30make you understand this iterative
  16267. 11:08:32workflows. I'm going to take one amazing
  16268. 11:08:34example. I'm going to take Facebook post
  16269. 11:08:37generation example. So what happens?
  16270. 11:08:40Let's say I want to post uh anything on
  16271. 11:08:43my Facebook. Let's say I want to post uh
  16272. 11:08:45any kinds of tech related uh content on
  16273. 11:08:48my Facebook. So nowadays actually what
  16274. 11:08:51will happen? I'll be definitely using
  16275. 11:08:53chat GPT or any other large language
  16276. 11:08:56model let's say provider and I'll try to
  16277. 11:08:59generate that content. Okay. And uh what
  16278. 11:09:02I will do, I will uh um copy that and I
  16279. 11:09:05will post on my Facebook. Okay. But it's
  16280. 11:09:08not like that. At the very first time,
  16281. 11:09:11you will be getting the perfect post,
  16282. 11:09:12right? Let's say you have given a prompt
  16283. 11:09:15uh and it has generated something for
  16284. 11:09:17the first uh time, right? It's not like
  16285. 11:09:19that that should be 100% uh perfect and
  16286. 11:09:22optimized for for you for your needs. So
  16287. 11:09:26maybe you just need to do some little
  16288. 11:09:27bit let's say change or you need some
  16289. 11:09:31improvement you need some optimization.
  16290. 11:09:33So again what you will do you will you
  16291. 11:09:35will send it to the LLM and you will try
  16292. 11:09:37to tell okay try to optimize it more.
  16293. 11:09:40Okay. So once you have let's say
  16294. 11:09:42optimized another one again you will try
  16295. 11:09:44to review that evaluate that if it is uh
  16296. 11:09:46perfect for you then you will try to
  16297. 11:09:48approve and you will post it over the
  16298. 11:09:50Facebook. Okay. Otherwise you will uh
  16299. 11:09:51again uh do the optimization. Okay. So
  16300. 11:09:54that's how let's say we usually generate
  16301. 11:09:57any kinds of content from the LLM right.
  16302. 11:09:59So why not we can uh create a automatic
  16303. 11:10:01workflow. So this workflow will
  16304. 11:10:03automatically generate u let's say u
  16305. 11:10:06Facebook content u based on the topic
  16306. 11:10:09you have provided. Then after that it
  16307. 11:10:11will automatically evaluate that whether
  16308. 11:10:13this content is perfect or not. Okay.
  16309. 11:10:15Let's say after doing the evaluation it
  16310. 11:10:17found okay this is uh useful this is
  16311. 11:10:19fine then it will approve. then you can
  16312. 11:10:22post over the Facebook otherwise it will
  16313. 11:10:24send it send it to the another let's say
  16314. 11:10:26nodes and that nodes will try to do the
  16315. 11:10:30optimization okay optimization it will
  16316. 11:10:32optimize
  16317. 11:10:34like um uh it will do some improvement
  16318. 11:10:37then after that um again it will try to
  16319. 11:10:40send it to the evaluator okay evaluate
  16320. 11:10:42will again evaluate that if found let's
  16321. 11:10:44say this content is fine then it will
  16322. 11:10:46approve otherwise again it will try to
  16323. 11:10:48send it to the optim optimizer then
  16324. 11:10:50optimizer again it will optimize the
  16325. 11:10:53content and it will again send it for
  16326. 11:10:54the uh evaluation. Okay, so that's how
  16327. 11:10:57this kind this particular loop will
  16328. 11:10:59continuously run unless and until this
  16329. 11:11:01content is approved. Okay, so this is
  16330. 11:11:03called actually iterative workflows. So
  16331. 11:11:05to make iterative workflows guys uh we
  16332. 11:11:08are using um conditional workflows as
  16333. 11:11:10well as you can see because here is the
  16334. 11:11:12condition if uh this content is
  16335. 11:11:15completely fine after doing the
  16336. 11:11:16evaluation it will approve okay
  16337. 11:11:18otherwise it will send it to the
  16338. 11:11:20optimizer and optimizer will u like do
  16339. 11:11:22the improvement and it will again send
  16340. 11:11:24it to evaluator okay so here is the
  16341. 11:11:27looping concept and this looping concept
  16342. 11:11:29we call it as a iterative workflows
  16343. 11:11:31inside lang graph. Now we'll try to
  16344. 11:11:33implement this particular workflows.
  16345. 11:11:34Okay, inside lang graph and for this
  16346. 11:11:36whatever uh uh state I need guys I
  16347. 11:11:39already prepared the state as you can
  16348. 11:11:40see this is the state I named it as post
  16349. 11:11:42state and I inherited with the type
  16350. 11:11:44dict. So first of all I have taken a
  16351. 11:11:46variable called topic. So user will pass
  16352. 11:11:49a topic. Okay for post generation let's
  16353. 11:11:52say I have given a topic related uh
  16354. 11:11:54let's say agentic AI. So it will
  16355. 11:11:55generate some kinds of post related
  16356. 11:11:57agentic AI. Okay. So that uh let's say
  16357. 11:12:00I'll send it to the generate llm. Right
  16358. 11:12:02here we'll be using a llm. Then this uh
  16359. 11:12:06uh this uh llm or let's say this node
  16360. 11:12:08will generate the post. Okay. Let's say
  16361. 11:12:10this post I'm going to save inside this
  16362. 11:12:12post variable. And this is also going to
  16363. 11:12:13be string type data. Then after that
  16364. 11:12:16we'll try to send it to the evaluator.
  16365. 11:12:17Evaluator will also use a llm right
  16366. 11:12:19large language model. And it will
  16367. 11:12:21evaluate that particular result. And it
  16368. 11:12:23will send two things. One is the
  16369. 11:12:25approved another is the needs
  16370. 11:12:27improvement. Okay. If it is sending uh
  16371. 11:12:29returning approved that that means this
  16372. 11:12:32post is completely fine we can directly
  16373. 11:12:34approve that and if it is sending needs
  16374. 11:12:36improvement okay that time we'll try to
  16375. 11:12:37send it to the optimizer okay and it
  16376. 11:12:40will also give you some kinds of
  16377. 11:12:41feedback okay let's say what should be
  16378. 11:12:43the improvement it will also send it to
  16379. 11:12:45the optimizer this feedback will try to
  16380. 11:12:47save inside this particular uh variable
  16381. 11:12:50then
  16382. 11:12:51uh we'll also try to see the iteration
  16383. 11:12:54iteration means let's say it has given
  16384. 11:12:56this uh content to to the evaluator.
  16385. 11:12:58Evaluator tells okay uh this needs the
  16386. 11:13:01improvement again it will send it to the
  16387. 11:13:03optimizer. Optimizer will try to again
  16388. 11:13:05generate a new uh or let's say optimize
  16389. 11:13:08that particular post and it will again
  16390. 11:13:10send it to the evaluator. That means one
  16391. 11:13:12iteration is done. Then again it
  16392. 11:13:14evaluator will try to check that again
  16393. 11:13:16let's say it will tell it needs the
  16394. 11:13:18improvement again it will try to send it
  16395. 11:13:19to the optimizer. optimizer again it
  16396. 11:13:21will improve that again we'll center the
  16397. 11:13:23evaluator that that means iteration goes
  16398. 11:13:25to that means how many loop it is
  16399. 11:13:27performing we'll try to log that
  16400. 11:13:29particular informations in this
  16401. 11:13:30iteration variable okay and here we'll
  16402. 11:13:32also set a maximum iteration let's say
  16403. 11:13:36uh if you don't set this maximum
  16404. 11:13:37iteration what what is the possibility
  16405. 11:13:39let's say if you're using any very poor
  16406. 11:13:41large language model that time let's say
  16407. 11:13:43every time whatever content it will
  16408. 11:13:45generate maybe your evaluator will not
  16409. 11:13:48evaluate that or let's say approve
  16410. 11:13:50that time this particular loop will
  16411. 11:13:52continuously running. Okay, we'll not
  16412. 11:13:54get any final result. That's why we'll
  16413. 11:13:56set a maximum iteration let's say four
  16414. 11:13:58to five. So after four or five uh let's
  16415. 11:14:00say iteration this particular loop will
  16416. 11:14:03break and whatever content we got after
  16417. 11:14:05four or five iteration that I will try
  16418. 11:14:07to make it as final post. Okay, that's
  16419. 11:14:09why this maximum iteration will also
  16420. 11:14:10set. Then whatever let's say post we are
  16421. 11:14:13generating whatever feedback we are
  16422. 11:14:16getting okay from this evaluator will
  16423. 11:14:18also try to save inside this particular
  16424. 11:14:20variable as a history that's why we made
  16425. 11:14:22it as post history and feedback history
  16426. 11:14:25that means it will continuously add okay
  16427. 11:14:27it will not replace it will continuously
  16428. 11:14:29add so that that's why we'll be using
  16429. 11:14:30reducer concept I think you know what is
  16430. 11:14:32reducer inside lang graph you can see
  16431. 11:14:34we're using annotated we are we have
  16432. 11:14:36taken a list uh type data structure and
  16433. 11:14:39we're using operation add That means
  16434. 11:14:41every time it will add the post story
  16435. 11:14:43and feedback story instead of replacing
  16436. 11:14:46but here we are we haven't take any
  16437. 11:14:47kinds of reducer it will continuously
  16438. 11:14:49replace here okay I hope you got it then
  16439. 11:14:52uh let's say once this uh uh improvement
  16440. 11:14:55is done evaluator will uh let's say
  16441. 11:14:57found this is useful or this is
  16442. 11:14:59completely fine that time this would be
  16443. 11:15:01approved and this loop would be break
  16444. 11:15:03okay so this is what actually iterative
  16445. 11:15:04workflows now we'll try to um we'll try
  16446. 11:15:07to code inside lang graph then we'll try
  16447. 11:15:09to understand uh the whole concept
  16448. 11:15:10script. Okay. Now for this what I'm
  16449. 11:15:12going to do guys, I'm going to simply
  16450. 11:15:14open up this uh iterative workflows.ipb
  16451. 11:15:17file and let's select our kernel. So
  16452. 11:15:20first of all we have to import the
  16453. 11:15:22necessary library. So let's import.
  16454. 11:15:28So I'll import all of the necessary
  16455. 11:15:30library. So you can see I'm importing
  16456. 11:15:32the state graph start end. Then from
  16457. 11:15:34typing I'm importing type dict literal
  16458. 11:15:37and annotated. Then uh I'm using chat
  16459. 11:15:40openi that means I'll be using openi
  16460. 11:15:42large language model. You can use any
  16461. 11:15:44kinds of large language model. For this
  16462. 11:15:45I have oneb file and I set my open key
  16463. 11:15:48here already. Then uh I'm importing the
  16464. 11:15:51system message and human message. Okay.
  16465. 11:15:53Where we are importing the system
  16466. 11:15:54message and human message because I want
  16467. 11:15:56to give the prompt for each and every
  16468. 11:15:58LLM. See you can see here we'll be using
  16469. 11:16:00the LLM. Here also we'll be using the
  16470. 11:16:02LLM. For optimization also we'll be
  16471. 11:16:04using the LLM. Okay. And every LLM I'll
  16472. 11:16:06try to set a different different prompt.
  16473. 11:16:08Let's say for generation one I will set
  16474. 11:16:10uh generation related prompt. For
  16475. 11:16:12evaluator I'll set evaluation related
  16476. 11:16:14prompt. For optimization I'll set
  16477. 11:16:16optimization related prompt. Okay. So
  16478. 11:16:18you can directly give the prompt as well
  16479. 11:16:20but it is recommended to use this system
  16480. 11:16:22message and human message function
  16481. 11:16:24whenever you are giving the prompt.
  16482. 11:16:25Okay. This should be more optimized one.
  16483. 11:16:27Then operator I need because I want to
  16484. 11:16:29perform the reducer. I have to do the
  16485. 11:16:30adding operation. Then env. So let's
  16486. 11:16:33import all of them.
  16487. 11:16:39So as you can see execution is complete.
  16488. 11:16:41Now we'll load our environment variable.
  16489. 11:16:46Now uh we'll define all the large
  16490. 11:16:49language model. So here you can see
  16491. 11:16:54um yeah so I need uh three large
  16492. 11:16:57language model. One is for generation,
  16493. 11:16:59one is for evaluator, one is for
  16494. 11:17:01optimization. Okay. So what I'm going to
  16495. 11:17:03do I'm going to make three object
  16496. 11:17:06for three large language model. Uh see
  16497. 11:17:09I'm going to use the same model only but
  16498. 11:17:11I'm going to create uh three object.
  16499. 11:17:13Okay because here I told you we'll be
  16500. 11:17:15using three no three nodes okay
  16501. 11:17:17differently. So whenever you are
  16502. 11:17:18creating this kinds of project uh let's
  16503. 11:17:20say uh in real time actual real project
  16504. 11:17:23that time you have to select this large
  16505. 11:17:25language model in such a way. So let's
  16506. 11:17:27say whatever model is very good for
  16507. 11:17:30generation that time you can use that
  16508. 11:17:32particular model. Let's say some model
  16509. 11:17:34is very much good for evaluation that
  16510. 11:17:36time you can take that particular model.
  16511. 11:17:38Let's say some model is very much good
  16512. 11:17:40for optimization you can take that
  16513. 11:17:42particular model. Okay. So that's how we
  16514. 11:17:43have to select in real time. But right
  16515. 11:17:45now we are only understanding the
  16516. 11:17:47example that's why I have taken the same
  16517. 11:17:49model but I created three object. Okay.
  16518. 11:17:51One is for generator, evaluator and
  16519. 11:17:52optimizer. Generator, evaluator and
  16520. 11:17:54optimizer. Done. Now next uh I'm going
  16521. 11:17:58to
  16522. 11:18:00uh I'm going to define the state. But
  16523. 11:18:02before define the state I already told
  16524. 11:18:04you uh here see this evaluator this
  16525. 11:18:08evaluator nodes will return you two
  16526. 11:18:11things. Okay one is the evaluation. Okay
  16527. 11:18:14evaluation uh that means it should be
  16528. 11:18:17approved or needs improvement. Okay
  16529. 11:18:20these two things and another one is the
  16530. 11:18:23feedback. Okay, what should be the
  16531. 11:18:24feedback for the optimization, right?
  16532. 11:18:26So, it will generate two things. I don't
  16533. 11:18:29need anything anything else apart from
  16534. 11:18:31these two two things. One is the
  16535. 11:18:33evaluation and another one is the
  16536. 11:18:34feedback. So, if I want to get this kind
  16537. 11:18:36of structured output, what I have to do?
  16538. 11:18:38I have to use the pidentic. I already
  16539. 11:18:39told you previously I also uh I have
  16540. 11:18:42also taken the same example. So, what
  16541. 11:18:44I'm going to do guys, I'm going to just
  16542. 11:18:46create a
  16543. 11:18:48um pyic class. As you can see, I have
  16544. 11:18:50created a pyic class. So here uh I have
  16545. 11:18:53named it as post evaluation I'm
  16546. 11:18:54inheriting with the pidentic based model
  16547. 11:18:57and two things I have taken evaluation
  16548. 11:18:59and feedback. So in evaluation you can
  16549. 11:19:01see this is the literal type it should
  16550. 11:19:03be approved or need needs approved okay
  16551. 11:19:06needs improvement and another one is the
  16552. 11:19:08feedback that means it will generate
  16553. 11:19:09some kinds of feedback for Facebook post
  16554. 11:19:12that means if I now pass this thing to
  16555. 11:19:14the u model that means if I add this
  16556. 11:19:17line uh evaluator lm with structured
  16557. 11:19:21output and if I pass this class this
  16558. 11:19:23model will try to generate the
  16559. 11:19:24structured output now so it will only
  16560. 11:19:26give you evaluation and feedback not
  16561. 11:19:28anything else okay now let Let me show
  16562. 11:19:30you. So let's say I have defined this
  16563. 11:19:32one.
  16564. 11:19:34Now here I'm going to just generate a
  16565. 11:19:37Facebook post from my chart GPT.
  16566. 11:19:51Facebook post
  16567. 11:19:56about
  16568. 11:20:03presentic AI.
  16569. 11:20:11Okay, I'll copy this and uh let's say
  16570. 11:20:15here
  16571. 11:20:17I can take a variable post.
  16572. 11:20:32Now inside that I'm going to paste this
  16573. 11:20:34post.
  16574. 11:20:39Okay. Now I'm going to send it to the
  16575. 11:20:44the structured evaluation.
  16576. 11:21:04Done. Now if I show you the result.
  16577. 11:21:07See this is giving you two things. One
  16578. 11:21:08is the evaluation. You can also extract
  16579. 11:21:11evaluation
  16580. 11:21:13approved and the feedback.
  16581. 11:21:19See this is the feedback for this
  16582. 11:21:21particular post. Okay. So that's how
  16583. 11:21:22every time we'll be getting this
  16584. 11:21:24structured output from this uh large
  16585. 11:21:27language model. Okay. The evaluated
  16586. 11:21:29large language model because we have
  16587. 11:21:30used pyic um um uh data evaluation for
  16588. 11:21:34that. Now what I'm going to do guys next
  16589. 11:21:37I'm going to define the state. I'm going
  16590. 11:21:39to define the same state I have taken
  16591. 11:21:40here. Um
  16592. 11:21:43this is my state as you can see topic
  16593. 11:21:46post evaluation feedback iteration max
  16594. 11:21:49iteration post history and feedback
  16595. 11:21:50history. So here I have uh added the
  16596. 11:21:53reducer concept. So every time I'll try
  16597. 11:21:55to add this uh two information instead
  16598. 11:21:57of replacing. And these are the things I
  16599. 11:21:59think you already got it right. Yeah.
  16600. 11:22:04H and why I've taken literal here
  16601. 11:22:06because evaluation will only return two
  16602. 11:22:07things approved or need needs
  16603. 11:22:09approvement. Okay, these two category
  16604. 11:22:10that's why I've taken literal type
  16605. 11:22:12instead of string.
  16606. 11:22:15So now I will um I will um add my nodes.
  16607. 11:22:20Let's define the graph and add the
  16608. 11:22:22nodes.
  16609. 11:22:26Yeah. So I have already defined the
  16610. 11:22:28graph. You can see state graph. I have
  16611. 11:22:30given this post state here. Now I'll add
  16612. 11:22:32the node.
  16613. 11:22:35Add
  16614. 11:22:37node.
  16615. 11:22:39So how many nodes we are having? 1 2 3.
  16616. 11:22:44Okay. Three nodes we are having. We'll
  16617. 11:22:46add this three node all together.
  16618. 11:22:50Yeah. So these are three nodes. Generate
  16619. 11:22:53post, evaluate post and optimize post.
  16620. 11:22:57Okay. Generate, evaluate and optimize.
  16621. 11:22:59Now we'll write this function one by
  16622. 11:23:01one. So first of all we'll just try to
  16623. 11:23:04write this generate post function note.
  16624. 11:23:12So this is the function guys I've
  16625. 11:23:14already written as you can see uh
  16626. 11:23:16generate post it will take the state and
  16627. 11:23:18here is the prompt I have prepared. It's
  16628. 11:23:20a detail prompt I created with the help
  16629. 11:23:22of chart GPT and here we are using the
  16630. 11:23:24system message and human message
  16631. 11:23:26function whatever I have imported from
  16632. 11:23:28here. Okay. So as you can see this is
  16633. 11:23:30the prompt. So system message I've given
  16634. 11:23:32you are a funny and clever Facebook in
  16635. 11:23:35influencer and human message write a
  16636. 11:23:38short original and hilarious Facebook
  16637. 11:23:40post on the topic whatever topic user
  16638. 11:23:43will give and here I have assigned some
  16639. 11:23:45rules do not use a question answer
  16640. 11:23:47format maximum
  16641. 11:23:49500 characters okay and blah blah blah
  16642. 11:23:51these are the things I have added now
  16643. 11:23:53after that I'm just uh invoking my
  16644. 11:23:55generator lm and whatever content I'm
  16645. 11:23:57getting I'm just updating the response
  16646. 11:23:59inside the post and post history I am
  16647. 11:24:02also updating because simultaneously
  16648. 11:24:04update two things one is the post and
  16649. 11:24:06this is the post history both I will
  16650. 11:24:07update right so here it will replace
  16651. 11:24:09every time here it will add every time
  16652. 11:24:11because here we're using reducer concept
  16653. 11:24:13and we are returning this particular
  16654. 11:24:14state okay instead of returning whole
  16655. 11:24:16state we are only returning the state we
  16656. 11:24:18are changing so this is our uh generate
  16657. 11:24:21post um nodes we have created that means
  16658. 11:24:23this node is complete now let's try to
  16659. 11:24:25add the evaluator one
  16660. 11:24:28generate is done now we'll try to create
  16661. 11:24:29the evaluator one.
  16662. 11:24:33So this is the evaluator one guys. Again
  16663. 11:24:35um I named it as evaluate post and
  16664. 11:24:38sending this state. And here is the
  16665. 11:24:39prompt guys I have prepared. Again I
  16666. 11:24:41have given a sim uh system prompt. So
  16667. 11:24:43this is the system prompt I have given.
  16668. 11:24:45Okay. Now this is the human prompt.
  16669. 11:24:47Evaluate the following Facebook post. Uh
  16670. 11:24:49we have given the post from the state
  16671. 11:24:51and here are some criteria I have given.
  16672. 11:24:54Based on that it will try to evaluate
  16673. 11:24:55and it will return two things. One is
  16674. 11:24:57the evaluation approved or need
  16675. 11:24:58improvements. Another one is the
  16676. 11:25:00feedback. Then we are uh invoking our
  16677. 11:25:03structured evaluator LLM that means this
  16678. 11:25:05one. Okay, this one we are invoking this
  16679. 11:25:08one instead of uh this one because here
  16680. 11:25:12we have added the pentic class for the
  16681. 11:25:13structured output.
  16682. 11:25:17See and whatever evaluation result we
  16683. 11:25:18are getting we are sending uh saving to
  16684. 11:25:20the evaluator state evaluation state and
  16685. 11:25:23feedback also uh I'm saving inside
  16686. 11:25:26feedback and I'm also saving the
  16687. 11:25:27feedback history because feedback
  16688. 11:25:29history should be also updated. Okay.
  16689. 11:25:32Yeah. So once it is done uh we are also
  16690. 11:25:35returning the state. Now let's
  16691. 11:25:38execute.
  16692. 11:25:40Done. Now we'll try to create the last
  16693. 11:25:42one which is optimize post.
  16694. 11:25:48So this is for the optimize post. Again
  16695. 11:25:50we are passing the state and here is the
  16696. 11:25:52prompt you are a punch uh a Facebook
  16697. 11:25:55post or virality and humor based on the
  16698. 11:25:59given feedback. Then here is the human
  16699. 11:26:02prompt I have given improve the Facebook
  16700. 11:26:03post based on this feedback. We are
  16701. 11:26:06giving the feedback. We're giving the
  16702. 11:26:07topic as well as the original post. it
  16703. 11:26:10uh my model has generated okay so based
  16704. 11:26:13on the original post based on the
  16705. 11:26:14feedback based on the topic it will
  16706. 11:26:16optimize that uh post okay and it will
  16707. 11:26:20rewrite that particular post and it will
  16708. 11:26:21give it to you for this I'm hitting this
  16709. 11:26:24uh optimizer lm and getting the response
  16710. 11:26:27and we are updating the iteration here
  16711. 11:26:29see here here we are updating the
  16712. 11:26:30iteration like how many iteration it has
  16713. 11:26:33to perform to give the final or let's
  16714. 11:26:36say uh optimized version of the post
  16715. 11:26:38okay every time this loop loop will
  16716. 11:26:40execute and once let's say it found okay
  16717. 11:26:43now this post is completely fine that
  16718. 11:26:45time it will approve otherwise this loop
  16719. 11:26:47would be continuously um running and how
  16720. 11:26:50many times it will run for this we are
  16721. 11:26:52just logging this iteration we are just
  16722. 11:26:54adding one okay so this iteration value
  16723. 11:26:57I'll give initially one okay u whenever
  16724. 11:27:00I'll create the initial state and every
  16725. 11:27:02time it will add the one how many time
  16726. 11:27:03it will execute okay after that we are
  16727. 11:27:06just returning the uh response okay that
  16728. 11:27:09means the final post
  16729. 11:27:11then the iteration okay then we are also
  16730. 11:27:15uh saving this inside the post history
  16731. 11:27:17and we are returning the state done guys
  16732. 11:27:20okay now all of the nodes we have
  16733. 11:27:23created successfully now we have to
  16734. 11:27:25define the edge connection now let's do
  16735. 11:27:27that so here I'll just try to comment
  16736. 11:27:30add edges so first of all here we have
  16737. 11:27:32to add the edges for
  16738. 11:27:36this um
  16739. 11:27:38start to generate
  16740. 11:27:40Let's define
  16741. 11:27:44start to generate.
  16742. 11:27:46Then we have to define generate to
  16743. 11:27:48evaluate.
  16744. 11:27:53Generate to evaluate. Okay. Now here
  16745. 11:27:56conditional ages will come because
  16746. 11:27:58evaluate either it will send it to the
  16747. 11:28:01approved. Okay. It will directly uh to
  16748. 11:28:04the approved otherwise it will send it
  16749. 11:28:06to the optimizer. Right? optimization.
  16750. 11:28:08So here we'll be using using the
  16751. 11:28:10conditional edges. So let's use the
  16752. 11:28:13conditional edges here.
  16753. 11:28:16So here we're using conditional edges.
  16754. 11:28:18So it will start from evaluate and
  16755. 11:28:20evaluate will decide where to send
  16756. 11:28:22whether it will approved or send it to
  16757. 11:28:24the optimize. For this we have to write
  16758. 11:28:26a conditional function. I think remember
  16759. 11:28:29for conditional statement we write a
  16760. 11:28:30conditional function separately. So this
  16761. 11:28:33is the conditional function. So it will
  16762. 11:28:36take the state and here we are checking
  16763. 11:28:37the condition if my evaluation okay that
  16764. 11:28:40means I already saved this evaluation
  16765. 11:28:42inside my state right you remember right
  16766. 11:28:44evaluation and what is the evaluation
  16767. 11:28:46approved or needs improvement okay so
  16768. 11:28:49here we are checking if this state is
  16769. 11:28:51equal to uh state evaluation is equal to
  16770. 11:28:52is equal to approved or state iteration
  16771. 11:28:55is greater than equal state max
  16772. 11:28:57iteration that means if let's say it has
  16773. 11:28:59performed maximum iteration let's say we
  16774. 11:29:01have given maximum iteration is equal to
  16775. 11:29:02four let's say four time it has done the
  16776. 11:29:05iteration and uh uh whenever it is
  16777. 11:29:08running for the five time that time I
  16778. 11:29:11think our condition is matching right
  16779. 11:29:13because my highest uh highest iteration
  16780. 11:29:16is maximum iteration is four but
  16781. 11:29:17whenever it is going for five that means
  16782. 11:29:19this particular loop will break right so
  16783. 11:29:21that's how we are checking another
  16784. 11:29:22condition if this iteration is equal to
  16785. 11:29:25it is greater greater than equal to
  16786. 11:29:26maximum iteration that time just return
  16787. 11:29:28approved okay otherwise return needs
  16788. 11:29:31approved so this will basically redirect
  16789. 11:29:34take this particular route whether it
  16790. 11:29:35will send it to the optimizer or for the
  16791. 11:29:38approver.
  16792. 11:29:39Now we'll try to define this uh method
  16793. 11:29:41here
  16794. 11:29:43route evaluation.
  16795. 11:29:45Route evaluation we'll write it here
  16796. 11:29:48route evaluation. Okay
  16797. 11:29:51H now here we'll be adding the
  16798. 11:29:55iteration. Okay this that means the
  16799. 11:29:56iterative workflows right now. Now now
  16800. 11:29:58what will happen? See, let's say this
  16801. 11:30:01evaluator returns approved. That means
  16802. 11:30:04this particular workflow will exit here
  16803. 11:30:06because I got my final post. But if it
  16804. 11:30:09doesn't got the approved, let's say it
  16805. 11:30:12it sends needs improvement that time
  16806. 11:30:14what will happen? It will send it to the
  16807. 11:30:17optimizer. Okay, it will send it to the
  16808. 11:30:19optimizer node and optimizer will
  16809. 11:30:20optimize then again it will send it to
  16810. 11:30:22the evaluation. So these kinds of things
  16811. 11:30:23if you want to write you have to give
  16812. 11:30:25this statement inside conditional
  16813. 11:30:27workflow only you have to write this you
  16814. 11:30:30have to write this additional line see
  16815. 11:30:33okay double comma I have given yeah now
  16816. 11:30:35I think you can get see once this route
  16817. 11:30:39evaluation returns approved okay that
  16818. 11:30:42means it will end that particular
  16819. 11:30:44workflow but if it return needs
  16820. 11:30:46improvement that time it will execute
  16821. 11:30:49the optimize node
  16822. 11:30:51this optimize node
  16823. 11:30:53Okay, optimize node. See, it is
  16824. 11:30:55redirecting from here. If it needs
  16825. 11:30:57improvement, it will hit the optimize
  16826. 11:30:59node. Otherwise, it will hit the end
  16827. 11:31:01note. See that? That is what we are
  16828. 11:31:02doing. And this is called actually your
  16829. 11:31:04iterative workflows. So, here we are
  16830. 11:31:06adding the iteration. Okay, this is
  16831. 11:31:08called actually iteration. I hope you
  16832. 11:31:10got it guys. You don't need to take any
  16833. 11:31:12kinds of separate function for this.
  16834. 11:31:13Inside conditional is only you have to
  16835. 11:31:15only write this statement. Okay, that
  16836. 11:31:17means this route evaluation if it is
  16837. 11:31:19returned the approved it will go to the
  16838. 11:31:21end otherwise if it returns needs
  16839. 11:31:24improvement it will um execute my
  16840. 11:31:26optimize node and how many time it will
  16841. 11:31:29perform unless and until we're not
  16842. 11:31:31getting approved okay approved from my
  16843. 11:31:34evaluator or this maximum iteration ends
  16844. 11:31:37okay I hope you got it now our age
  16845. 11:31:40connection is also done now simply what
  16846. 11:31:42I'm going to do I'm going to
  16847. 11:31:44um see this connection is
  16848. 11:31:47this connection and uh this connection
  16849. 11:31:49is done. Uh optimize to
  16850. 11:31:54uh evaluate. Huh. So this connection is
  16851. 11:31:56done. Now we'll try to make this
  16852. 11:31:58connection. Optimize to evaluate. So
  16853. 11:32:00let's say once it is in the optimize. So
  16854. 11:32:04optimize will try to connect to the
  16855. 11:32:05evaluator. That means optimize will send
  16856. 11:32:07this optimization result to the
  16857. 11:32:09evaluator. So this connection will try
  16858. 11:32:10to add. So this is the connection.
  16859. 11:32:17This is the connection. Okay. Optimize
  16860. 11:32:18to evaluator.
  16861. 11:32:20Now we'll try to compile.
  16862. 11:32:26Okay. Now we'll try we'll show you the
  16863. 11:32:28workflow.
  16864. 11:32:30So see this is the workflow. Now this
  16865. 11:32:32workflow and this workflow is exactly
  16866. 11:32:34same. You can check it here. Okay. Now
  16867. 11:32:36we'll try to execute this workflow. For
  16868. 11:32:39this let's u define uh
  16869. 11:32:44state
  16870. 11:32:50let's say I have given the topic
  16871. 11:32:53agentic AI let's say this is our topic
  16872. 11:32:57and iteration initially I have sent it I
  16873. 11:32:59have set it to the one because after
  16874. 11:33:01that it will every time update um it
  16875. 11:33:04will every time update one okay so uh
  16876. 11:33:07whenever it needs any kinds of
  16877. 11:33:09improvement optimization it will add
  16878. 11:33:10one. Okay, that means the iteration
  16879. 11:33:13update and this is our maximum
  16880. 11:33:15iteration. I want to uh perform this
  16881. 11:33:18iteration maximum five time. Okay, if it
  16882. 11:33:21is not found in five time that means
  16883. 11:33:23this loop will execute. Then we are
  16884. 11:33:25giving this uh initial state to my
  16885. 11:33:27workflow and we are getting the result.
  16886. 11:33:29Now let me execute.
  16887. 11:33:40Done. Now if I show you my result.
  16888. 11:33:44So see this is the result we are
  16889. 11:33:45getting. Uh as you can see
  16890. 11:33:49uh this is the topic and this is the
  16891. 11:33:51post it has generated. Evaluation is uh
  16892. 11:33:54okay evaluation return approved. See at
  16893. 11:33:57the first iteration it it got approved.
  16894. 11:33:59Okay. Then feedback. This is the
  16895. 11:34:01feedback and uh you can see iteration is
  16896. 11:34:05one. That means it didn't updated any
  16897. 11:34:07iteration. That means at the first time
  16898. 11:34:08only it has approved. This is our
  16899. 11:34:11maximum iteration and this is the post
  16900. 11:34:13history and this is the feedback
  16901. 11:34:14history. Okay. Now maybe you can change
  16902. 11:34:17to another topic. Let's say I'll give uh
  16903. 11:34:20LLM.
  16904. 11:34:21See here we are using openm right?
  16905. 11:34:23That's why this LLM is very powerful. Uh
  16906. 11:34:26at the very first time it is generating
  16907. 11:34:27good post. Okay. That's why it is
  16908. 11:34:29getting approved. Okay. In the first
  16909. 11:34:30iteration only. Now let me give any
  16910. 11:34:32other topic or random topic and see the
  16911. 11:34:35output. So maybe okay
  16912. 11:34:46I'll give any random topic and let's see
  16913. 11:34:55still uh at the first time only it is uh
  16914. 11:34:58approving okay it's completely fine you
  16915. 11:35:00can maybe try with different different
  16916. 11:35:02topic okay and you will able to see that
  16917. 11:35:04whenever it needs any kinds of improve
  16918. 11:35:06improvement. Okay. Um it will run this
  16919. 11:35:09iteration and it will update. Okay. And
  16920. 11:35:12again it will send it to the optimizer.
  16921. 11:35:14The reason uh it is giving you one short
  16922. 11:35:17uh approval because we're using this
  16923. 11:35:19open AAI uh GPTO mini and this is uh
  16924. 11:35:22like good model. Maybe you can use any
  16925. 11:35:25weaker model. Okay. Like more weaker
  16926. 11:35:26model, more poor model. That time I
  16927. 11:35:28think this uh loop will uh run. Okay.
  16928. 11:35:31Iteration will run because we're using
  16929. 11:35:33good model. That's why we are getting
  16930. 11:35:34the result at the very first time. Okay.
  16931. 11:35:36Okay, I hope you got it. Now, if you
  16932. 11:35:37want to see the post history separately,
  16933. 11:35:39you can also just write a loop and uh
  16934. 11:35:43from the result you can extract the post
  16935. 11:35:45history and you can see all of the post
  16936. 11:35:46history you are getting. Okay, you can
  16937. 11:35:49also see the feedback history. This is
  16938. 11:35:50also possible. Okay, anything you can
  16939. 11:35:52extract because you are getting all the
  16940. 11:35:54object here. Okay, so yes guys, that's
  16941. 11:35:57how we can write this uh iterative
  16942. 11:35:59workflows inside Langraph and this is
  16943. 11:36:01super useful. Trust me whenever you will
  16944. 11:36:03be implementing uh actual AI agents so
  16945. 11:36:05this concept you need okay without that
  16946. 11:36:08uh you can't perform this continuous u
  16947. 11:36:11looping operation and you need uh to
  16948. 11:36:13create a workflow I need this kinds of
  16949. 11:36:14looping I need this kinds of conditional
  16950. 11:36:16statement parallel statement okay each
  16951. 11:36:18and everything is required now we have
  16952. 11:36:20understood the last workflows inside
  16953. 11:36:22langraph now uh in the next video onward
  16954. 11:36:25guys we'll try to start working on the
  16955. 11:36:27project so guys as you know I have
  16956. 11:36:29started a complete agenti playlist on my
  16957. 11:36:32YouTube channel and so far we have
  16958. 11:36:34completed um uh so many important topic
  16959. 11:36:37uh in this playlist. So if I show you my
  16960. 11:36:40playlist guys, as you can see I started
  16961. 11:36:43from introduction. I have already
  16962. 11:36:45discussed about the uh evaluation from
  16963. 11:36:48LLM to uh aentki how aentki came. We
  16964. 11:36:52already understood about the entire
  16965. 11:36:54aentki concept how agentic system works.
  16966. 11:36:57Then I told you about asynchronous
  16967. 11:36:59programming pentic. Okay. We also saw
  16968. 11:37:02how we can implement AI agents with the
  16969. 11:37:04help of langen. Okay. Then we started
  16970. 11:37:06our first orchestration uh framework for
  16971. 11:37:09AI agents implementation which is
  16972. 11:37:11langraph. Uh even we also understood
  16973. 11:37:13this langraph u um each and every
  16974. 11:37:16component in detail with the code
  16975. 11:37:18implementation as well. Now what I'm
  16976. 11:37:21planning for guys I'm planning for the
  16977. 11:37:23uh practical development of uh project.
  16978. 11:37:26So what I'm going to do uh I'm going to
  16979. 11:37:28start implementing a agentic uh chatbot
  16980. 11:37:31from this video onward. So first of all
  16981. 11:37:33let's try to understand uh each and
  16982. 11:37:35every component in detail. Um we'll try
  16983. 11:37:38to explain the things in detail because
  16984. 11:37:40if you want to uh create a aentic
  16985. 11:37:42chatbot so for this you need lots of
  16986. 11:37:44component like you need uh tools, you
  16987. 11:37:47need memory, you need persistence, you
  16988. 11:37:49need streaming, you need user interface.
  16989. 11:37:51Okay, there are so many things you have
  16990. 11:37:53to implement uh independently then you
  16991. 11:37:55will be combining them all together then
  16992. 11:37:58one agentic chatbot would be ready.
  16993. 11:38:00Okay. And if you found my content useful
  16994. 11:38:02guys, please try to subscribe to my
  16995. 11:38:04channel and hit the like and please try
  16996. 11:38:05to share it with your friends and
  16997. 11:38:07family. So, uh first of all, let's try
  16998. 11:38:09to understand uh in this agentic chatbot
  16999. 11:38:12whatever component we're going to
  17000. 11:38:13implement. So, guys, first of all, let's
  17001. 11:38:16discuss our plan like how we'll be
  17002. 11:38:18implementing this entire agentic
  17003. 11:38:20chatbot. So, the entire agentic chatbot
  17004. 11:38:23I'll be implementing with the help of
  17005. 11:38:26langraph.
  17006. 11:38:28Okay, we'll be using Langraph
  17007. 11:38:31orchestration framework to implement the
  17008. 11:38:32entire agentic chatbot because uh this
  17009. 11:38:36project is the part of our langraph uh
  17010. 11:38:38orchestration framework in our playlist.
  17011. 11:38:42So in this video first of all I'm going
  17012. 11:38:44to create a simple
  17013. 11:38:48simple chatbot
  17014. 11:38:51workflow.
  17015. 11:38:53Okay, we'll try to create a simple
  17016. 11:38:55chatbot workflow.
  17017. 11:38:57uh then we'll try to um make this
  17018. 11:39:00agentic chatbot like more advanced. Uh
  17019. 11:39:04we'll try to add some more advanced
  17020. 11:39:06component in this particular agentic
  17021. 11:39:07chatbot and with the help of that we'll
  17022. 11:39:10be learning all of the langraph core
  17023. 11:39:14component. Okay. So whenever let's say
  17024. 11:39:16you want to implement this kinds of
  17025. 11:39:18project whatever component you need from
  17026. 11:39:21the langraph you will be understanding
  17027. 11:39:23each and every component. Okay. So
  17028. 11:39:25that's why I made this particular
  17029. 11:39:27implementation like a series okay series
  17030. 11:39:29of video. So next in the next video I'm
  17031. 11:39:32going to show you the persistence
  17032. 11:39:35concept
  17033. 11:39:37like what is persistent
  17034. 11:39:39okay persistence
  17035. 11:39:42and uh why it is required why uh
  17036. 11:39:44persistence uh we have to add inside our
  17037. 11:39:47agentic chatbot we'll try to understand.
  17038. 11:39:50So persistence in line graph.
  17039. 11:39:54Okay. Then we'll try to understand
  17040. 11:39:58um how to
  17041. 11:40:02how to add
  17042. 11:40:05streaming feature.
  17043. 11:40:08Okay. Streaming feature to our chatbot.
  17044. 11:40:12Then we'll try to understand the concept
  17045. 11:40:16of
  17046. 11:40:17um resume chat.
  17047. 11:40:22Okay. How we can resume any kinds of
  17048. 11:40:24chat inside our chatbot. Then we'll try
  17049. 11:40:28to see the database integration.
  17050. 11:40:33Okay.
  17051. 11:40:34Integration
  17052. 11:40:37in our chatbot.
  17053. 11:40:39Then we'll try to see how we can
  17054. 11:40:42implement
  17055. 11:40:44uh user interface. Okay, let's say
  17056. 11:40:48chatbot
  17057. 11:40:51UI. Okay, we'll try to also implement
  17058. 11:40:53this. Then uh after that I will also
  17059. 11:40:56show you
  17060. 11:40:58how to
  17061. 11:41:00add the tools.
  17062. 11:41:05Okay tools inline graph
  17063. 11:41:12then we'll try to understand um the
  17064. 11:41:15observability okay observability
  17065. 11:41:23uh so in observability we'll try to see
  17066. 11:41:25how we can integrate lang
  17067. 11:41:28okay langmith to our agent so I think
  17068. 11:41:32you have already heard of about lang
  17069. 11:41:34langismith is observability tool. Uh
  17070. 11:41:37with the help of that we can monitor the
  17071. 11:41:39entire application. Okay. Uh what is the
  17072. 11:41:41flow of the application? Uh when it is
  17073. 11:41:43executing uh what component each and
  17074. 11:41:46everything we can track okay in this
  17075. 11:41:47particular lang lang smmith we'll also
  17076. 11:41:49try to see how we can use the langismith
  17077. 11:41:51here. Then after that we'll see the
  17078. 11:41:55um RG concept okay how we can integrate
  17079. 11:41:59the rag features inside our agentic
  17080. 11:42:01chatbot because uh if you have already
  17081. 11:42:03used this kinds of agentic uh system you
  17082. 11:42:06know that it will also work with your
  17083. 11:42:08documents let's say you can upload your
  17084. 11:42:09documents and you can uh do the chat
  17085. 11:42:12operation on on top of your entire
  17086. 11:42:13documents okay this is called RG concept
  17087. 11:42:15so the rag means retrieval augmented
  17088. 11:42:17generation so we'll also try to
  17089. 11:42:19understand this thing then we'll
  17090. 11:42:21understand this uh
  17091. 11:42:24hi TL that means human in loop concept
  17092. 11:42:28then we'll also understand the
  17093. 11:42:30short-term
  17094. 11:42:32okay short-term and
  17095. 11:42:36long-term memory concept as well
  17096. 11:42:40okay memory so yes uh this is the entire
  17097. 11:42:43plan guys so in this video first of all
  17098. 11:42:45let's try to uh implement the simple
  17099. 11:42:48chatbot workflow with the help of lang
  17100. 11:42:50graph
  17101. 11:42:51uh then from the next video onward I'm
  17102. 11:42:53going to discuss these are the concept
  17103. 11:42:54as well. So guys uh let's try to
  17104. 11:42:57implement our chatbot workflow. So if
  17105. 11:43:00you want to implement any kinds of uh
  17106. 11:43:03agentic chatbot uh first of all you have
  17107. 11:43:05to implement the uh chatbot workflow and
  17108. 11:43:09how chat uh chatbot workflow works I
  17109. 11:43:11think you already know that um so let's
  17110. 11:43:14say if I want to uh implement with the
  17111. 11:43:16help of lang graph. So how many node I
  17112. 11:43:18have to take I have to take only one
  17113. 11:43:20node which would be chat node. So here
  17114. 11:43:22user will pass some message okay any
  17115. 11:43:25kinds of message and uh it will go to
  17116. 11:43:27the chat node and chat node will try to
  17117. 11:43:29return something okay so this is a
  17118. 11:43:31simple chat operations we'll be doing
  17119. 11:43:33here and to run this particular uh graph
  17120. 11:43:36actually we need a state and uh for this
  17121. 11:43:39particular chatbot what would be the
  17122. 11:43:40important state important state would be
  17123. 11:43:42the message okay uh let's say the
  17124. 11:43:44message user is passing let's say hi my
  17125. 11:43:46name is BP so this message should be
  17126. 11:43:48saved right and uh let's say your bot
  17127. 11:43:52has replied uh welcome bi okay and how I
  17128. 11:43:55can help you today. So these kinds of
  17129. 11:43:57message would be also saved uh inside
  17130. 11:43:59this particular state right. So for this
  17131. 11:44:01uh what I have done guys, I have taken
  17132. 11:44:03this um uh this particular state and
  17133. 11:44:07here we are using the reducer concept.
  17134. 11:44:09Okay, here we'll be using the reducer
  17135. 11:44:10concept otherwise what will happen every
  17136. 11:44:13time uh this uh state would be replaced
  17137. 11:44:16with the new message. So I don't want
  17138. 11:44:18that. I want to save all of the
  17139. 11:44:20conversation story inside this
  17140. 11:44:22particular state. Okay. And uh now you
  17141. 11:44:24can ask me why we haven't taken string
  17142. 11:44:27type data here because messages string
  17143. 11:44:29type data. uh because I already told you
  17144. 11:44:31here this is a conversational story and
  17145. 11:44:34uh in langraph actually this is
  17146. 11:44:36recommended whenever you are creating
  17147. 11:44:37this kinds of uh chatbot you have to
  17148. 11:44:40take this function this is a u uh like
  17149. 11:44:42langraph function we have to import from
  17150. 11:44:44the langraph called add messages in uh
  17151. 11:44:48uh basically this add messages will try
  17152. 11:44:49to handle this kinds of scenario it will
  17153. 11:44:52take all of the conversation story the
  17154. 11:44:53user message as well as the replied
  17155. 11:44:56message and it will stored in this
  17156. 11:44:57particular state okay and this state
  17157. 11:44:59will go to the chat node. I hope you
  17158. 11:45:01clear. Okay. So once we have built this
  17159. 11:45:03uh uh workflow, the simple chatbot
  17160. 11:45:06workflow, then we'll try to make it more
  17161. 11:45:08advanced. We'll try to make this
  17162. 11:45:11particular workflow uh as agentic
  17163. 11:45:14chatbot workflow. Okay. So for this what
  17164. 11:45:16we'll try to add guys uh we'll try to
  17165. 11:45:18add uh see as of now in this particular
  17166. 11:45:20workflow you can perform the simple chat
  17167. 11:45:23operation.
  17168. 11:45:25In this workflow you can perform simple
  17169. 11:45:29chat operation. Okay. After that we'll
  17170. 11:45:31try to add the rag functionality. That
  17171. 11:45:34means even you can also upload any kinds
  17172. 11:45:37of documents and you can perform the
  17173. 11:45:38chat operation on top of that. Okay. You
  17174. 11:45:40can add extra knowledge base on this
  17175. 11:45:42particular chatbot. Right? Then we'll
  17176. 11:45:44add the tools. Okay. Realtime tools
  17177. 11:45:47we'll try to add so that uh if you are
  17178. 11:45:49asking any kinds of question and if it
  17179. 11:45:51needs any kinds of tool it will try to
  17180. 11:45:53use that. Okay. And uh that time
  17181. 11:45:56actually it will become agentic chatbot
  17182. 11:45:58that means it doesn't only have the um
  17183. 11:46:01like uh I mean um the existing knowledge
  17184. 11:46:04base it has also connection with lots of
  17185. 11:46:06tools okay so that whenever you are
  17186. 11:46:09asking something it will real time fetch
  17187. 11:46:11those informations and it will give it
  17188. 11:46:12to you then um I will also add the user
  17189. 11:46:15interface
  17190. 11:46:17uh because user needs a user interface
  17191. 11:46:19to use this particular chatbot. So
  17192. 11:46:21definitely we try to create the UI and
  17193. 11:46:23for UI implementation as of now I'll be
  17194. 11:46:25using a streamlit package. It's a Python
  17195. 11:46:28package and here you don't need to write
  17196. 11:46:29any kinds of HTML and CSS code but later
  17197. 11:46:32on I'm also going to show you how we can
  17198. 11:46:34use HTML and CSS code how we can use the
  17199. 11:46:37fast API okay with the help of that
  17200. 11:46:39we'll try to create the entire asentic
  17201. 11:46:41chatbot but as of now we are learning
  17202. 11:46:43okay this is our first project so that's
  17203. 11:46:45why I'll be using streaml so that
  17204. 11:46:47everyone can implement with me okay then
  17205. 11:46:50we'll also try to add the observability
  17206. 11:46:52tool which is lang
  17207. 11:46:56okay lang hangmith will try to add. So
  17208. 11:46:58with the help of that we'll try to
  17209. 11:47:00monitor the entire chatbot. Okay. Uh
  17210. 11:47:02like how it is performing which
  17211. 11:47:03particular component is triggering each
  17212. 11:47:05and everything. We'll try to log in the
  17213. 11:47:07lang speed dashboard. Then we'll also
  17214. 11:47:09learn some advanced topic as well. Some
  17215. 11:47:12advanced topic as well.
  17216. 11:47:14Okay. Inside advanc topic we'll be
  17217. 11:47:16learning memory concept. Okay.
  17218. 11:47:19Short-term and long-term memory concept
  17219. 11:47:21we'll try to learn. Um um okay I missed
  17220. 11:47:24out one thing which is uh persistence.
  17221. 11:47:27Okay here we'll also try to learn this
  17222. 11:47:30persistence.
  17223. 11:47:33Okay we'll also try to add the
  17224. 11:47:35persistence in the chatbot. Then we'll
  17225. 11:47:37be learning the memory the advanced
  17226. 11:47:38topic. Then we'll also try to learn this
  17227. 11:47:42hit human in the loop. Okay. Uh then
  17228. 11:47:45here also we'll try to learn the retry
  17229. 11:47:47functionality like how we can perform
  17230. 11:47:49the retry functionality and all. So
  17231. 11:47:50these are the thing we'll try to cover
  17232. 11:47:52that means by this particular project
  17233. 11:47:54itself we'll try to master okay all of
  17234. 11:47:57these langraph concept in detail okay
  17235. 11:48:00that's why I made this particular
  17236. 11:48:02implementation as a series so that each
  17237. 11:48:04of the video will cover uh each of these
  17238. 11:48:06concept in a detailed way okay so yes
  17239. 11:48:09guys uh this is the uh plan I think you
  17240. 11:48:11got it now uh we already have the graph
  17241. 11:48:14okay we already have the workflow uh
  17242. 11:48:17architecture now based on this
  17243. 11:48:18architecture now let's try to implement
  17244. 11:48:20ment our uh chatbot. Okay, first of all,
  17245. 11:48:22we'll try to create this simple chatbot
  17246. 11:48:25workflow in this particular video. Then
  17247. 11:48:27from the next video onward, I'm going to
  17248. 11:48:29discuss one by one all of this advanced
  17249. 11:48:31component. So first of all, let's try to
  17250. 11:48:34create a Jupyter notebook file. Uh
  17251. 11:48:36because initially I want to show you
  17252. 11:48:38this workflow in the Jupyter notebook.
  17253. 11:48:40Then I'm going to just uh write
  17254. 11:48:43everything in the py file. Okay, Python
  17255. 11:48:45scripting file because Jupyter notebook
  17256. 11:48:47file we won't be using whenever we'll be
  17257. 11:48:49creating the project. Okay. But for
  17258. 11:48:50experiment purpose, we'll be using this
  17259. 11:48:52Jupyter notebook. So here, let's try to
  17260. 11:48:55create a file ipv.
  17261. 11:49:03Yeah. So previously I had my environment
  17262. 11:49:05which is uh this langraph test. I'll try
  17263. 11:49:08to select this one. And here we'll try
  17264. 11:49:11to import all the necessary library we
  17265. 11:49:13need. And this import would be common
  17266. 11:49:15guys. I think you know that what is this
  17267. 11:49:16import? Let's import everything.
  17268. 11:49:21So these are the import we need. Uh we
  17269. 11:49:24are importing this state graph start
  17270. 11:49:26end. Then from typing we are importing
  17271. 11:49:28uh type dict annotated. Then we are also
  17272. 11:49:31importing this base message and human
  17273. 11:49:33message. And uh we will be using openi
  17274. 11:49:36large language model. That's why from
  17275. 11:49:38langen we are importing chat openai. You
  17276. 11:49:40can also use any other uh large language
  17277. 11:49:42model provider like grock. You can also
  17278. 11:49:44use open router, gemini. Okay. anything
  17279. 11:49:48you can use only you just need to check
  17280. 11:49:49the lang chain documentation how to
  17281. 11:49:51import that okay even you can also copy
  17282. 11:49:53this code and if you give to the chat
  17283. 11:49:55JPT this will replace with another model
  17284. 11:49:58but I have my open API key that's why
  17285. 11:50:00I'll be using open AI model here so
  17286. 11:50:02let's import all of the package okay
  17287. 11:50:04it's done now the next thing guys what
  17288. 11:50:06you have to do you have to get this open
  17289. 11:50:08API key so quickly I'm going to move my
  17290. 11:50:11env file from my previous uh previous
  17291. 11:50:15code.
  17292. 11:50:17So guys, as you can see, this is myb
  17293. 11:50:19file. And inside that, I'm going to
  17294. 11:50:22simply copy my
  17295. 11:50:26um open environment v uh open API key.
  17296. 11:50:32So this is my open API key. I already
  17297. 11:50:34collected.
  17298. 11:50:37Now let's try to
  17299. 11:50:40uh write the further code. Yeah. So now
  17300. 11:50:43what I'm going to do guys uh first of
  17301. 11:50:45all here I'm going to
  17302. 11:50:48um I'm going to initialize the LM.
  17303. 11:50:53So here I'm initializing the LLM. Okay.
  17304. 11:50:56So we'll be taking the default large
  17305. 11:50:58language model. Okay. Here I'm getting
  17306. 11:50:59an error because uh I have to load this
  17307. 11:51:02environment variable right. So let's
  17308. 11:51:04load it. So from env
  17309. 11:51:12import load env
  17310. 11:51:15we'll try to load this environment
  17311. 11:51:16variable.
  17312. 11:51:20Then now this code will work. Yeah. Now
  17313. 11:51:23we are able to load our lm. Now first of
  17314. 11:51:26all you have to define the state. Uh so
  17315. 11:51:28let's try to define the state.
  17316. 11:51:31Um this is the state guys.
  17317. 11:51:34And I already told you if you are uh
  17318. 11:51:37storing conversational story that time
  17319. 11:51:40you can use this function add messages
  17320. 11:51:42from langraph graph message. Okay. So
  17321. 11:51:44here uh we are using the reducer
  17322. 11:51:46concept. Um um I think you know what is
  17323. 11:51:49the reducer function um like um
  17324. 11:51:52operation add previously we used but
  17325. 11:51:55right now uh this is a conversational
  17326. 11:51:57story. So we'll be using this add
  17327. 11:51:58message and by default actually it will
  17328. 11:52:00perform this uh adding operation instead
  17329. 11:52:02of replacing. Okay. And uh here I given
  17330. 11:52:06the base message.
  17331. 11:52:08Base message means uh see inside base
  17332. 11:52:10message what happens? We are telling
  17333. 11:52:12this is a uh like u uh chat history.
  17334. 11:52:15Chat history means uh there will be uh
  17335. 11:52:17user message as well and there would be
  17336. 11:52:19um like uh AI reply as well. Okay. So if
  17337. 11:52:22you combine all of them together, this
  17338. 11:52:24will become a base message. Okay. So
  17339. 11:52:26this is why we are using the base
  17340. 11:52:28message here. So this is going to be my
  17341. 11:52:31state. Now let's try to define the
  17342. 11:52:32state. So after that we'll try to create
  17343. 11:52:34the uh graph. Now let's create the
  17344. 11:52:37graph.
  17345. 11:52:40So this is our graph guys uh state graph
  17346. 11:52:42and we have given the state to the
  17347. 11:52:44graph. Now after that we'll try to add
  17348. 11:52:46the nodes. So let's comment here
  17349. 11:52:52add
  17350. 11:52:55nodes. So if you see we only have one
  17351. 11:52:59nodes which is chat nodes. Okay, let's
  17352. 11:53:01try to add that.
  17353. 11:53:04So, graph dot add
  17354. 11:53:08graph dot add uh chat node and uh this
  17355. 11:53:11function we have to write separately. Uh
  17356. 11:53:14so, let's try to write this function.
  17357. 11:53:17I'm going to create a function def chat
  17358. 11:53:19node and this will take this state
  17359. 11:53:24but I'm not going to return all of this
  17360. 11:53:25state all together. Instead of that
  17361. 11:53:28simply
  17362. 11:53:30um I'm going to only return the update
  17363. 11:53:33message. Okay.
  17364. 11:53:35So first of all here we'll be taking the
  17365. 11:53:37user query
  17366. 11:53:39from this state.
  17367. 11:53:41Okay. Take the user query from the
  17368. 11:53:44state.
  17369. 11:53:46Yeah. So user will give the message
  17370. 11:53:48right? User will give the message. So
  17371. 11:53:49this message I'll be uh uh basically
  17372. 11:53:52this will start store as a message.
  17373. 11:53:54Okay. So this message I'm extracting.
  17374. 11:53:57Then after that we'll try to send it to
  17375. 11:53:59the llm.
  17376. 11:54:02Okay. Send it to the llm. You can see
  17377. 11:54:04llm.inbox. We are giving the message and
  17378. 11:54:06we are getting the response. Okay. Now
  17379. 11:54:08this response
  17380. 11:54:10I'm going to store in the message again.
  17381. 11:54:12Okay. Uh response stored in the state.
  17382. 11:54:16Uh that means in the message keyword
  17383. 11:54:18because this is a list type. Okay. And
  17384. 11:54:19every time it will uh store your user
  17385. 11:54:22message as well as the um response.
  17386. 11:54:24Okay, altogether it will store and we
  17387. 11:54:27are returning the state. So this is
  17388. 11:54:28going to be my chat note. As you can see
  17389. 11:54:30this is going going to be my chat node.
  17390. 11:54:32So once this chat note is prepared. Now
  17391. 11:54:35let's try to add the edges. Okay. Now if
  17392. 11:54:37you see the edge connection first of all
  17393. 11:54:39start will be connected to the chat
  17394. 11:54:41node. So let's try to add the edges.
  17395. 11:54:47Add edges.
  17396. 11:54:49So start would be connected to the chat
  17397. 11:54:51node and chat node would be connected to
  17398. 11:54:54the end.
  17399. 11:54:56Chat node would be connected to the end.
  17400. 11:54:58Okay. So this is the simple um like edge
  17401. 11:55:00connection. After that we'll try to
  17402. 11:55:02compile the graph.
  17403. 11:55:08Let's compile the graph.
  17404. 11:55:11We have com uh here we'll be compiling a
  17405. 11:55:14graph. Okay. Now let's compile. Yeah.
  17406. 11:55:16Done. Now if you want to see the
  17407. 11:55:17workflow.
  17408. 11:55:21So this is the chatbot workflow. Okay.
  17409. 11:55:23This is the simple chatbot workflow we
  17410. 11:55:25have created like that. Okay. Now here
  17411. 11:55:28you can perform this simple chat
  17412. 11:55:30operation. So this simple chat operation
  17413. 11:55:32you can perform as of now. Now let me
  17414. 11:55:34show you how we can perform the chat
  17415. 11:55:35operation. Now let's give the initial
  17416. 11:55:37state. So this is our initial state
  17417. 11:55:39guys. As you can see, we are using human
  17418. 11:55:41message because this is a human prompt
  17419. 11:55:43and for this we have already imported
  17420. 11:55:45this human message. It's good to uh use
  17421. 11:55:48this function whenever using uh whenever
  17422. 11:55:50you are implementing this kinds of
  17423. 11:55:51chatbot. So as you can see message uh
  17424. 11:55:55this should be a dictionary we are
  17425. 11:55:56giving the message and uh you can see it
  17426. 11:56:00takes u as a list okay as you can see it
  17427. 11:56:04takes as a list okay input.
  17428. 11:56:07So that's why we are giving as a list.
  17429. 11:56:11Now we are giving the human message and
  17430. 11:56:13this is the content what is the object
  17431. 11:56:15oriented programming. So this thing I
  17432. 11:56:16will try to pass to my
  17433. 11:56:19uh chatbot. Okay. So chatbot do invoke
  17434. 11:56:22we are giving the initial state and this
  17435. 11:56:24will return you. Let me show you if I
  17436. 11:56:26don't give this line.
  17437. 11:56:32Yeah. So this will give you this kinds
  17438. 11:56:34of response. So maybe I can store inside
  17439. 11:56:36a variable response is equal to
  17440. 11:56:37chatbot.invoke.
  17441. 11:56:41Now if I show you the response. So this
  17442. 11:56:44is the response. Inside this response
  17443. 11:56:45you have two things.
  17444. 11:56:50Uh here one you have the message. Okay
  17445. 11:56:53the human message and another one is the
  17446. 11:56:56AI message. Okay. Now I have to extract
  17447. 11:56:59this AI message for this uh uh this is a
  17448. 11:57:03dictionary. First of all, I have to
  17449. 11:57:05extract the message. Okay, message
  17450. 11:57:06keyword.
  17451. 11:57:08This message uh message key I have to
  17452. 11:57:10extract. Once we got the extract, now
  17453. 11:57:13this is a list. And here we have two
  17454. 11:57:14items. Okay, one is the human message
  17455. 11:57:16and one is the AI message. And that's
  17456. 11:57:17how this uh um add message stores your
  17457. 11:57:21data right inside this list. Now I need
  17458. 11:57:24the last one. So for this I give minus
  17459. 11:57:26one.
  17460. 11:57:27Okay, the last index AI message. Now I
  17461. 11:57:30only need the content. So here simply
  17462. 11:57:32I'll just give dot content.
  17463. 11:57:34Okay, if you do it now you will be able
  17464. 11:57:36to get this content guys. Very simple.
  17465. 11:57:39Okay. So that's how guys you can perform
  17466. 11:57:41any kinds of chat operation right now
  17467. 11:57:43with this particular workflow. Now let's
  17468. 11:57:44say I will ask another question. What is
  17469. 11:57:46uh let's say
  17470. 11:57:48object- oriented programming in Python.
  17471. 11:57:56Now see object oriented programming in
  17472. 11:57:58Python blah blah blah. Okay, it's
  17473. 11:58:00working perfectly. Okay, so guys, now
  17474. 11:58:03what I'm going to do, I'm going to just
  17475. 11:58:05make a loop so that user can
  17476. 11:58:07continuously give the uh input and uh
  17477. 11:58:11this chatbot will be working. Okay, uh
  17478. 11:58:14it will provide the output u because
  17479. 11:58:16right now every time I have to change
  17480. 11:58:18the um message here and I have to
  17481. 11:58:20re-execute the cell but I don't want
  17482. 11:58:22that. I want a loop. Okay. So for this
  17483. 11:58:25uh what I can do guys, I can just make a
  17484. 11:58:28while loop.
  17485. 11:58:30So this is our while loop.
  17486. 11:58:33Okay. So here we are taking a input from
  17487. 11:58:35the user. Uh I'm just telling type here
  17488. 11:58:38some message. Then we are printing this
  17489. 11:58:41uh uh user message. Then I'm checking if
  17490. 11:58:45user messagees uh uh let's say if it is
  17491. 11:58:48uh if they write like say Z, exit, quite
  17492. 11:58:51and by. So that time I'm going to break
  17493. 11:58:53the loop. Okay. Otherwise I'm going to
  17494. 11:58:56simply invoke my
  17495. 11:58:59LM.
  17496. 11:59:02So let's do that.
  17497. 11:59:06So we'll be invoking our LM here. That
  17498. 11:59:09means the workflow. So as you can see we
  17499. 11:59:12are doing the same thing. We are just
  17500. 11:59:13hitting this chatbot invoke. We are
  17501. 11:59:16giving the message human message. Right
  17502. 11:59:19now the content should be equal to the
  17503. 11:59:20user message. Okay. because previously I
  17504. 11:59:23hardcoded this message but right now I'm
  17505. 11:59:25taking as a variable input variable once
  17506. 11:59:28it is done I'm going to print this
  17507. 11:59:29response in the terminal okay we'll be
  17508. 11:59:32printing this message in the terminal
  17509. 11:59:33that's it now let's execute okay now
  17510. 11:59:36let's execute this while loop now here I
  17511. 11:59:38can give the message hi
  17512. 11:59:42now see user given hi and it's telling
  17513. 11:59:45hello how I can assist you today I'll
  17514. 11:59:47tell my name is puppy
  17515. 11:59:52Okay. Hello By, nice to meet you. How I
  17516. 11:59:54can assist you? I'll tell
  17517. 11:59:57what is
  17518. 12:00:01Python.
  17519. 12:00:07See, it's working fine. Okay. But one
  17520. 12:00:10issue I want to show you in this
  17521. 12:00:11particular chatbot. Let's say now if I
  17522. 12:00:14ask what is my
  17523. 12:00:18name?
  17524. 12:00:22Now it will tell you I'm sorry I'm not
  17525. 12:00:24able to access the personal information
  17526. 12:00:26about the user. But although if you see
  17527. 12:00:29every time we are saving this
  17528. 12:00:32information to this state and we are
  17529. 12:00:34passing this state to the uh to this
  17530. 12:00:36node okay if I open my
  17531. 12:00:39um diagram I think you see that. So
  17532. 12:00:42every time what is happening whatever
  17533. 12:00:44message user is giving I'm storing in
  17534. 12:00:46this uh state and whatever uh response
  17535. 12:00:49also I'm getting I'm also storing in
  17536. 12:00:51this particular state and we are passing
  17537. 12:00:53the state to the chat node. So chat node
  17538. 12:00:55should have the informations okay about
  17539. 12:00:58the older conversation because we are
  17540. 12:01:00storing the conversation story but still
  17541. 12:01:03why it is not able to give you the
  17542. 12:01:05answer. Okay still why it is not able to
  17543. 12:01:07give you the answer? This is a question
  17544. 12:01:09to you just try to think about and uh
  17545. 12:01:12please reply in the comment if you uh
  17546. 12:01:14can you can pause the video and you can
  17547. 12:01:16reply in the comment okay why uh it is
  17548. 12:01:18happening like that see if I tell you um
  17549. 12:01:21uh see what is happening if you're using
  17550. 12:01:24the state concept right if you're using
  17551. 12:01:26the state concept so what will happen
  17552. 12:01:28first of all let's say it will start
  17553. 12:01:30this node then the input will go to the
  17554. 12:01:32chat nodes okay then chat node will
  17555. 12:01:35return some kinds of response then it
  17556. 12:01:37will go to the end okay so once Once it
  17557. 12:01:39is reaching to the end, right? Once it
  17558. 12:01:41is reaching to the end, that time this
  17559. 12:01:44execution is um this execution is
  17560. 12:01:47ending. Okay, this execution is ending
  17561. 12:01:49that means whatever you have in the chat
  17562. 12:01:52state. Okay, that means in the state
  17563. 12:01:54this particular data would be erased.
  17564. 12:01:57Okay, this particular data would be
  17565. 12:01:59erased. So that time whenever you are
  17566. 12:02:01running this loop, right? You are
  17567. 12:02:03running this loop. So every time what
  17568. 12:02:06you are doing you are invoking the
  17569. 12:02:07chatbot you are invoking the workflow
  17570. 12:02:09and whenever you are invoking the
  17571. 12:02:11workflow that means what is happening
  17572. 12:02:13you are re-executing from from here okay
  17573. 12:02:16you are reexecuting from here that means
  17574. 12:02:18again it will go to the chat node to the
  17575. 12:02:21end again this data would be erased okay
  17576. 12:02:23so every time this particular list will
  17577. 12:02:26be erased okay it is not able to like uh
  17578. 12:02:28let's say uh store the older
  17579. 12:02:32conversation it will only store in this
  17580. 12:02:34particular particular session only only
  17581. 12:02:36one session let's say right now this
  17582. 12:02:38loop is running right in this particular
  17583. 12:02:40session this information is available
  17584. 12:02:42but whenever we are again executing this
  17585. 12:02:44loop is again executing from here that
  17586. 12:02:47time this information is getting erased
  17587. 12:02:51this is the problem okay now how we can
  17588. 12:02:54handle this kinds of scenario we can
  17589. 12:02:56handle this kinds of scenario with help
  17590. 12:02:57of persistence okay I I think I already
  17591. 12:02:59told you about persistence right now
  17592. 12:03:01we'll be using persistence concept it
  17593. 12:03:04and uh we can uh we can actually handle
  17594. 12:03:07this kinds of scenario that means
  17595. 12:03:09whatever conversation story we are let's
  17596. 12:03:11say having okay so we [snorts] can store
  17597. 12:03:15somewhere this conversation story
  17598. 12:03:17because right now this is only storing
  17599. 12:03:19inside the variable and once it is
  17600. 12:03:21getting initialized again this variable
  17601. 12:03:23is getting cleared okay this is the main
  17602. 12:03:25problem so that's why langraph uh
  17603. 12:03:28supports actually persistence concept so
  17604. 12:03:30inside persistence either you can save
  17605. 12:03:33these informations in the memory saber
  17606. 12:03:34that means inside your RAM either you
  17607. 12:03:37can save this particular informations in
  17608. 12:03:38the database and you can load load
  17609. 12:03:41anytime okay these kinds of things you
  17610. 12:03:43can perform now let's try to see how we
  17611. 12:03:45can do this kinds of persistence uh
  17612. 12:03:47operation
  17613. 12:03:48so for this I'm going to open up my code
  17614. 12:03:50again
  17615. 12:03:52okay so here simply I can exit my bot so
  17616. 12:03:56for this you have to give this exit
  17617. 12:03:57message
  17618. 12:04:00sorry
  17619. 12:04:02this exit message only
  17620. 12:04:05done now see it has exited now see uh
  17621. 12:04:08persistence concept I'm going to explain
  17622. 12:04:10in detail in the next video so only I'm
  17623. 12:04:13just going to add this persistence uh
  17624. 12:04:16let's say um uh implementation here how
  17625. 12:04:19we can add the persistence so inside
  17626. 12:04:21persistence uh basically we just try to
  17627. 12:04:25add a memory here okay we just try to
  17628. 12:04:27add a checkpoint memory so what happens
  17629. 12:04:31let's say the entire state we we are
  17630. 12:04:32having right this entire state we are
  17631. 12:04:34having so this entire state we can save
  17632. 12:04:37inside a memory either you can save
  17633. 12:04:38inside your RAM okay this memory you can
  17634. 12:04:41say uh this state you can save inside
  17635. 12:04:42your RAM either you can save inside the
  17636. 12:04:45database okay but right now this
  17637. 12:04:47particular state is not getting saved
  17638. 12:04:48anywhere this is only storing the data
  17639. 12:04:51in the variable and you know whenever
  17640. 12:04:53code will re-execute this variable would
  17641. 12:04:55be clean clear that time right we
  17642. 12:04:58already know that if you understand the
  17643. 12:04:59Python concept you already know that so
  17644. 12:05:01Somehow we have we have to store this
  17645. 12:05:04state inside a storage uh storage
  17646. 12:05:07actually um let's say service either you
  17647. 12:05:10can uh use your RAM because you know
  17648. 12:05:12that RAM would be the temporary storage
  17649. 12:05:15it's completely fine but if you want a
  17650. 12:05:17permanent storage that time you can use
  17651. 12:05:20any kinds of database this database part
  17652. 12:05:22I will also show you in future but I
  17653. 12:05:24told you I'll be going uh step by step
  17654. 12:05:26so that I can explain each and every
  17655. 12:05:28concept in detail. So initially we'll
  17656. 12:05:30try to see how we can save this
  17657. 12:05:31information in the RAM. So whenever
  17658. 12:05:33we'll save inside the RAM so what will
  17659. 12:05:35happen this uh this particular uh data
  17660. 12:05:39would be saved unless and until I don't
  17661. 12:05:41restart my kernel. Okay if I restart my
  17662. 12:05:44kernel that time this information would
  17663. 12:05:46be clean up otherwise this information
  17664. 12:05:48will remain same inside my RAM. Okay. So
  17665. 12:05:50this kinds of concept we'll try to add
  17666. 12:05:51right now. So here
  17667. 12:05:54uh for this I'm going to import a
  17668. 12:05:56function from lang graph. So inside lang
  17669. 12:05:59graph there is a function called
  17670. 12:06:02um memory saver. Let me import that.
  17671. 12:06:06So this is the function langraph.
  17672. 12:06:08Checkpoint [snorts] domemory import
  17673. 12:06:10memory saver. Okay. So this memory saver
  17674. 12:06:12stores your state inside the memory
  17675. 12:06:14inside the RAM. You can also use any
  17676. 12:06:17kinds of database. That part I will also
  17677. 12:06:19show you later on. Okay. First of all
  17678. 12:06:20let's try to see the memory server one.
  17679. 12:06:22Now let me import.
  17680. 12:06:24Okay. So once it is done now simply
  17681. 12:06:28here whenever you are defining the
  17682. 12:06:31graph. So before the graph
  17683. 12:06:34initialization you have to define a
  17684. 12:06:36checkpoint. This checkpoint should be
  17685. 12:06:39the memory server. Okay. So this is
  17686. 12:06:41going to be this is going to become your
  17687. 12:06:43memory server object. Okay. Checkpoint.
  17688. 12:06:45Now whenever you are compiling your
  17689. 12:06:48entire graph that time you have to
  17690. 12:06:49mention I have a checkpointer. Okay I
  17691. 12:06:52have a checkpo pointer. So this
  17692. 12:06:54checkpointer will basically store your
  17693. 12:06:57state in the RAM. Okay you can see
  17694. 12:07:00checkpo pointer is equal to checkpoint
  17695. 12:07:01and here we are using memory server.
  17696. 12:07:03Memory server means the RAM that means
  17697. 12:07:05whatever state it is getting right the
  17698. 12:07:07chat state that means the entire state
  17699. 12:07:08it is getting and every time it is
  17700. 12:07:11updating right with the user message and
  17701. 12:07:13the reply of the AI message right every
  17702. 12:07:15time it is getting update so this
  17703. 12:07:17information will save in the RAM right
  17704. 12:07:19now okay because we are using the
  17705. 12:07:20checkpoint uh checkpointter right now
  17706. 12:07:22okay now let's try to compile the graph
  17707. 12:07:25so one compilation is done now let me
  17708. 12:07:29show you h now let's Okay. Uh I don't
  17709. 12:07:34need to execute this code. I will
  17710. 12:07:35directly execute my while loop. Okay.
  17711. 12:07:38Yeah. But before executing the while
  17712. 12:07:40loop
  17713. 12:07:42here, I will pass one thing. Uh here you
  17714. 12:07:45can specify the trade. Okay. Trade means
  17715. 12:07:50um
  17716. 12:07:52it should be like kinds of unique uh
  17717. 12:07:55unique ID for each of the user. Let's
  17718. 12:07:57say this chatbot can use many people,
  17719. 12:08:01right? This chatbot can use by me then
  17720. 12:08:05this chatbot can be used by any other
  17721. 12:08:07person. So all of the people can chat
  17722. 12:08:10together here right and if they're
  17723. 12:08:12chatting together it's not like that
  17724. 12:08:14let's say I will let the people to chat
  17725. 12:08:17with my chat history right so instead of
  17726. 12:08:20that what uh it should have it should
  17727. 12:08:22have a different trade ID okay different
  17728. 12:08:25trade ID different trade ID means let's
  17729. 12:08:26say if this trade ID is equal to one I
  17730. 12:08:29have set let's say trade is equal to one
  17731. 12:08:31that means this is my trade ID so
  17732. 12:08:33whatever chat I will perform
  17733. 12:08:35it will store all of the information in
  17734. 12:08:38this particular trade right in this
  17735. 12:08:40particular let's say whenever it will
  17736. 12:08:41store inside the memory right because I
  17737. 12:08:43used the memory server so in the memory
  17738. 12:08:45it will create a separate section for
  17739. 12:08:48one okay and all of the information all
  17740. 12:08:50of the chat history it will save inside
  17741. 12:08:52this particular trade okay now if I
  17742. 12:08:54change it to two right that time uh
  17743. 12:08:57another user will come and he will
  17744. 12:08:59perform the chat operation that means
  17745. 12:09:01what is happening in the memory there
  17746. 12:09:03are different block is getting created
  17747. 12:09:04let's say this is trade one this is
  17748. 12:09:07trade two okay whatever chat I'm
  17749. 12:09:10performing in the trade one uh trade two
  17750. 12:09:13person won't be able to see that okay he
  17751. 12:09:15won't be able to access this information
  17752. 12:09:17and whatever let's say uh chat trade two
  17753. 12:09:20is doing trade one won't be able to see
  17754. 12:09:22or get this particular information okay
  17755. 12:09:25like the chart GPT like chart GP is
  17756. 12:09:26having different trade right whenever
  17757. 12:09:29let's say you uh you just create a new
  17758. 12:09:32chart right uh in the chart GP whenever
  17759. 12:09:34you create a new chart let me show you
  17760. 12:09:37so here
  17761. 12:09:40so this is my chat GPT so let's say here
  17762. 12:09:43you can create a new chart right you can
  17763. 12:09:45create a new chat and you can perform
  17764. 12:09:47some chat operation here
  17765. 12:09:50right so this is this becomes a trade
  17766. 12:09:52right then whenever you takes another
  17767. 12:09:54new chart that means the complete new
  17768. 12:09:57trade will be getting here and you can
  17769. 12:09:58perform the another chart operation here
  17770. 12:10:01okay so that means you won't be able to
  17771. 12:10:03get the previous uh let's Okay. Uh
  17772. 12:10:07previous let's say trade uh information
  17773. 12:10:09in this particular trade but you can
  17774. 12:10:11switch to the trade. Okay. Let's say you
  17775. 12:10:12can uh switch to the trades anytime. You
  17776. 12:10:14can go to the previous trade. You can uh
  17777. 12:10:16go to the current trade. Okay. That's
  17778. 12:10:18how we can switch. So these kinds of
  17779. 12:10:20things also we can perform with the help
  17780. 12:10:21of this persistence. Okay. We can make
  17781. 12:10:23different different trades here. Now
  17782. 12:10:25let's try to do that. Let me show you. I
  17783. 12:10:27think after seeing the practical
  17784. 12:10:28implementation you will be able to
  17785. 12:10:30understand. Now let's say I'll make it
  17786. 12:10:31as trade ID. Initially I'll give it as
  17787. 12:10:33one. And uh whenever you are um using
  17788. 12:10:37this persistence concept that time you
  17789. 12:10:39have to define a configuration.
  17790. 12:10:42So this is the configuration before
  17791. 12:10:44response maybe I can create it.
  17792. 12:10:47So this is the configuration config is
  17793. 12:10:49equal to configurable and here you have
  17794. 12:10:51to pass this trade ID is equal to trade
  17795. 12:10:53ID. So your trade ID okay then this
  17796. 12:10:54should be a dictionary. Okay dictionary
  17797. 12:10:56object and this config you have to pass
  17798. 12:11:00whenever you are invoking the workflow.
  17799. 12:11:02So here at the last you have to give
  17800. 12:11:04this uh config.
  17801. 12:11:09You have to give this config. Config is
  17802. 12:11:10equal to config. Okay. Now what will
  17803. 12:11:13happen? Every time uh this uh this uh uh
  17804. 12:11:17persistence what it will do it will try
  17805. 12:11:19to uh load the information load the
  17806. 12:11:22state from the memory and it will try to
  17807. 12:11:25pass to the um it will try to pass to
  17808. 12:11:28the
  17809. 12:11:30um invoke function. Inbox function means
  17810. 12:11:32you are giving the user message as well
  17811. 12:11:34as the older history. Okay, user message
  17812. 12:11:37as well as the older history. That means
  17813. 12:11:38whatever older history you are having,
  17814. 12:11:40whatever chat state you are having, you
  17815. 12:11:42are entirely passing the chat history as
  17816. 12:11:46well as the new message user is giving.
  17817. 12:11:48Okay, right now it won't be replacing
  17818. 12:11:51because we are storing in the memory and
  17819. 12:11:53every time we are loading it and passing
  17820. 12:11:55it to the invoke function. Now see if I
  17821. 12:11:57execute the code.
  17822. 12:12:00Now let's say here I'll tell my name is
  17823. 12:12:04BP.
  17824. 12:12:10Okay. Now let's say I'll give another
  17825. 12:12:12message. What is Python?
  17826. 12:12:19Done. Now if I ask let's say what is my
  17827. 12:12:24name.
  17828. 12:12:26Now see your name is BYI. It is able to
  17829. 12:12:29remember right now. Okay, it has some
  17830. 12:12:31kinds of memory right now and this
  17831. 12:12:33information is saving inside my RAM
  17832. 12:12:36because we are using memory saver here.
  17833. 12:12:38And this is called persistence. Okay,
  17834. 12:12:40this is called persistence. Now if I
  17835. 12:12:42let's say give another trait. Okay,
  17836. 12:12:45let's see if I give another trade. Let's
  17837. 12:12:46see if I do exit right now. Um one thing
  17838. 12:12:49I want to show you uh if I run it inside
  17839. 12:12:51my while loop. So if I exit my while
  17840. 12:12:53loop so that time your entire session
  17841. 12:12:55will be um like restarted. So instead of
  17842. 12:12:58that maybe I can use this code. I'll
  17843. 12:13:01copy this trade ID here
  17844. 12:13:06trade ID and uh I will also copy this
  17845. 12:13:11config
  17846. 12:13:15and we'll pass this config to this
  17847. 12:13:24Whenever we're doing the invoke
  17848. 12:13:25operation here, I'll try to pass the
  17849. 12:13:26config. Okay. Now let's execute. So
  17850. 12:13:29let's say I'll type what is
  17851. 12:13:33or I'll pass my name is puppy.
  17852. 12:13:44Now see uh nice to meet you BP. Now if I
  17853. 12:13:47ask um
  17854. 12:13:50what is my name?
  17855. 12:13:58What is my name?
  17856. 12:14:05It's giving your name is BP. Okay. Now
  17857. 12:14:08let's see if I give another trade here.
  17858. 12:14:10Okay. Let's say trade two. Now if I ask
  17859. 12:14:13what is my name?
  17860. 12:14:16Now see it is telling I'm sorry I do not
  17861. 12:14:18know what is your name is an uh is uh as
  17862. 12:14:23I am a AI assistant and I do not do not
  17863. 12:14:25uh have access to the personal
  17864. 12:14:27informations. Okay because this is a
  17865. 12:14:29completely new trade right now. Okay.
  17866. 12:14:31Now let's say in this particular trade I
  17867. 12:14:33will give let's say my name is
  17868. 12:14:37my name is Alex.
  17869. 12:14:42Now it is telling nice to meet you Alex.
  17870. 12:14:44Okay. Now if I ask what is my name?
  17871. 12:14:55Now it will tell your name is Alex.
  17872. 12:14:57Okay. Now if I switch to my trade one.
  17873. 12:15:00Okay. Now if I again ask what is my
  17874. 12:15:02name? You will see that it will tell you
  17875. 12:15:04your name is BP. See your name is BP.
  17876. 12:15:06Okay. Now if I go to my trade two,
  17877. 12:15:11trade two that time uh your name is
  17878. 12:15:15Alex. Okay, I hope you got it this
  17879. 12:15:17concept. Okay, this trading concept that
  17880. 12:15:19means we can separate out the chat
  17881. 12:15:22session. Okay, chat session for each and
  17882. 12:15:24every user. This is possible, right? And
  17883. 12:15:28uh here you can also see the u state.
  17884. 12:15:33Uh so for this you can use this code
  17885. 12:15:37so chatbot dot get state and you have to
  17886. 12:15:40pass the config and you will be able to
  17887. 12:15:43see like uh how many trades you are
  17888. 12:15:46having okay all of the history you will
  17889. 12:15:48be able to see the entire state that
  17890. 12:15:50means the entire state you will be able
  17891. 12:15:51to see the state is saved in the memory
  17892. 12:15:53so this is the snapshot object as you
  17893. 12:15:55can see whatever question you have asked
  17894. 12:15:58like what is my name some other metadata
  17895. 12:16:01the AI response okay So each and
  17896. 12:16:03everything is visible here
  17897. 12:16:07the input token output token
  17898. 12:16:10and you will be able to see the trade ID
  17899. 12:16:11as well. So what is the trade ID?
  17900. 12:16:14Yeah. So this is the trade ID 2 and
  17901. 12:16:16trade ID one is also there
  17902. 12:16:20somewhere. Okay. So that means the
  17903. 12:16:21entire U state snapshot you will be able
  17904. 12:16:24to see here. So this entire step
  17905. 12:16:26snapshot you will be able to see here.
  17906. 12:16:28If you're using this persistence concept
  17907. 12:16:31and there is a function called get state
  17908. 12:16:33inside that you have to only pass the
  17909. 12:16:35configuration the configuration you are
  17910. 12:16:36preparing you'll be able to see the
  17911. 12:16:38entire state. Okay. Uh it is saved in
  17912. 12:16:41the memory. So yes uh this is the
  17913. 12:16:43concept uh of this persistence. Okay we
  17914. 12:16:45have learned this persistence concept.
  17915. 12:16:48So here I already told you persistence
  17916. 12:16:51we can add inside langraph. This is also
  17917. 12:16:53possible. And don't worry I'm also going
  17918. 12:16:55to um take another I'm also going to
  17919. 12:16:57record another video on top of this
  17920. 12:16:58persistent in detail. We'll try to
  17921. 12:17:00understand each and every uh concept
  17922. 12:17:02okay of this particular persistence. Now
  17923. 12:17:05uh this thing is working fine. Now what
  17924. 12:17:07I can do I can quickly
  17925. 12:17:10uh I can quickly convert it to the um py
  17926. 12:17:14file. So let's create a file here. I'm
  17927. 12:17:16going to name it as
  17928. 12:17:20aentic
  17929. 12:17:25chatbot.py
  17930. 12:17:29pipe
  17931. 12:17:31and whatever code I have written here
  17932. 12:17:34I'll just try to copy here
  17933. 12:17:41or let's name it as aic chatbot back end
  17934. 12:17:46back end okay now I'm going to copy here
  17935. 12:17:49so first of all let's import all the
  17936. 12:17:50necessary library.
  17937. 12:18:01Select my environment.
  17938. 12:18:05Then I'll load the environment variable.
  17939. 12:18:13Then
  17940. 12:18:16initialize the model.
  17941. 12:18:19Define the state.
  17942. 12:18:38So this is my state. Now I'll copy my
  17943. 12:18:42node.
  17944. 12:18:45After
  17945. 12:18:49node I will copy my
  17946. 12:18:53enter graph.
  17947. 12:18:57Okay. Uh so this is going to be my uh
  17948. 12:19:00final.
  17949. 12:19:03Yeah. So this is going to be my final uh
  17950. 12:19:06workflow object. Okay. Chatbot object.
  17951. 12:19:07Now we can use this chatbot object
  17952. 12:19:09anywhere to run this particular
  17953. 12:19:11workflow. Now what I'm going to do guys
  17954. 12:19:14um I'm going to show you whether it is
  17955. 12:19:16working or not. So maybe I can create
  17956. 12:19:18another file here called let's say
  17957. 12:19:21app.py.
  17958. 12:19:24Inside app.py let me first of all import
  17959. 12:19:27this chatbot object. So from
  17960. 12:19:31aentic
  17961. 12:19:33chatbot back end import chatbot.
  17962. 12:19:38Okay chatbot. Now I'll just write
  17963. 12:19:41response is equal to chatbox.invoke
  17964. 12:19:45and here we have to pass the human
  17965. 12:19:46message. Okay. And for human message we
  17966. 12:19:48have to import this library.
  17967. 12:19:50This one
  17968. 12:19:57so here I'll give let's say what is um
  17969. 12:20:03python
  17970. 12:20:05and whatever response I'll get I'll just
  17971. 12:20:07try to print the response. Okay. Now
  17972. 12:20:09let's see whether it's working or not.
  17973. 12:20:11So I'll open up my terminal.
  17974. 12:20:15Then I will activate my environment. So
  17975. 12:20:17cond activate
  17976. 12:20:22uh lang graph test
  17977. 12:20:24h. After that we'll try to execute then
  17978. 12:20:27app.py. So python app.py.
  17979. 12:20:35Okay. Here
  17980. 12:20:37uh okay. Uh sorry actually I have to
  17981. 12:20:39give this uh I have to give this um uh
  17982. 12:20:42trade ID right trade ID I haven't given
  17983. 12:20:44because here uh initially we pass the
  17984. 12:20:47trade right we are giving the checkp
  17985. 12:20:49pointer so here I have to get the uh
  17986. 12:20:50pass this trade
  17987. 12:20:53so here I will copy this trade
  17988. 12:21:05and also copy this configuration
  17989. 12:21:13Then we'll pass this config. Now I think
  17990. 12:21:16this will work.
  17991. 12:21:26See it's working. Python is a high level
  17992. 12:21:29um widely used programming language blah
  17993. 12:21:31blah blah. Okay. But here uh actually I
  17994. 12:21:34can't left this kinds of application to
  17995. 12:21:36the user because user don't know how to
  17996. 12:21:39code right and how to execute this uh
  17997. 12:21:41app.py from the terminal. So definitely
  17998. 12:21:43I have to add the user interface. Okay.
  17999. 12:21:46Now let's try to add a user interface
  18000. 12:21:47with the help of streaml here. So guys
  18001. 12:21:50now we'll try to add the user interface
  18002. 12:21:53uh for this uh chatbot with the help of
  18003. 12:21:55streamlit. So streamlit is a python uh
  18004. 12:21:58package and here you can uh create any
  18005. 12:22:01kinds of user interface without using
  18006. 12:22:02any HTML and CSS code. Right? So for
  18007. 12:22:05this uh uh we have to install this
  18008. 12:22:07streaml. So what I'm going to do in the
  18009. 12:22:10same requirement file uh I think you
  18010. 12:22:11know this requirement file I am using uh
  18011. 12:22:15so far okay inside my langraph u
  18012. 12:22:17tutorial. So here I'm going to add
  18013. 12:22:20another package. I'm going to name it as
  18014. 12:22:22stream.
  18015. 12:22:25Okay, streamlit. You can uh specify any
  18016. 12:22:28kinds of version if you want to install.
  18017. 12:22:30So let's say I want to install this uh
  18018. 12:22:32specific version. Then I will open up my
  18019. 12:22:34terminal and I'll just write pip
  18020. 12:22:36installer
  18021. 12:22:43requirement.txt.
  18022. 12:22:45Oh, sorry. Install spelling is not
  18023. 12:22:47correct.
  18024. 12:22:55Okay, as you can see installation is
  18025. 12:22:57complete. Now, uh I'll come back to my
  18026. 12:23:00app.py.
  18027. 12:23:01Uh I'll close these other are the file.
  18028. 12:23:04Now let's [clears throat] uh start
  18029. 12:23:05implementing the UI. See uh your back
  18030. 12:23:08end code will remain same. You don't
  18031. 12:23:10need to change anything. Uh you only
  18032. 12:23:12need this chatbot uh let's say uh object
  18033. 12:23:16here. So which we have already imported.
  18034. 12:23:18Okay. from agentic chatbot back end. We
  18035. 12:23:21have already imported the chatbot. Now
  18036. 12:23:24I'll just remove these are the code as
  18037. 12:23:27of now. Okay. So see first of all here I
  18038. 12:23:30need a streaml uh server right. Uh in
  18039. 12:23:33that particular server uh I'm going to
  18040. 12:23:36just add my UI functionality and uh this
  18041. 12:23:39server should be run on my local host
  18042. 12:23:42right and if you're using a streaml it's
  18043. 12:23:44super easy to launch the server only you
  18044. 12:23:46just need to import the streaml. So from
  18045. 12:23:49or import
  18046. 12:23:51streamllet
  18047. 12:23:57as st. Okay. If you only import that and
  18048. 12:24:01let's say here I will give a title only
  18049. 12:24:04st. title. Let's say I'll give uh
  18050. 12:24:07agentic chatbot with langraph. I have
  18051. 12:24:10given this title. Now you have to
  18052. 12:24:12execute this file only. Okay. Now if you
  18053. 12:24:14want to execute this file uh if you just
  18054. 12:24:17uh let's say write python app.py it
  18055. 12:24:19won't be running that time for this you
  18056. 12:24:20have to use streaml command streaml
  18057. 12:24:24run
  18058. 12:24:26app.py Pi. So basically you are
  18059. 12:24:28launching the streaml server. Okay. Now
  18060. 12:24:30if I execute
  18061. 12:24:32and now see streaml server will be
  18062. 12:24:34running.
  18063. 12:24:38See this is the streaml server guys. And
  18064. 12:24:40this is running on local host port
  18065. 12:24:42number 85.
  18066. 12:24:44Okay. Uh port number 8501. So by default
  18067. 12:24:47streamllet runs on port number 8501 on
  18068. 12:24:50the local host. See one thing you have
  18069. 12:24:52observed here without writing any kinds
  18070. 12:24:54of HTML and CSS. uh we got this kinds of
  18071. 12:24:57user interface. Okay. So this is the
  18072. 12:24:59work of streamllet and uh here you you
  18073. 12:25:02can also change the settings. You can go
  18074. 12:25:04to the settings. You can also um change
  18075. 12:25:07the appearances. If I let's say active
  18076. 12:25:10this wid mode uh this u title will be uh
  18077. 12:25:15moving to the left side and let's say if
  18078. 12:25:17I change the color let's say I want a
  18079. 12:25:19light color. I want a dark color. Okay.
  18080. 12:25:22Everything is [snorts] possible here.
  18081. 12:25:24But here we'll try to uh customize uh in
  18082. 12:25:26the code whatever things we need we'll
  18083. 12:25:28only just try to add it. Okay, you can
  18084. 12:25:30make it more beautiful for this. You can
  18085. 12:25:32go to the streaml documentation and you
  18086. 12:25:34can check it out. There are so many
  18087. 12:25:36functionality you can use. But uh this
  18088. 12:25:38front end is not like our concern. Okay.
  18089. 12:25:41Uh there would be other front- end
  18090. 12:25:43developer. Okay. They will take care
  18091. 12:25:45about the front end and everything. uh
  18092. 12:25:47but uh as a agent engineer we have to
  18093. 12:25:51know the actual concept actual back end
  18094. 12:25:53engineering I think this is more than
  18095. 12:25:55enough okay so for this particular
  18096. 12:25:57project uh whatever uh let's say uh UI
  18097. 12:26:00interface we need we'll only just try to
  18098. 12:26:02focus on that part see uh we already
  18099. 12:26:05launched this uh streaml server and we
  18100. 12:26:08set the title now here uh I need a user
  18101. 12:26:11input box okay that means the chat box
  18102. 12:26:13so here user will be able to pass any
  18103. 12:26:16kinds of messages Okay, for this uh we
  18104. 12:26:18can take this uh
  18105. 12:26:21chat input.
  18106. 12:26:24So if you want to get the chat input
  18107. 12:26:28uh you can write this code st. chat
  18108. 12:26:30input okay and you can give any kinds of
  18109. 12:26:32message um because if you go to the chat
  18110. 12:26:34GPT right so here you will see by
  18111. 12:26:37default ask anything. So if you want to
  18112. 12:26:39give this kinds of message, display
  18113. 12:26:40message, you can write it here. And
  18114. 12:26:42whatever message we will provide, it
  18115. 12:26:44will store in the user input variable.
  18116. 12:26:47Okay. So once we got the user input
  18117. 12:26:49variable, if I show you, so if I let's
  18118. 12:26:51say refresh now, see here, I got a chat
  18119. 12:26:53chat input box. Okay. Now, whatever uh
  18120. 12:26:56input you will give here, you will try
  18121. 12:26:57to send it here. It would be stored
  18122. 12:27:00here. Okay. Now I can also print and
  18123. 12:27:02show you our S3.print
  18124. 12:27:09ST
  18125. 12:27:12uh dot
  18126. 12:27:14text
  18127. 12:27:18or let's say write
  18128. 12:27:22I think there's a function called write
  18129. 12:27:27now let me show you refresh
  18130. 12:27:31user return none so if I let's say give
  18131. 12:27:33hi now see here hi will come okay Okay,
  18132. 12:27:36that's how you can take any kinds of
  18133. 12:27:38user input. So after taking the user
  18134. 12:27:40input guys, what I will check? I'll
  18135. 12:27:42check first of all user has given any
  18136. 12:27:43input or not. If uh user has given the
  18137. 12:27:46input that means if user input is equal
  18138. 12:27:48to is equal to true. Okay, that time
  18139. 12:27:52I'll just try to
  18140. 12:27:58um
  18141. 12:28:00I'll just try to give a uh display
  18142. 12:28:03display um actually icon. Okay. of the
  18143. 12:28:06user
  18144. 12:28:08and uh from this icon I'm going to take
  18145. 12:28:11the user message
  18146. 12:28:15H user input whatever user input we'll
  18147. 12:28:17pass we'll try to pass it here. Now see
  18148. 12:28:20what will happen if I refresh
  18149. 12:28:22now say if I pass any text here. Now see
  18150. 12:28:26uh this icon is coming because of this
  18151. 12:28:29particular line chat message and this is
  18152. 12:28:33user. Okay, this is the user icon and
  18153. 12:28:35user has passed hi. So if you see any
  18154. 12:28:37kinds of chatbot guys, you will be able
  18155. 12:28:38to see people are using this kinds of
  18156. 12:28:40icon to identify the human message as
  18157. 12:28:42well as the AI message. Okay, that's why
  18158. 12:28:44we have given this line and by default
  18159. 12:28:45in streamllet it is available.
  18160. 12:28:48So once I got the user input now what I
  18161. 12:28:52have to do guys, I have to uh invoke the
  18162. 12:28:55message to my chatbot. Okay, the chatbot
  18163. 12:28:57object we have created. But before that
  18164. 12:28:59we have to configure the
  18165. 12:29:03uh trade right. So maybe what I can do
  18166. 12:29:06here only I can prepare my trade.
  18167. 12:29:11So config is equal to configurable trade
  18168. 12:29:14ID. So here I have given let's say trade
  18169. 12:29:17one. Okay. Trade one. You can also give
  18170. 12:29:201 2 3 4. It's completely up to you.
  18171. 12:29:22Okay. Even you can also write like that.
  18172. 12:29:24Okay. You can also write like that. It's
  18173. 12:29:26completely fine. But in in just one line
  18174. 12:29:29I have added like that. Now let's try to
  18175. 12:29:33invoke the message.
  18176. 12:29:38Yeah. So here we'll try to invoke the
  18177. 12:29:40message. Yeah. Chatbot dot invoke and
  18178. 12:29:43message is equal to we are giving the
  18179. 12:29:44human message. Content is equal to right
  18180. 12:29:46now the user input and we're giving the
  18181. 12:29:48config. Now whatever response I'm
  18182. 12:29:50getting guys I will also show this
  18183. 12:29:52response. So first of all I will extract
  18184. 12:29:54the content from this response. So AI
  18185. 12:29:57message is equal to response message
  18186. 12:29:59minus one content. Okay, that means we
  18187. 12:30:00are we are doing this operation. We are
  18188. 12:30:03only extracting the AI message.
  18189. 12:30:05And this AI message I will try to uh
  18190. 12:30:08show in the console.
  18191. 12:30:11For this I'm going to create another
  18192. 12:30:12icon assistant icon and this message
  18193. 12:30:15would be showing the assistant icon.
  18194. 12:30:16Okay. Now let me show you if I refresh.
  18195. 12:30:20Done. Now let's say if I give hi send.
  18196. 12:30:24Now see assistant is giving hello. how I
  18197. 12:30:26can assist you today. Now this is the
  18198. 12:30:28assistant icon. This is the user icon.
  18199. 12:30:29Okay, that's why we have given this chat
  18200. 12:30:32message is uh inside that I have
  18201. 12:30:34mentioned assistant. Whenever you will
  18202. 12:30:36get give assistant automatically it will
  18203. 12:30:37take the assistant icon and whenever you
  18204. 12:30:40will give us user that time
  18205. 12:30:41automatically it will take user icon.
  18206. 12:30:43Okay. So that's how streamly it works
  18207. 12:30:45guys. By default internally they are
  18208. 12:30:46handling each and every scenario. Uh and
  18209. 12:30:49uh they have given some highle
  18210. 12:30:50functionality. We can use that and we
  18211. 12:30:52can create our chatbot. Okay, it's
  18212. 12:30:55working fine. But one issue uh in this
  18213. 12:30:58particular chatbot would be let's say if
  18214. 12:30:59I give another message I am bp
  18215. 12:31:04now see previous message is getting
  18216. 12:31:06replaced okay previous message is
  18217. 12:31:08getting replaced now it is giving you
  18218. 12:31:10the new one but I can't see my previous
  18219. 12:31:12conversation but in chat GPT so let's
  18220. 12:31:15say if I give I am buffy so I will be
  18221. 12:31:19able to see my previous message as well
  18222. 12:31:21okay so this kinds of thing uh if you
  18223. 12:31:23want to do it that time you have to use
  18224. 12:31:25something called session. Okay, session
  18225. 12:31:27state inside streamllet. So streamllet
  18226. 12:31:30also works in that way. U by default if
  18227. 12:31:33you're not using session state what is
  18228. 12:31:35happening? So every time it is
  18229. 12:31:37reexecuting re-executing code from here
  18230. 12:31:39and whenever it is re re-executing code
  18231. 12:31:41from the beginning that time this
  18232. 12:31:43message is getting erased. Okay, it is
  18233. 12:31:45getting cleaned and new message is
  18234. 12:31:47getting replaced here. But if you're
  18235. 12:31:48using session state, session state will
  18236. 12:31:50store this informations
  18237. 12:31:53in memory and every time whenever it
  18238. 12:31:56will execute from the beginning, it will
  18239. 12:31:58not erase. Okay, still uh this
  18240. 12:32:00information will be available inside
  18241. 12:32:01memory and from memory it will uh able
  18242. 12:32:03to load that. Okay, the same concept
  18243. 12:32:05like um uh trading. Okay, we have
  18244. 12:32:08learned before, right? Yeah. Now let's
  18245. 12:32:11try to add this uh uh session state.
  18246. 12:32:16First of all, we'll create a session
  18247. 12:32:17state here.
  18248. 12:32:21First of all, we'll try to create a
  18249. 12:32:22session state. I'll check if message
  18250. 12:32:24history is not in session state, then
  18251. 12:32:26I'll try to create this message. Okay,
  18252. 12:32:28it will uh create like a dictionary
  18253. 12:32:31kinds of thing uh by default inside um
  18254. 12:32:34this uh streamllet and this dictionary
  18255. 12:32:37um it's a different type of dictionary.
  18256. 12:32:39Basically, this dictionary will store
  18257. 12:32:41the informations in the memory. It will
  18258. 12:32:43not erase. Okay, if you execute the code
  18259. 12:32:46from the beginning, still this
  18260. 12:32:48dictionary data would be remaining same.
  18261. 12:32:50Okay, then after that we'll load the
  18262. 12:32:56conversation from the dictionary. So
  18263. 12:32:58this is the code I have written loading
  18264. 12:33:00the conversation story. So for message
  18265. 12:33:02in state uh session state message and if
  18266. 12:33:05it founds this message so it will
  18267. 12:33:08basically load the role and the content.
  18268. 12:33:11So role means uh whether it is the
  18269. 12:33:14message for the user or AI. Okay, this
  18270. 12:33:17particular role and the content.
  18271. 12:33:21Now
  18272. 12:33:22um here you have to write some line of
  18273. 12:33:25code. Let's say whenever user is giving
  18274. 12:33:27any kinds of input, this input should be
  18275. 12:33:29stored in the message story. So this
  18276. 12:33:32additional line you have to write here.
  18277. 12:33:41This is the additional line. First add
  18278. 12:33:43the message to the message story. So
  18279. 12:33:44state session state message story we are
  18280. 12:33:46appending it. Okay. Ro user content the
  18281. 12:33:51user input. Okay. We are storing in this
  18282. 12:33:53particular
  18283. 12:33:55list. Once it is done now I will also do
  18284. 12:33:59the same thing whenever I got the AI
  18285. 12:34:00response. So after getting the AI
  18286. 12:34:03response, we'll also
  18287. 12:34:07save this in the message story.
  18288. 12:34:11So you can see ST dos session state
  18289. 12:34:13message append role. Now this role
  18290. 12:34:15should be assistant. Okay, because this
  18291. 12:34:16is the response from the assistant
  18292. 12:34:18content is equal to AI message. Okay,
  18293. 12:34:20done. Now if I come back here, refresh.
  18294. 12:34:23Now if I give the message, let's say,
  18295. 12:34:25hi.
  18296. 12:34:27Hello. Hi. Can I assist you? My name is
  18297. 12:34:31BPI.
  18298. 12:34:35Um, nice to meet you. How I can assist
  18299. 12:34:37you today? Okay. But this agentic
  18300. 12:34:39chatbot with langraph is coming here.
  18301. 12:34:42Let me see why. Okay, because you have
  18302. 12:34:45to assign it at the beginning. Okay,
  18303. 12:34:48because after load conversation story,
  18304. 12:34:50we have assigned it. That's why it's
  18305. 12:34:51coming here. So maybe at the top I will
  18306. 12:34:53try to assign this one. Okay, now I
  18307. 12:34:55think this will work fine. Refresh. Now
  18308. 12:34:57I'll give hi.
  18309. 12:35:00Fine. My name is
  18310. 12:35:05BP.
  18311. 12:35:07Now see nice to meet you BP. What is
  18312. 12:35:10Python?
  18313. 12:35:13Now see okay it's working perfectly and
  18314. 12:35:16I am able to see my older message story
  18315. 12:35:18as well. Okay. So yes guys we are able
  18316. 12:35:21to create our um uh we are able to
  18317. 12:35:25create our uh first uh chatbot workflow
  18318. 12:35:29okay with the user interface even we
  18319. 12:35:30have also added the uh this uh
  18320. 12:35:33persistence concept that means the
  18321. 12:35:34trading concept and don't worry I'm
  18322. 12:35:36going to explain this trading course uh
  18323. 12:35:38persistence concept in more detail in
  18324. 12:35:39the next video but this is the first
  18325. 12:35:41video guys I wanted to show you how we
  18326. 12:35:43can create the skeleton of the agentic
  18327. 12:35:45chatbot now the chatbot skeleton is
  18328. 12:35:47ready okay now we have to add these are
  18329. 12:35:50the functionality one by one. Okay, we
  18330. 12:35:52have to add these are the functionality
  18331. 12:35:53one by one. Now next I'm going to show
  18332. 12:35:55you maybe the persistence concept in
  18333. 12:35:58detail. Okay. After uh next uh I will
  18334. 12:36:00discuss about the rag concept. How we
  18335. 12:36:03can add the rag functionality. How we
  18336. 12:36:04can add the tool functionality. Okay. UI
  18337. 12:36:06I have already I have already shown you.
  18338. 12:36:08Okay. UI um I'm not going to show you
  18339. 12:36:10again. Maybe I'm going to update
  18340. 12:36:12continuously update the UI as per my
  18341. 12:36:14need. Then I'm also going to show you
  18342. 12:36:15how we can uh add the observability tool
  18343. 12:36:18like lang memory okay HITL okay each and
  18344. 12:36:22everything we'll be discussing one by
  18345. 12:36:23one guys okay so yeah this is the part
  18346. 12:36:26one uh for this implementation guys of
  18347. 12:36:28this agentic chatbot and we are able to
  18348. 12:36:31build our first interface of the chatbot
  18349. 12:36:34but right now it doesn't have any kinds
  18350. 12:36:37of tool it doesn't have any kinds of
  18351. 12:36:38rack capacity uh we'll try to add one by
  18352. 12:36:41one okay uh through the entire series of
  18353. 12:36:43the video and I'm going to share all of
  18354. 12:36:46this code in my video description. From
  18355. 12:36:48there you can get and you can execute
  18356. 12:36:49inside your system guys. Okay. Now I can
  18357. 12:36:52test one more thing which is the
  18358. 12:36:53persistence. That means whether it is
  18359. 12:36:55able to remember my name or not. So I'll
  18360. 12:36:57ask what is
  18361. 12:37:02my name?
  18362. 12:37:07Your name is BPI as you mentioned
  18363. 12:37:09earlier. Okay perfect it is able to
  18364. 12:37:11remember. So guys here one more update
  18365. 12:37:13we have to do inside this uh chatbot um
  18366. 12:37:17which is let's say if I ask anything um
  18367. 12:37:22let's say if I tell generate
  18368. 12:37:26uh blog
  18369. 12:37:29about
  18370. 12:37:32um about let's say python now see if I
  18371. 12:37:36give this uh prompt to my chatbot
  18372. 12:37:40it will take some time Right? It is
  18373. 12:37:42taking some time to generate this
  18374. 12:37:44particular block and user has to wait uh
  18375. 12:37:47till the execution. Right? But if you go
  18376. 12:37:50to the chat GPT, if you give the same
  18377. 12:37:52prompt, right? If you give the same
  18378. 12:37:54prompt
  18379. 12:37:56and if you send this message, so
  18380. 12:37:59instantly you'll be able to see it will
  18381. 12:38:02start generating one by one. So this is
  18382. 12:38:04called streaming response. See it is
  18383. 12:38:07still generating streaming response. But
  18384. 12:38:10the chatbot we have created it is
  18385. 12:38:12generating in one shot. Okay, we have to
  18386. 12:38:14wait for the execution. Once execution
  18387. 12:38:16is complete, once my generation is
  18388. 12:38:18complete from the chatbot, then you will
  18389. 12:38:20be able to see the content. Okay, so
  18390. 12:38:22let's say if you are generating a big
  18391. 12:38:24blog or any kinds of big content from
  18392. 12:38:26the chatbot, that time you have to wait
  18393. 12:38:28and this is not a good user experience,
  18394. 12:38:30right? But in chat GPT, this is a good
  18395. 12:38:32experience. Uh if you give any kinds of
  18396. 12:38:34prompt, whether it is a big content, it
  18397. 12:38:37doesn't matter. it will generate this
  18398. 12:38:40content okay token by token uh and user
  18399. 12:38:43will read it okay instantly user will be
  18400. 12:38:45able to read it so this is called
  18401. 12:38:47streaming response so if you want to
  18402. 12:38:49implement this kinds of streaming
  18403. 12:38:50response inside your chatbot as well you
  18404. 12:38:53can also do it because I already told
  18405. 12:38:54you I will also show you this streaming
  18406. 12:38:56response as well okay uh streaming yeah
  18407. 12:38:59how to add the streaming uh inside
  18408. 12:39:01langraph in langraph also you can uh add
  18409. 12:39:04this streaming concept now let's try to
  18410. 12:39:05add it I will open up my
  18411. 12:39:08So in this app.py only you have to add
  18412. 12:39:12this line. So there is a like a very
  18413. 12:39:16minor change you have to do. See uh
  18414. 12:39:18whenever you are getting this um
  18415. 12:39:22you are getting this
  18416. 12:39:25uh assistant message right
  18417. 12:39:28we we are invoking the response
  18418. 12:39:32and after invoking the response we are
  18419. 12:39:35getting the AI message. So basically
  18420. 12:39:37here what is happening first of all you
  18421. 12:39:39are invoking the message and you are
  18422. 12:39:42waiting for the response once you got
  18423. 12:39:44the response then you are showing this
  18424. 12:39:46response to the streamly user interface.
  18425. 12:39:49So we have to replace this code with
  18426. 12:39:51this code.
  18427. 12:39:55So this is the code guys
  18428. 12:39:58you have to use. See here instead of
  18429. 12:40:01inboxing at the very first time first of
  18430. 12:40:03all what we are doing see we are
  18431. 12:40:05preparing this assistant icon. After
  18432. 12:40:07that there is a function inside streaml
  18433. 12:40:10called write stream. Okay we are using
  18434. 12:40:12this write stream function. Inside that
  18435. 12:40:15uh we are using the chatbot object.
  18436. 12:40:18Okay. Now instead of invoking we'll be
  18437. 12:40:20using stream. Inside that you have to
  18438. 12:40:22pass the uh message user input and you
  18439. 12:40:26have to give the configuration. Okay. We
  18440. 12:40:28already have the configuration. I need
  18441. 12:40:29to pass the config only. So config is
  18442. 12:40:33equal to config. Yeah. And stream mode
  18443. 12:40:36is equal to message. You have to provide
  18444. 12:40:37this particular uh configuration. And
  18445. 12:40:41you have to run a for loop uh for
  18446. 12:40:44message chunk and metadata. So whatever
  18447. 12:40:46message chunk you will be getting you
  18448. 12:40:48will only take the content and this
  18449. 12:40:50message chunk
  18450. 12:40:52uh continuously it will be showing in
  18451. 12:40:55the streaml cons uh streaml user
  18452. 12:40:57interface because we are using write
  18453. 12:40:58stream that means every time whenever
  18454. 12:41:01using chart gpt and you are generating
  18455. 12:41:02something okay let's say you are
  18456. 12:41:05generating something let's I'll tell
  18457. 12:41:07more about it
  18458. 12:41:10it is giving you the response token by
  18459. 12:41:12token as you can see token by token okay
  18460. 12:41:15so this kinds of token by token output
  18461. 12:41:17you will be getting and you will be
  18462. 12:41:19writing in the streamlit user interface.
  18463. 12:41:21So this will feel like uh this is a
  18464. 12:41:23streaming response that time. Okay. Then
  18465. 12:41:25once everything is done then we will try
  18466. 12:41:27to store this uh AI message to the
  18467. 12:41:31history message we are appending like a
  18468. 12:41:35same uh previously we did okay as
  18469. 12:41:37assistant we are appending in the
  18470. 12:41:38session state. Now let me show you. So
  18471. 12:41:40if I get back if I refresh fine now
  18472. 12:41:44let's say I'll give hi
  18473. 12:41:49stream has no attribute right stream
  18474. 12:41:55why this error is coming let me check
  18475. 12:42:02maybe the version we are using it
  18476. 12:42:04doesn't have this right stream so what I
  18477. 12:42:06can do I can install the latest on.
  18478. 12:42:22Now if I give the message again. Okay,
  18479. 12:42:25still the same issue. Let me check guys.
  18480. 12:42:31Okay, I have given this error to the
  18481. 12:42:33chart GPT and CH GP is telling you still
  18482. 12:42:35you need to upgrade this streaml. So let
  18483. 12:42:37me execute this command.
  18484. 12:42:42p install upgrade streamllet.
  18485. 12:42:47H. So basically this will download the
  18486. 12:42:49upgraded version.
  18487. 12:42:55Then now we can try again.
  18488. 12:43:08Now I'll give message hi.
  18489. 12:43:14Now see we are getting the response. Now
  18490. 12:43:16if I ask let's say generate
  18491. 12:43:20uh blog
  18492. 12:43:22about python.
  18493. 12:43:25Now see it is streaming response like
  18494. 12:43:27chatgity right now. Okay. And this is
  18495. 12:43:30more interesting and more
  18496. 12:43:33uh good experience to the user. Okay. So
  18497. 12:43:36that uh this kinds of scenario you also
  18498. 12:43:38you also need to take care whenever you
  18499. 12:43:40are creating this kinds of uh agentic
  18500. 12:43:43system. Okay. Or any kinds of simple
  18501. 12:43:44chatbot whatever you are creating this
  18502. 12:43:46kinds of thing you have to take care and
  18503. 12:43:49a lang uh graph is having this kinds of
  18504. 12:43:52concept integrated. Okay. You can easily
  18505. 12:43:54implement this thing in the lang graph.
  18506. 12:43:57Okay. Okay. So we have also se seen how
  18507. 12:43:59we can add the streaming response inside
  18508. 12:44:02our application. Okay. Now this
  18509. 12:44:04application looks more cool. Now in the
  18510. 12:44:06next video guys I'm going to discuss
  18511. 12:44:08about this uh persistence concept in
  18512. 12:44:10more detail. We'll try to see uh what is
  18513. 12:44:14this persistence is all about. We have
  18514. 12:44:16already understood in this video as a
  18515. 12:44:18high level but uh in detail I'll try to
  18516. 12:44:20discuss in the next video. So yeah guys
  18517. 12:44:22this is all about from this uh first
  18518. 12:44:24part of this implementation. So guys as
  18519. 12:44:27you can see this is the definition of
  18520. 12:44:29persistence and uh in my previous uh
  18521. 12:44:31video that means in the part one maybe I
  18522. 12:44:34already given you the highle overview on
  18523. 12:44:36top of this persistence like what is
  18524. 12:44:38persistence and how we can integrate
  18525. 12:44:40with our chatbot I already told you
  18526. 12:44:42about but let's try to understand the
  18527. 12:44:44detailed definition of persistence as
  18528. 12:44:46you can see persistence in langraph is a
  18529. 12:44:48built-in layer that automatically saves
  18530. 12:44:50and restores the state of your agent or
  18531. 12:44:54graph workflow over time. Okay. It works
  18532. 12:44:58by uh using a checkpointer to
  18533. 12:45:00automatically capture snapshot of the
  18534. 12:45:02graphs state at every step organizing
  18535. 12:45:06them into unique and retrievable traits.
  18536. 12:45:10Okay. So I think uh by the definition
  18537. 12:45:12itself you can understand uh what I'm
  18538. 12:45:14trying to say here because if you have
  18539. 12:45:16already completed the part one uh of
  18540. 12:45:18this uh uh chatbot implementation I
  18541. 12:45:20think you know that uh see persistence
  18542. 12:45:23why it is required. First of all, let's
  18543. 12:45:25try to understand from the beginning.
  18544. 12:45:28Um, I think you know uh inside aentic
  18545. 12:45:31application first of all we'll have a
  18546. 12:45:33goal, right? So let's say yeah let me
  18547. 12:45:35write down.
  18548. 12:45:38Yeah. So see in any kinds of agentic
  18549. 12:45:41application first of all definitely
  18550. 12:45:42we'll have a goal. Let's say you have a
  18551. 12:45:46problem statement right? You want to
  18552. 12:45:47let's say here we are creating a aentic
  18553. 12:45:49chatbot. So definitely this is our goal.
  18554. 12:45:51Now this goal should be divided into
  18555. 12:45:53multiple tasks. So first of all what
  18556. 12:45:55we'll do guys we'll try to divide this
  18557. 12:45:57goal to the multiple task. Let's say
  18558. 12:45:59this is task one. Okay this is task two
  18559. 12:46:05and so on. That's how we'll be breaking
  18560. 12:46:07down different different task and
  18561. 12:46:09whenever we'll be using lang graph right
  18562. 12:46:11whenever we'll be using lang graph
  18563. 12:46:15because so far we are learning about
  18564. 12:46:16lang graph. So in lang graph to define
  18565. 12:46:19this particular task we use something
  18566. 12:46:21called nodes right each of the task will
  18567. 12:46:23become a nodes let's say this is our
  18568. 12:46:25first nodes this is our second nodes
  18569. 12:46:27okay and so on so that means first of
  18570. 12:46:30all we'll be having a goal and we'll
  18571. 12:46:33define a task from this particular goal
  18572. 12:46:35like u step-by-step task and this
  18573. 12:46:38particular task would be our nodes okay
  18574. 12:46:40inside the graph because this is the
  18575. 12:46:42entire graph as you can see this is the
  18576. 12:46:44entire graph
  18577. 12:46:48entire graph in line graph, right? This
  18578. 12:46:50is the entire graph in line graph and
  18579. 12:46:52these are the nodes. Okay. And you can
  18580. 12:46:53see this is the age connection.
  18581. 12:46:56Uh this is the age connection and this
  18582. 12:46:58start node is nothing but this is the
  18583. 12:47:00input. So here we pass our initial state
  18584. 12:47:04initial input right and this input will
  18585. 12:47:06go through this edges. This edge is
  18586. 12:47:09nothing but it's a connection. This edge
  18587. 12:47:11defines basically after which node what
  18588. 12:47:14node should be executed. Okay, because
  18589. 12:47:16of this particular arrow symbol. As you
  18590. 12:47:19can see this arrow symbol defines okay
  18591. 12:47:20after start nodes node one would be
  18592. 12:47:23executed. After node one node two would
  18593. 12:47:25be executed like that right. So this is
  18594. 12:47:27called ages. This is called ages and
  18595. 12:47:30this is called nodes. We already know
  18596. 12:47:32about this is called nodes right.
  18597. 12:47:35Okay. Then this particular task will go
  18598. 12:47:38through all of the nodes. Then at the
  18599. 12:47:40last we use a end nodes. What this end
  18600. 12:47:43nodes will do it will first uh basically
  18601. 12:47:45uh stop the graph execution. Okay. Let's
  18602. 12:47:47say whenever we'll give any kinds of
  18603. 12:47:49input and whenever it will reach to this
  18604. 12:47:52particular end it will stop the graph
  18605. 12:47:55execution and you will be able to see
  18606. 12:47:56the final okay final result here. Final
  18607. 12:48:01result here and we have already seen
  18608. 12:48:02this particular things in the practical
  18609. 12:48:04implementation as well. I think this is
  18610. 12:48:06pretty much clear to you right now. See
  18611. 12:48:09the main things we have to understand uh
  18612. 12:48:12whenever we are defining any kinds of
  18613. 12:48:14graph right whenever we are defining any
  18614. 12:48:16kinds of graph and if I want to execute
  18615. 12:48:18this graph in lang graph we have to
  18616. 12:48:20provide something called state right we
  18617. 12:48:22have to provide something called state I
  18618. 12:48:24think you know that without state we
  18619. 12:48:25can't execute any kinds of graph and
  18620. 12:48:27what is state is nothing but it's kinds
  18621. 12:48:30of uh it's kinds of variable we are
  18622. 12:48:32passing right it's kind of some of the
  18623. 12:48:34data we are passing to the graph okay
  18624. 12:48:37let's say in this particular chatbot
  18625. 12:48:39what is should what should be the state
  18626. 12:48:41state should be the message let's say
  18627. 12:48:43the message user is giving okay and our
  18628. 12:48:46AI bot is replying so this is the
  18629. 12:48:48message this is the information so every
  18630. 12:48:49time what will happen this state will go
  18631. 12:48:51to the every nodes okay every nodes and
  18632. 12:48:54this nodes whatever uh output will
  18633. 12:48:56return it will basically update in this
  18634. 12:48:57particular variable okay this is called
  18635. 12:48:59state but what happens if we are giving
  18636. 12:49:02this particular state to the um graph so
  18637. 12:49:05let's say we are passing the state to
  18638. 12:49:07the start node right Then start node
  18639. 12:49:09will pass to the node one then node two
  18640. 12:49:11then n then end. So whenever it will go
  18641. 12:49:13to the end that means this graph
  18642. 12:49:16execution is getting over and whatever
  18643. 12:49:19state whatever state data you are having
  18644. 12:49:21here it will be basically erased that
  18645. 12:49:23time. Okay it will be basically erased
  18646. 12:49:25that time. Then whenever you will be
  18647. 12:49:27running second time you won't be able to
  18648. 12:49:29get the previous information whatever uh
  18649. 12:49:32you got in the first execution right
  18650. 12:49:34inside the state. So this is the main
  18651. 12:49:35problem. Then what we introduce we
  18652. 12:49:37introduce something called persistence
  18653. 12:49:39right we introduce something called
  18654. 12:49:42persistence. So in persistence what we
  18655. 12:49:45usually do here we basically save the
  18656. 12:49:49entire state okay inside a storage
  18657. 12:49:51service either you can use your uh RAM
  18658. 12:49:54okay we call it as a memory saver either
  18659. 12:49:56you can use any kinds of database that
  18660. 12:49:58means two kinds of storage service you
  18661. 12:50:00can use either you can use your RAM that
  18662. 12:50:03means memory
  18663. 12:50:05okay your computer memory either you can
  18664. 12:50:08use any kinds of database here okay
  18665. 12:50:11database is the permanent one. Okay,
  18666. 12:50:14perma
  18667. 12:50:16net one and this is the temporary one.
  18668. 12:50:20Temporary one. Okay, temporary means if
  18669. 12:50:22you restart your application that time
  18670. 12:50:24this data would be erased. But in
  18671. 12:50:26database if you restart your application
  18672. 12:50:28okay it doesn't matter you if you
  18673. 12:50:30restart if if your uh uh let's say
  18674. 12:50:33system crashes it doesn't matter your
  18675. 12:50:35data will be permanent okay you can load
  18676. 12:50:37anytime this kinds of data that okay
  18677. 12:50:40[snorts] that means uh inside persistent
  18678. 12:50:43whatever state snapshot we are having
  18679. 12:50:45okay we try to store inside a storage
  18680. 12:50:47service that's why in in the definition
  18681. 12:50:49itself you can see persistence in lang
  18682. 12:50:51graph is a built-in layer that
  18683. 12:50:52automatically save okay and restore That
  18684. 12:50:55means you can restore this particular uh
  18685. 12:50:57state anytime okay from the storage
  18686. 12:50:59service the state of your agents okay
  18687. 12:51:02the state of your agents or graph
  18688. 12:51:04workflow over time okay over time means
  18689. 12:51:07because it is every every time it is
  18690. 12:51:09capturing your snapshot it is um let's
  18691. 12:51:12say this persistence every time it will
  18692. 12:51:14save the informations in the u uh
  18693. 12:51:17storage service let's say after start
  18694. 12:51:18whatever uh state uh update you got
  18695. 12:51:21right this particular information would
  18696. 12:51:23be saved after node one execution
  18697. 12:51:25Whatever uh state would be saved, it
  18698. 12:51:27will be basically saved in the database
  18699. 12:51:29or your local storage. Okay, that's how
  18700. 12:51:31every step okay every step it will be
  18701. 12:51:35saving the information of your state.
  18702. 12:51:37That's why we call it as a overtime here
  18703. 12:51:39and it works by using a checkpointer to
  18704. 12:51:42automatically capture the snapshot of
  18705. 12:51:44the graph state at the every step. Okay,
  18706. 12:51:46I already told you and in my previous
  18707. 12:51:48implementation I used something called
  18708. 12:51:49checkpo pointer. I think you know that
  18709. 12:51:51again I will give you the idea. Okay,
  18710. 12:51:52how checkpoint pointer works and uh each
  18711. 12:51:54and everything I'll give you. Then one
  18712. 12:51:56uh another thing we learned this
  18713. 12:51:57organizing them into unique and uh
  18714. 12:51:59retrievable trades. Okay, we'll be also
  18715. 12:52:01learning about the trades. Trade means
  18716. 12:52:03you can create multiple trades. Let's
  18717. 12:52:05say uh trade one you can do some kinds
  18718. 12:52:08of conversation in trade two you can do
  18719. 12:52:10another uh kinds of conversation. Okay.
  18720. 12:52:12So both conversation would be different
  18721. 12:52:14and you can't use trade one information
  18722. 12:52:16in trade two and trade two information
  18723. 12:52:19in trade one. Okay. we can also make
  18724. 12:52:21this particular difference. Okay, I hope
  18725. 12:52:22you got it guys. Now that's how your
  18726. 12:52:25persistence comes into picture and this
  18727. 12:52:27is very much important whenever you are
  18728. 12:52:28creating this kinds of agentic AI
  18729. 12:52:30application otherwise what will happen
  18730. 12:52:32your application may not get this state
  18731. 12:52:35uh data okay over time whenever you are
  18732. 12:52:39creating this kinds of uh agentic
  18733. 12:52:41chatbot or any other let's say advanced
  18734. 12:52:44application uh which is required your
  18735. 12:52:46older data as well okay just try to
  18736. 12:52:48think about whenever we are creating
  18737. 12:52:49this agentic chatbot definitely I need
  18738. 12:52:51my previous response let's say I have
  18739. 12:52:53given the input my name is BP right and
  18740. 12:52:56second time if I'm asking what is my
  18741. 12:52:58name so definitely it should remember
  18742. 12:52:59that particular informations right
  18743. 12:53:01whatever it has updated uh in the state
  18744. 12:53:04okay but if it is getting end right and
  18745. 12:53:06if the final result is getting erased
  18746. 12:53:09okay of this state that time definitely
  18747. 12:53:11your uh definitely your agent won't be
  18748. 12:53:14able to give you the response but if
  18749. 12:53:15you're using the persistence concept and
  18750. 12:53:18if you're capturing this state okay
  18751. 12:53:19inside a memory okay if you're saving
  18752. 12:53:21this inside a memory so anytime time we
  18753. 12:53:23can load this and we can pass again to
  18754. 12:53:26the graph and graph will be able to
  18755. 12:53:27recall the previous information and that
  18756. 12:53:29that will be able to give me the result.
  18757. 12:53:31Let's see your name is BP. So this is
  18758. 12:53:33the main fun here. Okay, I hope you
  18759. 12:53:35clear guys. So guys now let's try to
  18760. 12:53:37understand the specialtity of
  18761. 12:53:39persistence. Uh see persistence
  18762. 12:53:42uh is having some kinds of specialtity.
  18763. 12:53:45Um see I told you uh whenever we define
  18764. 12:53:49any kinds of state right and uh uh
  18765. 12:53:52whenever we execute a graph so this
  18766. 12:53:54state will go to the every nodes right
  18767. 12:53:56every nodes it will go and uh all the
  18768. 12:53:59nodes will be uh updating something in
  18769. 12:54:02the state okay and we'll be getting a
  18770. 12:54:04final result from here so it doesn't
  18771. 12:54:07mean this persistence will only capture
  18772. 12:54:09the final updated state information
  18773. 12:54:12instead of that it will be able able to
  18774. 12:54:16uh store your intermediate uh let's say
  18775. 12:54:19data intermediate data means see what
  18776. 12:54:22happens whenever we define any kinds of
  18777. 12:54:24state right let's try to take example
  18778. 12:54:27let's say state so let's say here I have
  18779. 12:54:30taken a state um the state name is let's
  18780. 12:54:32say I will take name I want to only save
  18781. 12:54:35the name information here okay name
  18782. 12:54:38let's say I have only taken one variable
  18783. 12:54:40so what will happen this state will go
  18784. 12:54:42to the every node first of all it will
  18785. 12:54:44go to the start node. Okay. After going
  18786. 12:54:47to the start node, uh this uh uh uh your
  18787. 12:54:51graph would be initialized, your graph
  18788. 12:54:53would be executed. So through this
  18789. 12:54:55edges, it will reach to the node one.
  18790. 12:54:57Okay. Let's say in node one, we are
  18791. 12:54:59doing some kinds of update. That means
  18792. 12:55:00node one is updating this name.
  18793. 12:55:04Let's say initially it was uh let's say
  18794. 12:55:06initially I have given a let me take
  18795. 12:55:09this color. Initially let's say the name
  18796. 12:55:11was A. Okay. Now what will do? This node
  18797. 12:55:14one will try to update this particular
  18798. 12:55:16name. Let's say it will be uh updating
  18799. 12:55:20B. Okay. It will update B. But whenever
  18800. 12:55:23we pass this state okay initially it was
  18801. 12:55:26name A. Okay. But whenever we pass
  18802. 12:55:29through this node one uh this uh was
  18803. 12:55:32changed to to the B. Right. So the
  18804. 12:55:35execution you can see here node uh start
  18805. 12:55:37to node one uh that means through this
  18806. 12:55:40execution okay this is called super
  18807. 12:55:44super step okay this is called super
  18808. 12:55:47step so what is super step basically to
  18809. 12:55:49execute the entire nodes okay to execute
  18810. 12:55:52the entire graph uh whatever super step
  18811. 12:55:55we perform okay let's say if I want to
  18812. 12:55:58execute the entire graph definitely I
  18813. 12:56:00have to execute node one node two okay
  18814. 12:56:02then it will go to uh go to this end
  18815. 12:56:04then your entire graph would be
  18816. 12:56:06executed. Then you can see multiple age
  18817. 12:56:08connection is there and each of the age
  18818. 12:56:10connection is a super step here. Okay,
  18819. 12:56:12that means in every super step there
  18820. 12:56:14would be some kinds of update in the
  18821. 12:56:16state and your persistence would be able
  18822. 12:56:18to capture this informations in the uh
  18823. 12:56:21stories. Okay, that means let's say
  18824. 12:56:24after node one it will go to the node
  18825. 12:56:26two let's say node two will try to
  18826. 12:56:28replace this uh B to this C. Okay. And
  18827. 12:56:32whenever it will reach to the end and
  18828. 12:56:34here you will get the final name MC.
  18829. 12:56:37Right. But it's not like that. It is
  18830. 12:56:39replacing all of the previous
  18831. 12:56:41information. Still the previous
  18832. 12:56:42information is available. Okay. Still
  18833. 12:56:44the previous information is available.
  18834. 12:56:46Okay. So this information I we call it
  18835. 12:56:48as a intermediate
  18836. 12:56:51intermediate.
  18837. 12:56:55Okay. Intermediate state.
  18838. 12:56:58Okay. We call it as intermediate state.
  18839. 12:57:00And this is called final
  18840. 12:57:03state. Okay, final state. That means the
  18841. 12:57:06specialty of persistence is it will
  18842. 12:57:08capture your intermediate state. State
  18843. 12:57:10state as well and the final state as
  18844. 12:57:12well. Okay, it's not like that. Every
  18845. 12:57:13time you'll get the final state
  18846. 12:57:15definitely intermediate state would be
  18847. 12:57:17available uh after each and every super
  18848. 12:57:20step execution. Okay. Let's say in
  18849. 12:57:23future uh your application will crash
  18850. 12:57:25here. Let's say node one it will crash
  18851. 12:57:27or let's say node two it will crash.
  18852. 12:57:29Okay, that time it's not necessary.
  18853. 12:57:32Whenever you will restart your
  18854. 12:57:33application, it will execute from the
  18855. 12:57:35beginning. Okay, it's not like that
  18856. 12:57:36because it has the intermediate state
  18857. 12:57:38and it has already has the information.
  18858. 12:57:41Okay, so what it will do? It will re
  18859. 12:57:44able to resume. Okay, it will able to
  18860. 12:57:45resume your application from node one or
  18861. 12:57:48node two because it has captured the
  18862. 12:57:50intermediate state. Okay, so this is
  18863. 12:57:52called actually fault tolerance. I
  18864. 12:57:54already told you about this, right?
  18865. 12:57:56fault tolerance in my introductory
  18866. 12:58:00session I already told you about fault
  18867. 12:58:02tolerance right that means whenever your
  18868. 12:58:04application get crashes it not it's not
  18869. 12:58:07necessary to re-execute application from
  18870. 12:58:09the beginning okay you can execute your
  18871. 12:58:11application wherever your application
  18872. 12:58:13got crashes let's say this is crash
  18873. 12:58:15point okay or let's say this is crash
  18874. 12:58:17point wherever your crash point happens
  18875. 12:58:20it will resume the application from here
  18876. 12:58:22itself okay I hope you get it so this is
  18877. 12:58:25the specialty of This persistence uh if
  18878. 12:58:28you see these kinds of question in the
  18879. 12:58:30interview what is the specialty of
  18880. 12:58:32persistence that time you can tell it
  18881. 12:58:34can also save the information uh of the
  18882. 12:58:37intermediate state along with the final
  18883. 12:58:39state okay I hope you get it and if you
  18884. 12:58:42go to the uh uh real time let's say
  18885. 12:58:44application let's say if I go to the
  18886. 12:58:45chart GPT okay chart GPT also using this
  18887. 12:58:48kinds of persistence concept so in chat
  18888. 12:58:50GPT what you can do you can either
  18889. 12:58:52create a new conversation okay new chat
  18890. 12:58:55either you can continue with your old
  18891. 12:58:57chat, right? Either you can continue
  18892. 12:58:58with your old chat. Let's say if I want
  18893. 12:59:00to continue some kinds of old chat, I
  18894. 12:59:03can continue here. Let's say this is my
  18895. 12:59:05old chat as you can see, right? I can
  18896. 12:59:08continue here. So, let's say what is
  18897. 12:59:13the final
  18898. 12:59:15code?
  18899. 12:59:17See, it will basically uh reusing my
  18900. 12:59:21older state.
  18901. 12:59:23See and it is continuing the
  18902. 12:59:26conversation. Okay. And even I can also
  18903. 12:59:29start a new conversation here. Okay. If
  18904. 12:59:31I start a new conversation that means my
  18905. 12:59:33new state would be created and one by
  18906. 12:59:36one this uh super step will be executed
  18907. 12:59:39and each and every okay step this
  18908. 12:59:42snapshot would be captured. It will be
  18909. 12:59:43updated in the state. Okay. So without
  18910. 12:59:46this state you can't create this kinds
  18911. 12:59:48of application. Definitely uh for this
  18912. 12:59:51kinds of advanced agentic chatbot you
  18913. 12:59:53need this state and this state is
  18914. 12:59:55already sorry um uh you need this kinds
  18915. 12:59:58of persistence concept and this
  18916. 12:59:59persistence is already okay integrated
  18917. 13:00:02inside lang graph. Okay and with the
  18918. 13:00:04help of that you can handle this kinds
  18919. 13:00:06of fall tolerance in a very easiest
  18920. 13:00:07manner. Okay, I hope you got it guys.
  18921. 13:00:10I've given you the example with the real
  18922. 13:00:12world example as well like chart GPT. So
  18923. 13:00:14charge GPS are also using this kinds of
  18924. 13:00:18persistence in the back end. So in
  18925. 13:00:20charge GPT what is happening whatever
  18926. 13:00:22conversation you are doing okay whatever
  18927. 13:00:25conversation you are doing uh this kinds
  18928. 13:00:27of information is getting saved uh okay
  18929. 13:00:31uh in the state and they're using
  18930. 13:00:33persistence concept here definitely and
  18931. 13:00:36they're storing this kinds of
  18932. 13:00:37information um in a database okay
  18933. 13:00:39they're not using any kinds of local uh
  18934. 13:00:42storage service instead of that they're
  18935. 13:00:43using some kinds of database and from
  18936. 13:00:45the database itself this information is
  18937. 13:00:47getting okay fetched okay Whenever you
  18938. 13:00:50are opening any kinds of old
  18939. 13:00:51conversation, you will be able to see
  18940. 13:00:53whatever uh message you have done here.
  18941. 13:00:55So the this information is coming from
  18942. 13:00:57the database. Okay, I hope you clear
  18943. 13:00:59guys. Now guys, this definition would be
  18944. 13:01:02pretty much clear uh like uh what is
  18945. 13:01:04happening inside persistence. Uh now
  18946. 13:01:07let's try to understand another uh
  18947. 13:01:09concept here. As you can see, it works
  18948. 13:01:10by using a checkp pointer to
  18949. 13:01:12automatically capture the snapshot of
  18950. 13:01:14the uh graph states. Okay, at every
  18951. 13:01:17step. Now let's try to understand what
  18952. 13:01:19is this uh checkpointer exactly. So here
  18953. 13:01:22I have taken another example guys. As
  18954. 13:01:23you can see checkpointer is uh in inside
  18955. 13:01:26of persistence.
  18956. 13:01:28See checkpointer is nothing but uh you
  18957. 13:01:32can consider this checkpointer is kinds
  18958. 13:01:34of uh it's kinds of tracking uh tracking
  18959. 13:01:38functionality. Tracking functionality
  18960. 13:01:39means each and every super step whenever
  18961. 13:01:42it is executing and whatever update we
  18962. 13:01:45are making inside the state that time
  18963. 13:01:47checkpointer will be able to capture
  18964. 13:01:50those informations in the uh state right
  18965. 13:01:53in the state means it will be able to
  18966. 13:01:55capture those information and it will
  18967. 13:01:56save inside the uh persistence memory
  18968. 13:01:59okay so let's try to understand this
  18969. 13:02:01concept in detail so what I'm going to
  18970. 13:02:03do I'm going to open up my blackboard
  18971. 13:02:04and here let me make you understand see
  18972. 13:02:07what I told Okay. Uh whenever we uh give
  18973. 13:02:10any kinds of state to a graph. Okay. Uh
  18974. 13:02:14so what will happen? It will execute the
  18975. 13:02:15nodes one by one. As you can see we are
  18976. 13:02:18having lots of nodes here. And uh you
  18977. 13:02:21can see the age connection. This is the
  18978. 13:02:22age connection. And whenever you are
  18979. 13:02:24doing this kinds of age uh age
  18980. 13:02:26connection uh and age execution that
  18981. 13:02:28means after start to uh sorry um from
  18982. 13:02:31start to node one here we are get doing
  18983. 13:02:34a execution and this execution we call
  18984. 13:02:36it as a super step right I already told
  18985. 13:02:38you about super step
  18986. 13:02:41right. So when whenever you are having
  18987. 13:02:43this kinds of super step okay whenever
  18988. 13:02:46you are having this kinds of super state
  18989. 13:02:48uh after that you will basically set a
  18990. 13:02:51checkpoint okay set a checkpoint that
  18991. 13:02:53means whenever we are passing a initial
  18992. 13:02:55state to the start that time one
  18993. 13:02:57checkpoint would be available here
  18994. 13:02:59checkpoint
  18995. 13:03:01uh checkpoint one okay let's say this is
  18996. 13:03:03our checkpoint one then [snorts]
  18997. 13:03:06u after doing this uh superstep
  18998. 13:03:08execution there would be again a update
  18999. 13:03:10so there would be another Checkpoint
  19000. 13:03:13let's say this is checkpoint two and you
  19001. 13:03:16here you are having multiple nodes okay
  19002. 13:03:18as parallel so this is one execution
  19003. 13:03:21this is another execution this is
  19004. 13:03:22another execution we combine all of the
  19005. 13:03:24execution and we will be calling as a
  19006. 13:03:26another super step another
  19007. 13:03:29super step
  19008. 13:03:37right and uh after this super step there
  19009. 13:03:40would be another checkpoint and
  19010. 13:03:44checkpoint three. Okay. And at the last
  19011. 13:03:48uh because here we are doing another
  19012. 13:03:49superstep execution and I'm getting the
  19013. 13:03:51final response. Okay. Here also another
  19014. 13:03:53checkpoint would be available.
  19015. 13:03:55Checkpoint let's say four. Okay. And
  19016. 13:03:57every checkpoint will capture the
  19017. 13:03:59updated state. Let's say after this
  19018. 13:04:01start to node one whatever update will
  19019. 13:04:03be happening in this state this
  19020. 13:04:05checkpointer will capture that
  19021. 13:04:06information. It will save in the
  19022. 13:04:08persistence memory.
  19023. 13:04:11Okay, persistence
  19024. 13:04:13memory it will save either you are using
  19025. 13:04:15local local storage that means your RAM
  19026. 13:04:18either you you are using any kinds of
  19027. 13:04:20database okay database it will store
  19028. 13:04:24there okay whenever it is uh storing
  19029. 13:04:28that means it is not replacing the value
  19030. 13:04:30instead of that it is merging that means
  19031. 13:04:32it is adding the information
  19032. 13:04:34adding the information and we call it as
  19033. 13:04:36a reducer concept I think you know that
  19034. 13:04:39reducer That means whenever we are using
  19035. 13:04:41this kinds of persistence concept
  19036. 13:04:43definitely we have to use the reducer
  19037. 13:04:45okay reducer concept we'll be
  19038. 13:04:47continuously adding the informations
  19039. 13:04:49instead of replacing the old one okay I
  19040. 13:04:51hope you get it guys okay then uh this
  19041. 13:04:54kinds of uh checkpoint we have in every
  19042. 13:04:58uh super step and whenever any kinds of
  19043. 13:05:00update would be happen in the state it
  19044. 13:05:02will capture the information and you'll
  19045. 13:05:04be getting a final snapshot final let's
  19046. 13:05:06say state at the last checkpoint and
  19047. 13:05:08this will like store at the last. Okay,
  19048. 13:05:10but you will be able to see the previous
  19049. 13:05:12update as well in the state. Okay, this
  19050. 13:05:15is how this particular checkp pointer is
  19051. 13:05:17working.
  19052. 13:05:19I hope you got it right. To get the like
  19053. 13:05:23updated data in the state, we use this
  19054. 13:05:25kinds of checkpointter and the
  19055. 13:05:26checkpointer work is to capture this
  19056. 13:05:28information in the storage service. This
  19057. 13:05:30is the work of a checkpointer. That's
  19058. 13:05:32why in the definition itself I think you
  19059. 13:05:34see the definition in the definition
  19060. 13:05:36itself it is telling it works by using a
  19061. 13:05:38checkpoint to automatically capture
  19062. 13:05:40snapshot of a graph state at every step.
  19063. 13:05:42Okay. Because we're using every step
  19064. 13:05:44execution here. I hope you get it guys.
  19065. 13:05:47Okay. Now let's try to understand this
  19066. 13:05:49checkpointer concept through an example.
  19067. 13:05:51Let's say I'll take the same graph
  19068. 13:05:53execution here. So let's say here I will
  19069. 13:05:56define a state.
  19070. 13:05:58Let's say
  19071. 13:06:01I'll define a state here. Uh the state
  19072. 13:06:04variable I'll take number.
  19073. 13:06:07Okay. Number. So this number will be a
  19074. 13:06:11list of integer.
  19075. 13:06:13List of
  19076. 13:06:15integer. Okay. And here we are using add
  19077. 13:06:21operation. Why we are using add
  19078. 13:06:22operation? Because we are using reducer
  19079. 13:06:24concept. I think you know that. Okay.
  19080. 13:06:26And uh this uh this number would be a
  19081. 13:06:29list list of numbers and all of the
  19082. 13:06:31number would be integer. Okay. So let's
  19083. 13:06:34say initially whenever I will pass this
  19084. 13:06:36number
  19085. 13:06:38pass this number to the uh graph
  19086. 13:06:41initially let's say the value is one.
  19087. 13:06:43Okay. The value is one. So I told you
  19088. 13:06:47each and every
  19089. 13:06:49uh super step will be having a checkp
  19090. 13:06:51pointer. Let's say I can define all of
  19091. 13:06:54the checkpointer definitely uh at the
  19092. 13:06:57first node there would be a
  19093. 13:06:58checkpointter let's say CP1
  19094. 13:07:02then here also we'll be having a
  19095. 13:07:03checkpointer CP2 here also we'll be
  19096. 13:07:06having a checkpointer CP 3 and here we
  19097. 13:07:09are having let's say CP 4 we are having
  19098. 13:07:13all the checkp pointer so what will
  19099. 13:07:15happen
  19100. 13:07:17uh yeah so whenever it will execute it
  19101. 13:07:21will go to the node one. Okay, let's say
  19102. 13:07:23node one update um update this value.
  19103. 13:07:27Let's say this number, it will update uh
  19104. 13:07:30let's say two.
  19105. 13:07:32Okay, two. It will return two. So what
  19106. 13:07:35will happen? Um now the number will
  19107. 13:07:37become like that.
  19108. 13:07:40So in this list
  19109. 13:07:44list so initially the number was I'll
  19110. 13:07:47denote with n. N means number. Initially
  19111. 13:07:50it was one right one and now it has
  19112. 13:07:53updated uh two. So instead of replacing
  19113. 13:07:56the previous one it will add the number
  19114. 13:07:58at the last. Okay this is the concept of
  19115. 13:08:01the reducer. Okay and this is called
  19116. 13:08:03your intermediate state. Now we got the
  19117. 13:08:06intermediate state. Now it will go to
  19118. 13:08:08the next node execution and here also
  19119. 13:08:11you are having a check pointer. Now
  19120. 13:08:13let's say this generates uh single
  19121. 13:08:15number. Let's say it will generate
  19122. 13:08:17three. This will generate four and this
  19123. 13:08:19will generate five. So what will happen
  19124. 13:08:21again? The number should be like that 1
  19125. 13:08:252 then this uh three will come four will
  19126. 13:08:29come and five will come. So three
  19127. 13:08:33four and five. Okay. Then it will save
  19128. 13:08:36this information to the memory. Okay.
  19129. 13:08:40Every time it will save this information
  19130. 13:08:41to the memory because checkp pointer is
  19131. 13:08:43saving the information to the memory.
  19132. 13:08:45either you are using local memory or any
  19133. 13:08:46kinds of database. Okay, it will try to
  19134. 13:08:48save that particular state. Then it will
  19135. 13:08:50go to the last one that mean checkp
  19136. 13:08:52pointer um checkpo pointer four uh let's
  19137. 13:08:56say uh this returns the final result and
  19138. 13:08:58here you haven't done any kinds of
  19139. 13:09:01update. So what would be the final okay
  19140. 13:09:03final number final number should be 1 2
  19141. 13:09:073 4 and five then this final state would
  19142. 13:09:11be also saved okay in the database.
  19143. 13:09:13Okay, that's how we are not only getting
  19144. 13:09:16the updated state and instead of that we
  19145. 13:09:18are also getting the intermediate state.
  19146. 13:09:20How? Because of the checkp pointer.
  19147. 13:09:22Okay, now I think this part is clear to
  19148. 13:09:24all of you guys. So guys, we have
  19149. 13:09:26understood about this uh persistence. Uh
  19150. 13:09:29we have understood the persistence then
  19151. 13:09:31then we have also understood what is
  19152. 13:09:33checkpointer and how it works. Okay. Now
  19153. 13:09:36let's try to understand another
  19154. 13:09:37important concept as you can see
  19155. 13:09:39organizing them into unique and uh
  19156. 13:09:42retrievable traits. Okay. Now let's try
  19157. 13:09:44to understand what is this trades. Okay.
  19158. 13:09:46Trades is also a concept of persistence.
  19159. 13:09:49So in my previous uh uh part guys that
  19160. 13:09:52mean in the part one I already told you
  19161. 13:09:54about the trades right? We added the
  19162. 13:09:56trades uh with the help of trades
  19163. 13:09:58actually we can separate out each and
  19164. 13:10:00every let's say chat. Now let's say if
  19165. 13:10:04you are doing um chat in trade one that
  19166. 13:10:08means in trade two you won't be able to
  19167. 13:10:10see that particular chat or in trade
  19168. 13:10:13whatever uh chat you are doing in trade
  19169. 13:10:15one you won't be able to see in inside
  19170. 13:10:17trade two. So this kinds of thing I
  19171. 13:10:19think I already showed you if you
  19172. 13:10:20haven't checked that please try to check
  19173. 13:10:21check my previous part guys. So here
  19174. 13:10:24let's try to understand this trading
  19175. 13:10:26concept as you can see trades in part
  19176. 13:10:27persistence we have already taken an
  19177. 13:10:29example here. So I'm going to open it
  19178. 13:10:31up. So see here what is happening let's
  19179. 13:10:35say here we have taken two trades let's
  19180. 13:10:38say this is trade
  19181. 13:10:41this is trade one and this is trade
  19182. 13:10:45sorry this would be trade
  19183. 13:10:51trade one and this is
  19184. 13:10:54trade two okay now in trade one as you
  19185. 13:10:57can see I have um I have updated some
  19186. 13:11:01kinds of state okay so here would be one
  19187. 13:11:03actually I missed out. Yeah. So you can
  19188. 13:11:05see um let's say here we got one then
  19189. 13:11:07after node two execution we got one two
  19190. 13:11:09okay and so on like I already showed you
  19191. 13:11:12this example before right yeah now I
  19192. 13:11:15have taken the same example but I
  19193. 13:11:17updated let's say another state number
  19194. 13:11:20let's say here I started from six then
  19195. 13:11:22node after node one execution I got 6 7
  19196. 13:11:26then 6 7 8 9 10 okay then 6 7 8 9 10
  19197. 13:11:29this is the final number so see what is
  19198. 13:11:31happening here although I am executing
  19199. 13:11:34ing this graph two time okay two times
  19200. 13:11:37but in a different trades so for the
  19201. 13:11:40first time I have given a separate
  19202. 13:11:42number and for the second time I have
  19203. 13:11:45given another number so it is not
  19204. 13:11:48replacing the previous information as
  19205. 13:11:50you can see previous information is
  19206. 13:11:51remaining same because it is running in
  19207. 13:11:53a different trade and here trade ID is
  19208. 13:11:55different it is also running the same
  19209. 13:11:58graph but it is running in the another
  19210. 13:12:00trade okay I hope you got this concept
  19211. 13:12:03so if I uh give give you one real time
  19212. 13:12:05demo guys if I go to the chart GPT. So
  19213. 13:12:07in charge GPT also I think you
  19214. 13:12:09understand let's say whenever we do
  19215. 13:12:12chart operation right uh it will
  19216. 13:12:14basically creates a trades let's say
  19217. 13:12:16this is a trades this is another trades
  19218. 13:12:18okay that's why we are having different
  19219. 13:12:19different trades
  19220. 13:12:21okay let's say if I show you let's say
  19221. 13:12:24this is the different different trades
  19222. 13:12:25let's say this is another trades
  19223. 13:12:27okay this is another traits
  19224. 13:12:31that means this information you won't be
  19225. 13:12:34able to see in this particular trades
  19226. 13:12:37Right? And whatever information you are
  19227. 13:12:39having, you won't be able to see in this
  19228. 13:12:41particular trades. Right? These two
  19229. 13:12:44trades are completely different. And
  19230. 13:12:46whenever you are creating this kinds of
  19231. 13:12:48real time agentic chatbot or agentic
  19232. 13:12:51application definitely you have to take
  19233. 13:12:53care this particular traits otherwise
  19234. 13:12:55what will happen it will be getting the
  19235. 13:12:58previous context as well. Okay. and I
  19236. 13:13:01will be able to separate out my chat
  19237. 13:13:04whenever let's say this inform uh this
  19238. 13:13:07application uh is using by multiple
  19239. 13:13:09person or let's say by me only I won't
  19240. 13:13:12be able to uh separate out my chat
  19241. 13:13:15informations okay everything will be
  19242. 13:13:18combining in one particular trades and
  19243. 13:13:19this is not good right so that's why we
  19244. 13:13:22create this particular trades and now we
  19245. 13:13:24can also create another trades by click
  19246. 13:13:26on new chart now if you do any kinds of
  19247. 13:13:28conversation see it will create another
  19248. 13:13:30trades automatically here. See, new
  19249. 13:13:33chart has created and this is another
  19250. 13:13:34traits. Okay. So, we'll also able to see
  19251. 13:13:38uh how we can add this kinds of uh
  19252. 13:13:41trading uh how we can add this kinds of
  19253. 13:13:43let's say uh realtime trading inside our
  19254. 13:13:46chatbot also. Although I have shown you
  19255. 13:13:48the trades but I hardcoded the trade one
  19256. 13:13:50and trade two right u in my previous
  19257. 13:13:53demo but I will show you okay whenever
  19258. 13:13:55you are creating this kinds of chatbot
  19259. 13:13:56uh in a user interface also how we can
  19260. 13:13:59add uh like chart GPT okay these kinds
  19261. 13:14:01of trading I will also able to show you
  19262. 13:14:03so now I think you understood about the
  19263. 13:14:05trades guys what is trades exactly
  19264. 13:14:07trades is basically uh it stores the
  19265. 13:14:11informations with a trade ID let's say
  19266. 13:14:13whenever you are using any kinds of
  19267. 13:14:14database or your local storage it
  19268. 13:14:17doesn't matter let's say whenever you
  19269. 13:14:18are using local storage that means your
  19270. 13:14:20RAM that time what is happening in the
  19271. 13:14:22RAM only it is creating a separate ID
  19272. 13:14:26trade ID okay that means it is taking a
  19273. 13:14:28separate space inside a RAM and for
  19274. 13:14:32trade two it is taking another separate
  19275. 13:14:34space in the RAM although it is
  19276. 13:14:35executing the same graph but it is
  19277. 13:14:37executing in a two different place but
  19278. 13:14:39in database what is happening I know you
  19279. 13:14:41know that in database we create a table
  19280. 13:14:43right inside a table we can create a
  19281. 13:14:47another column called uh trade id okay
  19282. 13:14:50trade ID let's say if trade ID one all
  19283. 13:14:53of the information would be saved about
  19284. 13:14:55the trade ID in this particular row
  19285. 13:14:57itself let's see if trade is equal to
  19286. 13:14:58two all of this information would be
  19287. 13:15:00saved related trade two here so whenever
  19288. 13:15:02I need trade one I will try to fetch the
  19289. 13:15:04trade one whenever I need trade two I
  19290. 13:15:06will fetch the trade two okay that's how
  19291. 13:15:08the things work actually basically it
  19292. 13:15:09saves the same information but in a
  19293. 13:15:11different different threads to separate
  19294. 13:15:13out my each of the that's a state or
  19295. 13:15:15each of the charts. Okay, I hope you get
  19296. 13:15:17it guys. So guys, we have understood the
  19297. 13:15:20theoretical concept of persistence in
  19298. 13:15:23line graph. Now let's try to see the
  19299. 13:15:25code example. Okay, for this I will
  19300. 13:15:28create a simple sequential workflow
  19301. 13:15:30here. So this is the graph I have taken.
  19302. 13:15:32As you can see this is the this is our
  19303. 13:15:33workflow. So here basically we'll try to
  19304. 13:15:36um see um um see example. In this
  19305. 13:15:40example, first of all, we'll try to
  19306. 13:15:42generate a joke of a topic. Let's say
  19307. 13:15:46here we'll pass a topic. Let's say we
  19308. 13:15:47will pass any kinds of topic. Let's say
  19309. 13:15:50I passed football. So, first of all,
  19310. 13:15:51what will happen? Uh here we'll create a
  19311. 13:15:54node and this node will try to generate
  19312. 13:15:56a joke on top of that topic. Let's say
  19313. 13:15:58it will generate a joke on football.
  19314. 13:16:00Then after that, we'll pass this uh joke
  19315. 13:16:02to another nodes called gen um uh exp.
  19316. 13:16:07Basically uh this will uh generate the
  19317. 13:16:10explanation of that particular joke.
  19318. 13:16:12Let's say the joke we have generated we
  19319. 13:16:14want to generate the explanation of that
  19320. 13:16:16particular joke. Then this um workflow
  19321. 13:16:18will be end. And to make this uh graph
  19322. 13:16:20guys we need a state. So I already
  19323. 13:16:22prepared the state. As you can see we
  19324. 13:16:23named it a joke state. We are inheriting
  19325. 13:16:26with the type dict and uh we have taken
  19326. 13:16:28the state. First of all we need a topic.
  19327. 13:16:31Then whatever joke it will generate joke
  19328. 13:16:33would be there. Then explanation. Okay
  19329. 13:16:35that means the three variable we have
  19330. 13:16:36taken. I think this is pretty much
  19331. 13:16:37clear. So I have already written the
  19332. 13:16:40code. As you can see this is the code.
  19333. 13:16:42So first of all let's import all of the
  19334. 13:16:43necessary library. We are importing
  19335. 13:16:46state graph start type d chat openi load
  19336. 13:16:49env only the new things. I have imported
  19337. 13:16:51this inmemory saber from lang graph
  19338. 13:16:54checkpoint dot memory in memory saber.
  19339. 13:16:56Okay. So this is what your uh
  19340. 13:16:58persistence uh like uh persistence
  19341. 13:17:02memory that means the checkp pointer
  19342. 13:17:04like where you want to save this state.
  19343. 13:17:06So here we're using inmemory. Inmemory
  19344. 13:17:08means it will save the information
  19345. 13:17:09inside your RAM. You can also use any
  19346. 13:17:11kinds of database. We'll also see
  19347. 13:17:12database in future but as of now just to
  19348. 13:17:14show you the demo, we'll be using our
  19349. 13:17:16RAM. So let's import all of the
  19350. 13:17:18necessary library. Okay. Then we'll try
  19351. 13:17:20to load the environment variable because
  19352. 13:17:22there I have my open API key. I already
  19353. 13:17:24set my open API key here. Then after
  19354. 13:17:26that we'll try to define a large
  19355. 13:17:28language model. Then we'll define the
  19356. 13:17:30state. The same state I showed you here.
  19357. 13:17:33We are defining the state. Then we'll be
  19358. 13:17:35writing the nodes. Okay. So first of all
  19359. 13:17:38we have created the graph as you can
  19360. 13:17:40see. Then we are adding the nodes. First
  19361. 13:17:42node is generate joke. Second node is uh
  19362. 13:17:45generate explanation. So generate nodes
  19363. 13:17:47sorry generate jokes and generate
  19364. 13:17:49explanation. So these two function I
  19365. 13:17:50have to write separately because this is
  19366. 13:17:52going to be my node. So this is the
  19367. 13:17:54generate joke uh nodes. As you can see
  19368. 13:17:56it will take this state and it will
  19369. 13:17:58generate the joke and it will update
  19370. 13:18:00that joke state and this particular uh
  19371. 13:18:03nodes will try to generate the
  19372. 13:18:04explanation. Here we have given the
  19373. 13:18:06prompt. So it will take the joke from
  19374. 13:18:07this state and it will generate the
  19375. 13:18:09explanation and it will update the
  19376. 13:18:10explanation. Okay. So let's try to
  19377. 13:18:12define all of them.
  19378. 13:18:14H so after that we are uh defining the
  19379. 13:18:17graph. So as you can see we are adding
  19380. 13:18:19the nodes. After that we have to do the
  19381. 13:18:21edge connection. As you can see as
  19382. 13:18:22connection start to gen start to
  19383. 13:18:25generate joke then generate joke to
  19384. 13:18:27generate explanation generate joke to
  19385. 13:18:29generate explanation then generate
  19386. 13:18:31explanation to end generate explanation
  19387. 13:18:33to end. This is the connection. Now if
  19388. 13:18:35you're using this persistence concept
  19389. 13:18:37you have to define a checkpointer. So
  19390. 13:18:39here we are defining the checkpoint and
  19391. 13:18:40we are defining the inmemory server and
  19392. 13:18:43if you're using any kinds of database
  19393. 13:18:44you have to define the database uh class
  19394. 13:18:46here. This will become my checkpointter.
  19395. 13:18:48Now we'll whenever we'll try to compile
  19396. 13:18:50the graph we'll pass this particular
  19397. 13:18:52checkp pointer okay uh in this
  19398. 13:18:55particular parameter. Now basically by
  19399. 13:18:57this code you are telling your line
  19400. 13:18:59graph um graph to use this persistence
  19401. 13:19:02concept that means whatever state you
  19402. 13:19:05are having okay whatever state update it
  19403. 13:19:07will do whether it's intermediate or
  19404. 13:19:09final it will try to save all of the
  19405. 13:19:12information in this particular memory
  19406. 13:19:14okay I hope you get it now let's try to
  19407. 13:19:16compile the graph done now let me show
  19408. 13:19:19you uh how we can execute this workflow
  19409. 13:19:21to execute this workflow you need to
  19410. 13:19:24define a configuration okay you need to
  19411. 13:19:26define a configuration and in the
  19412. 13:19:28configuration you have to define the
  19413. 13:19:29trades. I already told you okay trades
  19414. 13:19:31is important whenever you are using
  19415. 13:19:32persistent concept definitely you have
  19416. 13:19:34to pass the trade and each and every
  19417. 13:19:37trade will store your informations in a
  19418. 13:19:40separate uh separate space in the memory
  19419. 13:19:42okay if you're using a memory it will
  19420. 13:19:44use a separate space if you're using a
  19421. 13:19:45database it will use this particular
  19422. 13:19:47trade ID to store those information
  19423. 13:19:49basically in trade one whatever
  19424. 13:19:51conversation you are doing you won't be
  19425. 13:19:53able to see in trade two or in trade two
  19426. 13:19:55whatever conversation you are doing you
  19427. 13:19:57won't be able to see in trade one okay
  19428. 13:19:59that's how you can create as much as
  19429. 13:20:00trade you can like the chat GPT we saw
  19430. 13:20:03the example right so we are preparing
  19431. 13:20:05the configuration there is a parameter
  19432. 13:20:07called configurable you have to define
  19433. 13:20:08as a dictionary then you have to define
  19434. 13:20:10the trade ID so let's say we have given
  19435. 13:20:12one then we are invoking the workflow we
  19436. 13:20:14are passing let's say topic is equal to
  19437. 13:20:15football let's say uh here the topic
  19438. 13:20:18should be the football and it will
  19439. 13:20:19generate a joke on top of the football
  19440. 13:20:21okay then we are passing the
  19441. 13:20:22configuration here now let's execute
  19442. 13:20:32Okay guys, so here I'm getting an error
  19443. 13:20:34rate remit uh limit error. I think my
  19444. 13:20:37openi credits is over. Uh so what I can
  19445. 13:20:40do? Maybe I can use um other model. So
  19446. 13:20:42let's use uh another model. Maybe I can
  19447. 13:20:44use Gemini. Gemini maybe I can use uh
  19448. 13:20:47this model uh freely. Okay, for some
  19449. 13:20:49request. So what I'm going to do guys uh
  19450. 13:20:52quickly
  19451. 13:20:53um
  19452. 13:20:55You can simply go to the chart GPT
  19453. 13:20:59I have already done. Let me show you
  19454. 13:21:03see. So I go to the chat GPT then I
  19455. 13:21:06given my code let's say this is the code
  19456. 13:21:08I'm using and can you change the model
  19457. 13:21:10to Gemini uh uh model to Gemini open a
  19458. 13:21:14credit is over. Now it has suggested
  19459. 13:21:17okay that's how you have to use the
  19460. 13:21:18Gemini model. First of all you have to
  19461. 13:21:19install this library langen uh Google
  19462. 13:21:22geni. So let's try to add inside our
  19463. 13:21:24requirement.
  19464. 13:21:26So I've already added inside my
  19465. 13:21:28requirement. Now let me install that. So
  19466. 13:21:30pip install
  19467. 13:21:32r requirement.txt.
  19468. 13:21:41Yeah, that's how you can use any model.
  19469. 13:21:42Okay, model doesn't matter either you
  19470. 13:21:44can use open model, gemini model, open
  19471. 13:21:46router provider, anything you can use.
  19472. 13:21:48Once it is done then I'll try to simply
  19473. 13:21:52uh see the next step. I have to collect
  19474. 13:21:54my Google API key. So and we have to add
  19475. 13:21:57inside the environment variable. So
  19476. 13:21:58let's try to do that. So this is my
  19477. 13:22:01environment variable.
  19478. 13:22:04So here I'll try to add my Google API
  19479. 13:22:07key. And where you will get the API key?
  19480. 13:22:09You have to go to the Google uh AI
  19481. 13:22:12studio.
  19482. 13:22:15Google AI Studio.
  19483. 13:22:24So left hand side you will be able to
  19484. 13:22:25see the API key option.
  19485. 13:22:28Now let's try to generate the API key.
  19486. 13:22:31I already have some API key here. Maybe
  19487. 13:22:33I can delete.
  19488. 13:22:40Okay. You want to create a new one.
  19489. 13:22:42Click on create API key. Gemini API key.
  19490. 13:22:44You can select your project if you have
  19491. 13:22:46any project. Let's I'll select my
  19492. 13:22:47project and create the API key.
  19493. 13:22:55Once done, let's copy this API key and
  19494. 13:22:57I'll try to paste it here.
  19495. 13:23:02Done.
  19496. 13:23:06Okay. Now let's try to Yeah. Now let let
  19497. 13:23:10me check. So if you want to do that
  19498. 13:23:12first of all you have to import this
  19499. 13:23:13line
  19500. 13:23:17instead of open AI you will import this
  19501. 13:23:20lang chain Google geni import chat
  19502. 13:23:23Google generative
  19503. 13:23:25let's import
  19504. 13:23:27load the environment variable then you
  19505. 13:23:29have to uh replace this
  19506. 13:23:36okay replace this uh model definition
  19507. 13:23:39with uh uh Here I'm using Gemini 1.5
  19508. 13:23:42flash. I think this is the free model,
  19509. 13:23:43free to use model and this is the
  19510. 13:23:44temperature parameter. Now let's define.
  19511. 13:23:47Okay, now I think it's fine. Now
  19512. 13:23:49everything is good. Now I'll come here
  19513. 13:23:52or let's try to uh execute all the
  19514. 13:23:56cell again otherwise I think I might get
  19515. 13:23:59some issue. I'll define the graph. Now
  19516. 13:24:02let's invoke this workflow. Okay, here
  19517. 13:24:05I'm getting a client error. Uh okay.
  19518. 13:24:09This model not found
  19519. 13:24:14is uh during the task with name joke ID.
  19520. 13:24:19Okay, let me check this model not found.
  19521. 13:24:31I can try with this pro model.
  19522. 13:24:50Okay, this is also not found. Maybe I
  19523. 13:24:52can try with this
  19524. 13:24:552.5 plus.
  19525. 13:25:03I think this should work.
  19526. 13:25:05Yeah, 1.5 I think it is deprecated from
  19527. 13:25:07the uh API. You have to use 2.5.
  19528. 13:25:16Now see we are getting the output that
  19529. 13:25:18means 2.5 is working. Okay. You have to
  19530. 13:25:20use this 2.5 flash. Okay. Now see here
  19531. 13:25:23is the topic we have given and this is
  19532. 13:25:24the joke I got and this is the
  19533. 13:25:26explanation. Okay. We are getting from
  19534. 13:25:28this particular joke. It's working fine.
  19535. 13:25:31Okay. Now if you want to see this state
  19536. 13:25:33right? If you want to see your state uh
  19537. 13:25:35because this state got saved in the
  19538. 13:25:37memory you have to call this function
  19539. 13:25:39get state and you have to pass the
  19540. 13:25:41configuration that means our trade ID
  19541. 13:25:43configuration trade one configuration.
  19542. 13:25:45Now if execute now see this is the
  19543. 13:25:47snapshot this is your state you can see
  19544. 13:25:49the topic you can see the joke you can
  19545. 13:25:52see the explanation and some other
  19546. 13:25:54metadata informations are available
  19547. 13:25:56here. Okay. Now if you want to see the
  19548. 13:25:58entire uh like uh intermediate state as
  19549. 13:26:01well as the final state you have to
  19550. 13:26:03execute this function get state history
  19551. 13:26:04story and again you have to pass the
  19552. 13:26:06configuration that means trade one. Now
  19553. 13:26:08if I execute this now see guys you are
  19554. 13:26:10getting all of the intermediate state as
  19555. 13:26:12well as the final state. Okay. Now the
  19556. 13:26:16last one you can see this is the last
  19557. 13:26:18last uh like that means the final state
  19558. 13:26:21and the first one this is the first uh
  19559. 13:26:23state first intermediate state. Now if I
  19560. 13:26:25show you this graph guys. So how many um
  19561. 13:26:29checkpoint you have here. See you have
  19562. 13:26:31one checkpoint 2 3 and four. So that
  19563. 13:26:34means four output we are getting. So
  19564. 13:26:36this is the first checkpoint output. So
  19565. 13:26:38initially whenever we pass the topic we
  19566. 13:26:41didn't have any kinds of joke. Uh then
  19567. 13:26:44uh uh explanation. Okay we didn't have
  19568. 13:26:47anything. You can see initially this was
  19569. 13:26:50only running the uh start node and there
  19570. 13:26:53is nothing. Okay. Then we executed the
  19571. 13:26:56second node that means the second
  19572. 13:26:57checkpoint. In second checkpoint we
  19573. 13:26:59passed the we only passed the topic.
  19574. 13:27:02Okay. And that time we didn't have any
  19575. 13:27:04kinds of joke. You can see we didn't
  19576. 13:27:06have any kinds of joke or uh this
  19577. 13:27:09explanation. Okay. You can see this was
  19578. 13:27:11nothing. Then at the third third uh you
  19579. 13:27:15can see checkpoint it was uh it has
  19580. 13:27:18generated the joke. Okay. Uh that time
  19581. 13:27:21explanation was not available. Okay. You
  19582. 13:27:23can see uh topic was there, joke was
  19583. 13:27:26also there. Okay, joke was also there
  19584. 13:27:28but explanation was not there. You can
  19585. 13:27:31you can see explanation is completely
  19586. 13:27:33empty. It it was not there. Right? Then
  19587. 13:27:36whenever we executed the last node that
  19588. 13:27:39means we uh got the checkpoint for that
  19589. 13:27:42time explanation was available. You can
  19590. 13:27:44see topics is available, joke is
  19591. 13:27:46available, explanation is also
  19592. 13:27:48available. Okay, that's how you will be
  19593. 13:27:50able to see the final snapshot as well
  19594. 13:27:52as the intermediate snapshot of this
  19595. 13:27:54state. Okay, this is amazing, right? And
  19596. 13:27:57that's how your persistence is working.
  19597. 13:27:59And this is super important guys. Just
  19598. 13:28:01trust me, this is super important
  19599. 13:28:03concept whenever you are implementing
  19600. 13:28:05any kinds of agentic AI application.
  19601. 13:28:07That's why uh in my first part the
  19602. 13:28:10application I started guys agentic
  19603. 13:28:11chatbot. So there I use this particular
  19604. 13:28:13concept this persistence concept. So
  19605. 13:28:16there also we created this checkpoint. I
  19606. 13:28:18think you remember we created a
  19607. 13:28:19checkpoint but here I used this memory
  19608. 13:28:21saber. I was saving everything in my RAM
  19609. 13:28:24but later on I will also show you how we
  19610. 13:28:26can add the database as well. Okay.
  19611. 13:28:28Because I told you we'll be going step
  19612. 13:28:30by step so that I can teach you each and
  19613. 13:28:31everything. Okay. I hope you clear. So
  19614. 13:28:35now I'll get back to my code. Yeah. Now
  19615. 13:28:37let's uh let me show you one thing this
  19616. 13:28:39uh uh trading concept. Let's say if I
  19617. 13:28:42right now give this trade ID is equal to
  19618. 13:28:44two. Right. That means uh completely one
  19619. 13:28:47another trade would be created another
  19620. 13:28:48block would be created in the memory and
  19621. 13:28:50in that particular memory it will save
  19622. 13:28:52all the informations. Now see we are
  19623. 13:28:54invoking with another topic called
  19624. 13:28:56cricket. Now it will generate uh
  19625. 13:28:58generate the joke on top of the cricket
  19626. 13:29:00but in a different rate.
  19627. 13:29:02Let me show you.
  19628. 13:29:12Okay. If you're using free model it
  19629. 13:29:14might take some time. Now you can see
  19630. 13:29:15this is the topic and this is the joke
  19631. 13:29:17and this is the explanation we are
  19632. 13:29:18getting on top of cricket. If you want
  19633. 13:29:19to see the state final state final
  19634. 13:29:21snapshot this is the final snapshot. And
  19635. 13:29:23if you want to see the all the
  19636. 13:29:24intermediate state as well as the final
  19637. 13:29:26state you have to execute this line. Now
  19638. 13:29:28you can see this is for football. Okay.
  19639. 13:29:30Now the best part is that if I change
  19640. 13:29:32this configuration anytime let's say I
  19641. 13:29:34want to get my uh I want to get my um uh
  19642. 13:29:38football. Sorry not football. Okay this
  19643. 13:29:41is configuration one pass. Sorry, I have
  19644. 13:29:42to give configuration two. Now if I give
  19645. 13:29:45configuration two, now see this is for
  19646. 13:29:46cricket here also I have to pass the
  19647. 13:29:48configuration two because this is my uh
  19648. 13:29:52uh trade two right now if I give
  19649. 13:29:54configuration one.
  19650. 13:29:56So this is my trade one that means
  19651. 13:29:57cricket sorry football. Now if I give
  19652. 13:30:00you trade two now this is cricket. Okay
  19653. 13:30:02see all of the state is different right
  19654. 13:30:05now because it is saving inside
  19655. 13:30:07different different trade. Okay I hope
  19656. 13:30:09you get it guys. So from this
  19657. 13:30:11persistence guys we got some benefit
  19658. 13:30:13definitely. So let's try to define the
  19659. 13:30:15benefit
  19660. 13:30:19benefit of
  19661. 13:30:21persistence.
  19662. 13:30:26So the first benefit we got the
  19663. 13:30:28short-term
  19664. 13:30:33memory.
  19665. 13:30:36I think you already saw the short-term
  19666. 13:30:38memory, right?
  19667. 13:30:40uh we have implemented because it is
  19668. 13:30:43saving the information in this state
  19669. 13:30:45okay in a database and in my previous
  19670. 13:30:49code example also the chatbot I created
  19671. 13:30:51this was also able to remember my
  19672. 13:30:53informations okay this is called
  19673. 13:30:54short-term memory we can implement okay
  19674. 13:30:56with the help of this persistence now
  19675. 13:30:59the second one
  19676. 13:31:01um benefit you will be getting called
  19677. 13:31:03this fault tolerance
  19678. 13:31:05fault
  19679. 13:31:07tolerance
  19680. 13:31:10Okay, I already told you about this
  19681. 13:31:12fault tolerance. Fault tolerant means I
  19682. 13:31:14think here I showed you somewhere. Yeah.
  19683. 13:31:16So let's say um if uh your application
  19684. 13:31:20got crashes um um from any any
  19685. 13:31:23particular nodes instead of executing
  19686. 13:31:26your application from the beginning you
  19687. 13:31:27can resume the application uh from the
  19688. 13:31:30same uh same crash point um itself.
  19689. 13:31:33Okay, let's say node one your
  19690. 13:31:35application got crashes. From node one
  19691. 13:31:36itself you can execute your application.
  19692. 13:31:38Okay, for this I will show you a
  19693. 13:31:40practical demo. I think after that you
  19694. 13:31:42will be able to um understand. Then uh
  19695. 13:31:46this persistent helps us to implement
  19696. 13:31:48this hl that means human in the loop
  19697. 13:31:51concept. Then there is another one
  19698. 13:31:53called time travel.
  19699. 13:31:57Okay time travel we'll also see the
  19700. 13:31:58example itself. Now uh we have al
  19701. 13:32:01already seen the shortterm memory
  19702. 13:32:03example. Uh even going forward also I'll
  19703. 13:32:06use this concept in my application.
  19704. 13:32:08Okay. Uh you already understood this
  19705. 13:32:10concept. Now let's try to understand
  19706. 13:32:12this fault tolerance like how we can
  19707. 13:32:13resume the application whenever it got
  19708. 13:32:16crashes. Okay. So let's see the fault uh
  19709. 13:32:19tolerance uh example. Um like I will
  19710. 13:32:22show you a code example how it works.
  19711. 13:32:24For this here I have taken uh this
  19712. 13:32:26particular workflow. uh it's a like very
  19713. 13:32:30uh basic dummy workflow I have taken I
  19714. 13:32:32generated from uh this uh workflow
  19715. 13:32:36uh from chart GPT. So here uh what I
  19716. 13:32:38have done guys I have um uh taken
  19717. 13:32:42actually three step one step two step
  19718. 13:32:44three. So what is fault tolerance? I
  19719. 13:32:46told you fall tolerance means uh let's
  19720. 13:32:48say uh at step two let's say you got
  19721. 13:32:51crash okay crash your application. So
  19722. 13:32:56instead of uh instead of running from
  19723. 13:32:59the beginning whenever you you are
  19724. 13:33:00resumeuming your application instead of
  19725. 13:33:02starting from beginning so what you can
  19726. 13:33:04do you can start from step two itself
  19727. 13:33:06okay because I have all of the
  19728. 13:33:08intermediate state data okay till uh
  19729. 13:33:12step one so I don't need to execute from
  19730. 13:33:14step uh uh sorry uh step uh from the
  19731. 13:33:17first step again I will execute from
  19732. 13:33:19step two okay so this is called fault
  19733. 13:33:21tolerance
  19734. 13:33:22so this example we'll try to see in a
  19735. 13:33:24code example So here what I have done
  19736. 13:33:26guys here uh manually just I have uh
  19737. 13:33:30taken up uh like time I am using time
  19738. 13:33:33module in Python and here I will wait
  19739. 13:33:35for 30 seconds okay and in 30 seconds
  19740. 13:33:37what I'm going to do I'm going to just
  19741. 13:33:39do a manual keyboard interruption and I
  19742. 13:33:42will just crash my application here okay
  19743. 13:33:44and I'll show you how we can resume your
  19744. 13:33:46application from step to itself okay
  19745. 13:33:48that means wherever your application
  19746. 13:33:50will get crashed from here itself it
  19747. 13:33:52will try to uh from here itself it will
  19748. 13:33:54try restart the application. Okay, this
  19749. 13:33:56part I'll show you for this. What I have
  19750. 13:33:58done guys, I have written a code u in
  19751. 13:34:01Google Collab. So why I'm writing in
  19752. 13:34:03Google Collab? Because in my VS code uh
  19753. 13:34:06I was not able to uh I was not able to
  19754. 13:34:09interrupt this uh sale. Okay, it was
  19755. 13:34:11taking lots of time that's why I have uh
  19756. 13:34:13copied this code on my Google Collab. So
  19757. 13:34:15I already connected the notebook and I
  19758. 13:34:17will share this notebook with you guys.
  19759. 13:34:18So here what I'm going to do guys I'm
  19760. 13:34:20going to import all of the necessary
  19761. 13:34:23library then here for this particular um
  19762. 13:34:27um graph I have defined all of the state
  19763. 13:34:29I need like I need input step one step
  19764. 13:34:32two okay and I uh inherited with the
  19765. 13:34:35type D then here I have defined all of
  19766. 13:34:37the step one step two step three you can
  19767. 13:34:40see all of the step I have defined step
  19768. 13:34:41one step two step three only in step two
  19769. 13:34:43guys here I am uh just taking this time
  19770. 13:34:46dots sleep I will wait for 30 seconds.
  19771. 13:34:49Okay. And here I'm only just doing the
  19772. 13:34:50print statement. I'm just doing like a
  19773. 13:34:52step one executed and return the step.
  19774. 13:34:54Okay. And update the state. And step two
  19775. 13:34:56only I'm just doing this uh waiting
  19776. 13:34:58operation. 30 secondond will wait. And
  19777. 13:35:00in between I'll just try to crash my um
  19778. 13:35:02the cell. And step three also I'm just
  19779. 13:35:04only doing the print statement. Okay.
  19780. 13:35:06This is a dummy code I generated from CH
  19781. 13:35:07GPT. Now let's execute this cell also.
  19782. 13:35:11Now here we are building the graph. As
  19783. 13:35:12you can see we are taking the graph and
  19784. 13:35:14we are adding all of the node one by
  19785. 13:35:15one. Then we are doing the edge
  19786. 13:35:16connection. Okay, then we are taking the
  19787. 13:35:19checkp pointer in memory saber. Then we
  19788. 13:35:21are just compiling the graph and we're
  19789. 13:35:23giving the check pointer.
  19790. 13:35:26Done. Now here guys, uh in the t set
  19791. 13:35:28block I am invoking my um you can see
  19792. 13:35:31graph and I am just doing some print
  19793. 13:35:33statement. Okay. So you can see I'm
  19794. 13:35:35giving um uh input is equal to start
  19795. 13:35:37because here I told you we are only
  19796. 13:35:39doing uh by very basic workflow
  19797. 13:35:42execution. That's why I have just given
  19798. 13:35:44some dummy value here. And here we are
  19799. 13:35:46giving the trade also that means the
  19800. 13:35:47configuration. I think you know in
  19801. 13:35:49persistence you have to give that. Then
  19802. 13:35:51in exception we are uh also printing
  19803. 13:35:53kernel manually interrupt crash
  19804. 13:35:55simulated. Okay. Now let's execute. Now
  19805. 13:35:57see it will wait for 30 second. In
  19806. 13:35:59between I'll just try to um stop the
  19807. 13:36:02kernel. Okay. Now see kernel stop that
  19808. 13:36:04means my application got crashed. Now if
  19809. 13:36:06I show you my state as you can see uh
  19810. 13:36:10step one done. Okay. Step one executed
  19811. 13:36:13perfectly. Uh perfectly it's done. Now
  19812. 13:36:16whenever it was running a step two right
  19813. 13:36:18there is nothing. You can see step two
  19814. 13:36:20didn't completed because here it got
  19815. 13:36:22crashed. Now I will rerun this
  19816. 13:36:26particular workflow again and you will
  19817. 13:36:29see that instead of running from the
  19818. 13:36:30beginning step one it will run from step
  19819. 13:36:32two. So again what I'm doing guys I'm
  19820. 13:36:34invoking the graph and as of now the
  19821. 13:36:36input I'm only giving this none. Okay.
  19822. 13:36:39Why I'm giving the none? Because uh if
  19823. 13:36:41you're uh uh doing the fault tolerance
  19824. 13:36:43instead of see previously I was giving
  19825. 13:36:45my input but right now I want I don't
  19826. 13:36:48want to start from the beginning. I want
  19827. 13:36:50to start where it got crashed. That's
  19828. 13:36:51why I have to pass the none. Okay then
  19829. 13:36:54we are giving the trade again and we are
  19830. 13:36:56giving the same trade. Now let's
  19831. 13:36:58execute. Now you'll see that it is
  19832. 13:37:00running from the step two. As you can
  19833. 13:37:01see it is not running from the step one.
  19834. 13:37:03It is running from the step two. And
  19835. 13:37:05after waiting for 30 seconds you will be
  19836. 13:37:06able to see the final output. Let me
  19837. 13:37:08show you.
  19838. 13:37:2830 second you have to wait. Now see
  19839. 13:37:30execution is done. Now we're getting the
  19840. 13:37:32final step. You can see step two is also
  19841. 13:37:34done. Now if you want to see the state
  19842. 13:37:36as you can see step one is done. Step
  19843. 13:37:38two is also done. Okay. So that's how
  19844. 13:37:40guys fault tolerance works with the help
  19845. 13:37:42of this persistence. I hope you get it
  19846. 13:37:44guys. That's how you can resume. Okay,
  19847. 13:37:46you can resume your any kinds of
  19848. 13:37:47workflow whenever it got crashes in
  19849. 13:37:49production. Okay, I hope you clear guys.
  19850. 13:37:52Now let's try to understand this hit
  19851. 13:37:55that means human in the loop. Uh like
  19852. 13:37:57how persistent helps us to implement
  19853. 13:37:59this human in the loop. See uh for this
  19854. 13:38:01u let's take a simple example and try to
  19855. 13:38:04understand this one because I'm not
  19856. 13:38:05going to show you as a code example for
  19857. 13:38:07this human in the loop. I'm going to
  19858. 13:38:09create a dedicated video. See let's say
  19859. 13:38:11I want to generate a LinkedIn post okay
  19860. 13:38:14or let's say Facebook post first of all
  19861. 13:38:15I have to take a topic okay topic name
  19862. 13:38:17from the user then it will go to the
  19863. 13:38:20next um nodes it will basically generate
  19864. 13:38:22let's say this
  19865. 13:38:24uh Facebook
  19866. 13:38:28post okay once it generated the Facebook
  19867. 13:38:32posts then uh I want actually uh it will
  19868. 13:38:35wait for the human verification let's
  19869. 13:38:37say it will wait for the human
  19870. 13:38:38verification let's say if I verify by
  19871. 13:38:41post is completely fine. That time I'll
  19872. 13:38:43give the permission just try to post
  19873. 13:38:45this particular uh post to the Facebook
  19874. 13:38:48platform. For this maybe we can use a
  19875. 13:38:50API provider Facebook API provider and
  19876. 13:38:52we can basically post this uh sorry here
  19877. 13:38:56I will yeah uh basically here we we we
  19878. 13:38:58can post this particular post on the
  19879. 13:39:00Facebook. So maybe I can draw it
  19880. 13:39:04uh perfectly.
  19881. 13:39:06So topic
  19882. 13:39:09then Facebook
  19883. 13:39:13post
  19884. 13:39:15then here it will wait
  19885. 13:39:19H I T L human in the loop then it will
  19886. 13:39:23post this uh post this uh let's say post
  19887. 13:39:29to the Facebook platform. Okay. Now you
  19888. 13:39:32can see here uh whenever we'll try to
  19889. 13:39:34build this workflow right whenever we
  19890. 13:39:35try to build this workflow so that time
  19891. 13:39:37user will give a topic name it's
  19892. 13:39:39completely fine from the topic itself
  19893. 13:39:41your Facebook post would be generated
  19894. 13:39:43then here itself it will wait for the
  19895. 13:39:45human verification okay here it will
  19896. 13:39:47wait for the human verification so that
  19897. 13:39:49time uh human can give this particular
  19898. 13:39:52verification in 1 minute 30 seconds 1
  19899. 13:39:55day 2 day okay it doesn't matter or
  19900. 13:39:56after 1 month also okay based on the
  19901. 13:39:58user let's say uh choice user
  19902. 13:40:01preferences Okay. So it's not like that
  19903. 13:40:03your entire workflow should be running.
  19904. 13:40:05Let's say user want to give this uh uh
  19905. 13:40:08permission after 2 days. It's not like
  19906. 13:40:09that you have to run your entire
  19907. 13:40:11workflow 2 days. Okay. And you have to
  19908. 13:40:13wait for the user verification.
  19909. 13:40:15Otherwise what will happen if you are
  19910. 13:40:16continuously running uh you are ending
  19911. 13:40:18up with like your hosting cost right? I
  19912. 13:40:21don't want that computation cost. I
  19913. 13:40:23don't want that. So what will happen
  19914. 13:40:24this uh fault uh sorry this persistence
  19915. 13:40:27that means uh you have learned about
  19916. 13:40:30this fault tolerance right so here
  19917. 13:40:32basically fault tolerance concept would
  19918. 13:40:34be applied that time automatically this
  19919. 13:40:36particular uh execution would be
  19920. 13:40:38interrupt okay
  19921. 13:40:41interrupt it this execution would be
  19922. 13:40:43interrupt interrupt would be it would be
  19923. 13:40:44stopped okay then human will come and
  19924. 13:40:48give the let's say feedback let's say he
  19925. 13:40:51has accepted this particular post that
  19926. 13:40:53time this workflow will again re-execute
  19927. 13:40:56and instead of running from the
  19928. 13:40:57beginning okay instead of running from
  19929. 13:40:59the beginning what it will do it will
  19930. 13:41:01start from here only that means the post
  19931. 13:41:03is accepted now it will run the next
  19932. 13:41:05workflow which is post okay the next
  19933. 13:41:07note which is post instead of running
  19934. 13:41:09from the beginning okay and how it is
  19935. 13:41:11remembering because it has the
  19936. 13:41:13persistence concept because all the
  19937. 13:41:15intermediate data it has also saved okay
  19938. 13:41:17so whenever it will get the new data
  19939. 13:41:19that time from here only it will start
  19940. 13:41:22the example I showed you right now fall
  19941. 13:41:24tolerance it will work in the same way.
  19942. 13:41:26Okay, I hope you got it guys. That's why
  19943. 13:41:28this percentage is also required
  19944. 13:41:30whenever you are using whenever you are
  19945. 13:41:32imple implementing this hit concept that
  19946. 13:41:34is human in the loop concept. Okay, I
  19947. 13:41:36hope you cleared. Now guys let's try to
  19948. 13:41:38understand the last benefit uh which is
  19949. 13:41:40time table. Okay. Uh the concept looks
  19950. 13:41:44interesting uh even this is also
  19951. 13:41:46interesting inside this um uh langraph
  19952. 13:41:49uh inside the persistence. Let's try to
  19953. 13:41:51understand what is time table exactly.
  19954. 13:41:53Okay. So see here I have already taken
  19955. 13:41:55the code example. Uh I will just show
  19956. 13:41:57you okay how things are working. So I
  19957. 13:41:59think remember we just created this um
  19958. 13:42:03this um um joke generator generator
  19959. 13:42:07actually workflow right we created this
  19960. 13:42:08joke generator workflow. So in tribe
  19961. 13:42:11table actually what you can do uh you
  19962. 13:42:13can actually uh go to the each and every
  19963. 13:42:16um nodes and you can see their
  19964. 13:42:18execution. Okay. So here see let's say
  19965. 13:42:21this is our workflow we created
  19966. 13:42:22previously right now uh here I showed
  19967. 13:42:26you all of the execution all of the
  19968. 13:42:28snapshot all of the like state update
  19969. 13:42:30right all of the intermediate and final
  19970. 13:42:32now let's say I want to go to a
  19971. 13:42:34particular um particular let's say
  19972. 13:42:37checkpoint let's say I want to go in
  19973. 13:42:39this particular checkpoint
  19974. 13:42:41okay where I only pass the uh where I
  19975. 13:42:44only pass the let's say topic is equal
  19976. 13:42:45to cricket so what I will do I'll just
  19977. 13:42:47do workflow get state And here you have
  19978. 13:42:50to pass the configure configuration. So
  19979. 13:42:52here this is was my uh trade two right
  19980. 13:42:55that means configuration two. I'm
  19981. 13:42:56passing my configuration two. That's why
  19982. 13:42:57you're giving the trade two here because
  19983. 13:42:59in configuration I was giving the trade
  19984. 13:43:01two. Then here you have something called
  19985. 13:43:03checkpoint ID. So here you have to give
  19986. 13:43:04the checkpoint ID. Now you can see every
  19987. 13:43:06snapshot is having a checkpoint ID. So
  19988. 13:43:08here if you just go right side here you
  19989. 13:43:10can see the checkpoint ID. You just need
  19990. 13:43:12to copy this checkpoint ID and you have
  19991. 13:43:14to provide it here. Okay. Once you do
  19992. 13:43:16that now if you execute this okay you
  19993. 13:43:18will be able to see that it will only
  19994. 13:43:19return you that particular snapshot uh
  19995. 13:43:21let's say output that particular state
  19996. 13:43:23only okay now you can ask me why it is
  19997. 13:43:26required and uh how it is helpful see
  19998. 13:43:28whenever you are creating any kinds of
  19999. 13:43:30complex workflow and you want to do the
  20000. 13:43:31debugging operation that time this
  20001. 13:43:33concept is required okay this thing you
  20002. 13:43:35won't be using frequently whenever you
  20003. 13:43:37want to perform some kinds of debugging
  20004. 13:43:39you want to see each and every node
  20005. 13:43:40execution that time this time travel you
  20006. 13:43:43can use okay now you can see the exact
  20007. 13:43:45same thing you are getting here. Now
  20008. 13:43:47let's say I want to see the after that
  20009. 13:43:49uh let's say this this uh snapshot.
  20010. 13:43:52Okay. So I'll give this particular ID.
  20011. 13:43:54So if I go to the right side you will
  20012. 13:43:56have the checkpoint ID. You just need to
  20013. 13:43:58copy that and here I have already passed
  20014. 13:44:00that. Okay. Now I already executed. You
  20015. 13:44:02can see here I'm getting topic is equal
  20016. 13:44:04to cricket and this is the joke and uh
  20017. 13:44:07here I got the explanation. Okay. Now if
  20018. 13:44:10I show you the entire uh get uh state
  20019. 13:44:13story. Now see initially it was four.
  20020. 13:44:15Now two more uh snapshot is created
  20021. 13:44:17because I did the time table. Okay. So
  20022. 13:44:19this is the first one. There I only got
  20023. 13:44:22the uh topic and here is the second one.
  20024. 13:44:25Okay. Now let's try to see another
  20025. 13:44:29concept which is update state. Okay. U
  20026. 13:44:31like let's say here I'm having this
  20027. 13:44:34particular node right and each and every
  20028. 13:44:36node is updating some kinds of state
  20029. 13:44:39right? Now if you want you can also
  20030. 13:44:41manually update your state. Let's say
  20031. 13:44:44your workflow has generated some state
  20032. 13:44:46state. Okay. But you want to update
  20033. 13:44:48let's say initially I have g given
  20034. 13:44:50cricket topic is equal to cricket but
  20035. 13:44:52right now I want to let's say debug with
  20036. 13:44:54uh tennis. Okay. So what I will do I'll
  20037. 13:44:57just write uh workflow update state and
  20038. 13:44:59here also you need to pass the
  20039. 13:45:01configuration that means your trade ID
  20040. 13:45:03and you have to give the checkpoint ID.
  20041. 13:45:04Now let's say uh at the very first
  20042. 13:45:06checkpoint this was the checkpoint right
  20043. 13:45:08there I give it the cricket topic is
  20044. 13:45:10equal to cricket. So I'll copy this uh
  20045. 13:45:12checkpoint ID. Okay, I'll copy the
  20046. 13:45:14checkpoint ID and you have to provide
  20047. 13:45:15the checkpoint ID here. Okay, after that
  20048. 13:45:17here you have to pass the topic. Topic
  20049. 13:45:19is equal to tennis I have given. Okay,
  20050. 13:45:21this is a dictionary. Now if you
  20051. 13:45:22execute, you will see that this
  20052. 13:45:24particular uh state would be updated.
  20053. 13:45:26Now if you again execute the workflow,
  20054. 13:45:27now you'll see that another state would
  20055. 13:45:29be created. Now here topic is equal to
  20056. 13:45:30tennis. Okay, so that's how you can do
  20057. 13:45:33the debugging operation. If you want you
  20058. 13:45:35can update your state even you can do
  20059. 13:45:36the time travel through your entire
  20060. 13:45:38state. Okay, this is also possible. And
  20061. 13:45:40here I already updated your fall
  20062. 13:45:41tolerance code in the same notebook
  20063. 13:45:43itself. Okay. So that you can copy paste
  20064. 13:45:45in the Google collab guys. So yes guys
  20065. 13:45:48this is the concept uh we have
  20066. 13:45:50understood inside persistence and by
  20067. 13:45:52this video itself you have now enough
  20068. 13:45:54informations like how much persistence
  20069. 13:45:57important uh importance uh is like
  20070. 13:46:00whenever we are creating this kinds of
  20071. 13:46:02agent application and how persistence is
  20072. 13:46:05helping us without persistence actually
  20073. 13:46:07what will happen. Okay, we have
  20074. 13:46:08understood each and everything. Now I
  20075. 13:46:10think you don't have any kinds of
  20076. 13:46:11question. Okay, that's why um in my
  20077. 13:46:13first part guys, I added this
  20078. 13:46:15persistence concept. I added this
  20079. 13:46:17checkpointter concept. Okay, now I think
  20080. 13:46:18this part is pretty much clear guys.
  20081. 13:46:20Okay, so that's how guys we'll be
  20082. 13:46:22implementing the chatbot um in detail. I
  20083. 13:46:25will try to make this particular chatbot
  20084. 13:46:27more advanced. Okay, aentic chatbot more
  20085. 13:46:29advanced. I'll try to add all of the
  20086. 13:46:31concept one by one by explaining this
  20087. 13:46:33kinds of concept separately. Okay. So we
  20088. 13:46:36have created our basic uh skeleton basic
  20089. 13:46:39uh agentic chatbot workflow. So here you
  20090. 13:46:41can perform any kinds of chat operation
  20091. 13:46:44right now. So let's see if I uh give a
  20092. 13:46:46message u
  20093. 13:46:49generate a
  20094. 13:46:51blog about
  20095. 13:46:55let's say python.
  20096. 13:47:00So if I send this prompt now see it is
  20097. 13:47:03able to generate the block. Okay. So we
  20098. 13:47:06have already created this kinds of uh
  20099. 13:47:08skeleton this kinds of workflow like
  20100. 13:47:10chat workflow and everything is working
  20101. 13:47:12fine. Now in this video guys I'm going
  20102. 13:47:14to um just deep dive into this streaming
  20103. 13:47:18like what this streaming is and why it
  20104. 13:47:20is required and we'll also try to
  20105. 13:47:21understand if we don't use this kinds of
  20106. 13:47:23streaming features inside our agentic
  20107. 13:47:25chatbot or any other agentic application
  20108. 13:47:27you are creating. So what should be the
  20109. 13:47:29issue? Okay. So guys uh we'll try to
  20110. 13:47:32continue with our discussion of the
  20111. 13:47:34streaming features inside uh agentic
  20112. 13:47:37chatbot and if you are using langraph
  20113. 13:47:40guys uh by default inside langraph the
  20114. 13:47:42streaming features is available. Okay uh
  20115. 13:47:44with the help of that you can easily
  20116. 13:47:46create the streaming features. So for
  20117. 13:47:48this you can go to the documentation of
  20118. 13:47:49this langraph. So there they have given
  20119. 13:47:51some code example. Okay. But let me
  20120. 13:47:53first of all show you my code example.
  20121. 13:47:56Okay. Okay. Then after that you can go
  20122. 13:47:57through the entire documentation. Okay.
  20123. 13:47:59And you can understand about the
  20124. 13:48:00streaming. Okay. Yeah. So guys see if I
  20125. 13:48:04not using the streaming features. So how
  20126. 13:48:06my chatbot will look like? First of all
  20127. 13:48:08let me show you. So guys as you can see
  20128. 13:48:10this is the code we have already written
  20129. 13:48:12uh for this uh agentic chatbot. And this
  20130. 13:48:15is our uh first initial workflow we have
  20131. 13:48:18created. Okay. Uh this is the chatbot
  20132. 13:48:21workflow we have created. And here if
  20133. 13:48:23you just go to the last part. So here I
  20134. 13:48:26already discussed about the streaming.
  20135. 13:48:28Okay, how to add the streaming features
  20136. 13:48:30but yeah I think in the first part you
  20137. 13:48:33might have uh some kinds of confusion
  20138. 13:48:35like how we have added this particular
  20139. 13:48:37stream uh stream features here. So in
  20140. 13:48:39this particular video I'm going to
  20141. 13:48:41clarify each and everything then I think
  20142. 13:48:43this would be more clear. Okay. So here
  20143. 13:48:46what I'm going to do guys uh let me show
  20144. 13:48:48you the non-streaming um like features
  20145. 13:48:50first of all. So I think this code is
  20146. 13:48:52also common. Initially I also created
  20147. 13:48:54this code and you remember there I'm not
  20148. 13:48:56using any kinds of streaming features.
  20149. 13:48:58Okay. So what I'm doing I'm just
  20150. 13:49:00generating the response after that I was
  20151. 13:49:02um like uh waiting for the entire
  20152. 13:49:05response. Once I got the response I was
  20153. 13:49:08just showing on the streamlit user
  20154. 13:49:10interface. So if I execute this
  20155. 13:49:12particular file let me show you. So I'll
  20156. 13:49:15stop my app.py and I will execute this
  20157. 13:49:18nonstream.py.
  20158. 13:49:20So I'll just write streamlit.
  20159. 13:49:23Okay, streamlit run non stream.pfy. Now
  20160. 13:49:29if I hit enter, so this will load my
  20161. 13:49:31application. Now here let's see if I
  20162. 13:49:33give the same prompt generate a blog
  20163. 13:49:38about
  20164. 13:49:41okay about let's say
  20165. 13:49:44I'll give um machine learning
  20166. 13:49:51now see if I give this prompt now see
  20167. 13:49:55here we have to wait right we have to
  20168. 13:49:58wait uh till the execution now see so
  20169. 13:50:00here I think you have observed uh we had
  20170. 13:50:02to wait uh unless and until this output
  20171. 13:50:05got generated here. Uh so let's say if
  20172. 13:50:07you're generating uh some more uh let's
  20173. 13:50:10say content here some more big content
  20174. 13:50:13that time it will take some time maybe
  20175. 13:50:15it can take let's say 30 seconds 60
  20176. 13:50:18seconds okay it depends upon your uh
  20177. 13:50:20output or the prompt you are giving
  20178. 13:50:22let's say you are running an agent and
  20179. 13:50:24that that agent is taking time it is
  20180. 13:50:26using some kinds of tool okay so uh in
  20181. 13:50:29between actually it will do lots of work
  20182. 13:50:31and you have to wait for the execution
  20183. 13:50:33so this is not good right uh this is not
  20184. 13:50:35good uh user experience. So if I open
  20185. 13:50:37chart GPT okay if I open chart GPT in
  20186. 13:50:40chart GPT if you give any kinds of
  20187. 13:50:43prompt let's say I will give the same
  20188. 13:50:44prompt in the chart GPT okay you'll see
  20189. 13:50:47that chart GPT also will give you some
  20190. 13:50:49kinds of streaming response see this is
  20191. 13:50:51giving you streaming response one by one
  20192. 13:50:53right and this is more interactive right
  20193. 13:50:56this is more interactive because we
  20194. 13:50:57don't need to wait for the entire
  20195. 13:50:59execution to be completed okay whether
  20196. 13:51:01it is using any kinds of tool whether it
  20197. 13:51:03is uh doing the reasoning operation it
  20198. 13:51:05doesn't matter But I'm able to see my
  20199. 13:51:07output token by token. Okay. So this is
  20200. 13:51:10good user experience here. But inside
  20201. 13:51:12this particular application this is not
  20202. 13:51:14good experience. So if I uh give this
  20203. 13:51:16kinds of prompt so what is happening? It
  20204. 13:51:18is taking some time. Right. That's I'll
  20205. 13:51:20give right now deep learning.
  20206. 13:51:23See it's taking lots of time. So this is
  20207. 13:51:25not a good experience. Okay. So that's
  20208. 13:51:27why streaming features is required.
  20209. 13:51:29Okay. Streaming features is required.
  20210. 13:51:31Now let's try to understand what is
  20211. 13:51:33streaming exactly and why it is
  20212. 13:51:35important inside our application
  20213. 13:51:36development. So guys first of all let's
  20214. 13:51:38try to understand uh what is streaming.
  20215. 13:51:41So here I have already written a
  20216. 13:51:42definition in LLM. Streaming means the
  20217. 13:51:45model start sending tokens uh that means
  20218. 13:51:48word as soon as they they are generated
  20219. 13:51:51instead of waiting for the entire
  20220. 13:51:53response to be ready before returning
  20221. 13:51:56it. Okay. See what happens whenever we
  20222. 13:51:58are using any kinds of large language
  20223. 13:52:00model, it generates the output as token
  20224. 13:52:04by token or word by word. Okay. So
  20225. 13:52:07whenever let's say we invoke any kinds
  20226. 13:52:09of large language model, let's say this
  20227. 13:52:10is our LLM and we are giving some kinds
  20228. 13:52:14of prompt here and we get a response
  20229. 13:52:16here. Okay. So what you can do either
  20230. 13:52:20you can get this response in one shot
  20231. 13:52:22that means you have to wait uh for the
  20232. 13:52:25entire output to be generated. Okay for
  20233. 13:52:28this we use something called invoke
  20234. 13:52:30function. Okay invok function I think
  20235. 13:52:32you already know that we are using okay
  20236. 13:52:34so far. So inbox what it does it will
  20237. 13:52:37wait for the entire output to be
  20238. 13:52:40generated but llm will try to generate
  20239. 13:52:42the output as token by token. Let's say
  20240. 13:52:44it is generating something. So first of
  20241. 13:52:46all uh one token will come then another
  20242. 13:52:48token will come another token will come
  20243. 13:52:50okay that's how it will complete the
  20244. 13:52:52entire execution okay that that's how it
  20245. 13:52:54will complete the entire execution then
  20246. 13:52:56you will be able to see the response but
  20247. 13:52:59in streaming actually what we do we use
  20248. 13:53:01something called stream function instead
  20249. 13:53:03of uh invoke we use dot stream function
  20250. 13:53:07uh this is already default inside lang
  20251. 13:53:09graph whenever we are defining any kinds
  20252. 13:53:12of graph object right and uh you
  20253. 13:53:14remember we we are doing the invoking
  20254. 13:53:15operations. So instead of invoking
  20255. 13:53:17operation we have to perform dot stream
  20256. 13:53:19operation. So if you do dot stream
  20257. 13:53:21operation so what will happen that time
  20258. 13:53:23you will be getting this particular
  20259. 13:53:24output as a token by token or word by
  20260. 13:53:26word as soon as they are generated.
  20261. 13:53:28Okay. Instead of waiting for the entire
  20262. 13:53:31response to be ready before returning
  20263. 13:53:33it. Okay. So this is what actually your
  20264. 13:53:34streaming is. I think you already saw
  20265. 13:53:36inside chart GPT. Okay. Chart GPT it was
  20266. 13:53:39generating token by token. Let me show
  20267. 13:53:41you again. So maybe I can give another
  20268. 13:53:44prompt. So I'll give let's say generate
  20269. 13:53:47a blog about deep learning. Now see it
  20270. 13:53:50will generate the output token by token.
  20271. 13:53:52You can see token by token it is
  20272. 13:53:54generating. Okay. Now I think this uh
  20273. 13:53:56definition is pretty much clear. Now
  20274. 13:53:58let's try to understand uh why this uh
  20275. 13:54:01streaming is required. Okay. You can see
  20276. 13:54:04the first point faster response time and
  20277. 13:54:06low drop off rates. Okay. I think by
  20278. 13:54:09this uh point itself you can understand
  20279. 13:54:12what I'm trying to say uh faster time
  20280. 13:54:15time uh uh response time is let's say
  20281. 13:54:17whenever I'm using any kinds of chatbot
  20282. 13:54:19let's say I'm using chat GPT okay I'm
  20283. 13:54:22using chart GPT or any other thing u so
  20284. 13:54:25there I definitely need a faster
  20285. 13:54:27response so if it is not giving faster
  20286. 13:54:29response that time like uh I won't be
  20287. 13:54:32getting interest right to use this
  20288. 13:54:34particular application because nowadays
  20289. 13:54:36time is expensive Okay, time is
  20290. 13:54:38expensive and and nowadays people don't
  20291. 13:54:41have that much of time so that they will
  20292. 13:54:42wait for the entire execution. Okay,
  20293. 13:54:45that is taking 1 minute to run. So they
  20294. 13:54:47don't have that much of time. They will
  20295. 13:54:48wait and they will get the uh let's say
  20296. 13:54:51entire output. Okay, so they need a
  20297. 13:54:53faster response. So definitely faster
  20298. 13:54:55response is required whenever you are
  20299. 13:54:57creating any kinds of application
  20300. 13:54:58whether you are creating chatbot whether
  20301. 13:55:00you are creating AI agents okay anything
  20302. 13:55:02you are creating faster response is
  20303. 13:55:04required otherwise what will happen
  20304. 13:55:07there would be a drop off rates okay
  20305. 13:55:09drop up rate means people will leave
  20306. 13:55:11your application okay let's say if it is
  20307. 13:55:13taking 1 minute to run so definitely
  20308. 13:55:15I'll leave your application okay I'll
  20309. 13:55:17leave your application I will look for
  20310. 13:55:19some other application which can give me
  20311. 13:55:20faster response so that's why uh if it
  20312. 13:55:23is faster response time that means low
  20313. 13:55:25drop off rates. Okay, low drop of rate
  20314. 13:55:27means people will not leave your
  20315. 13:55:29application. They will be continuously
  20316. 13:55:30using like chart GPT people are using
  20317. 13:55:32Delhi, right? Because it is having the
  20318. 13:55:34faster response because of the streaming
  20319. 13:55:36features. Okay, we know that LLM takes
  20320. 13:55:39some time to generate the entire output.
  20321. 13:55:41But we have to handle it smartly instead
  20322. 13:55:44of waiting for the entire let's say
  20323. 13:55:45output to be generated. Whatever token
  20324. 13:55:48it is generating okay one by one we'll
  20325. 13:55:50show to the user so that they will see
  20326. 13:55:52something in the screen. Okay, this is
  20327. 13:55:54what we have understood in the first
  20328. 13:55:56point. Now the second point you can
  20329. 13:55:57understand guys mimics the human-like
  20330. 13:55:59conversation, build trust, feel alive
  20331. 13:56:02and keep the user engaged. Okay, see
  20332. 13:56:06whenever you are doing any kinds of
  20333. 13:56:07conversation with any kinds of agent or
  20334. 13:56:10chatbot or whatever you are doing the
  20335. 13:56:12conversation. So definitely uh there
  20336. 13:56:15some kinds of engagement should be
  20337. 13:56:17there. Let's say if this application is
  20338. 13:56:19taking 1 minute to run, right? and you
  20339. 13:56:22have to wait for the execution. So
  20340. 13:56:24definitely I can't tell this is like a
  20341. 13:56:25human-like conversation. Let's say you
  20342. 13:56:28are talking with someone. Let's say this
  20343. 13:56:30is you. Okay, this is you and this is
  20344. 13:56:32someone. You are talking with someone,
  20345. 13:56:34right? And if you're asking something
  20346. 13:56:36and let's say this person is taking 1
  20347. 13:56:39minute to give you the response. So
  20348. 13:56:41definitely you will not feel like uh
  20349. 13:56:43interest, you will not feel engaged.
  20350. 13:56:45Okay, you will uh you will not be able
  20351. 13:56:47to build a trust with that particular
  20352. 13:56:49person. Okay. Uh I can give you another
  20353. 13:56:51example. Let's say I think you know uh
  20354. 13:56:53nowadays people are using lots of uh uh
  20355. 13:56:56hardware assistant right hardware
  20356. 13:56:58assistant means like Amazon Alexa.
  20357. 13:57:01Amazon Alexa then Google Home Mini. Okay
  20358. 13:57:04Google Home many people are using that
  20359. 13:57:06right? So this is kinds of personal
  20360. 13:57:08assistant system and what we do we use
  20361. 13:57:11this particular assistant system so that
  20362. 13:57:12we can speak with uh them right speak
  20363. 13:57:15with them and we can uh do lots of task.
  20364. 13:57:17Now let's see if you are talking with
  20365. 13:57:19your uh personal assistant, you are
  20366. 13:57:21talking with your let's say Google Home
  20367. 13:57:22Mini. Okay, you are talking with your
  20368. 13:57:24Google Home Mini and let's say it is
  20369. 13:57:25giving you the response after 1 minute.
  20370. 13:57:28So definitely you will not feel engaged,
  20371. 13:57:30you will not u feel alive, you will not
  20372. 13:57:32feel uh like uh you are not going to
  20373. 13:57:34build a trust okay with that particular
  20374. 13:57:36device. So that's why mimic human like
  20375. 13:57:38conversation it is required. So whenever
  20376. 13:57:40I will talk with uh my let's say bot or
  20377. 13:57:44let's say agents so I'll feel like okay
  20378. 13:57:46I'm talking with the human okay
  20379. 13:57:47instantly I'm getting the response and
  20380. 13:57:49the response is engaging as well okay
  20381. 13:57:51like chat GPT if you u if you're using
  20382. 13:57:54chat GPT I think you know that this um
  20383. 13:57:57engagement then alive trust is super
  20384. 13:58:00important right and we we found inside
  20385. 13:58:02that particular chatbot right that's why
  20386. 13:58:04we are using continuously so that's why
  20387. 13:58:05this is super important then important
  20388. 13:58:07for multimodel UIs okay so Whenever you
  20389. 13:58:10are using multimodel and you are
  20390. 13:58:12creating a user interface so this is
  20391. 13:58:14also required there. Okay. Sometimes you
  20392. 13:58:16will be generating some kinds of image
  20393. 13:58:18and whenever you are generating the
  20394. 13:58:20image that time you can show like we
  20395. 13:58:23okay we are generating the image we are
  20396. 13:58:24taking this particular let's say color
  20397. 13:58:27or there should be a image window
  20398. 13:58:30continuously it will tell okay we are
  20399. 13:58:32generating something. That's why you
  20400. 13:58:33have to show something. Streaming means
  20401. 13:58:35you have to show something on the
  20402. 13:58:36screen. Okay? Instead of uh just keep
  20403. 13:58:39waiting the user here. Then better UX uh
  20404. 13:58:43uh UX for long output such as code. So
  20405. 13:58:45whenever you are generating any kinds of
  20406. 13:58:47code, let's say you created a agent that
  20407. 13:58:49generates the code. So instead of
  20408. 13:58:51waiting for the entire code generation,
  20409. 13:58:53you can uh show the streaming. Okay?
  20410. 13:58:56Like it is uh importing, it is defining
  20411. 13:58:58the model, it is creating the
  20412. 13:59:00architecture. So one by one you can show
  20413. 13:59:02it here. Okay. So this is another user
  20414. 13:59:04experience we get. Then you can see uh
  20415. 13:59:06you can uh cancel midway savings uh
  20416. 13:59:09tokens. That means whenever let's say
  20417. 13:59:11you are uh chatting with your agents or
  20418. 13:59:14chatbot and uh you are generating a long
  20419. 13:59:17form content right and let's say you
  20420. 13:59:19found uh some kinds of content useful
  20421. 13:59:22and you don't need uh um like uh the
  20422. 13:59:25remaining content. So what you can do
  20423. 13:59:26you can stop you can cancel the midway
  20424. 13:59:29execution uh to save the token because
  20425. 13:59:31what happens whenever LLM generates the
  20426. 13:59:34output it generates as a token right and
  20427. 13:59:37whenever you're using any kinds of
  20428. 13:59:39provider let's say open AI or Gemini it
  20429. 13:59:41charge based on the tokens like how much
  20430. 13:59:43token you are giving as an input and how
  20431. 13:59:46much token your model is returning as an
  20432. 13:59:48output okay to based on the token count
  20433. 13:59:51it will charge you so let's say I don't
  20434. 13:59:53need uh some unnecessary information So
  20435. 13:59:55definitely I can uh stop the execution
  20436. 13:59:57and I can save my tokens. Okay, this is
  20437. 13:59:59only possible whenever you are adding
  20438. 14:00:01these kinds of streaming features. So if
  20439. 14:00:03you are adding like one short oneshot
  20440. 14:00:05output that time this is not possible.
  20441. 14:00:07Okay, then you can inter uh interl UI
  20442. 14:00:10updates uh uh example show thinking show
  20443. 14:00:14tool result okay etc. So whenever we'll
  20444. 14:00:16be creating any kinds of agents so
  20445. 14:00:18definitely it will be using tools right
  20446. 14:00:20and whenever it is using tools that mean
  20447. 14:00:22uh that execution will take some time.
  20448. 14:00:24First of all tool will be executed and
  20449. 14:00:26this will fetch the uh informations then
  20450. 14:00:29it will pass to the LLM. So it's taking
  20451. 14:00:31some time right that time instead of
  20452. 14:00:33waiting I can show something in the user
  20453. 14:00:35interface. Let's say it is right now
  20454. 14:00:37using this particular tool and uh this
  20455. 14:00:40tool is uh facing this kinds of
  20456. 14:00:42information. Okay I can just show this
  20457. 14:00:44kinds of output to the user so that user
  20458. 14:00:45feels like okay now my uh application
  20459. 14:00:48are using some kinds of tools uh so that
  20460. 14:00:51it will generate the final outputs. user
  20461. 14:00:53will wait but if it is if you are not
  20462. 14:00:55showing that so what will happen user
  20463. 14:00:57will think like okay my application got
  20464. 14:00:59hang so definitely they will leave your
  20465. 14:01:01application okay so that's why this
  20466. 14:01:03streaming is super important and we need
  20467. 14:01:05the streaming whenever we are getting
  20468. 14:01:07this kinds of agentic system guys now we
  20469. 14:01:09have already understood this uh
  20470. 14:01:11streaming now let's try to understand
  20471. 14:01:13through the code although I have showed
  20472. 14:01:14you the code uh implementation before so
  20473. 14:01:17let me show you so this is the code
  20474. 14:01:18implementation I showed you but in this
  20475. 14:01:20video let me show you how things are
  20476. 14:01:22working. Okay, how we are adding this
  20477. 14:01:24kinds of streaming features. So for this
  20478. 14:01:26uh I think you know we have already
  20479. 14:01:27written this um aentic chatbot back end.
  20480. 14:01:31So in the back end I already created the
  20481. 14:01:33entire workflow. So this is our workflow
  20482. 14:01:35we created and this is our chatbot
  20483. 14:01:37object we created. Okay, this is the
  20484. 14:01:38graph. So what I can do maybe I can uh
  20485. 14:01:41show you
  20486. 14:01:43uh I will create another file. Let's say
  20487. 14:01:46I'm going to name it as test.py.
  20488. 14:01:49So inside that I'm going to first of all
  20489. 14:01:51import my
  20490. 14:01:53uh import my chatbot from agentic back
  20491. 14:01:56end. So from agentic chatbot back end we
  20492. 14:01:59are importing chatbot. Now see if I'm
  20493. 14:02:01not using this uh uh if I'm not using u
  20494. 14:02:06like uh streaming that time I was using
  20495. 14:02:08inboke. I think you remember I was using
  20496. 14:02:10inboke and we also need to import this
  20497. 14:02:13library as well.
  20498. 14:02:17Yeah.
  20499. 14:02:22Human message and base message we have
  20500. 14:02:23to also import
  20501. 14:02:26H.
  20502. 14:02:27So let me check again.
  20503. 14:02:34Then I I need to also pass the
  20504. 14:02:35configuration as well. So let me copy
  20505. 14:02:37the configuration.
  20506. 14:02:40Config should be also passed here. So
  20507. 14:02:42I'll also import the define the
  20508. 14:02:44configuration
  20509. 14:02:46because we're using persistence here.
  20510. 14:02:48Okay, we have to pass the trade and
  20511. 14:02:49everything. I think you know that. Now
  20512. 14:02:51we'll try to replace with that. Yeah.
  20513. 14:02:55Now this is the code guys. So basically
  20514. 14:02:57we are using inboke here and if you're
  20515. 14:02:59using inboke so that means you have to
  20516. 14:03:00wait for the entire execution to be
  20517. 14:03:02completed. Let me show you now. Let's
  20518. 14:03:04say if I stop the execution.
  20519. 14:03:08Python test.py
  20520. 14:03:17Now see uh we have to wait for the
  20521. 14:03:19execution. Maybe I can show you with
  20522. 14:03:20another question. Generate a blog
  20523. 14:03:28about Python programming. Now you'll be
  20524. 14:03:32able to observe.
  20525. 14:03:39Now see okay you have to wait for the
  20526. 14:03:41entire execution. So this is not good.
  20527. 14:03:44Okay now we have to add the streaming
  20528. 14:03:45features here. So here instead of using
  20529. 14:03:48invoke uh we'll be using dot stream. So
  20530. 14:03:52you can write like that chatbot
  20531. 14:03:57dot stream. Okay
  20532. 14:04:01stream.
  20533. 14:04:04Now stream uh takes some argument. uh
  20534. 14:04:07first of all you have to provide
  20535. 14:04:10uh the message
  20536. 14:04:13okay I'll try to provide the message
  20537. 14:04:20yeah I'll try to provide the message uh
  20538. 14:04:23now let's say I'll give the same message
  20539. 14:04:26generate
  20540. 14:04:31uh block
  20541. 14:04:35line graph or let's say
  20542. 14:04:39machine learning.
  20543. 14:04:41Okay, this is the message. Now the
  20544. 14:04:43second parameter you have to provide the
  20545. 14:04:45configuration. Okay, and the third uh
  20546. 14:04:50parameter you have to provide uh the
  20547. 14:04:52stream mode. Okay. Now there are
  20548. 14:04:54multiple stream mode are available. If I
  20549. 14:04:55go to the documentation as you can see
  20550. 14:04:58we have update values messes. Okay,
  20551. 14:05:00custom. Uh so here I want to print the
  20552. 14:05:02message only. So that's why I'll be
  20553. 14:05:04using stream mode is equal to message.
  20554. 14:05:05Okay, because I want to show show my
  20555. 14:05:07message streaming. Okay, whatever um
  20556. 14:05:09output I'm getting from my lm, I want to
  20557. 14:05:12show show this. Okay, that's why we're
  20558. 14:05:14using this. Now, once it is done, now if
  20559. 14:05:16I let's say um show you the result. See
  20560. 14:05:21this stream will return two things. One
  20561. 14:05:23is the
  20562. 14:05:25message chunk.
  20563. 14:05:27Okay, message
  20564. 14:05:31chunk
  20565. 14:05:34that means the token. Okay, token output
  20566. 14:05:37and it will also give you some kinds of
  20567. 14:05:40metadata.
  20568. 14:05:42Okay, metadata. But I don't need the
  20569. 14:05:43metadata. I only need the message chunk
  20570. 14:05:46and metadata. Okay, so basically this
  20571. 14:05:49returns a generator object. Let me show
  20572. 14:05:51you. So I'll give you
  20573. 14:05:54example response.
  20574. 14:05:57Now if I print the response.
  20575. 14:06:05Now if I execute this code
  20576. 14:06:08python test.py.
  20577. 14:06:11So this will give you a generator object
  20578. 14:06:12as you can see. Okay. Stream generator
  20579. 14:06:15object. And you already studied inside
  20580. 14:06:17Python. If we are getting the generator
  20581. 14:06:19object, I can use any kinds of iterator
  20582. 14:06:21to get the output. And what is the
  20583. 14:06:23iterator? We can use for loop here.
  20584. 14:06:25Okay. Uh for loop will try to iterate
  20585. 14:06:28the output one by one here. Okay.
  20586. 14:06:30Instead of getting everything in one
  20587. 14:06:33shot, it will take one by one. So for
  20588. 14:06:35this I will just write a for loop. So
  20589. 14:06:37now I can write like that. Instead of uh
  20590. 14:06:40going through the response, maybe I can
  20591. 14:06:42write the for loop here only. I think
  20592. 14:06:44that would be amazing. So for uh it will
  20593. 14:06:48return two things I told you. One is the
  20594. 14:06:49message chunk
  20595. 14:06:55and it will return the metadata.
  20596. 14:07:00Okay. In chatbot stream okay now I'll
  20597. 14:07:05give this one H.
  20598. 14:07:12Yeah. Now here I'll just write a
  20599. 14:07:14condition
  20600. 14:07:16if uh let's say message
  20601. 14:07:20message chunk
  20602. 14:07:26message chunk
  20603. 14:07:28um dot content okay I will extract the
  20604. 14:07:31content only okay if there is a content
  20605. 14:07:34sorry content
  20606. 14:07:37content I'll just try to print this
  20607. 14:07:39content so print
  20608. 14:07:43message chunk dot content. Okay. And
  20609. 14:07:45here I will give some other parameter
  20610. 14:07:47like end is equal to this empty string
  20611. 14:07:50and uh
  20612. 14:07:53and I will give this splash is equal to
  20613. 14:07:54true.
  20614. 14:07:56Okay, these two things you have to give.
  20615. 14:07:58If you check the documentation, they
  20616. 14:07:59have written the same thing. Okay, now
  20617. 14:08:01let me show you how this output would be
  20618. 14:08:03generated. Now I again I'll execute my
  20619. 14:08:05test.py.
  20620. 14:08:08Now see it is giving you token by token
  20621. 14:08:10as a streaming output. Okay, I think you
  20622. 14:08:12saw the difference and that's how we can
  20623. 14:08:15um implement the streaming features
  20624. 14:08:17inside lang graph. Okay, I hope you
  20625. 14:08:20cleared. Now the same thing uh you have
  20626. 14:08:22to also do in the user interface because
  20627. 14:08:25user interface uh we created this should
  20628. 14:08:28also show as a streaming output and how
  20629. 14:08:31we have done guys uh I think I already
  20630. 14:08:33written the code. Let me show you. See
  20631. 14:08:35it is available in the app.py. So here
  20632. 14:08:37is the code guys. Okay, we written
  20633. 14:08:39already. Now we are using something
  20634. 14:08:41called
  20635. 14:08:43um this one write stream here from
  20636. 14:08:46streamllet we're using write stream. So
  20637. 14:08:48if you go to the streaml documentation
  20638. 14:08:50as you can see stream it has having a
  20639. 14:08:52chat element. So it is having multiple
  20640. 14:08:54chat element like chat input chat
  20641. 14:08:55message start container and there is
  20642. 14:08:58another one called write stream. Okay.
  20643. 14:09:00If you see the right stream so they have
  20644. 14:09:01already written like how to um actually
  20645. 14:09:04write this particular use this
  20646. 14:09:05particular right stream. Okay. So we are
  20647. 14:09:08using this write stream here. Let me
  20648. 14:09:10show you. We're using this write stream.
  20649. 14:09:12So inside that we have written the same
  20650. 14:09:13code. We are um instead of doing the
  20651. 14:09:15invoking operation, we're doing the
  20652. 14:09:17streaming operation. We're giving the
  20653. 14:09:18input config and stream. And we are
  20654. 14:09:21running the for loop. It is returning
  20655. 14:09:23two things. Message chunks and metadata.
  20656. 14:09:25We are only taking the message chunks.
  20657. 14:09:27Okay. And once we got the message trans
  20658. 14:09:30what we doing guys we are just writing
  20659. 14:09:33the stream on the uh streaml streaml
  20660. 14:09:36user interface and once everything is
  20661. 14:09:38done we are updating inside this uh
  20662. 14:09:41message story inside uh streaml session
  20663. 14:09:43state. Okay this is a simple code we
  20664. 14:09:45have written now I think this code is
  20665. 14:09:47clear guys. Okay how I have written. So
  20666. 14:09:49I think many people has the confusion
  20667. 14:09:50how these things are working. Now I
  20668. 14:09:52think this is clear. Now let me show you
  20669. 14:09:54the final execution. I will clear I'll
  20670. 14:09:57run my app.py. So streaml run app.py.
  20671. 14:10:06So this is our app. Now I'll give
  20672. 14:10:09generate
  20673. 14:10:12generate let's say
  20674. 14:10:14code
  20675. 14:10:16for image classification
  20676. 14:10:21in Python.
  20677. 14:10:25Now see
  20678. 14:10:27okay see streaming output we are
  20679. 14:10:29getting. So yes guys uh this is all
  20680. 14:10:31about from this video. I hope you got
  20681. 14:10:33it. Uh what is the streaming and why it
  20682. 14:10:35is required and why we have implemented
  20683. 14:10:37inside our chatbot. So if you check my
  20684. 14:10:41uh agentic chatbot guys so far we
  20685. 14:10:43implemented u till here. So here we can
  20686. 14:10:46perform any kinds of chat operation
  20687. 14:10:47right now. Okay. And uh you can see it's
  20688. 14:10:50working and it is also giving you some
  20689. 14:10:52kinds of streaming response like charge
  20690. 14:10:54GPT right. So in charge GPT what happens
  20691. 14:10:56guys? Uh in charge GPT you can resume
  20692. 14:10:58your conversation with your old trades.
  20693. 14:11:01Let's say I did some kinds of
  20694. 14:11:03conversation previously. I can continue
  20695. 14:11:05anytime. These are the conversations. So
  20696. 14:11:07let's say this was my previous trades
  20697. 14:11:09right? So if I open this particular
  20698. 14:11:11trades I'll be able to see all of my
  20699. 14:11:13conversation story. Okay. And I can uh
  20700. 14:11:16resume my chat from here only. Okay. I
  20701. 14:11:18can resume my chat from here only
  20702. 14:11:21right now like that I can go to any
  20703. 14:11:24another trades let's say I will go to
  20704. 14:11:25this uh
  20705. 14:11:27the this trades okay so from here only I
  20706. 14:11:30can do my conversation so this is called
  20707. 14:11:33trading okay with the help of this
  20708. 14:11:34trading we can separate out uh each and
  20709. 14:11:37every topic let's say message okay let's
  20710. 14:11:40say right now I want to do a
  20711. 14:11:42conversation related uh uh let's say
  20712. 14:11:45deep learning let's say I need another
  20713. 14:11:47uh new session for another topic. Let's
  20714. 14:11:50say I want to do the conversation
  20715. 14:11:51regarding let's say NLP. It's like that.
  20716. 14:11:54Okay. Instead of doing all of the
  20717. 14:11:56conversation in a single trade in a
  20718. 14:11:58single session, you can create multiple
  20719. 14:12:01trades. Okay. And you can do the
  20720. 14:12:03conversation anytime. You can come here,
  20721. 14:12:05you can see the older conversation as
  20722. 14:12:07well with a different different trades.
  20723. 14:12:09But this kinds of feature is not
  20724. 14:12:11available inside our agentic chatbot. So
  20725. 14:12:14in this video what I'm going to do guys
  20726. 14:12:15I'm going to implement this particular
  20727. 14:12:17features so that uh you can also get
  20728. 14:12:20your older trades uh and you can also
  20729. 14:12:22see all of the uh old trades
  20730. 14:12:25conversation as well and anytime you can
  20731. 14:12:27continue your conversation from there
  20732. 14:12:29only. Okay. So these kinds of features
  20733. 14:12:31we'll try to add in this particular
  20734. 14:12:33agentic chatbot in this video. So make
  20735. 14:12:35sure guys you watch this video till the
  20736. 14:12:37end. don't miss anything and if you
  20737. 14:12:39found this content useful please try to
  20738. 14:12:41subscribe to my channel and hit the like
  20739. 14:12:43and please try to share it with your
  20740. 14:12:44friends and family. So instead of
  20741. 14:12:47talking too much guys let's start the
  20742. 14:12:48implementation and I'm going to show you
  20743. 14:12:50how we can add this trading features
  20744. 14:12:52inside this agentic chatbot. So guys
  20745. 14:12:55before starting the development first of
  20746. 14:12:57all I want to show you the final result
  20747. 14:13:00final demo uh like what are the uh
  20748. 14:13:03features we are going to add in this
  20749. 14:13:05particular agentic chatbot. So as you
  20750. 14:13:07can see we already added this uh trading
  20751. 14:13:09features inside our aentic chatbot.
  20752. 14:13:11Previously uh it was a simple chatbot
  20753. 14:13:14only. Okay there we didn't have any
  20754. 14:13:16kinds of uh trading features like uh I
  20755. 14:13:19can't see my older trades right uh it
  20756. 14:13:22was not there but in the new update as
  20757. 14:13:24you can see here we have added a
  20758. 14:13:26separate section. So from here only you
  20759. 14:13:28can go to your previous conversation. So
  20760. 14:13:30let's say here I'm doing a conversation.
  20761. 14:13:33Let's say I'm asking what is Python,
  20762. 14:13:36right?
  20763. 14:13:38Uh let's say I will ask
  20764. 14:13:41my name
  20765. 14:13:44is Buppy
  20766. 14:13:50and I'll tell what is Python.
  20767. 14:13:54Now you can see Python is a highle
  20768. 14:13:57programming language and blah blah blah.
  20769. 14:13:58Now if I ask what is my name?
  20770. 14:14:05Now it is telling your name is BP. Okay.
  20771. 14:14:07So this is a conversation we have done
  20772. 14:14:11in this particular trades. As you can
  20773. 14:14:12see we are using uh unique uh uh ID
  20774. 14:14:16right to save this particular uh
  20775. 14:14:18conversation story in this particular
  20776. 14:14:19trades. Now what you can do like the
  20777. 14:14:21chart GPT you can start a new
  20778. 14:14:23conversation here. So I will click on
  20779. 14:14:24new chart. Now see it will give me a
  20780. 14:14:27completely new traits here. Now here if
  20781. 14:14:29I ask what is my
  20782. 14:14:34name?
  20783. 14:14:37Okay what is my name? You'll see that
  20784. 14:14:39I'm sorry I'm a assistant. I do not have
  20785. 14:14:42access your personal information. Now if
  20786. 14:14:44I ask my name is Alex.
  20787. 14:14:50what is
  20788. 14:14:54ML?
  20789. 14:14:57Now see it is giving you the response.
  20790. 14:14:59Now if I ask what is my name?
  20791. 14:15:06Now it will tell your name is Alex.
  20792. 14:15:07Okay. Now see this this particular
  20793. 14:15:09conversation is completely separate from
  20794. 14:15:10your previous conversation. Now I can go
  20795. 14:15:12to the previous conversation anytime.
  20796. 14:15:14Okay. Where I did like my name is By
  20797. 14:15:17what is Python? Now here I can continue
  20798. 14:15:19the conversation. Let's say now I'll
  20799. 14:15:21tell I want to see
  20800. 14:15:26hello world
  20801. 14:15:31program.
  20802. 14:15:34Now see it is giving you the hello world
  20803. 14:15:36program because we did the conversation
  20804. 14:15:38related Python. Okay. And here we are
  20805. 14:15:40doing the conversation
  20806. 14:15:42uh with the uh help of Buppy. Okay. So
  20807. 14:15:45here Buppy is doing the conversation.
  20808. 14:15:47Now even I can go to my previous
  20809. 14:15:49conversation as well. So this is my
  20810. 14:15:52previous conversation. This one my
  20811. 14:15:53previous conversation. Now here you can
  20812. 14:15:55anytime uh resume the conversation.
  20813. 14:15:57Let's say um how it helps in
  20814. 14:16:04AI.
  20815. 14:16:07See how machine learning helps in AI. It
  20816. 14:16:10is uh telling you each and everything.
  20817. 14:16:12Okay. So that's how you can create
  20818. 14:16:14different different trades and you can
  20819. 14:16:16see your older conversation as well like
  20820. 14:16:18chart GPT. So chart GPT does the same
  20821. 14:16:21thing. It also using trading concept and
  20822. 14:16:24every time whenever you are doing the
  20823. 14:16:26chatting operation it is continuously
  20824. 14:16:28saving your conversation history in a
  20825. 14:16:30one particular trades and you can uh
  20826. 14:16:32start new conversation anytime but the
  20827. 14:16:35older conversation will remain same.
  20828. 14:16:37Okay. So this kinds of thing guys we
  20829. 14:16:39have added inside this particular
  20830. 14:16:41agentic chatbot. Now throughout the
  20831. 14:16:43entire video I'm going to show you the
  20832. 14:16:44implementation part. So guys uh this was
  20833. 14:16:47our uh previous code we have already
  20834. 14:16:49written. So as you can see this was our
  20835. 14:16:51previous app and it doesn't have any
  20836. 14:16:53kinds of uh uh trading related uh uh
  20837. 14:16:57code although I added the trading as you
  20838. 14:17:00can see I added the trading but it was
  20839. 14:17:01hardcoded. So only I was using trade one
  20840. 14:17:04for all the conversation. Okay that's
  20841. 14:17:07why this application was simple. Now I'm
  20842. 14:17:09going to use the same code and we'll be
  20843. 14:17:12writing the trading features inside this
  20844. 14:17:14agentic chatbot. So what I can do
  20845. 14:17:17instead of uh giving the name to app.py
  20846. 14:17:20maybe I can give another name just for
  20847. 14:17:22your reference. So let's say u um
  20848. 14:17:26whenever you want to refer this
  20849. 14:17:27particular simple code only that time
  20850. 14:17:29you will be able to get this code from
  20851. 14:17:31here. Okay. So I can also replace the
  20852. 14:17:33code in my uh app.py pi but uh uh I
  20853. 14:17:36think you won't be able to get the
  20854. 14:17:38previous uh code that time. So that's
  20855. 14:17:39why I'm going to create a new file. So
  20856. 14:17:42first of all, let me rename it. So this
  20857. 14:17:44is let's say
  20858. 14:17:46simple app.
  20859. 14:17:48Okay, this is simple app we created. Now
  20860. 14:17:50I'm going to create another file. I'm
  20861. 14:17:52going to name name it as app
  20862. 14:17:55uh trade.
  20863. 14:18:00Okay, that means uh this uh code has the
  20864. 14:18:04trading uh trading code. Okay, trading
  20865. 14:18:06related code, trading related features.
  20866. 14:18:08Now what I can do, I can copy the same
  20867. 14:18:10code as it is
  20868. 14:18:15here. Okay. Yeah. And here this back end
  20869. 14:18:19code will remain same. The back end code
  20870. 14:18:21we have written this code will remain
  20871. 14:18:23same here. You don't need to change
  20872. 14:18:24anything. The change would be applied in
  20873. 14:18:26the front end part only. Okay? because
  20874. 14:18:28in the back end we are only returning
  20875. 14:18:30the chatbot uh this uh graph object.
  20876. 14:18:33Okay. So here what I'm going to do guys
  20877. 14:18:36first of all I need some more library.
  20878. 14:18:38So let me import. So I need u so here I
  20879. 14:18:42need u u id. So with the help of this u
  20880. 14:18:45u id I'll try to generate unique ID so
  20881. 14:18:48that I can separate out my each and
  20882. 14:18:50every trades. Okay instead of doing the
  20883. 14:18:52hard coding. So every time I will
  20884. 14:18:53generate a unique ID and I'm going to
  20885. 14:18:55create my trades. Okay. uh first I'm
  20886. 14:18:58going to create uh one function that
  20887. 14:19:00will generate unique uh unique uh ID
  20888. 14:19:04okay unique user ID because every time I
  20889. 14:19:07need this unique user ID for this
  20890. 14:19:09particular trading right I already
  20891. 14:19:11showed you that part so for this let's
  20892. 14:19:13create a function
  20893. 14:19:15so this is the function guys I have
  20894. 14:19:18already created
  20895. 14:19:19yeah so this function what it does it u
  20896. 14:19:22generates unique ID uh unique user ID
  20897. 14:19:26every
  20898. 14:19:27uh whenever you will execute this
  20899. 14:19:28function it will give you unique user
  20900. 14:19:30ID.
  20901. 14:19:32So after getting this unique user ID uh
  20902. 14:19:35what I want to do guys I want to
  20903. 14:19:38um I want to add this uh unique ID
  20904. 14:19:42inside my trades. Okay. So for this u I
  20905. 14:19:45can create another function
  20906. 14:19:51um called add trades. So what this add
  20907. 14:19:53trades will do uh basically it will add
  20908. 14:19:56a new trades ID to the conversation
  20909. 14:19:59list. Okay. So basically this will get
  20910. 14:20:01the trade ID and where you will get the
  20911. 14:20:03trade ID we will get from this
  20912. 14:20:04particular function. First of all it
  20913. 14:20:06will check this trade ID it is available
  20914. 14:20:09in the session state or not. Okay that
  20915. 14:20:11means uh stream session state or not. Uh
  20916. 14:20:14we'll try to save uh with the help of
  20917. 14:20:15this chat traits um like key. So if it
  20918. 14:20:19is not there it will uh try to set my uh
  20919. 14:20:23trade ID the trade ID it will generate.
  20920. 14:20:25Okay. So this is a simple function we
  20921. 14:20:27have created because whenever you will
  20922. 14:20:29try to initialize your application for
  20923. 14:20:31the first time there it won't be having
  20924. 14:20:34any kinds of chat trades right so that
  20925. 14:20:37time one new trades should be created
  20926. 14:20:39completely new trades should be created
  20927. 14:20:42and it will try to append there and with
  20928. 14:20:44that particular trades only we'll do the
  20929. 14:20:46conversation then later on if user wants
  20930. 14:20:48they can create the trades okay as per
  20931. 14:20:50their requirement now you can see this
  20932. 14:20:53uh chat trades is not available uh So we
  20933. 14:20:56have to also create that. So if you just
  20934. 14:20:58go below. So I think remember we created
  20935. 14:21:02um message story previously. So here
  20936. 14:21:04only I'll try to add another one.
  20937. 14:21:07So after message so we'll just try to
  20938. 14:21:10write this uh chat threads. Okay. As you
  20939. 14:21:13can see if chat traits not in session
  20940. 14:21:16state it will create a empty chat
  20941. 14:21:18traits. Okay. And this will become a
  20942. 14:21:21list.
  20943. 14:21:23And right now we'll be able to we'll be
  20944. 14:21:26able to um append that particular trades
  20945. 14:21:29because now this chat trades session is
  20946. 14:21:32created. Okay. Here only I will also try
  20947. 14:21:34to add the comments in my previous code
  20948. 14:21:37as well. So that later on whenever you
  20949. 14:21:40are uh revising this code I think it
  20950. 14:21:42would it will be helpful for you. Okay.
  20951. 14:21:46By seeing the comments only you can
  20952. 14:21:47understand what this code is doing.
  20953. 14:21:49Okay. You can see this uh this code
  20954. 14:21:51actually creates the message story when
  20955. 14:21:53the app runs for the first time. Okay, I
  20956. 14:21:55already created previously I think you
  20957. 14:21:57remember. So once it is done now let me
  20958. 14:22:01uh add uh the user interface because if
  20959. 14:22:05you go to the chat GP left hand side you
  20960. 14:22:07will be able to see all of your uh
  20961. 14:22:09conversation okay all of the threads. So
  20962. 14:22:10we'll try to create the same thing here.
  20963. 14:22:13So for this let me just create a sidebar
  20964. 14:22:15first of all. So here I'll just try to
  20965. 14:22:19add a sidebar
  20966. 14:22:21with the help of streamllet. So I
  20967. 14:22:23already commented out this is that uh
  20968. 14:22:26sidebar trading features display the
  20969. 14:22:28sidebar title. So stidebar.title
  20970. 14:22:32I just name it as my conversations.
  20971. 14:22:35Now if I execute my code
  20972. 14:22:38okay if I execute my code you will be
  20973. 14:22:40able to see that. system streamllet run
  20974. 14:22:44uh app
  20975. 14:22:47trade.py.
  20976. 14:22:49Okay, this file we are executing. Now if
  20977. 14:22:52I show you my code, so as you can see
  20978. 14:22:55guys, this is our uh sidebar we created.
  20979. 14:22:57So anytime you can open and close it uh
  20980. 14:23:00like the chart GPT chart GPT also has
  20981. 14:23:02the same thing. Okay, this is the
  20982. 14:23:04sidebar. Now here only we'll be adding
  20983. 14:23:06our trading. Okay. So for this uh let me
  20984. 14:23:10just uh show you my updated code what I
  20985. 14:23:13have done. Um
  20986. 14:23:16I can show you step by step. I think
  20987. 14:23:18that would be uh best. So what I can do
  20988. 14:23:21I can just uh quickly show you.
  20989. 14:23:29So I'll just uh remove these are the
  20990. 14:23:31code. Okay. My old code and I'm going to
  20991. 14:23:33show you my updated code. I think that
  20992. 14:23:34would be amazing.
  20993. 14:23:40I'll just try to remove all of the code.
  20994. 14:23:43[clears throat]
  20995. 14:23:44So, first uh we'll be adding some
  20996. 14:23:45utility functions. First of all,
  20997. 14:23:48generate uh trade ID. I already told you
  20998. 14:23:50it will generate the trade ID every
  20999. 14:23:51time. And another function I have
  21000. 14:23:53written uh this will basically add the
  21001. 14:23:55trade ID where to the session state.
  21002. 14:23:58Okay. But we have to create the session
  21003. 14:24:00state. So, let's create all the session
  21004. 14:24:03state. I'll just try to add all of the
  21005. 14:24:05session state.
  21006. 14:24:11So this is my message story session uh
  21007. 14:24:14session state and this is for my
  21008. 14:24:20chat uh session state. Okay, chat
  21009. 14:24:23traits. Okay, that mean this this one.
  21010. 14:24:26and um
  21011. 14:24:29um I'm going to
  21012. 14:24:32create a sidebar here.
  21013. 14:24:38Sidebar here. Okay. So, this is my
  21014. 14:24:40sidebar. Now, if I go to my application
  21015. 14:24:43again, if I refresh
  21016. 14:24:46now, see it looks like that. Okay. Don't
  21017. 14:24:48worry about this chat input feature. I'm
  21018. 14:24:50going to add it. Uh just let me update
  21019. 14:24:52my uh this code first of all, then I'm
  21020. 14:24:54going to add. Okay, that that will
  21021. 14:24:55remain same like we did the previously.
  21022. 14:24:57Right now, what I'm going to do guys,
  21023. 14:25:00I'm going to add a new button here. So,
  21024. 14:25:02I think you remember chat GP also has a
  21025. 14:25:05button. If you click on this new chat
  21026. 14:25:07button, it will start a new conversation
  21027. 14:25:09for you and you will be able to see the
  21028. 14:25:11old uh trades as well. So, these kinds
  21029. 14:25:13of features we'll try to add here. So,
  21030. 14:25:16this is the code. I'm going to tell you
  21031. 14:25:19about this reset chat what this reset
  21032. 14:25:21chat will do. But let's try to
  21033. 14:25:23understand. Uh see this uh creates a
  21034. 14:25:25button for starting a new conversation.
  21035. 14:25:27So there would be a button stidebar dot
  21036. 14:25:30button new chart. And if you click on
  21037. 14:25:32new chart, see what will happen in chart
  21038. 14:25:34GPT. Let's say uh let's say I'm inside a
  21039. 14:25:37trades. Let's say I'm inside this
  21040. 14:25:38particular trades. Okay, I'm inside this
  21041. 14:25:40particular trades. Now once I click on
  21042. 14:25:43new chart, you'll see that one new
  21043. 14:25:45window will come and all of the previous
  21044. 14:25:47chart history will be clean up. Right?
  21045. 14:25:50So for this kind uh this reason I'm also
  21046. 14:25:52going to write a function called recent
  21047. 14:25:54reset chat. So whenever user will take
  21048. 14:25:55the new chat all of the previous
  21049. 14:25:57conversation would be removed. So for
  21050. 14:25:59this let's create another function here.
  21051. 14:26:02I'm going to name it as
  21052. 14:26:05um
  21053. 14:26:07reset chat. So after this function maybe
  21054. 14:26:10I can add
  21055. 14:26:13okay reset chat. So what it it is doing
  21056. 14:26:16you can see uh first of all it will u
  21057. 14:26:18basically generate a new trade id with
  21058. 14:26:22the help of this function
  21059. 14:26:24and it will store in the trade ID. The
  21060. 14:26:26trade ID uh we created
  21061. 14:26:30uh session state I think session state
  21062. 14:26:32trade ID is not created. So let me
  21063. 14:26:33create it quickly.
  21064. 14:26:38So this is my
  21065. 14:26:41trade ID. Okay. If trade ID not in
  21066. 14:26:43session state uh it will create a trade
  21067. 14:26:45ID and it will take a trade ID from this
  21068. 14:26:47particular function. Okay, unique trade
  21069. 14:26:49ID. Now it is resetting and uh what it
  21070. 14:26:52is doing it is uh setting a new trade
  21071. 14:26:55ID. Then after that all of the message
  21072. 14:26:58would be empty. We you can see we are
  21073. 14:26:59giving empty list. Then after that we
  21074. 14:27:02are adding this particular trade ID in
  21075. 14:27:04my session state. Okay, you can see we
  21076. 14:27:06are using this add trade function and we
  21077. 14:27:08are adding this trade ID the current
  21078. 14:27:10trade ID in the session state because
  21079. 14:27:13whenever I'm inside this particular
  21080. 14:27:15trade okay I'm inside this this
  21081. 14:27:16particular trade so all of the
  21082. 14:27:18conversation should be saved in this
  21083. 14:27:20particular trades only that's why this
  21084. 14:27:23thing we are doing so every time we have
  21085. 14:27:24to track this trade trade ID all right
  21086. 14:27:27now uh let's say if I go to my
  21087. 14:27:32application if I refresh now you'll be
  21088. 14:27:34able to the uh see this new chat. Okay.
  21089. 14:27:37Now, if I click on this new chat, so it
  21090. 14:27:39will basically
  21091. 14:27:41run this code. It will basically run
  21092. 14:27:43this code and all of the recent uh uh I
  21093. 14:27:46mean recent conversation would be
  21094. 14:27:48removed. Okay. And uh uh we have to
  21095. 14:27:52write this st. If you are doing the
  21096. 14:27:54reset chat operation, this is
  21097. 14:27:55recommended. So basically this this will
  21098. 14:27:57uh return the streaml app to update uh
  21099. 14:28:00update the interface. Okay. So basically
  21100. 14:28:02what is happening uh whenever you are
  21101. 14:28:04doing this uh new chat operation it is
  21102. 14:28:06resetting after getting the resetting
  21103. 14:28:08operation it is giving you the new
  21104. 14:28:09window. Okay. So whenever you are
  21105. 14:28:12getting the new window st. Return. Okay.
  21106. 14:28:15This is recommended. If you check the
  21107. 14:28:17documentation, you'll be able to see
  21108. 14:28:19that. Okay. Now let's try to add the
  21109. 14:28:21chat feature. Uh I'll just try to add
  21110. 14:28:23the updated chat feature. So I already
  21111. 14:28:26written the code guys. Let me show you.
  21112. 14:28:29So this is the code
  21113. 14:28:35and this is the same code guys. Uh only
  21114. 14:28:37just few update I have done. So here
  21115. 14:28:39we're taking a chat input from the user.
  21116. 14:28:42Okay. And whenever user is giving their
  21117. 14:28:44input, first of all we are appending to
  21118. 14:28:46the message story. The same thing we did
  21119. 14:28:48our uh previous code as well. So message
  21120. 14:28:51story. Uh after that uh we are setting
  21121. 14:28:55this is a user conversation and content
  21122. 14:28:57is user input. Okay. And why we are
  21123. 14:28:59doing this? Because I want to save my
  21124. 14:29:02conversation story and this is the
  21125. 14:29:04format to save the conversation story.
  21126. 14:29:06First of all, you have to define uh what
  21127. 14:29:08is the role of this conversation. This
  21128. 14:29:10is user and what is the content of that.
  21129. 14:29:12Okay. After this, we are showing this
  21130. 14:29:15conversation in the streamlit user
  21131. 14:29:16interface. For this, we're taking a chat
  21132. 14:29:18message. I think remember there would be
  21133. 14:29:20a um there would be a icon. Okay. User
  21134. 14:29:23icon. So, we are setting that this is a
  21135. 14:29:25user icon and this is the user
  21136. 14:29:26conversation. Okay. And here guys, we
  21137. 14:29:28are defining the configuration right
  21138. 14:29:30now. Okay. This is the persistence
  21139. 14:29:33configuration. This is the trading
  21140. 14:29:34configuration. Config is equal to
  21141. 14:29:36configurable. Now trade ID is equal to
  21142. 14:29:38ST dot session state trade ID. Now we
  21143. 14:29:41are not taking the hardcoded trade ID.
  21144. 14:29:43Instead of that see previously we are
  21145. 14:29:44taking the hardcoded trade ID. We are
  21146. 14:29:46only giving trade one. But right now
  21147. 14:29:48there would be a multiple trade. User
  21148. 14:29:50can create the trades right. So we are
  21149. 14:29:52taking it from the session state and
  21150. 14:29:53already session state we have created
  21151. 14:29:55here. The session state it is already
  21152. 14:29:57created.
  21153. 14:29:59Uh session state
  21154. 14:30:02uh what is that? Yeah, s state trade ID.
  21155. 14:30:05Now I think trade ID it is available.
  21156. 14:30:07Yeah, you can see trade ID is available.
  21157. 14:30:09And how we are getting the trade ID? It
  21158. 14:30:11is generating by the UI ID. Okay, from
  21159. 14:30:13here only it is getting generated. Okay,
  21160. 14:30:15I hope you get it now. Yeah, from here
  21161. 14:30:20actually we are showing the user uh
  21162. 14:30:22sorry assistant message. As you can see
  21163. 14:30:24we are taking this S3 uh chat message.
  21164. 14:30:28Uh we are taking this is assistant
  21165. 14:30:30reply. After that we are uh taking the
  21166. 14:30:33write stream function. I told you in my
  21167. 14:30:35previous video how stream it streaming
  21168. 14:30:38works right how we can show the
  21169. 14:30:39streaming response. So inside that we
  21170. 14:30:42are generating the responses from our
  21171. 14:30:44chatbot object. The chatbot we have
  21172. 14:30:46imported from the back end. Okay as you
  21173. 14:30:48can see this is the same code guys there
  21174. 14:30:50is no chance we are using after that
  21175. 14:30:53whatever message chunk we are getting we
  21176. 14:30:55are continuously
  21177. 14:30:57uh writing with the help of write stream
  21178. 14:30:59function. Okay. And here we're passing
  21179. 14:31:01the configuration and we are giving
  21180. 14:31:04stream mode is equal to masses. Okay.
  21181. 14:31:06And here we're getting one u suggestion.
  21182. 14:31:08I have to import this AI message. So
  21183. 14:31:10let's import it quickly.
  21184. 14:31:16I'll just try to import this AI message
  21185. 14:31:20after human message AI message. Okay.
  21186. 14:31:22Because this streaming response should
  21187. 14:31:23be AI message here. Okay. That's why I'm
  21188. 14:31:26telling if is instance message chunk if
  21189. 14:31:29it is like message chunk that means we
  21190. 14:31:32are getting AI AI reply right so that's
  21191. 14:31:34why telling this should be IM message so
  21192. 14:31:36this will only uh show the IM message
  21193. 14:31:38here then we are saving the complete
  21194. 14:31:42assistant response in this stream
  21195. 14:31:43session state in the message story so
  21196. 14:31:45this code is common I think you already
  21197. 14:31:46know that yeah this is pretty much clear
  21198. 14:31:49so after uh this uh part is done guys
  21199. 14:31:52now what I'm going to do I'm going to
  21200. 14:31:54simply
  21201. 14:31:56execute my app. Refresh.
  21202. 14:32:00Now see guys, you are getting this
  21203. 14:32:02window. Now if I do the chat operation,
  21204. 14:32:04let's say hi.
  21205. 14:32:09See, I'm getting the response. Now I'll
  21206. 14:32:11tell my name
  21207. 14:32:14is puppy.
  21208. 14:32:16Now see previous uh message is getting
  21209. 14:32:19replaced because I haven't added this
  21210. 14:32:22code here. I think remember previously
  21211. 14:32:23also I added this code and this uh
  21212. 14:32:26loading the conversation history. Okay,
  21213. 14:32:28we have to load the conversation story
  21214. 14:32:29every time. So let's load that before
  21215. 14:32:32the user input. So every time it will
  21216. 14:32:34load the conversation story message and
  21217. 14:32:37it will uh write in the stream that user
  21218. 14:32:40interface as a uh human role and
  21219. 14:32:42assistant role. Okay, because we are
  21220. 14:32:45running a for loops every time it will
  21221. 14:32:47looping through the role. First of all
  21222. 14:32:50user role will come then assistant role
  21223. 14:32:52then user role then assistant role and
  21224. 14:32:53their content. Now let me refresh and
  21225. 14:32:57again try. So hello
  21226. 14:33:05my name is
  21227. 14:33:09Buffy.
  21228. 14:33:12Okay. Now nice to meet you Buffy. Now
  21229. 14:33:14see we are able to see the previous
  21230. 14:33:15conversation but right now what I have
  21231. 14:33:18to do so let's say if I click on a new
  21232. 14:33:20chart okay new chart will is coming okay
  21233. 14:33:23it's completely fine but I am not able
  21234. 14:33:25to see my older chart that means older
  21235. 14:33:28trades so now we'll be adding the code
  21236. 14:33:30related older trades so you can also see
  21237. 14:33:32the older trades so what I can do guys u
  21238. 14:33:36I can show you my updated code I already
  21239. 14:33:37created for this
  21240. 14:33:40here I can write
  21241. 14:33:45So this is the code guys I have written
  21242. 14:33:47display all the conversation trades in
  21243. 14:33:48reverse order and why I have to uh show
  21244. 14:33:52in the reverse order. See every time
  21245. 14:33:53what is happening if you create new
  21246. 14:33:55trades right? If you create new trades
  21247. 14:33:58so your
  21248. 14:34:00uh your u new trades is coming
  21249. 14:34:04uh new trait is coming at the last.
  21250. 14:34:06Okay. Because by default Python will add
  21251. 14:34:09this new traits at the last. Okay. But
  21252. 14:34:12if you see if I click on new trades
  21253. 14:34:14every time this new trade should be
  21254. 14:34:16coming at the recent chart okay at the
  21255. 14:34:18first uh first uh let's say order. So
  21256. 14:34:21that's why we are reversing the order.
  21257. 14:34:23So if my new chart is getting added at
  21258. 14:34:25the last if I do the reverse operation
  21259. 14:34:28that means from the last it will come at
  21260. 14:34:29the first. Okay I think you understood
  21261. 14:34:31that's why we're doing the reverse order
  21262. 14:34:33operation. So this is a list we are just
  21263. 14:34:35doing the reverse order operation
  21264. 14:34:36because in this session state we have
  21265. 14:34:38the chat traits. Okay, in this session
  21266. 14:34:40state we have the chat trades and this
  21267. 14:34:41is a list and it will continuously add
  21268. 14:34:44at the last. Okay, let's see if you
  21269. 14:34:45click on the add new. So new chat will
  21270. 14:34:48add here. New chat will add here, right?
  21271. 14:34:52And this has your old chat also.
  21272. 14:34:55But this will show at at the last but I
  21273. 14:34:57don't want to see at the last because
  21274. 14:34:59whenever I'm doing the new conversation
  21275. 14:35:01I want to see in the recent chat
  21276. 14:35:03operation that means it will come at the
  21277. 14:35:05first. Okay, that's why we have to do
  21278. 14:35:06the reverse operation. So if you perform
  21279. 14:35:08the reverse operation what will happen
  21280. 14:35:10this new chat will come here right now
  21281. 14:35:12okay before the old chat and with the
  21282. 14:35:15help of that I will be able to make it
  21283. 14:35:17in the recent conversation. So this is
  21284. 14:35:19why we are doing this one
  21285. 14:35:25just a minute let me
  21286. 14:35:28so this is why we are adding this
  21287. 14:35:30particular code. So it is going through
  21288. 14:35:32the entire uh chat trades and uh here we
  21289. 14:35:36are giving a button because this should
  21290. 14:35:38be also a clickable object. If I click
  21291. 14:35:40on this particular traits, it will be
  21292. 14:35:42able to show my conversation. Okay,
  21293. 14:35:45that's why we are making it as a button.
  21294. 14:35:48ST dot sidebar button. So button uh name
  21295. 14:35:51should be trade ID only.
  21296. 14:35:54Even you can also uh you can also uh
  21297. 14:35:57give any message name if you want. Okay,
  21298. 14:36:00if you want you can also add any message
  21299. 14:36:02name and uh the key should be trade ID.
  21300. 14:36:05So once uh button creation is done, we
  21301. 14:36:08are again saving this trade ID in our
  21302. 14:36:11current trade because this is the
  21303. 14:36:12current trade user will do the
  21304. 14:36:14conversation
  21305. 14:36:15and we'll load all of the conversation
  21306. 14:36:18in this particular traits because if you
  21307. 14:36:20click here see if I click here it is
  21308. 14:36:22loading all of the conversation I did
  21309. 14:36:24previously okay from my memory. So I
  21310. 14:36:27will write a function for this called
  21311. 14:36:29load conversation.
  21312. 14:36:31So basically this will load all the
  21313. 14:36:32previous conversation here.
  21314. 14:36:36So after this uh reset chat maybe I can
  21315. 14:36:43write this function. So load
  21316. 14:36:45conversation this will take the trade ID
  21317. 14:36:47and I think you remember uh from the uh
  21318. 14:36:50langraph graph we get the state. Okay.
  21319. 14:36:52If you call this get state function, it
  21320. 14:36:54will give you all of the all of the
  21321. 14:36:57previous conversation. If you want to
  21322. 14:36:59understand this guys, you have to go
  21323. 14:37:01through this particular session because
  21324. 14:37:02here I already explained each and
  21325. 14:37:04everything. So that's why I'm not going
  21326. 14:37:05to repeat it again. So this get state
  21327. 14:37:07function will return you all of the
  21328. 14:37:08previous conversation. So we are taking
  21329. 14:37:10all of the conversation and we are only
  21330. 14:37:12getting the messages. Okay, from the
  21331. 14:37:14value itself, we're only getting the
  21332. 14:37:15messages.
  21333. 14:37:16Okay, so this particular messages will
  21334. 14:37:20show here. Then we are taking a empty
  21335. 14:37:23list here. Then we are going through the
  21336. 14:37:25messages one by one. Then we are trying
  21337. 14:37:27to separate out the u user conversation
  21338. 14:37:30as well as the assistant conversation.
  21339. 14:37:32Okay. So we we are using is instance uh
  21340. 14:37:36function for this. If you pass any
  21341. 14:37:38message uh it will automatically tell
  21342. 14:37:40you whether it is human message or let's
  21343. 14:37:44say AI message. If it is human message
  21344. 14:37:46role should be set to the user otherwise
  21345. 14:37:49role should be set to the assistant.
  21346. 14:37:51Then after that we are adding inside my
  21347. 14:37:53temporary message list all of the
  21348. 14:37:55conversation as a role and content. Then
  21349. 14:37:58after that we are just updating in my
  21350. 14:38:00session state and it is uh showing you
  21351. 14:38:03in the user interface. Okay. Then again
  21352. 14:38:05we are doing the return operation. Now
  21353. 14:38:07let me show you. So if I let's say come
  21354. 14:38:09here refresh.
  21355. 14:38:12Now see uh if I do any kinds of
  21356. 14:38:15conversation
  21357. 14:38:19if I take a new chat now see guys new
  21358. 14:38:22new chat is getting created and I can
  21359. 14:38:25see my previous conversation as well.
  21360. 14:38:26Now let's see if I do another
  21361. 14:38:28conversation. Hi
  21362. 14:38:32done. Now I can go to my previous
  21363. 14:38:33conversation.
  21364. 14:38:43See I can go to my previous
  21365. 14:38:44conversation. This is the new
  21366. 14:38:46conversation. This is previous
  21367. 14:38:47conversation. Okay. So we have added
  21368. 14:38:49this particular code. And I'm also able
  21369. 14:38:51to see my conversation history. Let's
  21370. 14:38:53see if I've done any kinds of previous
  21371. 14:38:54conversation. I can see the history
  21372. 14:38:56because of this code. Okay. This is
  21373. 14:38:58continuously
  21374. 14:39:00uh where is that this function load
  21375. 14:39:02conversation. this loop conversation is
  21376. 14:39:04continuously fetching the informations
  21377. 14:39:07because we're running a for uh running a
  21378. 14:39:09for loop here. Okay. So every time uh
  21379. 14:39:11this uh message is getting fetched
  21380. 14:39:18and one more update we have to do
  21381. 14:39:22uh every time we have to set the current
  21382. 14:39:24trade to the conversation list. Okay,
  21383. 14:39:27for this we'll try to add this
  21384. 14:39:28particular code. Okay, now I think my
  21385. 14:39:30application is ready. This is a simple
  21386. 14:39:33uh code we have written only. We're just
  21387. 14:39:36playing with the trade. Okay, trade ID
  21388. 14:39:38and for this we're using UI ID. We can
  21389. 14:39:41also make it as a u readable title like
  21390. 14:39:44chart JP. Chat GPT actually generates
  21391. 14:39:46readable title uh uh title. So if you
  21392. 14:39:48are asking any kinds of question, it
  21393. 14:39:50will generate title instead of giving a
  21394. 14:39:52trade ID. We can also do do this
  21395. 14:39:53particular update. It is also possible.
  21396. 14:39:56Now let me refresh my app.
  21397. 14:39:59Okay. So this is the app. My name
  21398. 14:40:06is BBY.
  21399. 14:40:11Okay. So basically this conversation is
  21400. 14:40:13getting saved inside this particular
  21401. 14:40:14trade. Okay. In this particular trade it
  21402. 14:40:16is saving. Now I love cricket.
  21403. 14:40:24Okay. Now if I take new conversation now
  21404. 14:40:27it is coming as a new uh new session
  21405. 14:40:30again and this particular session is
  21406. 14:40:32coming at the first and previous was a
  21407. 14:40:35previous one it is going at the last
  21408. 14:40:36because we are doing the reverse
  21409. 14:40:37operation. Now here I'll tell my
  21410. 14:40:42name is Alex.
  21411. 14:40:46I love football.
  21412. 14:40:54Okay. Now I go I can go to my previous
  21413. 14:40:56conversation
  21414. 14:40:58and here I can resume the conversation.
  21415. 14:41:00What is my
  21416. 14:41:04uh what is my favorite
  21417. 14:41:10sport.
  21418. 14:41:15Okay you can see cricket is the favorite
  21419. 14:41:17sport. Now I can go to my current trade
  21420. 14:41:20and here also I can ask what is my name?
  21421. 14:41:25Your name is Alex. Okay. So that's how
  21422. 14:41:27you can create as much as trade as you
  21423. 14:41:29can. What is
  21424. 14:41:32transformers?
  21425. 14:41:38Okay.
  21426. 14:41:39So this is uh telling you about the
  21427. 14:41:42movie but I can ask what is transformers
  21428. 14:41:45in AI?
  21429. 14:41:48Okay, now it is telling you what is
  21430. 14:41:50transformers in AI. Okay, so that's how
  21431. 14:41:52guys uh like chart JPT we created the
  21432. 14:41:54trades. Now we can switch to different
  21433. 14:41:56different trades and I can resume the
  21434. 14:41:58conversation. So yes guys, that's how we
  21435. 14:42:00can add this trading features uh like
  21436. 14:42:02chart JPT. Now if you want you can also
  21437. 14:42:04change this name to the actual let's say
  21438. 14:42:07chat title. If you want you can also add
  21439. 14:42:09inside this code. So I'll try to u give
  21440. 14:42:12this part uh as an assignment to you.
  21441. 14:42:14Maybe you can uh add this functionality
  21442. 14:42:16in this code. Okay, simply you can go to
  21443. 14:42:18the chat GPT and you can ask uh I want
  21444. 14:42:21this particular features how should I
  21445. 14:42:23add? You'll be getting the suggestion.
  21446. 14:42:25Okay, so just try to add uh this update
  21447. 14:42:28instead of showing you this uh you uh uh
  21448. 14:42:32unique user ID maybe you can show chat
  21449. 14:42:34title like chat GPT the way chat GPT
  21450. 14:42:37shows okay you can also add this
  21451. 14:42:38particular things. So we have already
  21452. 14:42:40integrated this uh chat trading. Uh now
  21453. 14:42:43we are able to uh continue the
  21454. 14:42:46conversation uh with our previous chat
  21455. 14:42:49as well. That means right now I can
  21456. 14:42:51separate out my uh chat trades. I can
  21457. 14:42:54create a new conversation. I can
  21458. 14:42:56continue with my old conversation like
  21459. 14:42:58chat GPT. So yeah we have already added
  21460. 14:43:01this uh trading features. So what will
  21461. 14:43:04happen right now? Let's say if I
  21462. 14:43:06continue any kinds of conversation.
  21463. 14:43:07Let's see here I will give hi my name is
  21464. 14:43:12BP. Okay.
  21465. 14:43:14So as you can see it is giving you
  21466. 14:43:16response uh nice to meet you BP how I
  21467. 14:43:18can assist you today. Now let's say I
  21468. 14:43:20want to create a new chat like chat GPT.
  21469. 14:43:22So what I will do I'll just click on new
  21470. 14:43:24chat and you can see one new trade has
  21471. 14:43:27created. Okay, new um conversation has
  21472. 14:43:30created. Now here I will tell hi my name
  21473. 14:43:34is Alex.
  21474. 14:43:38See hello Alex how I can assist you
  21475. 14:43:40today now I can go to my previous
  21476. 14:43:43conversation where I told my name is BPI
  21477. 14:43:46even I can continue with my um the
  21478. 14:43:49current conversation I did right so
  21479. 14:43:51that's how you can create as much as
  21480. 14:43:53session you can okay but I think you
  21481. 14:43:56have observed one thing uh which is if I
  21482. 14:43:59refresh the application okay let's say
  21483. 14:44:01if I refresh the application so see my
  21484. 14:44:04previous conversation is getting erased.
  21485. 14:44:06Okay, previous conversation is getting
  21486. 14:44:08removed. So whenever you are refreshing,
  21487. 14:44:10okay, whenever you are refreshing, that
  21488. 14:44:12means your RAM is getting cleared. Okay,
  21489. 14:44:14and all of the conversation is getting
  21490. 14:44:16erased. And if you close your
  21491. 14:44:18application as well, let's say if I
  21492. 14:44:19disconnect from my terminal, so what
  21493. 14:44:21will happen uh from the RAM itself, it
  21494. 14:44:23will be removed and again you will be
  21495. 14:44:25able to see the new chat here. You won't
  21496. 14:44:27be able to see the older conversation.
  21497. 14:44:29This is the problem. So yeah uh today in
  21498. 14:44:31this particular video guys we'll try to
  21499. 14:44:33understand how we can add the database
  21500. 14:44:35features inside the agentic chatbot uh
  21501. 14:44:37so that uh whenever you are refreshing
  21502. 14:44:39right your agentic chatbot uh you will
  21503. 14:44:41be able to see the old conversation
  21504. 14:44:43right now this is the problem. So right
  21505. 14:44:45now if you perform conversation with
  21506. 14:44:47your chatbot and uh if you are creating
  21507. 14:44:50different different let's say chat
  21508. 14:44:52traits so if you refresh your
  21509. 14:44:53application or if you close your
  21510. 14:44:55application it will be removed from the
  21511. 14:44:56RAM right so these kinds of things we
  21512. 14:44:58have to fix. So that's how guys we'll
  21513. 14:45:00try to add uh uh new features inside
  21514. 14:45:03this agentic chatbot and we'll try to
  21515. 14:45:05make this agentic chatbot more advanced
  21516. 14:45:07and uh we'll be learning this particular
  21517. 14:45:09project. Okay. So if you found my
  21518. 14:45:11content useful guys please try to
  21519. 14:45:13subscribe to my channel and please share
  21520. 14:45:14it with your friends and family and
  21521. 14:45:17please support me guys. Uh if you
  21522. 14:45:18support me so definitely I will be
  21523. 14:45:20bringing this kinds of content more okay
  21524. 14:45:22on my channel. So uh instead of talking
  21525. 14:45:25too much guys, let's start with the
  21526. 14:45:26implementation and uh here uh in this
  21527. 14:45:29video guys, I'm going to show you how we
  21528. 14:45:31can integrate database functionality in
  21529. 14:45:33the persistence memory. So guys, I have
  21530. 14:45:36already shared the source code with you.
  21531. 14:45:38It is already available in the video
  21532. 14:45:40description. So if you open up my
  21533. 14:45:42previous code guys, I have already
  21534. 14:45:44written this code as you remember. So
  21535. 14:45:46there I uh tried to uh uh integrate this
  21536. 14:45:49trading features inside our agentic
  21537. 14:45:51chatbot and this is the code we have
  21538. 14:45:53written right. So this is the entire
  21539. 14:45:55code and uh the change we have done in
  21540. 14:45:58the front end uh because you can see
  21541. 14:45:59this is the front end uh uh front end
  21542. 14:46:02file and we had another file which is
  21543. 14:46:04the back end. Okay, in the back end
  21544. 14:46:05itself I had my um like let's say uh
  21545. 14:46:09aentic chatbot back end. So here I
  21546. 14:46:11created the chat node then the uh graph
  21547. 14:46:14and ages. Okay, each and everything I
  21548. 14:46:16initialized it here and I was returning
  21549. 14:46:18as a checkpoint uh sorry chatbot uh
  21550. 14:46:20graph object. So here uh if you see in
  21551. 14:46:23this particular backend file here I was
  21552. 14:46:26using this memory saver okay from the uh
  21553. 14:46:29checkpoint check checkpo pointer lang
  21554. 14:46:31graph checkpo pointer so I was importing
  21555. 14:46:33lang graph dot checkpoint dot memory
  21556. 14:46:36import in memory saver so if you're
  21557. 14:46:38using this uh memory saver that means
  21558. 14:46:40what is happening uh you are storing all
  21559. 14:46:42of the conversation in the RAM and
  21560. 14:46:44whenever you are refreshing or closing
  21561. 14:46:46your terminal it is getting erased okay
  21562. 14:46:48because RAM is a temporary memory now we
  21563. 14:46:50have to make it as permanent okay For
  21564. 14:46:52this we have to use some kinds of
  21565. 14:46:53database. Now if you visit this lang
  21566. 14:46:55graph documentation lang graph
  21567. 14:46:57documentation um uh you will be u you'll
  21568. 14:47:00be finding like uh uh some database they
  21569. 14:47:04are suggesting whenever you are creating
  21570. 14:47:06uh this kinds of persistence memory. So
  21571. 14:47:09uh if you check the langraph
  21572. 14:47:10documentation there you will be getting
  21573. 14:47:12some kinds of database like SQLite
  21574. 14:47:14database they are suggesting. So
  21575. 14:47:15skillite database when you can use
  21576. 14:47:17whenever you are creating the prototype
  21577. 14:47:18right as of now we are learning uh we
  21578. 14:47:21are trying to implement this agentic
  21579. 14:47:23chatbot. So we are in the learning phase
  21580. 14:47:25maybe we can utilize the SQLite database
  21581. 14:47:27because this is completely free to use
  21582. 14:47:29and SQLite database actually basically
  21583. 14:47:32it will create the instance inside your
  21584. 14:47:34local storage. Okay. But uh you can also
  21585. 14:47:37utilize any production uh grade database
  21586. 14:47:40like postgress is there then um some
  21587. 14:47:43other database are also there. Okay, you
  21588. 14:47:45can also utilize that. So going forward
  21589. 14:47:47whenever we'll try to create production
  21590. 14:47:49grade actually agentic uh chatbot uh
  21591. 14:47:51that time I'll try to use these are the
  21592. 14:47:53database but right now we are in the
  21593. 14:47:55learning phase. So we'll try to use some
  21594. 14:47:57kinds of prototype based database. Okay,
  21595. 14:47:59I can utilize SQLite database because
  21596. 14:48:01this is this would be lightweight for me
  21597. 14:48:03and I don't need to take uh any kinds of
  21598. 14:48:05subscription plan for that. Right? So
  21599. 14:48:07that's why I'll continue with the SQLite
  21600. 14:48:09database. So if you uh go to the SQLite
  21601. 14:48:11documentation SQLite documentation
  21602. 14:48:16um
  21603. 14:48:18so this is the SQLite documentation
  21604. 14:48:20guys. So this is uh basically a
  21605. 14:48:23database. Uh this is a database actually
  21606. 14:48:25you can utilize uh with the help of
  21607. 14:48:27python and uh if you're using this
  21608. 14:48:30langraph guys lang graph also has the
  21609. 14:48:32connection with SQLite. Okay for this
  21610. 14:48:35you have to install one library uh this
  21611. 14:48:37library uh langraph checkpoint SQLite.
  21612. 14:48:40Okay. So you have to install this
  21613. 14:48:42particular library. If you install this
  21614. 14:48:43library you will be able to use this
  21615. 14:48:45SQLite uh with your langraph. You can
  21616. 14:48:48also separately install this SQL light
  21617. 14:48:50if you are only using Python programming
  21618. 14:48:52that time separately you can utilize but
  21619. 14:48:54here we want to utilize with the help of
  21620. 14:48:56this langraph okay that's why lang graph
  21621. 14:48:58connection is also there langraph SDK is
  21622. 14:49:00also there someone I think has created
  21623. 14:49:02this and published on the pi and we are
  21624. 14:49:04able to use this um package inside our
  21625. 14:49:07development okay if you check the
  21626. 14:49:10langraph documentation guys uh here in
  21627. 14:49:12the memory section as you can see add
  21628. 14:49:14short-term memory that means this is the
  21629. 14:49:16persistence memory as you can see
  21630. 14:49:17short-term memory
  21631. 14:49:18trade level persistence. Okay. So here
  21632. 14:49:20as of now we use this memory saber uh
  21633. 14:49:23database uh sorry memory saber actually
  21634. 14:49:26stories uh basically this stores your uh
  21635. 14:49:28conversation in the RAM and uh you can
  21636. 14:49:31see uh they are also suggesting for the
  21637. 14:49:33production. So for production use either
  21638. 14:49:35you can use postgrace
  21639. 14:49:37a postgrace it is also production grade
  21640. 14:49:40database and you can create a postgrace
  21641. 14:49:42server either you can create a local uh
  21642. 14:49:45server local host server either you can
  21643. 14:49:46create a cloud-based servers okay so um
  21644. 14:49:49any kinds of cloud you can set up this
  21645. 14:49:51postgrace either you can use um like
  21646. 14:49:53render either you can use uh AWS GCP
  21647. 14:49:57anywhere you can set up this uh uh
  21648. 14:49:59postgra server and you can connect with
  21649. 14:50:01your langraph okay this is possible so
  21650. 14:50:03uh That's how you can also use MongoDB.
  21651. 14:50:05Uh you can also connect with MongoDB.
  21652. 14:50:07You can also connect with radius. You
  21653. 14:50:09can also connect with Oracle. Okay,
  21654. 14:50:10that's how it is having different
  21655. 14:50:11different database connection. But
  21656. 14:50:13whenever we are creating prototype, uh I
  21657. 14:50:15think this SQL light is fine for us
  21658. 14:50:17because we can u set up inside our um
  21659. 14:50:20local storage only. Okay, I don't need
  21660. 14:50:22to take any kinds of separate server for
  21661. 14:50:24that. Okay, that's why I'm using this
  21662. 14:50:26SQLite. Uh so uh database doesn't
  21663. 14:50:29matter. You can use any kinds of
  21664. 14:50:30database. Uh anything will work. But
  21665. 14:50:32only you just need to know the um like
  21666. 14:50:35connection. Okay, integration how we can
  21667. 14:50:36integrate the database. Okay, right now
  21668. 14:50:38I'm integrating the SQLite. Maybe you
  21669. 14:50:41can also integrate any other database.
  21670. 14:50:43Only you just need to get this
  21671. 14:50:44connection string. Okay, let's see if
  21672. 14:50:46you're uh setting up this database in a
  21673. 14:50:48server. You just need to get this
  21674. 14:50:50connection string. Okay, if you get this
  21675. 14:50:51connection string, you can check the
  21676. 14:50:52documentation and you can copy this code
  21677. 14:50:54and you can change it any time. Okay,
  21678. 14:50:56it's up to you. So here the main change
  21679. 14:50:59guys I have to do in the back end file
  21680. 14:51:01because in the back end file I am using
  21681. 14:51:03this memory saber and instead of memory
  21682. 14:51:05saber I have to use my uh this one uh I
  21683. 14:51:09have to use my um um database. Okay so
  21684. 14:51:12for this uh I have to first of all
  21685. 14:51:14install this library uh where is that
  21686. 14:51:18uh yeah the install this library. So
  21687. 14:51:19I'll copy this command or I can copy the
  21688. 14:51:24name
  21689. 14:51:26and I will add inside my requirements.
  21690. 14:51:30Now let's install it here
  21691. 14:51:36install
  21692. 14:51:38at requirement.txt.
  21693. 14:51:41So for me it is already satisfied
  21694. 14:51:42because I installed it previously but
  21695. 14:51:44for you it may take some time. So once
  21696. 14:51:47installation is complete guys
  21697. 14:51:50uh I'll open up my
  21698. 14:51:53backend file and in the back end itself
  21699. 14:51:56I'll try to change that change that. So
  21700. 14:51:59here what I'm going to do um
  21701. 14:52:04I'm going to
  21702. 14:52:08um should I change in the same file or
  21703. 14:52:10should I create a new file. uh if I
  21704. 14:52:12change in the same file then you will be
  21705. 14:52:14able to uh you won't be able to get the
  21706. 14:52:16older code. So what I can do maybe I
  21707. 14:52:18can't um
  21708. 14:52:21I can create another file. Okay.
  21709. 14:52:26So I'll create a same file. I'll just
  21710. 14:52:28rename it aentic chatbot
  21711. 14:52:33um back end
  21712. 14:52:38here. I'll just try to add DB back end.
  21713. 14:52:43Okay, DB back end means uh it has the
  21714. 14:52:45database integration. Okay. Uh that's
  21715. 14:52:48how you will be able to see the previous
  21716. 14:52:49code as well. Okay. Yeah, I think this
  21717. 14:52:51is fine. Now here uh instead of this
  21718. 14:52:54memory saber, we have to import this uh
  21719. 14:52:57SQLite saber. So from lang graph
  21720. 14:53:00checkpoint here you have a uh class
  21721. 14:53:03called SQLite. Okay. And instead of
  21722. 14:53:07memory server, we have to import SQLite.
  21723. 14:53:10SQLite saber.
  21724. 14:53:15Okay, SQLite saber. So you have to
  21725. 14:53:17import that. So once it is done now,
  21726. 14:53:20I'll just go below and uh here you can
  21727. 14:53:22see I created a checkpoint object and I
  21728. 14:53:24use this memory saber. Instead of memory
  21729. 14:53:26saber, I will use my SQLite saber.
  21730. 14:53:30SQLite saber. Okay, this class. Now this
  21731. 14:53:34SQLite saber takes a connection object.
  21732. 14:53:36Now you have to initialize the
  21733. 14:53:37connection object. Database connection
  21734. 14:53:38object. Basically you will be connecting
  21735. 14:53:40with the SQLite uh database. So for this
  21736. 14:53:43uh you have to import this SQLite
  21737. 14:53:46library. import
  21738. 14:53:49SQLite 3. Okay. SQLite 3. So this is
  21739. 14:53:53already available inside Python. Then
  21740. 14:53:56after that here I will create a
  21741. 14:53:58connection object. So to create the
  21742. 14:54:00connection object guys uh you just need
  21743. 14:54:02to initialize this SQLite 3. Then there
  21744. 14:54:06is a function you have to call called
  21745. 14:54:08connect. Okay connect and inside that
  21746. 14:54:12you have to give a first parameter which
  21747. 14:54:15is database. You have to initialize the
  21748. 14:54:17database. Okay. So here basically this
  21749. 14:54:20SQLite creates the database object
  21750. 14:54:22inside your local storage only. That
  21751. 14:54:24means inside your project folder only it
  21752. 14:54:26will create a database. Okay. Uh it will
  21753. 14:54:27create a DB file. So you have to give
  21754. 14:54:29the DB file name. So here I'm going to
  21755. 14:54:31name this file as chatbot DB. Okay. And
  21756. 14:54:35uh here you have to give another
  21757. 14:54:37parameter which is check same trade is
  21758. 14:54:39equal to false. Okay. Why we have to
  21759. 14:54:40give this particular parameter? Because
  21760. 14:54:42I think you remember we are using the
  21761. 14:54:44trading concept, right? Tra uh chat
  21762. 14:54:46trading concept. So every time uh user
  21763. 14:54:50uh is creating separate trades and they
  21764. 14:54:52are doing the conversation and uh by
  21765. 14:54:54default actually scaleite doesn't
  21766. 14:54:56support uh actually multi-rading that
  21767. 14:54:58means you can't uh apply the trading uh
  21768. 14:55:01you can't create a different trades in
  21769. 14:55:03this Qite once you have created one
  21770. 14:55:05particular session you have to continue
  21771. 14:55:07uh the uh the same execution in that
  21772. 14:55:09particular session only okay by default
  21773. 14:55:11this parameter basically it's true right
  21774. 14:55:13but if you make it as false then SQLite
  21775. 14:55:15will try to give you the access for the
  21776. 14:55:17trading concept. That means you can do
  21777. 14:55:20the multiple trading chart. Okay, that
  21778. 14:55:22means you can store uh your checkpoint
  21779. 14:55:24in a multiple trades. Okay, this will uh
  21780. 14:55:26basically allow that particular option.
  21781. 14:55:28That's why we have given uh check uh
  21782. 14:55:30same trades is equal to false. Okay, I
  21783. 14:55:33hope you cleared. So this is basically
  21784. 14:55:34here you will be getting a connection
  21785. 14:55:36object. So I'm going to store inside a
  21786. 14:55:37variable. Let's say this is connection
  21787. 14:55:38object. Now this connection object you
  21788. 14:55:40have to pass inside this SQL lightsaber.
  21789. 14:55:43Okay, you have to pass inside this SQ
  21790. 14:55:44lightsaber. So once you have done that
  21791. 14:55:46uh now you will be getting the
  21792. 14:55:48checkpoint. Okay. Now this checkpoint is
  21793. 14:55:50not a simple checkpoint. It will not
  21794. 14:55:52store your conversation. It will not
  21795. 14:55:53store your checkpoint inside the RAM.
  21796. 14:55:56Okay. Instead of that it will save the
  21797. 14:55:57conversation or checkpoint inside a
  21798. 14:56:00storage service inside a database
  21799. 14:56:02storage which is chatbot DB. Although
  21800. 14:56:05this storage service will create inside
  21801. 14:56:06your uh computer storage only. But this
  21802. 14:56:10is not storing inside a RAM. Okay. it
  21803. 14:56:12will store as a file and we know that
  21804. 14:56:14unless and until we are not uh deleting
  21805. 14:56:16the file this file will be available
  21806. 14:56:17inside my computer. If I turn off my
  21807. 14:56:20computer as well this file will remain
  21808. 14:56:21same. Okay, this is the main benefit
  21809. 14:56:23here. So once we have done that guys uh
  21810. 14:56:25the same code you have to write here. Uh
  21811. 14:56:27no need to change anything. Now let me
  21812. 14:56:29show you whether it's working or not. So
  21813. 14:56:32here uh maybe I can test this file. So
  21814. 14:56:35for this let's do the invoke operation.
  21815. 14:56:38uh so here uh what I'm going to do guys
  21816. 14:56:40I'm going to just uh
  21817. 14:56:42do the invoke operation so response is
  21818. 14:56:45equal to yeah so I have uh written like
  21819. 14:56:48that so I just created a config because
  21820. 14:56:50you know that we're using persistence
  21821. 14:56:52memory and we have to pass the config
  21822. 14:56:53whenever we're doing the invoke
  21823. 14:56:54operation so here uh by default I have
  21824. 14:56:57taken this default rate I have just done
  21825. 14:56:59hard coding operation and we are
  21826. 14:57:02invoking and we're giving the message
  21827. 14:57:04hello how are you or let's say I'll just
  21828. 14:57:06give uh
  21829. 14:57:08my name is BP.
  21830. 14:57:12Okay. And we're passing the
  21831. 14:57:14configuration and this will give you the
  21832. 14:57:15response. We'll try to print that as
  21833. 14:57:17well. Okay. Now see if I execute what
  21834. 14:57:19will happen. Uh you'll be able to see
  21835. 14:57:21one chatbot. DB file would be created
  21836. 14:57:23here. So Python
  21837. 14:57:26um agentic chatbot
  21838. 14:57:29DB backend, right? DB backend.py. If I
  21839. 14:57:31execute,
  21840. 14:57:34see chatbot. DV has created and we are
  21841. 14:57:38getting the response as you can see I
  21842. 14:57:39given my name is BP and my AI message
  21843. 14:57:43that means my uh agent has replied hello
  21844. 14:57:45BP how I can assist you today and some
  21845. 14:57:48other let's say metadata informations we
  21846. 14:57:50are getting okay now you can see one uh
  21847. 14:57:52chatbot uh DB has created you can also
  21848. 14:57:56visualize that okay it is also possible
  21849. 14:57:58for this you have to install one
  21850. 14:57:59extension called SQite
  21851. 14:58:03viewer
  21852. 14:58:05SQLite VR. Okay, I have already
  21853. 14:58:07installed this uh extension inside my VS
  21854. 14:58:09code. Uh if you don't have just try to
  21855. 14:58:11uh install that and you can see this is
  21856. 14:58:13the um this is the publisher Florian uh
  21857. 14:58:16clam clamper. Uh make sure you install
  21858. 14:58:19the same version. Okay, once you have
  21859. 14:58:21done that uh you just need to double
  21860. 14:58:23click on this uh chatbot DB and you will
  21861. 14:58:26be able to see this
  21862. 14:58:29uh checkpoint. It has saved in the
  21863. 14:58:30memory as you can see uh sorry not
  21864. 14:58:32memory in the database as you can see.
  21865. 14:58:34Okay. Now you can see it has uh stored
  21866. 14:58:37my trade uh checkpoint and this is the
  21867. 14:58:39trade ID. Okay. We have given default
  21868. 14:58:41trade as you remember we have given uh
  21869. 14:58:43what is that chatbot back end. Okay. Not
  21870. 14:58:46this one. Yeah this one we have given
  21871. 14:58:48the default trade. Okay. Now you can see
  21872. 14:58:49default rate. Now you can ask me why
  21873. 14:58:51this uh three three time it is coming
  21874. 14:58:53because as per our workflow guys the
  21875. 14:58:56workflow we have created it has three
  21876. 14:58:58checkpoint uh uh one checkpoint at the
  21877. 14:59:00start uh start position uh second
  21878. 14:59:03checkpoint in the uh chat node position
  21879. 14:59:06and other one is the end position okay I
  21880. 14:59:08think I already told you about this
  21881. 14:59:09right uh in my uh this video uh
  21882. 14:59:12persistence video I already told you
  21883. 14:59:13about that right so please go through
  21884. 14:59:15the persistence video if you don't
  21885. 14:59:16understand the checkpointer concept like
  21886. 14:59:18how many checkpointer uh would be
  21887. 14:59:21available uh in which node it would be
  21888. 14:59:23available each and everything I have
  21889. 14:59:24discussed here. So here we are having uh
  21890. 14:59:26three layer okay three layer inside uh
  21891. 14:59:30this uh uh sorry three three node inside
  21892. 14:59:33our uh agentic chatbot that's why three
  21893. 14:59:36time this uh um checkpoint is getting
  21894. 14:59:38created and all of the checkpoint ID as
  21895. 14:59:41well as the checkpoint uh some meta
  21896. 14:59:44information is also available okay and
  21897. 14:59:46if you want to see the checkpoint guys
  21898. 14:59:47directly you can click here so if I
  21899. 14:59:49click here you'll be able to see the
  21900. 14:59:51data now this data uh it stores
  21901. 14:59:54basically in a binary format it's not
  21902. 14:59:56readable properly but I think some of
  21903. 14:59:58the message you can still able to
  21904. 15:00:00understand like my name is BP okay I
  21905. 15:00:02have given uh now let me show you
  21906. 15:00:04whether it is able to uh store my
  21907. 15:00:07checkpoint inside my database or not so
  21908. 15:00:10let's say if I re-execute my um back end
  21909. 15:00:14uh whether I will be able to see my old
  21910. 15:00:16uh old conversation or not let's say I
  21911. 15:00:18given my name is BP okay so this uh uh
  21912. 15:00:21this checkpoint would be available or
  21913. 15:00:23not okay so For this maybe I can just
  21914. 15:00:26give a separate name here. Let's say
  21915. 15:00:28Alex I will give. And uh what you can do
  21916. 15:00:31you can also change the trade ID if you
  21917. 15:00:32want. Let's say I will give default
  21918. 15:00:34trade one. Okay. Now if I reexecute my
  21919. 15:00:40back end.
  21920. 15:00:43Okay. Now if I open my database um I
  21921. 15:00:46have to refresh
  21922. 15:00:48this.
  21923. 15:00:50Okay. Now see another trade got created
  21924. 15:00:52and still my previous trade is available
  21925. 15:00:55here. Okay, previous trade is available
  21926. 15:00:57and in the response also you can see my
  21927. 15:01:00name is Alex and this is a separate
  21928. 15:01:02trade it is coming. Okay, so that's how
  21929. 15:01:04guys we have seen it is able to store my
  21930. 15:01:08checkpoints. It is able to store my
  21931. 15:01:11conversation inside my database. Okay,
  21932. 15:01:14amazing. Now uh this is ready. Now we
  21933. 15:01:17have to add uh we have to integrate this
  21934. 15:01:19thing inside our front end app. Uh
  21935. 15:01:21because right now we tested inside the
  21936. 15:01:23back end file only but I have to add
  21937. 15:01:25inside my front end. So what I'm going
  21938. 15:01:27to do guys I will open up my front end.
  21939. 15:01:29So this is the front end uh app trade or
  21940. 15:01:32maybe I can create another same file.
  21941. 15:01:35I'll just try to copy and paste
  21942. 15:01:39and I'll just rename it app
  21943. 15:01:43uh
  21944. 15:01:46DB.
  21945. 15:01:50Okay. So with the help of that you can
  21946. 15:01:52understand um like this is uh this is
  21947. 15:01:55actually database, this is trading, this
  21948. 15:01:57is simple app. Okay. You can understand.
  21949. 15:01:58So DB means this this has the uh
  21950. 15:02:01database uh actually update. Now see
  21951. 15:02:03here you don't need to change uh uh I
  21952. 15:02:05mean um uh in in all the code only just
  21953. 15:02:09change you have to do uh here in the
  21954. 15:02:11chat uh uh chat traits okay so whenever
  21955. 15:02:14I was uh actually creating this uh
  21956. 15:02:17session state in the uh streaml right
  21957. 15:02:20there I was uh using simple list only
  21958. 15:02:23okay and whenever you are using simple
  21959. 15:02:25list that time what is happening if I am
  21960. 15:02:27refreshing my application and it is
  21961. 15:02:30re-executing from the beginning and this
  21962. 15:02:32particular ular uh list is getting
  21963. 15:02:34created again and all of the data we had
  21964. 15:02:37inside the list it was getting erased.
  21965. 15:02:39Okay, this is this was the problem. So
  21966. 15:02:41instead of uh taking this uh simple list
  21967. 15:02:44here. So here I have to uh connect my
  21968. 15:02:48database. Connect my database means in
  21969. 15:02:50the back end I am already storing my
  21970. 15:02:53checkpoint inside my database inside my
  21971. 15:02:55SQLite database. So what I'm going to do
  21972. 15:02:58uh instead of uh instead of actually uh
  21973. 15:03:01u instead of actually giving a simple
  21974. 15:03:03list here I'll try to load my uh all of
  21975. 15:03:06the trades okay from my database only
  21976. 15:03:09and I will just try to provide a list
  21977. 15:03:11here. Okay. So for this uh in my backend
  21978. 15:03:14code I'll just try to do a simple uh
  21979. 15:03:17simple modification. I'll remove this
  21980. 15:03:20code. It's not required. So here I'll
  21981. 15:03:22just do a simple modification.
  21982. 15:03:25Uh let me show you the modification.
  21983. 15:03:28Yeah. So here I'll just try to write a
  21984. 15:03:30function here.
  21985. 15:03:33I'm going to name it as uh get
  21986. 15:03:38uh all trades.
  21987. 15:03:43Okay. Get all trades.
  21988. 15:03:48So here uh I'll just try to um first of
  21989. 15:03:51all show you this one.
  21990. 15:03:53uh see uh first of all I will write a
  21991. 15:03:56script then I'll just try to convert to
  21992. 15:03:58a function otherwise I think you might
  21993. 15:03:59get some difficulties so here uh first
  21994. 15:04:02of all I'll write my checkpoint
  21995. 15:04:08h checkpoint now in see checkpoint
  21996. 15:04:11object is nothing but it's a database
  21997. 15:04:13object right now we are using SQL
  21998. 15:04:14lightsaber so it has a function the
  21999. 15:04:17function name is list okay list so if
  22000. 15:04:19you give uh give this function call this
  22001. 15:04:21function list And uh if you execute so
  22002. 15:04:24what will happen basically it will
  22003. 15:04:26return you uh how many trades right now
  22004. 15:04:28you are having inside the database but
  22005. 15:04:31inside this list param uh list function
  22006. 15:04:34you have to provide a parameter either
  22007. 15:04:36you can tell okay I need uh I need let's
  22008. 15:04:38say information about my default trades
  22009. 15:04:40one so you have to give this name here
  22010. 15:04:42okay you have to give this name here why
  22011. 15:04:44is that uh here you have to give this
  22012. 15:04:47name here you can give the trade name
  22013. 15:04:49here but I don't want to give the trade
  22014. 15:04:51name any specific trade trade name I
  22015. 15:04:52want to get all of the trade right for
  22016. 15:04:54this you have to provide none here so
  22017. 15:04:56basically we're telling I don't need any
  22018. 15:04:58specific trade I need all of the trade
  22019. 15:05:00informations okay now see this will
  22020. 15:05:02return you uh this will return you the
  22021. 15:05:04trades
  22022. 15:05:08trades okay
  22023. 15:05:11uh I'll give equal sign now if I print
  22024. 15:05:14that
  22025. 15:05:19okay okay print that print all of my
  22026. 15:05:21trades
  22027. 15:05:23Now let's execute this file again.
  22028. 15:05:28Okay. So this is uh giving you a
  22029. 15:05:30generator object and you know that if
  22030. 15:05:32you're getting a generator object so
  22031. 15:05:33what you can do you can run a for loop
  22032. 15:05:35on top of that. So for uh checkpoint
  22033. 15:05:42in checkpoint
  22034. 15:05:45or let's say trade
  22035. 15:05:52or let's say I'll just write right trade
  22036. 15:05:56in trades. Okay.
  22037. 15:05:59uh once you have done that or you can
  22038. 15:06:01directly write uh uh write like that
  22039. 15:06:03let's say instead of writing two line I
  22040. 15:06:06can directly run a for loop for
  22041. 15:06:13for checkpoint in checkpointer
  22042. 15:06:16I think this is also checkpoint right
  22043. 15:06:20yeah checkpoint in checkpoint list okay
  22044. 15:06:24then after that um
  22045. 15:06:27uh what I'm going to do I'm going to
  22046. 15:06:28just uh print my checkpoint
  22047. 15:06:40both name is same. Okay. So what I can
  22048. 15:06:42do I can maybe
  22049. 15:06:45write like that security. Okay. That
  22050. 15:06:47means checkpoint.
  22051. 15:06:50Now if I
  22052. 15:06:53reexecute
  22053. 15:06:55now see guys uh here we are getting all
  22054. 15:06:57of the trade right now it is available
  22055. 15:06:58inside my uh inside my
  22056. 15:07:02database as you can see and uh here we
  22057. 15:07:05are getting lots of trades because if I
  22058. 15:07:06open my chatbot we are getting uh six
  22059. 15:07:09trades right now and why six six trades
  22060. 15:07:11because every time if you execute the um
  22061. 15:07:14execute the graph it will generate three
  22062. 15:07:16three checkpoint why I told you because
  22063. 15:07:19our uh How would actually workflow
  22064. 15:07:21having three checkpoints? So in every
  22065. 15:07:23conversation, every execution three
  22066. 15:07:25checkpoint would be available. Okay,
  22067. 15:07:27three checkpoint would be available. So
  22068. 15:07:28this was the first trade and this was
  22069. 15:07:30the second trade. We executed two times
  22070. 15:07:31that six six times is available. Okay,
  22071. 15:07:33so all of the six trades you are getting
  22072. 15:07:35here. Okay, but uh here I uh whenever I
  22073. 15:07:39will extract that so this would be a
  22074. 15:07:41kinds of duplicates to us. I I will only
  22075. 15:07:45track the unique trades here. Okay,
  22076. 15:07:46let's say here I how many unique trades
  22077. 15:07:48I'm having. uh default trade one and
  22078. 15:07:50default trade only two units okay
  22079. 15:07:52otherwise everything is repetitive one
  22080. 15:07:53so I'll also try to handle this part as
  22081. 15:07:55well so once we are getting all of these
  22082. 15:07:58uh this uh this actually checkpoints now
  22083. 15:08:01uh from the checkpoint only I only need
  22084. 15:08:03this um
  22085. 15:08:05config
  22086. 15:08:08config
  22087. 15:08:11now if I reexecute my terminal
  22088. 15:08:16now I'm getting the config only okay now
  22089. 15:08:18from the config I I need this trade ID
  22090. 15:08:20only. First of all, I need to go to the
  22091. 15:08:22configurable.
  22092. 15:08:24So this is a uh this is actually
  22093. 15:08:26dictionary right dictionary. So I will
  22094. 15:08:28give the key
  22095. 15:08:32configurable.
  22096. 15:08:36Now again we are getting another
  22097. 15:08:37dictionary and here we have the trade
  22098. 15:08:39ID. So I only need to extract the trade
  22099. 15:08:40ID.
  22100. 15:08:48Now see I'm getting all of the trade but
  22101. 15:08:51uh I'm getting repetitive trades. Okay,
  22102. 15:08:53same uh same actually name again and
  22103. 15:08:55again but I only need the unique one. So
  22104. 15:08:57for this I think you know um set right?
  22105. 15:09:00Set inside Python. So what what set does
  22106. 15:09:03sets basically um will give you the
  22107. 15:09:06unique uh unique actually name. So here
  22108. 15:09:09I'll take a set. I'll just try to create
  22109. 15:09:12empty sets and I'm going to name it as
  22110. 15:09:15all trades.
  22111. 15:09:17Okay. And whenever I'm getting my
  22112. 15:09:20trades, I'll just try to add inside my
  22113. 15:09:22trades.
  22114. 15:09:25Sorry. Uh I'm going to add inside my
  22115. 15:09:30um set.
  22116. 15:09:33So there is a add function we can use
  22117. 15:09:34for this. H
  22118. 15:09:38then uh I'll just try to print my
  22119. 15:09:42alls right now.
  22120. 15:09:47Now if I execute
  22121. 15:09:51now see I'm only getting trade one and
  22122. 15:09:54my trades. Okay. Uh that means the
  22123. 15:09:56unique one. Now I have to provide as a
  22124. 15:09:59list. Okay. I have to uh give as a list
  22125. 15:10:02here because here um uh the session
  22126. 15:10:04state we created it it it takes a list
  22127. 15:10:07right but here I'm getting a dictionary.
  22128. 15:10:09As you can see here I'm getting a
  22129. 15:10:10dictionary. I'm uh returning as a
  22130. 15:10:12dictionary. So what I can do I can
  22131. 15:10:13convert it to the list. So instead of uh
  22132. 15:10:17printing um this I will just try do the
  22133. 15:10:20type type conversion operation
  22134. 15:10:24just try to convert to the list. Now if
  22135. 15:10:27I execute
  22136. 15:10:29now see it is a list right now. Okay.
  22137. 15:10:32Now simply I'll just I'll just try to
  22138. 15:10:34write inside a function. So I'm going to
  22139. 15:10:37uh name this function as def get
  22140. 15:10:42all traits.
  22141. 15:10:44Okay. And all of the code I'm going to
  22142. 15:10:46write inside that.
  22143. 15:10:52Okay. Instead of printing, I'll just uh
  22144. 15:10:54do the return operation.
  22145. 15:11:00So everything is fine. Now this function
  22146. 15:11:03basically will return you uh all the
  22147. 15:11:05threads okay from the database itself.
  22148. 15:11:08So now uh here uh in the app DB
  22149. 15:11:13whenever you are importing this chatbot
  22150. 15:11:14right uh so right now we have to import
  22151. 15:11:17from the agentic chatbot DB back end.
  22152. 15:11:19Okay instead of the simple uh aentic
  22153. 15:11:23chatbot back end because we are using DB
  22154. 15:11:25DB back end right now we have to import
  22155. 15:11:27chatbot as well as the get all trades.
  22156. 15:11:31Okay, this function we have to import.
  22157. 15:11:33Now, simply you just need to call this
  22158. 15:11:36function here. Whenever you are uh
  22159. 15:11:39initializing this uh chat threads,
  22160. 15:11:41instead of giving the simple uh list
  22161. 15:11:43empty list, you will give this function
  22162. 15:11:46name. Okay. So, what this function will
  22163. 15:11:47do, it will get all of the trades and it
  22164. 15:11:50will store in line inside my chat
  22165. 15:11:51threads. Okay. So, this particular um
  22166. 15:11:54code is uh sorry, this particular uh
  22167. 15:11:56data is coming from my back end from my
  22168. 15:11:59database. Okay, that's how. So if you
  22169. 15:12:01restart your application as well, it
  22170. 15:12:03will not uh effect on my app because
  22171. 15:12:06every time this function is getting
  22172. 15:12:08executed from my back end and it has the
  22173. 15:12:10connection with my checkpointer and
  22174. 15:12:12checkpointer is connected with my
  22175. 15:12:14database, right? Chatbot db. So every
  22176. 15:12:16time it will open the chatbot db and it
  22177. 15:12:18will get how many trades you are having
  22178. 15:12:20only this part will return here. Okay,
  22179. 15:12:22this part will return here and after
  22180. 15:12:24that we are just passing it here. That
  22181. 15:12:25means if I'm refreshing my page, if I'm
  22182. 15:12:28closing the application, it doesn't
  22183. 15:12:29matter. Every time I'm extracting my
  22184. 15:12:31trades, I'm getting my trades, I'm
  22185. 15:12:32facing my trades from my database only.
  22186. 15:12:34But previously, I was doing inside my
  22187. 15:12:36memory because I was using simple list.
  22188. 15:12:39And simple list only creates the
  22189. 15:12:40instance inside the RAM. Okay. And if
  22190. 15:12:43you refresh your RAM would be getting
  22191. 15:12:45cleared. I hope you got the concept
  22192. 15:12:47guys. Okay. Now let's try to execute and
  22193. 15:12:49see whether it's working or not. So here
  22194. 15:12:51I'll open up my terminal.
  22195. 15:12:53Clear. Then I'll just try to run my app.
  22196. 15:12:56So streaml
  22197. 15:12:59run
  22198. 15:13:00app
  22199. 15:13:02db.py.
  22200. 15:13:07Now see guys uh you you can already see
  22201. 15:13:10uh I already created some trades right
  22202. 15:13:13here. Uh manually I created some trades
  22203. 15:13:15and these trades is also getting uh load
  22204. 15:13:18here. You can see I did some
  22205. 15:13:19conversation like Alex then my name is
  22206. 15:13:21BP and this is the current trade right
  22207. 15:13:24now. So what I can do maybe I can delete
  22208. 15:13:25my database and do start a new
  22209. 15:13:27conversation. I'll just try to delete
  22210. 15:13:30it.
  22211. 15:13:32Okay, it will not getting delete because
  22212. 15:13:34it is running in the app right now. I
  22213. 15:13:36can try
  22214. 15:13:41delete
  22215. 15:13:45some temporary file also came. I'll just
  22216. 15:13:47try to delete. Okay, now I'll freshly
  22217. 15:13:49execute my app.
  22218. 15:13:54H. Now let's do the conversation.
  22219. 15:13:57Hi, my name is By
  22220. 15:14:05a
  22221. 15:14:06teacher.
  22222. 15:14:11Okay, great. Now I'll create a new chat.
  22223. 15:14:15I'll tell, hi, my name is
  22224. 15:14:19Alex.
  22225. 15:14:21I am a learner.
  22226. 15:14:30Okay, done. Now if I uh click my
  22227. 15:14:32previous uh conversation, now you can
  22228. 15:14:34see this is my previous conversation and
  22229. 15:14:35this is my current conversation. Now the
  22230. 15:14:37best part is that if I refresh my app,
  22231. 15:14:39right? See, still this conversation
  22232. 15:14:42remains same. Okay. Now if you also
  22233. 15:14:44close your app, let's say I will close
  22234. 15:14:45my app from my terminal. See it's
  22235. 15:14:47closed. Okay. And I closed my
  22236. 15:14:49application. Okay. Okay, I close my
  22237. 15:14:50application. Now if I restart my
  22238. 15:14:52application, see if I restart my
  22239. 15:14:54application. Now, still it will be able
  22240. 15:14:56to load my previous conversation. And
  22241. 15:14:59anytime I can continue the conversation,
  22242. 15:15:01let's say here, I'll just try to
  22243. 15:15:03continue the conversation. Who am I?
  22244. 15:15:10See, it is uh giving you you are Alex, a
  22245. 15:15:13learner who is seeking knowledge and
  22246. 15:15:14growth blah blah blah. Okay. Now I can
  22247. 15:15:16also do the conversation here only. Who
  22248. 15:15:21am I?
  22249. 15:15:24See, you are BYP, you are a teacher, you
  22250. 15:15:26are you enjoy helping students learn and
  22251. 15:15:28grow in their knowledge and skills.
  22252. 15:15:30Okay. So yes guys uh that's how actually
  22253. 15:15:33we can add the permanent persistence
  22254. 15:15:35memory uh right now inside our agentic
  22255. 15:15:38chatbot and now this is like more
  22256. 15:15:40powerful uh actually it will not erase
  22257. 15:15:43your conversation. It will not erase
  22258. 15:15:44your checkpoint if you restart your
  22259. 15:15:46application like chat GP like if I open
  22260. 15:15:48my chat GPT right anytime and I can
  22261. 15:15:51anytime I can see my previous chat
  22262. 15:15:53previous trades as well okay if I close
  22263. 15:15:56the app also if I turn off my computer
  22264. 15:15:57also if I disconnect my internet
  22265. 15:15:59connection also still these are the
  22266. 15:16:01things would be common these are the
  22267. 15:16:03things would be available because
  22268. 15:16:04they're using p permanent persistence
  22269. 15:16:06memory okay they're using some kinds of
  22270. 15:16:08database whether they're using postgrace
  22271. 15:16:11whether they're using MongoDB doesn't
  22272. 15:16:13matter But they're using some kinds of
  22273. 15:16:14database because of that this thing is
  22274. 15:16:16permanent like our application. Okay, I
  22275. 15:16:19hope you are getting it guys. Okay. So
  22276. 15:16:21yes guys, that's how we can uh slowly
  22277. 15:16:23slowly make this particular chatbot more
  22278. 15:16:26advanced and uh in my next video uh I'm
  22279. 15:16:30going to show you some more uh advanced
  22280. 15:16:32features guys. Uh we uh will be adding
  22281. 15:16:34inside this aentic chatbot and we'll try
  22282. 15:16:36to make it more powerful. Okay. And for
  22283. 15:16:39this guys please try to complete all of
  22284. 15:16:41this video uh if you want to uh uh
  22285. 15:16:43implement this kinds of project because
  22286. 15:16:45going forward I have lots of plan I will
  22287. 15:16:47be bringing lots of project here. Okay.
  22288. 15:16:50So for this definitely you have to
  22289. 15:16:51understand all of this concept. Okay. So
  22290. 15:16:53yes guys this is all about from this
  22291. 15:16:55video. I hope you liked it and you have
  22292. 15:16:57understood the entire implementation. If
  22293. 15:16:59you found my content useful please try
  22294. 15:17:01to subscribe to my channel, hit the like
  22295. 15:17:03and please share it with your friends
  22296. 15:17:04and family. And all of the code I will
  22297. 15:17:06share in my description from there you
  22298. 15:17:07can download. So guys in this video
  22299. 15:17:09we'll be learning one very important and
  22300. 15:17:12interesting concept uh called
  22301. 15:17:14observability.
  22302. 15:17:15So I think you have already heard of
  22303. 15:17:17these kinds of word like observability
  22304. 15:17:20monitoring tracing okay of agentic
  22305. 15:17:22application or any kinds of GNI powered
  22306. 15:17:25application. See we use this
  22307. 15:17:27observability monitoring tracing not
  22308. 15:17:29only in agentic application uh but also
  22309. 15:17:32we use this kinds of concept in any
  22310. 15:17:35kinds of LM powered application. So
  22311. 15:17:37whenever you are implementing any kinds
  22312. 15:17:39of LLM powered application with the help
  22313. 15:17:40of lang chain or lang graph or any kinds
  22314. 15:17:44of framework this observability
  22315. 15:17:46monitoring tracing is super important
  22316. 15:17:48there okay without that you can't
  22317. 15:17:51actually debug monitor and evaluate your
  22318. 15:17:53application this is not possible so for
  22319. 15:17:56this observability guys we can use one
  22320. 15:18:00uh very interesting and powerful tool
  22321. 15:18:02called lang okay so what is this
  22322. 15:18:05langismith langismith is a uh
  22323. 15:18:07observability monitoring uh tool uh it
  22324. 15:18:10is created by langin and uh with the
  22325. 15:18:12help of that actually we can monitor any
  22326. 15:18:14kinds of lm powered application whether
  22327. 15:18:16it's agenti whether it's any kinds of
  22328. 15:18:18rack system okay any kinds of
  22329. 15:18:20application we can monitor here real
  22330. 15:18:23time we can monitor here okay so first
  22331. 15:18:25of all let me give you the idea what is
  22332. 15:18:27this langismith is and why it is
  22333. 15:18:29required then um we'll try to see the
  22334. 15:18:31practical demo how we can observe how we
  22335. 15:18:34can monitor our entire agentic chatbot
  22336. 15:18:36with the help of this languid. Okay,
  22337. 15:18:38each and every integration [snorts] I'm
  22338. 15:18:40going to show you guys and trust me guys
  22339. 15:18:42uh if you learn this concept I think uh
  22340. 15:18:45uh it would be very helpful for you
  22341. 15:18:47whenever you are creating production
  22342. 15:18:48grade uh uh agent application because in
  22343. 15:18:52productions uh whenever you are creating
  22344. 15:18:54this kinds of system there would be lots
  22345. 15:18:55of bugs there would be lots of issues
  22346. 15:18:58and uh you can trace everything in a
  22347. 15:19:01single platform with the help of this
  22348. 15:19:02lang this is super important guys so as
  22349. 15:19:05you can see guys uh langismith is a
  22350. 15:19:06debugging monitoring and uh evaluation
  22351. 15:19:09platform for application uh builts with
  22352. 15:19:12LLM and AI agents. It is made by
  22353. 15:19:15Langchen team but it can also work with
  22354. 15:19:18application that do not use langen.
  22355. 15:19:20Okay. So I already told you this
  22356. 15:19:22langismith is uh let's say it is
  22357. 15:19:24developed by Langchen but if you are not
  22358. 15:19:26using any uh lang let's say framework
  22359. 15:19:28inside your application development
  22360. 15:19:30still you can use this lang with other
  22361. 15:19:32framework integration as well. Okay it
  22362. 15:19:34has all kinds of integration. So let's
  22363. 15:19:36try to understand why this is useful. So
  22364. 15:19:39whenever uh you are creating any kinds
  22365. 15:19:41of chatbot or any kinds of let's say
  22366. 15:19:43agentic powered application or any kinds
  22367. 15:19:46of LM powered application there you
  22368. 15:19:48perform some kinds of step some kinds of
  22369. 15:19:50operation right let's say user can sends
  22370. 15:19:53the questions then in between you can um
  22371. 15:19:56construct the prompt then you can
  22372. 15:19:58perform the LM call if you're
  22373. 15:19:59implementing any kinds of agents that
  22374. 15:20:01will use any kinds of tool or database
  22375. 15:20:03okay then it can also use memory and
  22376. 15:20:05checkpointer for the retriever then it
  22377. 15:20:07can give you the final responses. So
  22378. 15:20:09that means in between there are some
  22379. 15:20:11hidden operations are happening but this
  22380. 15:20:13is not visible to you. Okay. If you're
  22381. 15:20:15writing only the code if you're not
  22382. 15:20:18monitoring the entire uh if you're not
  22383. 15:20:20let's say tracing the entire application
  22384. 15:20:22this part is invisible to you.
  22385. 15:20:25Okay. So that's why you can see lang is
  22386. 15:20:28a debugging monitoring and evaluation
  22387. 15:20:29platform for application building built
  22388. 15:20:32with large language model or AI agents.
  22389. 15:20:34Okay. because inside all of this
  22390. 15:20:36application this hidden operation
  22391. 15:20:38happens. Okay, this hidden operation
  22392. 15:20:40happens. So if you're using Langismith
  22393. 15:20:42so what will happen? Um Langismith uh
  22394. 15:20:46records this complete execution as a
  22395. 15:20:48trace. That means whatever execution you
  22396. 15:20:50are doing here. Okay, Langismith records
  22397. 15:20:53this complete execution as a trace.
  22398. 15:20:55Okay, it will u u record all of the
  22399. 15:20:57execution as a trace allowing you to
  22400. 15:20:59inspect every step including inputs,
  22401. 15:21:02outputs, error, execution time, token
  22402. 15:21:04uses, tool calls and model behavior.
  22403. 15:21:06Okay, this is super important guys. Uh I
  22404. 15:21:08think by the definition itself you can
  22405. 15:21:10understand whatever hidden operation you
  22406. 15:21:12are executing okay whatever things are
  22407. 15:21:14happening in between everything l speed
  22408. 15:21:17can record as a trace okay in that
  22409. 15:21:19platform itself okay so that anytime you
  22410. 15:21:22can see the input output errors
  22411. 15:21:24execution time token uses tool call
  22412. 15:21:26model behavior each and everything
  22413. 15:21:28should be visible to you in a single
  22414. 15:21:29platform okay now as you can see for
  22415. 15:21:32your langraph agentic chatbot langismith
  22416. 15:21:35can help you that means the application
  22417. 15:21:36we are developing right now. So here uh
  22418. 15:21:39this langismith
  22419. 15:21:41can help us for uh finding why an agent
  22420. 15:21:44selected the wrong tool. Let's say uh
  22421. 15:21:47you are running your agents and it has
  22422. 15:21:49selected a wrong tool. It is giving you
  22423. 15:21:51some kinds of other responses but you
  22424. 15:21:53don't know why okay why it is uh giving
  22425. 15:21:55you this kinds of output why it is
  22426. 15:21:57selecting the wrong tool. If you want to
  22427. 15:21:59see the step-by-step execution like
  22428. 15:22:01after user query prompt construction lm
  22429. 15:22:03call which tool it has selected okay
  22430. 15:22:05based on the prompt or lm call. Okay, if
  22431. 15:22:07you want to understand these things, you
  22432. 15:22:09have to first of all monitor, trace your
  22433. 15:22:11entire application. Okay, monitoring is
  22434. 15:22:13important. Any kinds of application
  22435. 15:22:14whether creating MLDDL, CB, whatever
  22436. 15:22:17project you are creating, monitoring,
  22437. 15:22:19monitoring is super important. If you
  22438. 15:22:20cannot monitor your application, that
  22439. 15:22:23means in production you will be finding
  22440. 15:22:24difficulties for sure. Okay, that's why
  22441. 15:22:26application monitoring is super
  22442. 15:22:28important and for this Langmith is a
  22443. 15:22:30very powerful tools we'll be using.
  22444. 15:22:32Okay. So that's why find uh why an agent
  22445. 15:22:36selected the wrong tool. Uh we can
  22446. 15:22:37easily understand with the help of
  22447. 15:22:39Langismith. Then inspect the exact
  22448. 15:22:41prompt sent to the uh model. That means
  22449. 15:22:44uh you can see like whether this palm
  22450. 15:22:46con prompt construction is happening in
  22451. 15:22:48a good way or not. That prompt you are
  22452. 15:22:50constructing um whether it is right or
  22453. 15:22:52not. It is going to the LM or not. Okay.
  22454. 15:22:54Each and everything you can inspect
  22455. 15:22:56here. Then debug failed nodes in a
  22456. 15:22:58langraph workflow. That means if any of
  22457. 15:23:00the nodes uh let's say failed during the
  22458. 15:23:03execution you can easily monitor inside
  22459. 15:23:05the langismith dashboard. Then measures
  22460. 15:23:08responses latency and token cost. So
  22461. 15:23:10that means if u some of the model is
  22462. 15:23:13taking much time you can uh see like how
  22463. 15:23:16much time it is taking why it is taking
  22464. 15:23:18the time and how much token token
  22465. 15:23:20actually it is uh spending okay to give
  22466. 15:23:23you the response each and everything you
  22467. 15:23:24can monitor. Then review conversations
  22468. 15:23:26and multi-trren trades. That means you
  22469. 15:23:29can uh review the construction uh sorry
  22470. 15:23:31conversation uh review conversation and
  22471. 15:23:33multi uh trend trades. That means you
  22472. 15:23:35can see the entire conversation even you
  22473. 15:23:38can see the trades conversation. Trade
  22474. 15:23:40conversation means I think you know we
  22475. 15:23:41have integrated the trades inside our
  22476. 15:23:43aentic chatbot. Now user can create
  22477. 15:23:45different different trades. User can
  22478. 15:23:47create different different charts right.
  22479. 15:23:49So you can see the trades as well. Not
  22480. 15:23:51only the single conversation, you can
  22481. 15:23:53also see the trades wise. Okay, this is
  22482. 15:23:55also possible. I will also show you this
  22483. 15:23:56part. Then compare different prompts or
  22484. 15:23:59model versions. You can also compare
  22485. 15:24:01different prompts or model versions.
  22486. 15:24:03Then you can evaluate chatbot uh quality
  22487. 15:24:06before and after the deployment. Okay,
  22488. 15:24:08that means all of these uh things you
  22489. 15:24:11will be getting u inside this lang and
  22490. 15:24:14it will help you uh for this kinds of
  22491. 15:24:17work. Okay, if you are using this uh
  22492. 15:24:18this inside your application
  22493. 15:24:20development. So I think um apart from
  22494. 15:24:22this there is nothing uh you can monitor
  22495. 15:24:24inside your application. If you can
  22496. 15:24:26monitor these are the thing I think u
  22497. 15:24:28your uh application should be production
  22498. 15:24:30ready and you won't be having any kinds
  22499. 15:24:32of problem okay going forward. So now
  22500. 15:24:34we'll try to see guys this language
  22501. 15:24:36speed in practical that means the
  22502. 15:24:38application we have created uh this code
  22503. 15:24:40is already available in my description
  22504. 15:24:41from there you can get uh get the code
  22505. 15:24:43guys I think you remember we created a
  22506. 15:24:45uh agentic uh chatbot okay and uh in my
  22507. 15:24:49last video I showed you how we can
  22508. 15:24:50integrate database features okay so that
  22509. 15:24:52it can uh it can have the permanent
  22510. 15:24:54persistence memory okay so first of all
  22511. 15:24:56let me show you the application guys we
  22512. 15:24:58have developed so guys uh this is our
  22513. 15:25:00agentic chatbot we have developed so far
  22514. 15:25:02and uh we can perform any kinds of chat
  22515. 15:25:05operation. Let's say if I give a prompt
  22516. 15:25:07uh give me a
  22517. 15:25:10road map to learn okay ML.
  22518. 15:25:19So see this is giving you the detailed
  22519. 15:25:21road map and uh you can see the previous
  22520. 15:25:24trades as well. You can also continue
  22521. 15:25:26the conversation with the previous
  22522. 15:25:27trades you had here and this is your
  22523. 15:25:29current trades. Okay. And if you refresh
  22524. 15:25:30your application still this uh uh
  22525. 15:25:33previous conversation will remain same
  22526. 15:25:35because we have added the permanent
  22527. 15:25:37memory here with the help of database.
  22528. 15:25:38Okay. So in this particular video I
  22529. 15:25:40already explained this concept. If you
  22530. 15:25:42haven't checked that guys please try to
  22531. 15:25:43go through this recording. So see guys
  22532. 15:25:45uh here we have performed a
  22533. 15:25:47conversation. It's completely fine. But
  22534. 15:25:49uh this application doesn't have any
  22535. 15:25:51kinds of observability or monitoring uh
  22536. 15:25:54connection. Okay. So I can't monitor
  22537. 15:25:56this application like in the back end.
  22538. 15:25:58What is happening? Let's say uh if I
  22539. 15:26:00deploy this application in production
  22540. 15:26:02server so I don't have any kinds of
  22541. 15:26:05platform there I can continuously
  22542. 15:26:06monitor my application what is happening
  22543. 15:26:09how much token it is uh taking okay or
  22544. 15:26:11let's say any of the nodes is giving you
  22545. 15:26:13any kinds of errors so I can't see these
  22546. 15:26:15kinds of let's say uh issues right so
  22547. 15:26:18for this we can utilize this langismith
  22548. 15:26:21platform so you have to visit uh
  22549. 15:26:23smith.langchen.com langchen.com. So if
  22550. 15:26:25you visit this website guys, this is the
  22551. 15:26:27langid platform. So first of all here
  22552. 15:26:29what you have to do, you have to create
  22553. 15:26:31an account. Okay. So here you just need
  22554. 15:26:33to create an account guys. You can use
  22555. 15:26:35your Google, GitHub, discord, anything
  22556. 15:26:36you can uh use and you can create an
  22557. 15:26:38account. So I already have an account
  22558. 15:26:40guys. I will just try to login.
  22559. 15:26:46So once you log guys, you will be able
  22560. 15:26:48to see this kinds of dashboard. So this
  22561. 15:26:49is your language dashboard. And
  22562. 15:26:51previously I uh already created some of
  22563. 15:26:54the project here. I already uh traced
  22564. 15:26:56some of my project that's why it's
  22565. 15:26:57coming here. But if you are using for
  22566. 15:27:00the first time, you won't be able to see
  22567. 15:27:01this kinds of uh like project name here
  22568. 15:27:03or tracing name here. Okay. So first of
  22569. 15:27:06all guys, if you want to use this uh
  22570. 15:27:07langismith inside your uh application,
  22571. 15:27:10you just need to collect a API key.
  22572. 15:27:12Okay. And this is super easy to use. You
  22573. 15:27:15don't need to write uh like uh any kinds
  22574. 15:27:17of code if you want to use this lang
  22575. 15:27:19guys. Only you just need to add some of
  22576. 15:27:22the environment variables and
  22577. 15:27:24automatically this langismith will start
  22578. 15:27:26tracing your application. Okay, I'll
  22579. 15:27:28show you this part. So if you want to
  22580. 15:27:30get the u um API key, so what you have
  22581. 15:27:33to do, you just need to uh go to the API
  22582. 15:27:35section. So I think API is available in
  22583. 15:27:38the settings and uh here is the API key
  22584. 15:27:40guys. Okay. Now previously I already
  22585. 15:27:42created some API key. What I will do? I
  22586. 15:27:43just try to remove some of the API key
  22587. 15:27:45so that I can create a new one.
  22588. 15:27:49H So I'll create a new API key. So you
  22589. 15:27:52can give the name. So let's say I'll
  22590. 15:27:54give the name of u
  22591. 15:27:57uh agentic
  22592. 15:28:01chatbot.
  22593. 15:28:05So everything just keep it as it as it
  22594. 15:28:07is. Okay. Don't need to change anything.
  22595. 15:28:09Now just create the API key.
  22596. 15:28:11So once you have created the API key
  22597. 15:28:13just try to copy and you have to add
  22598. 15:28:16this API key in the environment
  22599. 15:28:18variable. Okay. So let's say this is our
  22600. 15:28:20app. Uh so this application we have
  22601. 15:28:22created guys. This is the code I think
  22602. 15:28:23you remember in my previous uh video
  22603. 15:28:26previous part. So now you just need to
  22604. 15:28:28open this env file.
  22605. 15:28:30Um after that here you have to add uh
  22606. 15:28:34some of the environment variable. Let me
  22607. 15:28:36show you. So these things you have to
  22608. 15:28:39add here. Yeah. So see these things will
  22609. 15:28:43common for all the project you will be
  22610. 15:28:44creating going forward. Only you just
  22611. 15:28:46need to change the project name. So see
  22612. 15:28:48first of all you have to provide languid
  22613. 15:28:50tracing
  22614. 15:28:52uh this parameter is equal to true. Okay
  22615. 15:28:53that means you are uh allowing your as
  22616. 15:28:56uh allowing your langis to trace your
  22617. 15:28:58entire application. Whenever you are
  22618. 15:29:00executing your application lang will
  22619. 15:29:02automatically start tracing your
  22620. 15:29:04application. It will automatically start
  22621. 15:29:06monitoring your application. That's why
  22622. 15:29:07this parameter you have to give as true.
  22623. 15:29:09Then you are telling what should be the
  22624. 15:29:11endpoint that means after tracing it the
  22625. 15:29:14data it will get okay the let's say
  22626. 15:29:17information it will get where it will
  22627. 15:29:19save those information okay it needs an
  22628. 15:29:21endpoint so endpoint is langismith
  22629. 15:29:24platform I'm giving you have to save
  22630. 15:29:26everything in the langismith platform
  22631. 15:29:27that means inside this particular
  22632. 15:29:29platform this is the dashboard right so
  22633. 15:29:31this is what actually we're doing then
  22634. 15:29:32you have to pass the API key now to
  22635. 15:29:35authenticate with your dashboard you
  22636. 15:29:36need a API key so what I will do I'll
  22637. 15:29:38just copy this API
  22638. 15:29:39And here you have to provide the API key
  22639. 15:29:41and make sure you don't share this API
  22640. 15:29:43key with anyone otherwise they will be
  22641. 15:29:44able to uh use your platform. Okay. Then
  22642. 15:29:47you have to provide the langismith
  22643. 15:29:49project name. Okay. Because every time
  22644. 15:29:52whenever you will execute for the first
  22645. 15:29:54time it will create a project. Right?
  22646. 15:29:56Inside the project it will start tracing
  22647. 15:29:59all of the execution. So project is
  22648. 15:30:01important. So here I'm giving agentic
  22649. 15:30:02chatbot project. Okay. If you're
  22650. 15:30:04creating any other project you can
  22651. 15:30:05change the name as per your requirement.
  22652. 15:30:07Once it is done, you just need to save
  22653. 15:30:09this file and no need to change
  22654. 15:30:11anywhere. Okay, no need to change
  22655. 15:30:12anywhere. I can uh re-execute my app
  22656. 15:30:15again. So I'll stop the execution. Clear
  22657. 15:30:18and let's re-execute my app. Streamlitly
  22658. 15:30:20run my app.py. Okay. So once you have
  22659. 15:30:23done now what I will do uh here I
  22660. 15:30:25already saved this uh API key. H so it's
  22661. 15:30:28done. Now I'll go to the uh homepage.
  22662. 15:30:32Yeah. Now let's execute my app. See my
  22663. 15:30:35application is running right now.
  22664. 15:30:37Now here again I will give the prompt.
  22665. 15:30:38Let's say I'll give hi my name
  22666. 15:30:43is
  22667. 15:30:46By
  22668. 15:30:52plan to learn AI.
  22669. 15:30:56I'll send it
  22670. 15:30:59now. See it is giving you some kinds of
  22671. 15:31:01response. Okay. Now once I go to my
  22672. 15:31:05platform. Okay. Once I go to my platform
  22673. 15:31:07and if I refresh here.
  22674. 15:31:13So see this agentic chatbot project is
  22675. 15:31:16created few seconds ago. See
  22676. 15:31:17automatically it has created. I didn't
  22677. 15:31:19uh change anything inside my code. Okay.
  22678. 15:31:21Now if I go inside that now inside the
  22679. 15:31:24project guys you will be able to see
  22680. 15:31:25your trace. Okay. So this is our first
  22681. 15:31:27trace. That means we have executed uh
  22682. 15:31:30only one time. We have gi a single
  22683. 15:31:32prompt. That's why that's why one trace
  22684. 15:31:34came and by default this trace name will
  22685. 15:31:36be taken as lang graph because we are
  22686. 15:31:38using lang graph and now if I click on
  22687. 15:31:40the uh this trace our first trace so
  22688. 15:31:42whatever message you have given as an
  22689. 15:31:44input you will be able to see and
  22690. 15:31:46whatever uh output you got from your AI
  22691. 15:31:49even you will be also able to see okay
  22692. 15:31:51and this is also coming as a chatbot
  22693. 15:31:52interface okay this is like very
  22694. 15:31:54interesting then there is a option
  22695. 15:31:56called details so you have to click on
  22696. 15:31:58details okay if you click on details you
  22697. 15:32:00will be able to see all of the details
  22698. 15:32:01that means you have executed your
  22699. 15:32:03langraph and it has a chat node. I think
  22700. 15:32:06you remember uh we are using a chat node
  22701. 15:32:07if you can see uh our entire application
  22702. 15:32:11workflow. So this is the chat node
  22703. 15:32:12inside chat node we are using u lm right
  22704. 15:32:16we are using a large language model uh
  22705. 15:32:17openi model and we are using gpt 3.5
  22706. 15:32:20turbo model because I used a default
  22707. 15:32:22model there okay and by default GP3.5
  22708. 15:32:26turbo would be available now everything
  22709. 15:32:28you can see which model which node you
  22710. 15:32:30are executing okay each and everything
  22711. 15:32:32is visible now you can see the input and
  22712. 15:32:34output you got here you can even see the
  22713. 15:32:37attribute okay all of the attribute
  22714. 15:32:39metadata version everything is visible
  22715. 15:32:41here. And if you hover on each and every
  22716. 15:32:44let's say step here, you you will be
  22717. 15:32:46able to see the um uh let's say
  22718. 15:32:49estimated token cost. You can see token
  22719. 15:32:51cost and uh how many how much token
  22720. 15:32:54actually it used. Okay, how much token
  22721. 15:32:56it used for input, output, total. Okay,
  22722. 15:32:59each and everything you would be able to
  22723. 15:33:00see that. Okay, that's how you can see
  22724. 15:33:02the each and every execution of your
  22725. 15:33:05application. If you're using multiple LM
  22726. 15:33:08calls, you'll be able to see the
  22727. 15:33:09multiple LM. You can see the prompt.
  22728. 15:33:10Okay. Each and everything should be
  22729. 15:33:12available here. Okay. Now let's say if I
  22730. 15:33:14do for the second time what I will do
  22731. 15:33:17let's say I will give another message.
  22732. 15:33:20Um let's say how much
  22733. 15:33:25time it will take.
  22734. 15:33:32Now I got a response. Now if I again go
  22735. 15:33:34to my um dashboard. Now see another
  22736. 15:33:37trace has created. Okay. because this is
  22737. 15:33:39my second run. Now if I go to this trace
  22738. 15:33:42and you'll be able to again see the uh
  22739. 15:33:44conversation okay so how much time it
  22740. 15:33:47will take based on that you got the
  22741. 15:33:49entire output then you'll be able to
  22742. 15:33:51also see the uh token okay like input
  22743. 15:33:54token output token okay total token each
  22744. 15:33:56and everything would be available here
  22745. 15:33:58now even you can also switch to your
  22746. 15:34:00previous uh trans as well so if I go to
  22747. 15:34:02my previous trans this is the first
  22748. 15:34:03trans this is the second trans okay
  22749. 15:34:06everything you can see even you can see
  22750. 15:34:07the name so this is tr one and this is
  22751. 15:34:09tr too. Okay. So that's how everything
  22752. 15:34:12would be available and even if you zoom
  22753. 15:34:14out here so you'll be able to see some
  22754. 15:34:16other information right side like start
  22755. 15:34:18time latency like how much time it took
  22756. 15:34:20to execute then whether you are using
  22757. 15:34:22any data set or not then tokens cost
  22758. 15:34:25okay first tokens then metadata langmith
  22759. 15:34:28endpoint okay and everything you will be
  22760. 15:34:29able to see. So yes that's how you can
  22761. 15:34:32utilize this uh lang platform uh only
  22762. 15:34:35you just need to add those uh three to
  22763. 15:34:37four things in the environment variable
  22764. 15:34:39and tracing would be uh automatically uh
  22765. 15:34:43happening okay inside this particular
  22766. 15:34:44dashboard but one issue I think you have
  22767. 15:34:46observed here which is that let's say
  22768. 15:34:49here let's say if I create a new trades
  22769. 15:34:51okay let's say I create a new trades and
  22770. 15:34:53if I do the conversation let's say I
  22771. 15:34:55will give hi I am bi let's say this is
  22772. 15:35:00completely new trades. Okay. But if I go
  22773. 15:35:03to my um dashboard that means language
  22774. 15:35:06dashboard. So as you can see in the same
  22775. 15:35:10um I mean trace only it has created my
  22776. 15:35:13uh my current execution that means the
  22777. 15:35:15current trace the uh execution we have
  22778. 15:35:17done right now. So see uh here I given I
  22779. 15:35:20uh my name is BPI and hello I can assist
  22780. 15:35:22you today. Okay. So that's how actually
  22781. 15:35:24it is uh uh it is not separating my
  22782. 15:35:28trades instead of that it is saving
  22783. 15:35:30everything inside a single trace only.
  22784. 15:35:32So here if you want to separate your
  22785. 15:35:34trades guys uh it is also possible
  22786. 15:35:36because Langismith
  22787. 15:35:38by default has this uh trading uh
  22788. 15:35:40features here. So if you want to
  22789. 15:35:42separate out uh each and every trades
  22790. 15:35:44okay the trades you are maintaining
  22791. 15:35:46here. So it is possible for this inside
  22792. 15:35:48the code you have to only modifi uh
  22793. 15:35:50modify one particular line. Let me show
  22794. 15:35:52you. So this code only you just need to
  22795. 15:35:55modify. See here uh I was uh writing the
  22796. 15:35:58configuration. In the configuration I
  22797. 15:36:00was only giving the trade ID. Okay. Uh
  22798. 15:36:02and we are passing this configuration
  22799. 15:36:04whenever we are executing the uh chatbot
  22800. 15:36:06whenever we're invoking the chatbot.
  22801. 15:36:08Okay. Now instead of that you have to
  22802. 15:36:09write this configuration. Okay. Some
  22803. 15:36:11other information you need to also pass
  22804. 15:36:13this metadata and the runtime. Okay. So
  22805. 15:36:15run name see every time this run name is
  22806. 15:36:17coming as a lang graph by by default
  22807. 15:36:19name but you can change this run name if
  22808. 15:36:20you want. You can give any kinds of run
  22809. 15:36:22name. Let's say I give I'll give chat
  22810. 15:36:24trace. Okay, you can also give any other
  22811. 15:36:25name. And if you pass this configuration
  22812. 15:36:28guys, right now this uh trading would be
  22813. 15:36:32uh trading would be applied. That means
  22814. 15:36:34all of the trades individual trades
  22815. 15:36:35would be saved in the trades. Okay, let
  22816. 15:36:37me show you. So I'll remove this
  22817. 15:36:39configuration right now. This is not
  22818. 15:36:40required. I'll use my new one. Okay, new
  22819. 15:36:43configuration.
  22820. 15:36:45Yeah, so let me show you the fresh
  22821. 15:36:46execution. So for this I'll remove my uh
  22822. 15:36:50I'll remove my let's say project. So
  22823. 15:36:53here just go to the tracing and select
  22824. 15:36:55your project and just try to delete the
  22825. 15:36:57project.
  22826. 15:37:00Okay, done. Now I will re-execute my
  22827. 15:37:03code.
  22828. 15:37:11So let's say here uh I'll give a
  22829. 15:37:13message. Hi,
  22830. 15:37:15my
  22831. 15:37:17name is Buppy.
  22832. 15:37:22Okay, done. So this is uh this is the
  22833. 15:37:25trade guys. Uh I just uh start the
  22834. 15:37:27conversation. Now if I come here, see my
  22835. 15:37:30project has created. If I go inside
  22836. 15:37:32that. So first trace has created the uh
  22837. 15:37:34the name of the trace is chat trace
  22838. 15:37:36because we changed the name and this is
  22839. 15:37:38the conversation we have done. Okay. Now
  22840. 15:37:40let's say I will give another message.
  22841. 15:37:42Uh I will create a new trades here and
  22842. 15:37:44I'll perform another message. Let's say
  22843. 15:37:47I am Alex.
  22844. 15:37:54Now if I come here
  22845. 15:37:57now if I go to the trades now guys you
  22846. 15:38:00can see trades has created. Okay. Now
  22847. 15:38:02this is the trades. This was my first
  22848. 15:38:04trace. Uh there I performed. Hello my
  22849. 15:38:07name is BPY. Okay. How I can assist you
  22850. 15:38:09today. Now let's say if I give another
  22851. 15:38:11message um
  22852. 15:38:13I need
  22853. 15:38:16um I need a plan
  22854. 15:38:20to learn Python.
  22855. 15:38:28Now if I go to my trades. So see inside
  22856. 15:38:31the same trace uh inside the same trade
  22857. 15:38:33there is uh two trans right now. Um now
  22858. 15:38:36if I go to this uh trades as you can see
  22859. 15:38:40the first I given hi my name is BP uh
  22860. 15:38:42how and it it has given you hello BP how
  22861. 15:38:45I can assist you today. Now in the
  22862. 15:38:47second trace
  22863. 15:38:49uh you can see I given I need a plan to
  22864. 15:38:51learn Python and uh it has given you the
  22865. 15:38:54plan. Okay that means in a single trade
  22866. 15:38:56now it is storing multiple trans that
  22867. 15:38:58means multiple conversation. Previously
  22868. 15:39:00I also did for Alex. See Alex is also
  22869. 15:39:02available here. Uh yeah, you can see the
  22870. 15:39:05Alex. Uh but it takes some time guys. I
  22871. 15:39:07think it takes uh 10 to 20 seconds to
  22872. 15:39:10update in the trades. Okay, that's why
  22873. 15:39:12initially whenever I showed you uh this
  22874. 15:39:14information was not updated. Now see
  22875. 15:39:16here also whenever I did let's say Alex,
  22876. 15:39:19right? Uh this is the Alex Alex
  22877. 15:39:22conversation.
  22878. 15:39:23Uh this is Alex conversation. I'm Alex.
  22879. 15:39:25I need a plan to learn Python. As you
  22880. 15:39:28can see I am Alex and here I given you I
  22881. 15:39:31need a plan to learn Python. Okay. So
  22882. 15:39:33that's how guys every uh trades you will
  22883. 15:39:36be creating all of the trades would be
  22884. 15:39:37available inside the trades or whatever
  22885. 15:39:39conversation you'll be doing it would be
  22886. 15:39:41saving as a run. Now let me show you
  22887. 15:39:43another let's execution let's say in the
  22888. 15:39:45Alex only I'll tell how much
  22889. 15:39:51time it will take.
  22890. 15:39:55Now this is my third run. Okay.
  22891. 15:39:58Now if I come here.
  22892. 15:40:01So you have to wait for some time then
  22893. 15:40:04this TR would be updated here.
  22894. 15:40:08Now see it got updated run three. Now if
  22895. 15:40:11I click here now this is the turn three
  22896. 15:40:13guys and here I asked how much time it
  22897. 15:40:16will take and this is the answer I got.
  22898. 15:40:17Okay. So that's how guys you can
  22899. 15:40:19separate out the trades uh by adding
  22900. 15:40:21this line of code only. You just need to
  22901. 15:40:23update your configuration and everything
  22902. 15:40:25will remain same. Okay. So that's how
  22903. 15:40:26guys with help of Langismith we can
  22904. 15:40:28continuously monitor our application. we
  22905. 15:40:30can continuously trace our application.
  22906. 15:40:32Lots of thing we can perform with the
  22907. 15:40:33help of this languid. Going forward also
  22908. 15:40:36I'll be using this uh tool okay in my
  22909. 15:40:38project development and I will also show
  22910. 15:40:40you some other advantage we can utilize
  22911. 15:40:43from this lang language speed itself.
  22912. 15:40:45Okay. So all the code I'm going to uh
  22913. 15:40:47upload in my GitHub and give the link in
  22914. 15:40:50the description from there you can get
  22915. 15:40:52and please try to practice in your
  22916. 15:40:53system and do let me know if you have
  22917. 15:40:55any question. So yes guys, this is all
  22918. 15:40:57about it and if you found my content
  22919. 15:40:59useful, please try to subscribe to my
  22920. 15:41:00channel and hit the like. In this video,
  22921. 15:41:02I'm going to uh explain one very
  22922. 15:41:05important concept, one very important
  22923. 15:41:07features inside our agentic chatbot
  22924. 15:41:10which is tools. If you are implementing
  22925. 15:41:12any kinds of agentic system, this tools
  22926. 15:41:14is very much important. Without tools,
  22927. 15:41:17an AI agent cannot perform any kinds of
  22928. 15:41:19action. With the help of this tools
  22929. 15:41:21integration, we can make our AI agents
  22930. 15:41:24more smarter and intelligence and
  22931. 15:41:26powerful.
  22932. 15:41:27So far the application we have created,
  22933. 15:41:29it doesn't have any kinds of tool. It
  22934. 15:41:32can only use the large language model
  22935. 15:41:33and give you some kinds of response. So
  22936. 15:41:36if I show you my application guys, so
  22937. 15:41:38this is the application guys. So far we
  22938. 15:41:40have developed. Uh this is our agentic
  22939. 15:41:42chatbot with lang graph we have
  22940. 15:41:44developed so far and we have added lots
  22941. 15:41:46of feature in this particular uh
  22942. 15:41:48application. We saw how we can create
  22943. 15:41:51the uh basic workflow of our agentic
  22944. 15:41:53chatbot. We saw how we can add the
  22945. 15:41:55streaming features. We saw how to add
  22946. 15:41:57the trading features. Okay. Uh we saw
  22947. 15:42:00how to add the persistence memory. Um
  22948. 15:42:02even how to integrate the database with
  22949. 15:42:04that. Even in my last video, I showed
  22950. 15:42:06you how we can add the observability
  22951. 15:42:09tool to monitor the entire application.
  22952. 15:42:11And we created a dashboard. Uh this is
  22953. 15:42:13the lang dashboard guys. And here
  22954. 15:42:16continuously we're tracing our um like
  22955. 15:42:18conversation. So this is the application
  22956. 15:42:21guys. And the problem with this
  22957. 15:42:22application is let's say if you are
  22958. 15:42:24asking any kinds of uh question uh which
  22959. 15:42:27is latest uh which is not available in
  22960. 15:42:30the large language model that time this
  22961. 15:42:32particular chatbot will not uh able to
  22962. 15:42:34give you the response. So let's say here
  22963. 15:42:36we are telling hello uh tell me
  22964. 15:42:41about
  22965. 15:42:43Python.
  22966. 15:42:45So if I give this prompt it will be able
  22967. 15:42:48to give you the response.
  22968. 15:42:51So see guys it is uh able to give you
  22969. 15:42:53the response and why it is able to give
  22970. 15:42:55you the response about the Python
  22971. 15:42:57because uh this Python information is
  22972. 15:42:59already available in the LLM knowledge
  22973. 15:43:01base. Okay. So the model we are using uh
  22974. 15:43:04every model has a knowledge cutoff date
  22975. 15:43:06and the model we are using this model
  22976. 15:43:08got trained till 2022
  22977. 15:43:11uh I think till December it uh this
  22978. 15:43:13model got trained and that time actually
  22979. 15:43:15python information was available in the
  22980. 15:43:17internet that's why it is able to
  22981. 15:43:19generate the response but let's say if
  22982. 15:43:21you are asking anything which is latest
  22983. 15:43:22information this information is not
  22984. 15:43:24available in the knowledge base that
  22985. 15:43:26time your chatbot will fail now let's
  22986. 15:43:28ask about a latest uh information uh uh
  22987. 15:43:32into my chatbot. So here I will tell u
  22988. 15:43:36give me
  22989. 15:43:39all the latest
  22990. 15:43:41news
  22991. 15:43:43for [snorts] today's
  22992. 15:43:49now see it is telling I understand you
  22993. 15:43:51are looking for the very latest news.
  22994. 15:43:53However, uh as an AI, I don't have
  22995. 15:43:56realtime access to the live news feed
  22996. 15:43:59and my knowledge cutoff is a specific
  22997. 15:44:01point in time typically a few month ago.
  22998. 15:44:04Okay, this means I cannot provide with
  22999. 15:44:06you today's uh minuteby minutes uh news
  23000. 15:44:09headlines. Okay, to uh get most current
  23001. 15:44:12news, I highly recommend checking reput
  23002. 15:44:14uh reputable news sources directly.
  23003. 15:44:17Okay, and blah blah blah. That means
  23004. 15:44:19this chatbot is directly telling you
  23005. 15:44:22okay I don't have the access to the
  23006. 15:44:24latest data okay because this this is
  23007. 15:44:27using a large language model and this
  23008. 15:44:28large language model has a knowledge cut
  23009. 15:44:30off date okay I think uh till uh 2022
  23010. 15:44:35or 2024 I don't know but uh till the
  23011. 15:44:38date actually they have trained this
  23012. 15:44:39model and uh um actually in that period
  23013. 15:44:43of time whatever news were available in
  23014. 15:44:45the internet uh this has the information
  23015. 15:44:47okay but if you are asking anything
  23016. 15:44:48which is latest this model will not able
  23017. 15:44:50to give you the response. Okay. So this
  23018. 15:44:52is the problem right now even uh if if
  23019. 15:44:55you uh want to perform like other things
  23020. 15:44:58as well. Let's say if you want to let's
  23021. 15:45:00say uh see the stock market analysis
  23022. 15:45:03report. Okay the latest stock market
  23023. 15:45:04analysis report. This model won't be
  23024. 15:45:06able to give you the response. So let me
  23025. 15:45:08give you another demo. So tell me
  23026. 15:45:11the latest stock
  23027. 15:45:15of Apple.
  23028. 15:45:23So as you can see as an AI I do have
  23029. 15:45:25access uh to real time live stock market
  23030. 15:45:27data. Stock uh prices uh fluctu
  23031. 15:45:32fluctuate uh consistently uh throughout
  23032. 15:45:34the trading day. Okay. and my knowledge
  23033. 15:45:37cutoff means any specific price I could
  23034. 15:45:40I could uh give you would be outdated
  23035. 15:45:42almost im uh immediately. Okay, that
  23036. 15:45:44means it is not able to give you the
  23037. 15:45:46realtime information about this stock.
  23038. 15:45:48And if you're asking anything, let's say
  23039. 15:45:49you are asking about the current
  23040. 15:45:51weather. Okay, let's say I'm asking
  23041. 15:45:52about tell me the
  23042. 15:45:55tell me the current
  23043. 15:45:59weather
  23044. 15:46:03in let's say New York.
  23045. 15:46:17So see it is telling you again I don't
  23046. 15:46:19have realtime access to the live uh
  23047. 15:46:21weather data. Okay. So this is the
  23048. 15:46:23problem with our uh agentic chatbot we
  23049. 15:46:26have created so far because it doesn't
  23050. 15:46:27have any kinds of tool. Okay. So tool
  23051. 15:46:30means uh it is kinds of function it is
  23052. 15:46:33kinds of API okay it is kinds of let's
  23053. 15:46:36say uh different different tools that my
  23054. 15:46:39agent can use to get the latest
  23055. 15:46:42information or perform any kinds of
  23056. 15:46:43action. Okay. So let's say if I go to
  23057. 15:46:45the chat GPT and if I ask the same
  23058. 15:46:47question, Chad GPT will be able to give
  23059. 15:46:49me the response. Okay. So let's say I
  23060. 15:46:51will copy the same question. Um I'll
  23061. 15:46:54copy this question and if I ask in the
  23062. 15:46:56chart GPT see chart GPT will be using
  23063. 15:46:59some kinds of tool in action. See see
  23064. 15:47:02just try to notice here now see it is
  23065. 15:47:04searching over the internet. Okay. You
  23066. 15:47:06see it is searching over the internet
  23067. 15:47:08and it is finding different different
  23068. 15:47:10latest news and once it has collected
  23069. 15:47:12all the latest news then it will refine
  23070. 15:47:14that particular news and it will give me
  23071. 15:47:16all of the see news for today's okay and
  23072. 15:47:21the reference uh reference URL as well
  23073. 15:47:23like where it got uh it referred that
  23074. 15:47:25particular headline where uh it uh
  23075. 15:47:28referred that news okay each and
  23076. 15:47:29everything it is giving me now let's say
  23077. 15:47:31if I asking
  23078. 15:47:33uh this question as well tell me the
  23079. 15:47:35latest stock of Apple again it will be
  23080. 15:47:37using some kinds of tool
  23081. 15:47:43see it is using some kinds of tool and
  23082. 15:47:46after that it will give you the response
  23083. 15:47:48see it is using this stock market
  23084. 15:47:51analysis tool and it is giving you the
  23085. 15:47:53real time Apple um stock stock stock
  23086. 15:47:56data okay then you can also ask um about
  23087. 15:48:00the weather information
  23088. 15:48:02again it will be able to give you the
  23089. 15:48:04response because it has the uh current
  23090. 15:48:06weather tools as well in the back end
  23091. 15:48:08with the help of that particular tool.
  23092. 15:48:10It is real time searching the uh current
  23093. 15:48:12weather information in New York and it
  23094. 15:48:14will give you the uh weather see. Okay.
  23095. 15:48:18So this is called actually tool in
  23096. 15:48:19action. Okay. So whenever you are
  23097. 15:48:21creating the agentic system it should
  23098. 15:48:24have lots of tool. Okay. And wherever it
  23099. 15:48:28needs any kinds of tool it will
  23100. 15:48:29automatically decide and it will select
  23101. 15:48:30that particular tool. Let's say here I
  23102. 15:48:32was asking about the news right that
  23103. 15:48:35time to get the latest news what what I
  23104. 15:48:37have to do I have to perform the
  23105. 15:48:38internet search operation I have to
  23106. 15:48:39perform the Google search operation so
  23107. 15:48:41here it is using some kinds of search
  23108. 15:48:43tool okay with the help of the search
  23109. 15:48:44tool it is giving you all kinds of
  23110. 15:48:46latest information latest news then I
  23111. 15:48:48asked about the latest stock of Apple
  23112. 15:48:51okay now it is using the stock market uh
  23113. 15:48:54actually tool with the help of this tool
  23114. 15:48:57actually it is getting the real time uh
  23115. 15:48:59real time actually um the uh real time
  23116. 15:49:03actually stock of Apple and it is giving
  23117. 15:49:05you the response. So it is using some
  23118. 15:49:07kinds of stock stock price or stock
  23119. 15:49:09related tools in the back end. Now again
  23120. 15:49:12I asked about the weather. So here it is
  23121. 15:49:14using a weather tool. Okay, with the
  23122. 15:49:16help of weather tool it is hitting some
  23123. 15:49:18kinds of uh API of the weather and it is
  23124. 15:49:21getting real time this weather
  23125. 15:49:23information. Okay, the given uh location
  23126. 15:49:26we are giving. Okay, so that's how
  23127. 15:49:28things are working. So that's how chart
  23128. 15:49:29GPT uh has lots of tool connection.
  23129. 15:49:33Okay, not only three to four tools, it
  23130. 15:49:34has lots of tool connection. So you can
  23131. 15:49:36ask any kinds of question whether it's a
  23132. 15:49:38latest news, whether it's any kinds of
  23133. 15:49:40outdated news, whether you want to
  23134. 15:49:42perform any kinds of task. Okay,
  23135. 15:49:44everything it can perform because it has
  23136. 15:49:46the tool and without this tool it can
  23137. 15:49:48perform the action. Okay, I hope you get
  23138. 15:49:50it. So these kinds of things we will be
  23139. 15:49:52also integrating inside our agentic
  23140. 15:49:54chatbot. So whenever we are asking this
  23141. 15:49:56kinds of question, my agentic chatbot
  23142. 15:49:58will be also able to give you the
  23143. 15:50:00response. It will be also able to use
  23144. 15:50:02this kinds of tool and perform the
  23145. 15:50:04action. Okay. So yeah, in this
  23146. 15:50:06particular video, we'll be learning this
  23147. 15:50:07concept guys. We'll try to see how we
  23148. 15:50:09can integrate the tools inside our
  23149. 15:50:11agentic chatbot. And trust me, this is
  23150. 15:50:13very important concept. If you are
  23151. 15:50:15implementing any kinds of agentic uh
  23152. 15:50:17powered application, you have to use the
  23153. 15:50:19tool. Okay, there are lots of tools are
  23154. 15:50:21available over the internet, over the
  23155. 15:50:23market. Uh as per your requirement, you
  23156. 15:50:26can select the tools and you can
  23157. 15:50:27integrate inside your uh chatbot or
  23158. 15:50:29whatever application you are developing
  23159. 15:50:31and you can even create your custom
  23160. 15:50:33tools. It is also possible. I'll show
  23161. 15:50:35you both of them. Okay. So guys before I
  23162. 15:50:37discuss about the tools concept the
  23163. 15:50:39tools uh integration uh inside our
  23164. 15:50:41agentic chatbot first of all I want to
  23165. 15:50:43show you the demo like after adding this
  23166. 15:50:46tools how my aentic chatbot will work.
  23167. 15:50:49So I already integrated the tools inside
  23168. 15:50:50my aentic chatbot this is the updated
  23169. 15:50:52version. First of all let me show you
  23170. 15:50:54the demo. So see this is the uh updated
  23171. 15:50:56application. Now if I ask uh the these
  23172. 15:50:59kinds of question let's say I will give
  23173. 15:51:00u give me the
  23174. 15:51:05latest
  23175. 15:51:06news
  23176. 15:51:08in AI. Okay. Now if I send this prompt
  23177. 15:51:11you will be able to see uh it it will
  23178. 15:51:13use some kinds of tool. Okay.
  23179. 15:51:16So see it is using tably search tool. So
  23180. 15:51:18with help of tably search tool it is
  23181. 15:51:20searching over the internet uh about the
  23182. 15:51:23latest news in AI and this will give you
  23183. 15:51:25the response. See this is giving you the
  23184. 15:51:27response. See so all of the latest news
  23185. 15:51:30it has given me okay from different
  23186. 15:51:32different uh paper different different
  23187. 15:51:34publication it has given me all the
  23188. 15:51:36latest news in AI. Even you can see the
  23189. 15:51:39um like tools uh tools action as you can
  23190. 15:51:42see internally it is using some kinds of
  23191. 15:51:44uh URL some kinds of let's say uh
  23192. 15:51:48resources and it is giving you this
  23193. 15:51:49kinds of information even in charge also
  23194. 15:51:52you'll be able to see this uh uh uh this
  23195. 15:51:54back end execution okay this is also
  23196. 15:51:56possible so every like said tools
  23197. 15:51:58execution you'll be able to see if you
  23198. 15:52:00want you can also open it and you can
  23199. 15:52:02see okay so this kinds of thing we have
  23200. 15:52:04also um implemented inside our agentic
  23201. 15:52:07chatbot And throughout this entire video
  23202. 15:52:09guys, I'm going to show you how we can
  23203. 15:52:11develop these things. Okay, how we can
  23204. 15:52:12add this particular tools integration
  23205. 15:52:14inside our aentic chatbot. Now let me
  23206. 15:52:16ask another question. Let's say here I
  23207. 15:52:17will tell um um calculate
  23208. 15:52:24okay um this number. Okay. So let's say
  23209. 15:52:27this is my expression. I want to do a
  23210. 15:52:29mathematical calculation and inside this
  23211. 15:52:32aentic chatbot I I am using a a tool
  23212. 15:52:35called calculator tool. So with the help
  23213. 15:52:37of this calculator tool you can
  23214. 15:52:39calculate any kinds of complex let's say
  23215. 15:52:41expression any kinds of complex uh let's
  23216. 15:52:43say um u equation you can calculate
  23217. 15:52:46here. Now if I send this now you will
  23218. 15:52:49see that it will be using calculator
  23219. 15:52:50tool. Okay. Now with the help of this
  23220. 15:52:51calculator it is calculating the entire
  23221. 15:52:54uh let's say number and it is giving you
  23222. 15:52:55the response. So any kinds of complex
  23223. 15:52:57math problem you can give it will be
  23224. 15:52:59able to perform that. Okay. So once it
  23225. 15:53:01is done let me show you another demo.
  23226. 15:53:03Then I have given another prompt. Tell
  23227. 15:53:05me the latest stock price of Apple.
  23228. 15:53:08Again you can see it is using some kinds
  23229. 15:53:10of tool. It is using stock uh price uh
  23230. 15:53:12tool and it is uh able to give you the
  23231. 15:53:14latest stock price of Apple. Okay. Even
  23232. 15:53:17you can also ask the stock related any
  23233. 15:53:19other companies let's say stock price of
  23234. 15:53:22Google. So stock price of Google. Now
  23235. 15:53:25see it is using get stock price uh tool
  23236. 15:53:27and it is able to give you the latest
  23237. 15:53:29stock price of Google is uh that much.
  23238. 15:53:33Okay. So yes guys that's how our entire
  23239. 15:53:35uh agentic system is working right now
  23240. 15:53:38and we are we have already integrated uh
  23241. 15:53:40uh some tools okay inside our agentic
  23242. 15:53:42chatbot that's why it is performing like
  23243. 15:53:44chart GPT but chart GPT is having lots
  23244. 15:53:47of uh tools guys um if you want you can
  23245. 15:53:49also integrate lots of tools inside your
  23246. 15:53:50application this part I will leave it to
  23247. 15:53:52you first of all let me show you the
  23248. 15:53:54entire development then you can uh you
  23249. 15:53:56can improve this application a lot so
  23250. 15:53:58first of all uh I'll be discussing about
  23251. 15:54:00the tools guys what is tools uh why
  23252. 15:54:03tools is required then I'm going to show
  23253. 15:54:04you the implementation. So guys first of
  23254. 15:54:06all let's try to understand about the
  23255. 15:54:08tools what is tools exactly and why it
  23256. 15:54:11is required and how tools works. Okay.
  23257. 15:54:13So as you can see uh in agentic AI tools
  23258. 15:54:16are external functions APIs database or
  23259. 15:54:20any kinds of service that an uh AI agent
  23260. 15:54:23can use to perform actions beyond
  23261. 15:54:25generating the text. Okay. So previously
  23262. 15:54:28the application we created guys this
  23263. 15:54:29agentic uh application the previous
  23264. 15:54:31version application that means in my
  23265. 15:54:33previous video uh it was only able to
  23266. 15:54:35generate the text okay uh if you give
  23267. 15:54:37any kinds of let's say prompt based on
  23268. 15:54:39the prompt if this information is
  23269. 15:54:41available in the knowledge base of the
  23270. 15:54:43model it is able to generate some kinds
  23271. 15:54:45of text okay but with the help of these
  23272. 15:54:47tools an agent can um agent can perform
  23273. 15:54:51action okay like I showed you right now
  23274. 15:54:53right I uh I uh per I did different
  23275. 15:54:56different prompting in my agent. I asked
  23276. 15:54:59about the stock price. I uh asked about
  23277. 15:55:01the latest news. Then I asked to
  23278. 15:55:03calculate u some kinds of mathematical
  23279. 15:55:05equation and it was performing some
  23280. 15:55:07kinds of action with the help of some
  23281. 15:55:09third party tools. Okay. So that's why
  23282. 15:55:12our agent can perform any kinds of
  23283. 15:55:14actions. Okay. Uh using the tool beyond
  23284. 15:55:17the text generation. So our agent cannot
  23285. 15:55:19only generate the text. Okay. It can
  23286. 15:55:22also perform some kinds of action with
  23287. 15:55:24the help of this tool. So this is very
  23288. 15:55:25much important. So a normal LM can only
  23289. 15:55:28respond based on this knowledge and the
  23290. 15:55:31information in in the prompt. Okay. An
  23291. 15:55:33AI agent works with tool and it can
  23292. 15:55:36search, calculate, retrieve the data,
  23293. 15:55:38execute code, update database or
  23294. 15:55:40interact with other systems as well.
  23295. 15:55:42Okay. So by this definition itself I
  23296. 15:55:44think you can understand what is tools
  23297. 15:55:46exactly and why these tools is super
  23298. 15:55:48important. Okay. So with the help of
  23299. 15:55:49tools you can perform any kinds of
  23300. 15:55:51searching operation, calculate
  23301. 15:55:52operation, retrieve data operation. You
  23302. 15:55:54can even execute any kinds of code.
  23303. 15:55:55Okay. I think inside GPT you can execute
  23304. 15:55:57the code. You can debug your code. Okay.
  23305. 15:55:59How it is happening? Because it is using
  23306. 15:56:01some kinds of tool and that tool
  23307. 15:56:03actually it is working with the Python
  23308. 15:56:05interpreter. Okay. So in the Python
  23309. 15:56:07interpreter or any other let's say
  23310. 15:56:08program you are using it is using that
  23311. 15:56:10particular interpreter. It is executing
  23312. 15:56:12the code. It is reviewing your code. It
  23313. 15:56:14is finding the bugs inside your code and
  23314. 15:56:16it is giving you the final response.
  23315. 15:56:18Okay. this is the problem inside your
  23316. 15:56:19code. So everything is happening with
  23317. 15:56:21the help of this particular tools. Okay.
  23318. 15:56:23So they're using these kinds of tool
  23319. 15:56:25external tools and they are performing
  23320. 15:56:26this kinds of operation. Okay. I hope
  23321. 15:56:28you get it. Now let's try to understand
  23322. 15:56:30a simple example. Suppose a user asked
  23323. 15:56:33what is the current weather in Texas.
  23324. 15:56:35Okay. The agent does not know the live
  23325. 15:56:37weather uh by itself. Now it can call a
  23326. 15:56:40weather tool. Okay. Let's say you have
  23327. 15:56:42uh already integrated the weather tools
  23328. 15:56:44inside your agents. Now your agents will
  23329. 15:56:46automatically decide which tool to call.
  23330. 15:56:48Now you are asking about the weather. So
  23331. 15:56:50definitely it will let's say uh hit this
  23332. 15:56:53get weather tools. Okay. It will use
  23333. 15:56:54this get a weather tool and you are
  23334. 15:56:56asking for Texas. Okay. So that's how
  23335. 15:56:58the location you are giving it will find
  23336. 15:57:00the weather okay of that particular
  23337. 15:57:02location. Then the tool returns the
  23338. 15:57:04current weather and the agent uses that
  23339. 15:57:06result to answer the user. Okay. So
  23340. 15:57:08that's how the entire system works. Now
  23341. 15:57:10some common tools in agenti. So you can
  23342. 15:57:13see web search tools can be used a lot
  23343. 15:57:16whenever you are creating this kinds of
  23344. 15:57:17agentic application with the help of you
  23345. 15:57:19can perform search operation over the uh
  23346. 15:57:22internet and you can get the current
  23347. 15:57:23information. Then calculator tool okay I
  23348. 15:57:25think you saw the calculator tool you
  23349. 15:57:27can perform any kinds of complex
  23350. 15:57:28mathematical operation. Okay then
  23351. 15:57:30database tool you can even reads and
  23352. 15:57:32writes data inside your database or any
  23353. 15:57:34other let's say storage service these uh
  23354. 15:57:37tools can be also used inside your
  23355. 15:57:38aentic chatbot. then rag retriever
  23356. 15:57:41tools. Okay, searches do uh searches
  23357. 15:57:42over the documents or vector database.
  23358. 15:57:44We'll uh in future we'll also try to add
  23359. 15:57:46this uh tools inside our aentic chart
  23360. 15:57:48but we'll also add the uh functionality.
  23361. 15:57:51Okay, I'll show you this part as well.
  23362. 15:57:52So this is also important things like
  23363. 15:57:54inside GPT you can upload any kinds of
  23364. 15:57:56documents right and in the document you
  23365. 15:57:58can perform the uh you can perform the
  23366. 15:58:00search operation you can perform the
  23367. 15:58:01query operation how it is happening
  23368. 15:58:02because it has the rag retriever tool
  23369. 15:58:05then you can use python tool with the
  23370. 15:58:06help of python tool you can execute the
  23371. 15:58:08code analyze the data okay everything is
  23372. 15:58:10possible you can even use email tool
  23373. 15:58:12with the help of email you can read
  23374. 15:58:14email you can draft your email you can
  23375. 15:58:16send the email okay so everything is
  23376. 15:58:18possible even in charge GPT or Google
  23377. 15:58:20Gemini you can connect your email. Okay.
  23378. 15:58:23Even from there only you can send the
  23379. 15:58:25email. This is also possible. And how it
  23380. 15:58:27is happening? Because it is using email
  23381. 15:58:28tool. Then calendar tool you can use.
  23382. 15:58:30You can even access your calendar. You
  23383. 15:58:32can use different different API tool
  23384. 15:58:34like uh you can use weather API tool,
  23385. 15:58:36finance API tool, CRM API tool, any
  23386. 15:58:38kinds of payment system API tool. Any
  23387. 15:58:39kinds of API you can connect with your
  23388. 15:58:42aentic chatbot. Okay. Aenti system. Then
  23389. 15:58:44custom businesses tool. Let's say if you
  23390. 15:58:46have some custom uh businesses okay if
  23391. 15:58:49you want to integrate that particular
  23392. 15:58:50tool let's say you can create the
  23393. 15:58:52tickets you can check the inventory you
  23394. 15:58:54can generate the reports okay you can
  23395. 15:58:55update the customer records everything
  23396. 15:58:57is possible here so these are the common
  23397. 15:58:59tool guys you can integrate inside your
  23398. 15:59:00aentic system okay apart from that there
  23399. 15:59:03are lots of tools are available you can
  23400. 15:59:05search over the internet okay there are
  23401. 15:59:06thousands of thousands tools are
  23402. 15:59:08available whatever you need okay you
  23403. 15:59:10just try to integrate inside your
  23404. 15:59:12project itself okay very simple then How
  23405. 15:59:16two calling works guys? As you can see
  23406. 15:59:17the typical workflow is the user gives a
  23407. 15:59:20request first of all then the agent
  23408. 15:59:22understand the goal. Let's say uh
  23409. 15:59:24previously I showed you some kinds of uh
  23410. 15:59:27action right? I asked about the uh stock
  23411. 15:59:30price of Google. So this is my user
  23412. 15:59:32request. Okay. My agent understand the
  23413. 15:59:34goal. What is the goal? It has to
  23414. 15:59:36understand the sorry it has to get the
  23415. 15:59:38latest stock of the Apple. Okay. Or
  23416. 15:59:40Google. Then the agent decided whether
  23417. 15:59:43uh whether a tool is required. Then our
  23418. 15:59:46agent was understanding okay to give
  23419. 15:59:49this particular answer whether I need to
  23420. 15:59:50use any kinds of tool or not. So in this
  23421. 15:59:52scenario definitely it has to use the
  23422. 15:59:54tool because inside the LLM uh the
  23423. 15:59:56default LLM it doesn't have this kinds
  23424. 15:59:58of information. Definitely it has to use
  23425. 16:00:00the tool. Okay. So the agents will
  23426. 16:00:02decide okay it has to use the tool. It
  23427. 16:00:03it needs the tool requirement. Okay.
  23428. 16:00:05Then it selects the appropriate tool
  23429. 16:00:07because inside my application there are
  23430. 16:00:09multiple tools I have added. Now which
  23431. 16:00:11tool to call? Okay, which tool to use?
  23432. 16:00:12Because here I ask different different
  23433. 16:00:14uh question, right? And uh for each and
  23434. 16:00:16every question uh it uh it should use
  23435. 16:00:19different different tools. Okay, it it's
  23436. 16:00:21not like that for all the questions it
  23437. 16:00:23will be using one specific tool. Okay,
  23438. 16:00:25because question might be different,
  23439. 16:00:26prompt might be different. First of all,
  23440. 16:00:28it has to understand the goal based on
  23441. 16:00:29the goal. It will automatically select
  23442. 16:00:31the specific tool it requires. Okay,
  23443. 16:00:33that's why uh it selects the appropriate
  23444. 16:00:35tools. Then it generates the tool
  23445. 16:00:37arguments. Okay, tool argument means
  23446. 16:00:39that here we are asking about let's say
  23447. 16:00:41give me the latest news in AI. So what
  23448. 16:00:43will happen? Uh it will search this uh
  23449. 16:00:45this particular word in the internet.
  23450. 16:00:47Okay, because it is using tably search
  23451. 16:00:49tool, right? And you know tably search
  23452. 16:00:50tool uh uh what it does? It does the
  23453. 16:00:52internet search operation. The way you
  23454. 16:00:54search the Google, right? Uh it will be
  23455. 16:00:56using tably search and it will perform
  23456. 16:00:58the search operation. Okay? And this
  23457. 16:00:59will give you the latest uh information
  23458. 16:01:02of that. So that's why uh this uh uh it
  23459. 16:01:05generates the tool argument. Okay. Let's
  23460. 16:01:06say whenever you are giving any kinds of
  23461. 16:01:09uh let's say equation let's say
  23462. 16:01:10calculate
  23463. 16:01:14calculate
  23464. 16:01:15this number with this number
  23465. 16:01:18now it will be using calculated tool
  23466. 16:01:20okay see and what is the uh tool
  23467. 16:01:24argument here this expression okay this
  23468. 16:01:26expression is the tool argument right
  23469. 16:01:27now and it is calculating that and it is
  23470. 16:01:30you are able to see the response okay
  23471. 16:01:32then tool execution in action that means
  23472. 16:01:34tool will execute and uh this will give
  23473. 16:01:36you the response and this response the
  23474. 16:01:38result is return it to the agent. That
  23475. 16:01:40means whatever responses you will be
  23476. 16:01:41getting from the tools. Okay. Uh
  23477. 16:01:43sometimes these responses won't be
  23478. 16:01:45readable to the user. Okay. So that's
  23479. 16:01:47why what you have to do you have to send
  23480. 16:01:49this response to the large language
  23481. 16:01:51model again that means your agent again
  23482. 16:01:53and agent will try to refine that
  23483. 16:01:54particular output and you will be able
  23484. 16:01:56to see the final result. Then the last
  23485. 16:01:58one the agent uh produces the final
  23486. 16:02:01responses. Okay, that means once my tool
  23487. 16:02:03execution is complete and whatever
  23488. 16:02:05output we are getting from the tools
  23489. 16:02:07we'll try to pass to the agents and
  23490. 16:02:08agents will try to refine that
  23491. 16:02:10particular output. Okay, and this will
  23492. 16:02:12generate the final uh responses to the
  23493. 16:02:14user. So that's why the agents produces
  23494. 16:02:17the final responses. Okay, example you
  23495. 16:02:20are asking let's say what is uh uh 25%
  23496. 16:02:23of uh 8,500.
  23497. 16:02:27Now agent decide u you have it has to
  23498. 16:02:30use calculated tool. Okay. Now it will
  23499. 16:02:32perform the tool call. Now this is the
  23500. 16:02:34calculation it has to do, right? Uh this
  23501. 16:02:36is the expression it has to calculate.
  23502. 16:02:38So after calculating this will uh uh
  23503. 16:02:40your let's say uh uh tool has generated
  23504. 16:02:42this output. Uh let's say this is the
  23505. 16:02:44final response. But if I show this
  23506. 16:02:46response to the user, user won't be able
  23507. 16:02:48to understand in a in a good way. Okay.
  23508. 16:02:51So I have to generate some kinds of
  23509. 16:02:53readable response. So again I will send
  23510. 16:02:55this particular result to my agent. Now
  23511. 16:02:58agent will try to refine this out uh
  23512. 16:02:59let's say answer and it will generate a
  23513. 16:03:02uh final responses. You can see now
  23514. 16:03:04agent is uh generating 25% of 8,500 is
  23515. 16:03:092,125.
  23516. 16:03:11Okay. Now this is more readable than
  23517. 16:03:13this one. Okay. So that's why this this
  23518. 16:03:16step is super important and whenever you
  23519. 16:03:18are using any kinds of tool whenever
  23520. 16:03:19your agent is calling any kinds of tool
  23521. 16:03:21so this eight step it is following.
  23522. 16:03:23Okay. And we'll also follow this a step
  23523. 16:03:25eight step to implement tools
  23524. 16:03:27integration inside our uh AI agents.
  23525. 16:03:30Okay, this is the entire idea guys. So
  23526. 16:03:32now guys, I think pretty much clear how
  23527. 16:03:34the tools works and what is tools
  23528. 16:03:35exactly and in the chart GP also how
  23529. 16:03:38chart GP works and whenever you are
  23530. 16:03:39asking any kinds of realtime question
  23531. 16:03:41how it is able to give you the response
  23532. 16:03:43because it has the tools connection.
  23533. 16:03:44Okay, lots of tools connection because
  23534. 16:03:46of that you are able to see the latest
  23535. 16:03:48information or any kinds of action you
  23536. 16:03:50can perform here. Now let's uh start the
  23537. 16:03:52implementation guys. I will show you the
  23538. 16:03:54entire implementation how we can add the
  23539. 16:03:55tools inside our aentic chatbot. So
  23540. 16:03:58guys, first of all, let's try to
  23541. 16:04:00understand the workflow. Uh after adding
  23542. 16:04:02this tool node inside our workflow, how
  23543. 16:04:05our workflow will look like and how it
  23544. 16:04:07will work. So as you can see uh this is
  23545. 16:04:10the first workflow we have created so
  23546. 16:04:12far. So this workflow has only one
  23547. 16:04:14particular node which is chat node. So
  23548. 16:04:16basically if user is giving any kinds of
  23549. 16:04:18uh input it is going it uh going to the
  23550. 16:04:21chat node and chat node is giving some
  23551. 16:04:23kinds of output and the right side you
  23552. 16:04:26can see this is the updated workflow uh
  23553. 16:04:28we'll be creating inside this video. Uh
  23554. 16:04:30basically we'll be adding our tools node
  23555. 16:04:33here. So as you can see this is the
  23556. 16:04:36updated workflow. So here uh you if user
  23557. 16:04:39gives any kinds of input uh it will go
  23558. 16:04:41to the chat node and here actually we'll
  23559. 16:04:44be using something called tool condition
  23560. 16:04:46function. Okay, there is a function
  23561. 16:04:48called tool condition function. So here
  23562. 16:04:50I have already written what is this tool
  23563. 16:04:52condition function. it uh function does
  23564. 16:04:54it's a uh tool condition. It's a uh
  23565. 16:04:56pre-built conditional age function that
  23566. 16:04:59helps your graph to decide should the
  23567. 16:05:02flow go to the tool node uh next or back
  23568. 16:05:06to the lm. Okay, that means whatever
  23569. 16:05:09input user is giving. Okay, let's say if
  23570. 16:05:11user is asking tell me about Python. So
  23571. 16:05:14I think you know that inside large
  23572. 16:05:16language model this information is
  23573. 16:05:17already available. So in this scenario
  23574. 16:05:19your agent doesn't need to call the
  23575. 16:05:21tool, right? It can only use this chat
  23576. 16:05:24node and give the response and the
  23577. 16:05:26response will go to the end directly.
  23578. 16:05:28Right? But if user is asking tell me the
  23579. 16:05:31latest news in AI in 2026. Okay. This
  23580. 16:05:35information is not available inside the
  23581. 16:05:37large language model knowledge base that
  23582. 16:05:40time your tool condition okay tool
  23583. 16:05:42condition function will decide okay now
  23584. 16:05:44it has to use some kinds of tool that
  23585. 16:05:46means this kinds of question will
  23586. 16:05:47redirect to the tool nodes. Okay. So
  23587. 16:05:50this is how this uh two condition works.
  23588. 16:05:52That's why you can see the definition.
  23589. 16:05:54So this uh two condition is a pre-built
  23590. 16:05:56conditional age function. Okay, I think
  23591. 16:05:58I already told you about conditional uh
  23592. 16:06:00conditional workflow. Okay, how
  23593. 16:06:02conditional workflow works. If you
  23594. 16:06:03haven't checked that, please try to
  23595. 16:06:04check my previous video. So conditional
  23596. 16:06:06ages function that helps your graph to
  23597. 16:06:08decide should the flow go to the tool
  23598. 16:06:10nodes. Okay, or back to the lm. Okay,
  23599. 16:06:13now I think you got it what will happen
  23600. 16:06:15here. Okay, now here we have added this
  23601. 16:06:18tool. So this tool we call it as a tool
  23602. 16:06:20nodes. Okay. Inside this graph this tool
  23603. 16:06:21is a call we call it as a tool nodes. So
  23604. 16:06:24tool nodes is also a pre-built node
  23605. 16:06:27inside langraph. Okay. So as you can see
  23606. 16:06:29in lang graph tool node is a pre-built
  23607. 16:06:31node type that acts as a bridge between
  23608. 16:06:34your graph and external tools. Okay.
  23609. 16:06:37That means inside tool nodes you can use
  23610. 16:06:39any kinds of function APIs utilities
  23611. 16:06:42etc. So as you can see normally in
  23612. 16:06:44langraph you would write a node function
  23613. 16:06:47yourself. Okay it takes a state and
  23614. 16:06:50return the state. So far we have written
  23615. 16:06:52like that. But a tool node is a readym
  23616. 16:06:55made node that knows how to handle a
  23617. 16:06:58list of lang tools. That means this tool
  23618. 16:07:01nodes you don't need to write
  23619. 16:07:02separately. Okay. This is already
  23620. 16:07:03pre-built inside langraph. You just need
  23621. 16:07:06to define that. Okay as a node and it
  23622. 16:07:08will automatically okay. it will
  23623. 16:07:09automatically handle uh like uh the list
  23624. 16:07:12of the tools you will be adding inside
  23625. 16:07:14this tool nodes. Okay. Then it uh its
  23626. 16:07:17job listen for tools calls from the LLM
  23627. 16:07:20like let's say user wants to search
  23628. 16:07:22something on the internet about the
  23629. 16:07:24latest information or let's say he or
  23630. 16:07:26she wants to get the weather
  23631. 16:07:27information. So automatically this uh uh
  23632. 16:07:30tools node will decide which tool to use
  23633. 16:07:32because it has the list of the tools.
  23634. 16:07:34Okay. automatically based on the input
  23635. 16:07:37user input it will decide which uh tool
  23636. 16:07:38to use and automatically route the
  23637. 16:07:41request to the correct tools okay that
  23638. 16:07:43means if user is asking about latest
  23639. 16:07:44information in AI it will be using
  23640. 16:07:46search tool let's say if user is using
  23641. 16:07:49uh if user wants to uh know about the
  23642. 16:07:51current weather okay so that time it
  23643. 16:07:54will redirect to the get weather tool
  23644. 16:07:55that's how it will route the request to
  23645. 16:07:58the correct tool then pass the tool's
  23646. 16:07:59output back to the graph okay so that's
  23647. 16:08:01how the system works okay that means
  23648. 16:08:04whenever you will pass any kinds of
  23649. 16:08:05input. First of all, this tools
  23650. 16:08:07condition will decide whether it has to
  23651. 16:08:09use the any tool or not or whether it
  23652. 16:08:11has to use the default large language
  23653. 16:08:13model to generate the response. Okay.
  23654. 16:08:15But if it needs any kinds of let's say
  23655. 16:08:17tool uh tool functionality that time it
  23656. 16:08:20will automatically route to these tool
  23657. 16:08:22nodes. Okay. And tool nodes will try to
  23658. 16:08:24decide which tool to use for what kinds
  23659. 16:08:27of uh input. Okay. Now I think you are
  23660. 16:08:29pretty much clear with this particular
  23661. 16:08:31workflow and this workflow we'll try to
  23662. 16:08:33develop inside our system. Okay. So for
  23663. 16:08:36this first of all uh I'm going to show
  23664. 16:08:38you a notebook experiment guys. We'll
  23665. 16:08:40try to write everything in a Jupyter
  23666. 16:08:41notebook. Uh we'll try to understand the
  23667. 16:08:44entire tools concept there. Then we'll
  23668. 16:08:46try to um integrate inside our agentic
  23669. 16:08:49chatbot we have created so far. So here
  23670. 16:08:51what I have done guys as you can see
  23671. 16:08:53left hand side I created a notebook
  23672. 16:08:55folder and inside that I already kept my
  23673. 16:08:57previous notebook. I showed you right so
  23674. 16:08:59this is the previous notebook I created
  23675. 16:09:01uh at the very first time right uh there
  23676. 16:09:03I showed you the chatbot workflow we
  23677. 16:09:05created this workflow and this was the
  23678. 16:09:07simple workflow so here I created
  23679. 16:09:09another notebook called tools demo now
  23680. 16:09:11if I open it up so you can see this is
  23681. 16:09:13the tools uh demo uh related code so
  23682. 16:09:16here uh basically I'm going to explain
  23683. 16:09:18this code like how we have to add these
  23684. 16:09:20tools inside our workflow and how we can
  23685. 16:09:24uh how we can uh practically test that
  23686. 16:09:25okay so once everything is working fine
  23687. 16:09:27then we'll try to integrate inside our
  23688. 16:09:29development and here I already added
  23689. 16:09:31that documentation the documentation I
  23690. 16:09:33showed you tools documentation if I
  23691. 16:09:34click here so this is the documentation
  23692. 16:09:36guys I already showed you this
  23693. 16:09:38documentation right so this
  23694. 16:09:39documentation reference I already given
  23695. 16:09:41in this particular notebook you can
  23696. 16:09:42refer it here now here first of all I'm
  23697. 16:09:44going to select my environment so let's
  23698. 16:09:46select my environment
  23699. 16:09:50so this is the environment now first of
  23700. 16:09:52all we'll import all the necessary
  23701. 16:09:54library so as you can see we are
  23702. 16:09:55importing um state graph of start end
  23703. 16:09:58from lang graph then type dict annotated
  23704. 16:10:00so these are the things are common I
  23705. 16:10:02think you are pretty much familiar with
  23706. 16:10:04this now base model human
  23707. 16:10:05[clears throat] masses and one thing
  23708. 16:10:07guys I have done uh actually my openi
  23709. 16:10:09API key is over okay u uh my limit is
  23710. 16:10:13over that's why I am using u like u
  23711. 16:10:17gemini model and if you want to use
  23712. 16:10:19gemini model so that time you can import
  23713. 16:10:21this library called chat google
  23714. 16:10:24generative AI from lang google ji Okay.
  23715. 16:10:27And for this you have to install one
  23716. 16:10:29library. So this is the library guys.
  23717. 16:10:31Langen Google generate. Okay. And this
  23718. 16:10:33specific version I have installed in my
  23719. 16:10:36uh uh in my environment. Okay. So again
  23720. 16:10:38you just need to open your environment
  23721. 16:10:40and just write pip install
  23722. 16:10:43r requirement.txt. Okay. If you do that
  23723. 16:10:46it will automatically install this uh
  23724. 16:10:48library inside your environment. So I
  23725. 16:10:50have already done that. So let me open
  23726. 16:10:51it up. So see this is the alternative
  23727. 16:10:53way to use uh any kinds of large
  23728. 16:10:55language model if you don't have open
  23729. 16:10:57API key or if your API key limit is over
  23730. 16:11:00that time you can use these are the
  23731. 16:11:01freeto use large language model okay uh
  23732. 16:11:04but if you want to use open API key guys
  23733. 16:11:06you can refer my previous notebook I
  23734. 16:11:08think in previous notebook I used the
  23735. 16:11:10open API key here I used this open AI
  23736. 16:11:13model okay chat open AI model only this
  23737. 16:11:15part you just need to change okay h uh
  23738. 16:11:19and one more thing you have to collect
  23739. 16:11:20which is uh uh like Gemini API key that
  23740. 16:11:22means Google API key and how you will
  23741. 16:11:24get this Google API key. So for this you
  23742. 16:11:27have to go to the uh Google
  23743. 16:11:31AI studio. Okay this particular website
  23744. 16:11:39and here you can click on get started.
  23745. 16:11:43Now left hand side you will see this API
  23746. 16:11:45key option get API key. I'll just click
  23747. 16:11:47on get API key. Now from here you just
  23748. 16:11:49need to create an API key. Okay, I
  23749. 16:11:50already created the API key. So I can
  23750. 16:11:52copy and I can simply paste it here.
  23751. 16:11:56Okay, so make sure you collect your own
  23752. 16:11:58API key guys. I'm going to remove my API
  23753. 16:12:00key after this recording. So don't use
  23754. 16:12:02my API key. Try to create your own API
  23755. 16:12:04key from here. Okay, once you have
  23756. 16:12:05created the API key, then you will be
  23757. 16:12:07able to execute this notebook. Then I'm
  23758. 16:12:10importing this uh add message from graph
  23759. 16:12:12itself. Then load env to load my
  23760. 16:12:14involvement variable. Then uh I'm
  23761. 16:12:16importing some other additional library
  23762. 16:12:18as you can see from langraph pre-built.
  23763. 16:12:20I'm importing this tool node. Okay, I
  23764. 16:12:21think I already told you about tool
  23765. 16:12:22nodes, right? So here in this demo I
  23766. 16:12:25told told you about the tool nodes. So
  23767. 16:12:27this tool nodes will uh basically help
  23768. 16:12:29you to
  23769. 16:12:31uh tool nodes will basically help you to
  23770. 16:12:34uh uh so yeah I think this is the tool
  23771. 16:12:36node. Yeah, tool node. So this
  23772. 16:12:37particular tool node. Okay, so this tool
  23773. 16:12:39node will help you to um define your
  23774. 16:12:41nodes. Okay, that means tool nodes and
  23775. 16:12:43you don't need to write this tool node
  23776. 16:12:45separately. This is already pre-built
  23777. 16:12:46inside Langraph. Okay, that's why we're
  23778. 16:12:48importing from pre-built. Then there is
  23779. 16:12:49another function called tool condition.
  23780. 16:12:51So this function I told you. So this
  23781. 16:12:53tool condition we also need to add as a
  23782. 16:12:55conditional ages. So basically this
  23783. 16:12:58function will decide whether it has to
  23784. 16:12:59use the tool or it has to use the simple
  23785. 16:13:01LM call. Okay. So this is also a
  23786. 16:13:03pre-built function inside langraph.
  23787. 16:13:05We'll be importing that. Then I need
  23788. 16:13:07this tab search. So tabularly search is
  23789. 16:13:09a internet search tool. With the help of
  23790. 16:13:11that you can perform the internet search
  23791. 16:13:13operation. Let's see if user is asking
  23792. 16:13:14any kinds of latest informations uh like
  23793. 16:13:16chat GPT I showed you. Okay. Previously
  23794. 16:13:18the demo I showed you if user is asking
  23795. 16:13:20about latest uh information um uh
  23796. 16:13:22anything which is let's say completely
  23797. 16:13:24latest and available over the internet.
  23798. 16:13:26So with the help of tably search we can
  23799. 16:13:28uh get this informations. Okay. And if
  23800. 16:13:31you're using tably search tool guys you
  23801. 16:13:33have to install uh these two library
  23802. 16:13:35lang tabi and tably python. Okay. So
  23803. 16:13:38these two library you have to install
  23804. 16:13:40and this is the specific version I'm
  23805. 16:13:42installing in this project. Now what you
  23806. 16:13:44have to do you just need to simply write
  23807. 16:13:47pip install hyphen
  23808. 16:13:54requirement.txt.
  23809. 16:13:55Okay. If you do that it will install all
  23810. 16:13:58of the necessary library inside your
  23811. 16:14:01okay inside your environment. Okay. So
  23812. 16:14:04these two libraries required if you're
  23813. 16:14:05using taberts tool then uh we'll be
  23814. 16:14:08importing these tools. Okay. Right now
  23815. 16:14:10we have to create the tools. Okay. And
  23816. 16:14:13whenever you want to create your custom
  23817. 16:14:15function okay let's say custom function
  23818. 16:14:17as a tool that time this tools has uh
  23819. 16:14:19has to be uh imported with the help of
  23820. 16:14:21this tool we'll be creating a decorator
  23821. 16:14:24and this decorator will be uh will be
  23822. 16:14:26represent my function as a tool okay
  23823. 16:14:28I'll show you this part how to do that
  23824. 16:14:30then request and math module okay so
  23825. 16:14:32these are the input you have to uh you
  23826. 16:14:35have to write inside your code
  23827. 16:14:38done right now first of all let me load
  23828. 16:14:40the environment variable so I have
  23829. 16:14:41loaded my environment variable model.
  23830. 16:14:42Okay. Now here I'm initializing my uh
  23831. 16:14:46model guys. So as you can see here I'm
  23832. 16:14:47initializing Germany 2.5 flash model and
  23833. 16:14:50this is the creativity parameter. I
  23834. 16:14:51think you already know about and this is
  23835. 16:14:53your LLM object. And if you want to use
  23836. 16:14:55OpenAI large language model here this is
  23837. 16:14:58very much simple only you just need to
  23838. 16:15:00write chat open AI. Okay. And if you
  23839. 16:15:02want to use Gemini model you have to use
  23840. 16:15:04this particular code. Okay. And if you
  23841. 16:15:07want to use any other provider as well
  23842. 16:15:09simply just try to change here. You can
  23843. 16:15:10go to the chat GP and you can ask okay I
  23844. 16:15:12want to use grock model let's say Grock
  23845. 16:15:14meta model or open uh I want to use open
  23846. 16:15:17router provider and I want to this this
  23847. 16:15:19model okay so this particular code will
  23848. 16:15:22uh change uh and you will get this code
  23849. 16:15:24from the charge or any kinds of
  23850. 16:15:25documentation you can change it anytime
  23851. 16:15:27here okay so this will my large language
  23852. 16:15:31model this will uh this will be my large
  23853. 16:15:33language model okay now we'll be
  23854. 16:15:34initializing the uh tably search okay so
  23855. 16:15:37tably search is a internet search tool I
  23856. 16:15:40already told you about right and to use
  23857. 16:15:42this tably search tool you need a API
  23858. 16:15:44key okay so for this what you have to do
  23859. 16:15:45you have to go to this tably website tab
  23860. 16:15:48you just need to write tab API key go to
  23861. 16:15:51the first website
  23862. 16:15:55and just try to uh continue with your
  23863. 16:15:58Google
  23864. 16:16:00okay so here you will be getting your
  23865. 16:16:01API key if you don't have API key try to
  23866. 16:16:04create from here so you just need to
  23867. 16:16:05create here give the name let's say I'll
  23868. 16:16:07give demo and simply create the API key.
  23869. 16:16:10Okay, once you have created just try to
  23870. 16:16:11copy this API key and
  23871. 16:16:15uh you have to place inside your
  23872. 16:16:16environment variable. So here you just
  23873. 16:16:18need to create another key called table
  23874. 16:16:20API key and here you just need to paste
  23875. 16:16:22your API key. That's it. Okay, I already
  23876. 16:16:24have my API key. I'm not going to change
  23877. 16:16:26it here.
  23878. 16:16:27Uh okay, so API key is also collected.
  23879. 16:16:30Now see this is our first
  23880. 16:16:33uh tools actually we have defined. So
  23881. 16:16:35tab is it's a like a tool inside like
  23882. 16:16:38aentic AI if you are creating against ai
  23883. 16:16:41project. So tab is a tool by default
  23884. 16:16:44it's a tool. So you don't need to give
  23885. 16:16:46this particular decorator sign. So you
  23886. 16:16:48just need to create an object of tably
  23887. 16:16:50search. So inside the tably search you
  23888. 16:16:52just need to give maximum result like
  23889. 16:16:54how many uh result you need whenever it
  23890. 16:16:57will search uh do the search operation.
  23891. 16:16:58Let's say it has searched for uh latest
  23892. 16:17:01AI news. Okay. in 2026 it will search
  23893. 16:17:05maximum in five website. Okay, five
  23894. 16:17:07website and it will give you the
  23895. 16:17:08response. Okay, I think previously I
  23896. 16:17:11showed you this part. I think I created
  23897. 16:17:12lang chain agent right there I showed
  23898. 16:17:14you how to use the tab search right. Uh
  23899. 16:17:17then topic topic basically I want to
  23900. 16:17:19search the general uh topic related
  23901. 16:17:21search operation and search depth
  23902. 16:17:23advance. Okay, so this kinds of
  23903. 16:17:25parameter you have to pass inside table
  23904. 16:17:27search and this will give you a search
  23905. 16:17:28tool object. Okay, and then you have to
  23906. 16:17:30create this object. So this will become
  23907. 16:17:32your first tool. Then the next tool guys
  23908. 16:17:35I have created here called calculator
  23909. 16:17:36tool. So you can see I have written a
  23910. 16:17:38custom function. So just try to ignore
  23911. 16:17:40this part. Let's say as of now I haven't
  23912. 16:17:42added this decorator. So let's say I'll
  23913. 16:17:44remove this decorator. First of all you
  23914. 16:17:46have to write a custom function. So see
  23915. 16:17:47this is the custom function I have
  23916. 16:17:48written. So here I'm using math module
  23917. 16:17:51and here I if you are passing any kinds
  23918. 16:17:53of expression right any kinds of
  23919. 16:17:54mathematical expression. So this
  23920. 16:17:56function will be able to calculate uh
  23921. 16:17:58that expression and it will give you the
  23922. 16:18:00result and if any exception is occurring
  23923. 16:18:02it will raise the exception. Now let's
  23924. 16:18:03if you want to uh create any kinds of
  23925. 16:18:06custom function as a tool only you just
  23926. 16:18:08need to give this particular decorator
  23927. 16:18:10this decorator add the red tool and this
  23928. 16:18:12tool we have already imported here as
  23929. 16:18:13you can see from langen course tools
  23930. 16:18:16tools. Okay now this will become a
  23931. 16:18:18tools. Okay now this will become a tool
  23932. 16:18:20object. Now you can use this tool inside
  23933. 16:18:22your agents. So this is super simple
  23934. 16:18:24guys. Okay. And this is very much
  23935. 16:18:26interesting. You can create any kinds of
  23936. 16:18:28uh like Python custom function and you
  23937. 16:18:30can convert it as a tool and you can use
  23938. 16:18:32it inside your AI agent. It's not like
  23939. 16:18:34that. Always you have to use the
  23940. 16:18:35predefined tools. Okay. It's not like
  23941. 16:18:37that because I I can write any kinds of
  23942. 16:18:40custom function okay for my work and
  23943. 16:18:42that has to be my tools. Okay. That has
  23944. 16:18:44to work with uh work work like my tools.
  23945. 16:18:47So I can do that. This kinds of
  23946. 16:18:48customization is also available inside
  23947. 16:18:50line graph. Now as you can see this is
  23948. 16:18:52my second tool calculator tool. Now the
  23949. 16:18:55third tool I created get stock price. So
  23950. 16:18:58let's say if you if user is asking about
  23951. 16:19:00any kind of stock price about Apple,
  23952. 16:19:02Tesla or Google whatever. So this uh
  23953. 16:19:05tool will be working that time and it
  23954. 16:19:07will give me real time stock data. Okay.
  23955. 16:19:10So as you can see again I written a
  23956. 16:19:11custom function. So this will basically
  23957. 16:19:13take any kinds of company name uh
  23958. 16:19:15example Apple, Tesla or whatever. And
  23959. 16:19:18here I'm using a website. As you can see
  23960. 16:19:20this is the website alphavantage.co.
  23961. 16:19:24Okay, this is the website. So in this
  23962. 16:19:26website basically uh this is the uh API
  23963. 16:19:30endpoint of this website and to hit this
  23964. 16:19:32API endpoint I you need a API key. Okay,
  23965. 16:19:34so let me show you this website first of
  23966. 16:19:36all. So this is the website guys. So
  23967. 16:19:39this website has all of the stock
  23968. 16:19:41related realtime data. Okay. Restock
  23969. 16:19:43market data uh stock market data API for
  23970. 16:19:46LM uh and u LLM and any other let's say
  23971. 16:19:52uh uh application you are implementing.
  23972. 16:19:54Okay. So here basically you just need to
  23973. 16:19:56collect an API key. So to collect the
  23974. 16:19:58API key so there is a option get free
  23975. 16:20:00API key. I'll click here.
  23976. 16:20:03Now you just need to give your
  23977. 16:20:04organization name. Let's say I'll give
  23978. 16:20:05DS with BP. And you just need to also
  23979. 16:20:07pass your email. Let's say I'll pass my
  23980. 16:20:09email. And once it is done just try to
  23981. 16:20:11click on get free API key. Okay. So this
  23982. 16:20:13is your API key. Just try to copy that
  23983. 16:20:18and don't share this API key guys and
  23984. 16:20:21try to use your API key on API key.
  23985. 16:20:23Okay. And here you just need to paste
  23986. 16:20:24this API key. Okay. Now this will become
  23987. 16:20:27your this will become your
  23988. 16:20:30um
  23989. 16:20:33API endpoint.
  23990. 16:20:37See now here you just need to pass a
  23991. 16:20:39symbol only. Let's say I'll give
  23992. 16:20:47apple.
  23993. 16:20:49Um okay u
  23994. 16:20:56I'll pass like that.
  23995. 16:21:04See now this is giving you this stock
  23996. 16:21:07data related apple okay real time you
  23997. 16:21:09are getting a JSON response so that's
  23998. 16:21:11how we are using this uh uh website guys
  23999. 16:21:13that's how we are using this API and to
  24000. 16:21:16hit this API endpoint I'm using request
  24001. 16:21:18module inside Python we are passing this
  24002. 16:21:20URL and it is giving you the result some
  24003. 16:21:22response and we are returning that okay
  24004. 16:21:24to the LLM so this is our next tool I
  24005. 16:21:27have used here so in this uh like demo
  24006. 16:21:30Now guys, I only use three tools. You
  24007. 16:21:32can add uh like more tools here if you
  24008. 16:21:34want. You can add like get current
  24009. 16:21:36weather informations. You can add uh
  24010. 16:21:38let's say um emailing tool. You can add
  24011. 16:21:41let's say Google drive tool. Any kinds
  24012. 16:21:43of tool you can add. All you just need
  24013. 16:21:44to go to the chart GPT and ask like okay
  24014. 16:21:46I need to use this tool. Uh how to write
  24015. 16:21:49that particular function? This is a
  24016. 16:21:50simple Python function you need to
  24017. 16:21:51write. Okay. So just for uh just to show
  24018. 16:21:54you guys I used only three tools in this
  24019. 16:21:56particular project. uh but you can add
  24020. 16:21:59you can feel free to add more tools here
  24021. 16:22:01okay anytime let's say uh let me show
  24022. 16:22:03you another example let's say if I go to
  24023. 16:22:04the chart GPT and if I let's say ask I
  24024. 16:22:08want to
  24025. 16:22:13add a tool in
  24026. 16:22:17my agent
  24027. 16:22:19that will
  24028. 16:22:22fetch
  24029. 16:22:24weather
  24030. 16:22:29or given location
  24031. 16:22:34real time.
  24032. 16:22:38Give me a Python
  24033. 16:22:42function.
  24034. 16:22:50So see this is the get current weather
  24035. 16:22:52tool.
  24036. 16:22:59Okay. Now simply you just need to copy
  24037. 16:23:01this code
  24038. 16:23:04and here it is telling what to install
  24039. 16:23:06here. Okay. And uh it is telling uh this
  24040. 16:23:09uh API key you also need because it is
  24041. 16:23:11using open weather API I think. So let
  24042. 16:23:14me copy this function as it is uh just
  24043. 16:23:17I'm I'm showing you okay how to add uh
  24044. 16:23:19different different tools. Okay. You can
  24045. 16:23:20take the help from chart GPT anytime and
  24046. 16:23:23you can create this kinds of custom
  24047. 16:23:24function. So let's say here I'm going to
  24048. 16:23:26add another tool.
  24049. 16:23:28This is my tool.
  24050. 16:23:33Okay. Get current weather tool. It will
  24051. 16:23:35take a location and based on the
  24052. 16:23:37location actually it will u uh give you
  24053. 16:23:40the realtime information. So here I need
  24054. 16:23:42to import this operating system library
  24055. 16:23:46import OS
  24056. 16:23:54H. So and it needs an API key. Okay,
  24057. 16:23:58open weather API key. So how you will
  24058. 16:24:00get this open weather API key? You can
  24059. 16:24:03copy this key and search on Google. So
  24060. 16:24:06this is the weather API.
  24061. 16:24:10Get API key. So this is the website guys
  24062. 16:24:12it is using get API key.
  24063. 16:24:15Now you just need to first of all sign
  24064. 16:24:17in I think
  24065. 16:24:28first of all I'll create an account.
  24066. 16:24:30Okay. I think I don't have any account.
  24067. 16:24:49I'll give the password.
  24068. 16:25:01I'll confirm all of these
  24069. 16:25:04things and let's create the account.
  24070. 16:25:11Okay, email is already taken. Uh okay,
  24071. 16:25:13previously I think I already used this
  24072. 16:25:15email. So let me sign in and see whether
  24073. 16:25:18it's working or not.
  24074. 16:25:30Okay guys, let me login. I think I don't
  24075. 16:25:32I am having some issue. First of all,
  24076. 16:25:34let me login with this website.
  24077. 16:25:37So guys, as you can see, I have
  24078. 16:25:39successfully signed up uh in this
  24079. 16:25:41website. Uh basically, I I forget my
  24080. 16:25:44password. Okay. And now I changed my
  24081. 16:25:46password and now I'm able to uh visit
  24082. 16:25:48this website. Okay. First of all, you
  24083. 16:25:49just need to create an account here.
  24084. 16:25:51Then once you have done uh here you will
  24085. 16:25:53see one option called API key and here
  24086. 16:25:55is your API key. Okay. So you just need
  24087. 16:25:58to
  24088. 16:26:00um create an API key. Let's create an
  24089. 16:26:03API key. I'll give the name let's say
  24090. 16:26:05agent
  24091. 16:26:07generate.
  24092. 16:26:10Uh this is your API key. Let's copy
  24093. 16:26:12that.
  24094. 16:26:16And uh here you have to write it inside
  24095. 16:26:19your environment variable
  24096. 16:26:27and this should be the key name.
  24097. 16:26:36Okay, open weather API. So that's how
  24098. 16:26:38you can collect the API and now it will
  24099. 16:26:40work.
  24100. 16:26:42So I will re-execute from the beginning.
  24101. 16:26:52So here I have added another function
  24102. 16:26:54that will basically fetch the real-time
  24103. 16:26:56weather information.
  24104. 16:27:04Then uh here what you have to do guys
  24105. 16:27:07you have to make a tool list. So here
  24106. 16:27:09you just need to pass all of the object
  24107. 16:27:11one by one. First of all, uh I created
  24108. 16:27:14search tool, right?
  24109. 16:27:16So I'll give the search tool.
  24110. 16:27:19Then I created calculator.
  24111. 16:27:25Okay, calculator.
  24112. 16:27:28Then I created get stock price. Then
  24113. 16:27:31uh I created this uh current weather.
  24114. 16:27:40this function I'll pass here.
  24115. 16:27:43Okay. So that's how uh let's say
  24116. 16:27:46whatever tools you are creating you you
  24117. 16:27:47just need to make a tools list. Okay.
  24118. 16:27:49You have to give one by one. All the
  24119. 16:27:51tool list you have to give one by one.
  24120. 16:27:52Okay. Just try to remember. Let's say
  24121. 16:27:54you are creating 10 different tools you
  24122. 16:27:55have to give 10 different list here.
  24123. 16:27:57Once it is done you have to uh do the
  24124. 16:28:01bind operation with your LM. That means
  24125. 16:28:03you just need to uh tell your LM. Okay.
  24126. 16:28:05Now you have the tool. So that's why I'm
  24127. 16:28:08not going to use the simple LM right
  24128. 16:28:09now. Uh so the LLM object we have
  24129. 16:28:11created this completely fine.
  24130. 16:28:14This is completely fine. Okay. Now we
  24131. 16:28:16just need to bind this tool with the
  24132. 16:28:18LLM. So here there is a function called
  24133. 16:28:20bind tools and inside that you have to
  24134. 16:28:22pass all of the list of the tools. And
  24135. 16:28:24now you'll be using this object lm with
  24136. 16:28:26tools. Okay. Now let's bind that tool.
  24137. 16:28:28Then now we are defining the state. I
  24138. 16:28:30think the same state you remember we
  24139. 16:28:32created previously this state. No
  24140. 16:28:34change. Let's define that. Now this is
  24141. 16:28:37our chat node guys. I think you remember
  24142. 16:28:38we created this chat node. And here we
  24143. 16:28:41need to create another additional node
  24144. 16:28:43called tool nodes. Okay, I told you
  24145. 16:28:45about this tool nodes right in this my
  24146. 16:28:48uh excalator file. You can see this is
  24147. 16:28:49the node. Additionally, we are adding
  24148. 16:28:51this particular node and this is a
  24149. 16:28:52predefined node. Okay, you don't need to
  24150. 16:28:54separately write that. So here we are
  24151. 16:28:56using this tool node function. I think
  24152. 16:28:58we have imported this tool node and
  24153. 16:29:01inside that we are passing the tool.
  24154. 16:29:04Okay, tools list of the tools we have
  24155. 16:29:06and this will become your tool nodes.
  24156. 16:29:07Let's define both of the nodes. Now,
  24157. 16:29:10once it is done guys, now we'll try to
  24158. 16:29:12create the graph. Now we are using uh
  24159. 16:29:14state graph and we are passing the
  24160. 16:29:15state. Now we are adding the nodes. The
  24161. 16:29:17first node we are adding which is chat
  24162. 16:29:19node. Okay, we are adding the chat node
  24163. 16:29:21as you can see. Then the second node we
  24164. 16:29:23are adding the tool node. You can see
  24165. 16:29:25the tool node. Okay, we are adding this
  24166. 16:29:26tool node. So both node we have added.
  24167. 16:29:29Now we have to the age connection. Now
  24168. 16:29:31how my age connection will look like.
  24169. 16:29:34As you can see first of all start to
  24170. 16:29:36chat node. So start to chat node then
  24171. 16:29:40chat node itself will have a conditional
  24172. 16:29:42edges with the tool condition. I think
  24173. 16:29:44okay I think I told you about this one
  24174. 16:29:46chat node will have a two condition.
  24175. 16:29:48Okay edge connection. Basically this
  24176. 16:29:50tool condition will decide whether it
  24177. 16:29:52has to call the tool or whe whether it
  24178. 16:29:54has to use the default large language
  24179. 16:29:55model. So that's why this connection
  24180. 16:29:57would like uh will look like that. So
  24181. 16:29:59you will be using add additional
  24182. 16:30:00conditional edges and from chat node to
  24183. 16:30:03tool condition. Okay. Now this tool
  24184. 16:30:05condition will decide whether it has to
  24185. 16:30:06use any kinds of tools or not. Okay.
  24186. 16:30:08Then here you just need to write another
  24187. 16:30:10age connection tools to chat node. Okay.
  24188. 16:30:12Why you have to write this one? Let me
  24189. 16:30:14show you. If I let's say don't give this
  24190. 16:30:16line. Let's say I'll comment this line.
  24191. 16:30:19So what will happen? Let's try to see.
  24192. 16:30:21Let's say I have uh added my chat node
  24193. 16:30:25and tool condition. Now if I show you
  24194. 16:30:28compile and show you my graph. So that's
  24195. 16:30:30how my graph looks like. Okay. And this
  24196. 16:30:32is similar to this particular graph.
  24197. 16:30:33Okay. And one thing I think you have
  24198. 16:30:35observed here I'm not using the simple
  24199. 16:30:37LLM. Okay. Right now I'm using LLM with
  24200. 16:30:40tools. So that means this object because
  24201. 16:30:42here I did the bind operation with my
  24202. 16:30:44tools. Okay. So make sure you add this
  24203. 16:30:46line otherwise it will not work. Okay.
  24204. 16:30:48So many people uh do this mistake. So
  24205. 16:30:50basically they use the simple LLM and uh
  24206. 16:30:53they they feel like okay it is not using
  24207. 16:30:56the tool. So that's why this object has
  24208. 16:30:57to be called here. Now let me show you
  24209. 16:31:00my execution.
  24210. 16:31:02So now uh here we are giving a message.
  24211. 16:31:04So first of all I'm giving hello and you
  24212. 16:31:07know like uh uh for the hello actually
  24213. 16:31:09it doesn't need any kinds of tool right.
  24214. 16:31:11So this will my regular chat.
  24215. 16:31:14So it is telling hello how I can uh help
  24216. 16:31:16you today. Now here I'm asking another
  24217. 16:31:19question. Let's say what is uh uh this
  24218. 16:31:21particular expression. Okay. uh what
  24219. 16:31:23would be the result of this expression
  24220. 16:31:25mathematical expression and now it will
  24221. 16:31:27use the tool okay because it has the
  24222. 16:31:29calculator tool I think you know so
  24223. 16:31:31previously we created the calculator
  24224. 16:31:32tool so this is the calculator tool
  24225. 16:31:36right it will uh use that particular
  24226. 16:31:38tool let's execute
  24227. 16:31:44see this is the result it has given me
  24228. 16:31:47okay now here I will ask another
  24229. 16:31:49question what is the new movie released
  24230. 16:31:50in 2026 now again it will use the tool
  24231. 16:31:59see new movie released in 2026
  24232. 16:32:03and all of the URL it has also given it
  24233. 16:32:05has referred see this is the different
  24234. 16:32:07different website uh my tool has
  24235. 16:32:09referred that means I'm using tably
  24236. 16:32:12search tool right and it has so my tably
  24237. 16:32:15tool uh did the internet search
  24238. 16:32:16operation and it found the latest movies
  24239. 16:32:18okay as you can see and it has given me
  24240. 16:32:21all of the title of the latest movies as
  24241. 16:32:23you can see. Okay. See, but here the
  24242. 16:32:26output we are seeing. See this output is
  24243. 16:32:28not properly readable. Uh this output
  24244. 16:32:31has also some metadata information.
  24245. 16:32:33Okay. So if I give this kinds of output
  24246. 16:32:35to the user, so user will confuse okay
  24247. 16:32:37what to read. So that's why uh I have to
  24248. 16:32:40pass this output to the agent again.
  24249. 16:32:43That's why I told you in my file itself.
  24250. 16:32:49Okay. So you can see uh our tools listen
  24251. 16:32:53for the uh uh tool calls okay and once
  24252. 16:32:56let's say it perform any kinds of tool
  24253. 16:32:57calls uh then it automatically route to
  24254. 16:33:00that particular correct tool then pass
  24255. 16:33:02the tools output back to the graph okay
  24256. 16:33:04why it has to pass this output back to
  24257. 16:33:06the graph because of that because this
  24258. 16:33:08output is not readable so again what I
  24259. 16:33:10will do this output I'll try to pass to
  24260. 16:33:12the the output we are getting see right
  24261. 16:33:14now this is our architecture so whatever
  24262. 16:33:17output we are getting from the tools it
  24263. 16:33:18is getting ended Okay, now we have to
  24264. 16:33:21again give this output output to the
  24265. 16:33:23chat node. Okay, if I pass this output
  24266. 16:33:25to the chat node, chat node will try to
  24267. 16:33:27refine this output and it will generate
  24268. 16:33:29a readable output for me. Okay, so
  24269. 16:33:31that's why I have to do little
  24270. 16:33:32modification inside my architecture. So
  24271. 16:33:34let me show you. So here uh I'll just
  24272. 16:33:38try to add this line. Okay, basically
  24273. 16:33:40the tools output you are getting okay,
  24274. 16:33:43you are again sending to the chat node.
  24275. 16:33:45Okay, this is the modification you only
  24276. 16:33:47only just need to do. Now let me again
  24277. 16:33:49execute. Uh okay. So I have to execute
  24278. 16:33:53from the beginning.
  24279. 16:34:00Now that's how your structure will look
  24280. 16:34:02like. See right now we are not returning
  24281. 16:34:05the tools output. Instead of that the
  24282. 16:34:07tools output we are getting we are again
  24283. 16:34:08sending to the chat node. Okay. And chat
  24284. 16:34:11node will refine the output and it will
  24285. 16:34:12go to the end node. Now let me show you
  24286. 16:34:14my output.
  24287. 16:34:18Now see again uh this will this is using
  24288. 16:34:20tool
  24289. 16:34:29see now see the result guys okay see the
  24290. 16:34:33uh response previously it was only
  24291. 16:34:35giving this number but right now this
  24292. 16:34:37giving the result of this equation is
  24293. 16:34:39this this is more readable right because
  24294. 16:34:42right now the output we are getting from
  24295. 16:34:43the tools we again passing to the chat
  24296. 16:34:45node and chat node is doing the
  24297. 16:34:47refinement. Now here I'm asking what is
  24298. 16:34:49the new movies released in 2026. Okay.
  24299. 16:34:51Now if I send this prompt
  24300. 16:34:57so this is the response I'm getting.
  24301. 16:34:58Here are some new movies release
  24302. 16:35:00scheduled uh for this date. Okay. And
  24303. 16:35:02you can see all of the movie it has
  24304. 16:35:04given me. Uh again this is a list. Okay.
  24305. 16:35:06Uh so what I can do I can get the
  24306. 16:35:11um
  24307. 16:35:14get the output.
  24308. 16:35:19Now I just need to get this text.
  24309. 16:35:25Now see that's how you can extract the
  24310. 16:35:28final result. Now see this is more
  24311. 16:35:29readable. Okay this is more readable.
  24312. 16:35:33I hope you get it guys. Okay. Now let me
  24313. 16:35:34show you another question. Uh first find
  24314. 16:35:37out the stock price of Apple using get
  24315. 16:35:39stock price tool. Then uh use the
  24316. 16:35:41calculator tool to find how much it will
  24317. 16:35:44take to purchase
  24318. 16:35:46uh 50 shares. Okay. Now these kinds of
  24319. 16:35:48question I'm asking. Let's see whether
  24320. 16:35:49it is able to use my tool or not.
  24321. 16:35:54Now see again I'm getting the result and
  24322. 16:35:58if you want to get the text you can
  24323. 16:36:01extract from here.
  24324. 16:36:04Okay, the stock price of AF is that much
  24325. 16:36:06and to purchase 50 uh 50 shares it would
  24326. 16:36:09cost around that that much of money. So,
  24327. 16:36:13okay, now I think you saw it is able to
  24328. 16:36:15use the tools right now and this is not
  24329. 16:36:17a simple chatbot. Okay, this has the
  24330. 16:36:19tool connection. It can perform any
  24331. 16:36:20kinds of action. Even you can also ask
  24332. 16:36:23about the realtime uh weather
  24333. 16:36:24information. Let me also ask
  24334. 16:36:32what is the current weather in let's say
  24335. 16:36:35New York.
  24336. 16:36:43The kind of weather in New York. Uh New
  24337. 16:36:45York is moderate rain with the
  24338. 16:36:47temperature that uh this is the
  24339. 16:36:50temperature and feeling like uh uh see
  24340. 16:36:53this is the temperature uh humidity and
  24341. 16:36:56the pressure. Okay. Each and everything
  24342. 16:36:59it is giving you. Okay. So yeah guys our
  24343. 16:37:03uh system is working perfectly.
  24344. 16:37:05Now we'll be um integrating inside our
  24345. 16:37:08agentic chatbot. This is the complete
  24346. 16:37:09notebook experiment I showed you and you
  24347. 16:37:12have already understood the concept.
  24348. 16:37:13Okay. Uh how to add the tools and uh I
  24349. 16:37:16mean how to add the tools and how we can
  24350. 16:37:18write our custom tools as well. Each and
  24351. 16:37:20everything I showed you. So guys, now
  24352. 16:37:22we'll try to add inside our project. So
  24353. 16:37:24here what I can do uh I can simply
  24354. 16:37:28create a separate file so that you can
  24355. 16:37:31refer all of the previous code as well.
  24356. 16:37:33So I'm going to create a
  24357. 16:37:37file here.
  24358. 16:37:45I'm going to name it as let's say
  24359. 16:37:52this name
  24360. 16:37:54agentic chatbot
  24361. 16:37:56tool back end.py
  24362. 16:38:01file.
  24363. 16:38:05Okay.
  24364. 16:38:06And inside that I'm going to copy all of
  24365. 16:38:08my backend code I had.
  24366. 16:38:11Okay. The same code you just need to
  24367. 16:38:13copy paste here. Same code.
  24368. 16:38:19H. And here I'll do the modification.
  24369. 16:38:22And again uh I just uh uh finished my
  24370. 16:38:25open API key limit. That's why I'm using
  24371. 16:38:28this uh Gemini model. Okay. But if you
  24372. 16:38:31have your open API key, you can
  24373. 16:38:32uncomment this line and comment this
  24374. 16:38:33line. Okay. So, alternative approach I
  24375. 16:38:35showed you here. So now here I'm going
  24376. 16:38:38to first of all import all of the
  24377. 16:38:39necessary library from my notebook.
  24378. 16:38:45Just import all of this necessary
  24379. 16:38:47library.
  24380. 16:38:50Okay. After that we are loading the
  24381. 16:38:53environment variable. It's completely
  24382. 16:38:54fine. Then if you have open AP you can
  24383. 16:38:57unccomment this. that I don't have. I'll
  24384. 16:38:59be using Gemini model. So once uh model
  24385. 16:39:02uh initialization is done. So let me
  24386. 16:39:04comment also so that
  24387. 16:39:07it would be easy for you to remember. So
  24388. 16:39:09this is the LLM definition. Now we'll
  24389. 16:39:11try to define the tools. Okay. So here
  24390. 16:39:13we'll try to define all of the tool. The
  24391. 16:39:15tools we have created here. Okay. All of
  24392. 16:39:17the tools we'll try to define here. So
  24393. 16:39:19let's copy all of the tools.
  24394. 16:39:25So here I copy pasted all of the tools.
  24395. 16:39:27So first tools I had my search tool tab
  24396. 16:39:29search tool. Second tool I had my
  24397. 16:39:31calculated tool. Third tool I had my
  24398. 16:39:33stock price and the fourth tool I
  24399. 16:39:35created this weather.
  24400. 16:39:38I'll also copy this one.
  24401. 16:39:48Copy and
  24402. 16:39:52paste it here.
  24403. 16:40:05Okay, some error is coming.
  24404. 16:40:10Uh, okay. Now it is solved. Uh, the
  24405. 16:40:13problem was that I just copied till
  24406. 16:40:14here. Okay. Uh, the last part was uh not
  24407. 16:40:17copied. Uh, now I think this is fine.
  24408. 16:40:20Okay, now this is fine. But here I have
  24409. 16:40:22to import another uh things which is
  24410. 16:40:24this
  24411. 16:40:27any. Okay. So any and ways
  24412. 16:40:35import
  24413. 16:40:50now from typing I will import this any.
  24414. 16:40:57So in the tools also I have to do the
  24415. 16:41:00same thing.
  24416. 16:41:04Fine. Now uh I think everything is good.
  24417. 16:41:06Uh this is my calculator. This is my get
  24418. 16:41:09stock. This is my current weather tool.
  24419. 16:41:14And this is my chart state.
  24420. 16:41:17This is my chat state. So here let me
  24421. 16:41:19comment.
  24422. 16:41:23This is my chat state. Now I'll define
  24423. 16:41:25my nodes.
  24424. 16:41:28same notes only. Okay, one more thing I
  24425. 16:41:31just forget to do. I just need to do the
  24426. 16:41:34tool bind operation. I think you
  24427. 16:41:36remember
  24428. 16:41:38here. We just need to bind this tool.
  24429. 16:41:39Let's do that.
  24430. 16:41:45So before initializing the state, I will
  24431. 16:41:47just bind this tool. Let me comment
  24432. 16:41:49here. Bind tools to lm. Now the state
  24433. 16:41:54definition is also done. Now I'll define
  24434. 16:41:56my chat nodes.
  24435. 16:41:58So this is the chat node and the change
  24436. 16:42:01I have done instead of calling the uh
  24437. 16:42:04simple llm I'm calling llm with tools.
  24438. 16:42:07Okay, this object
  24439. 16:42:09now I'll define my second node which is
  24440. 16:42:11tool node.
  24441. 16:42:14Okay, tool node. So I think remember
  24442. 16:42:16here also I did the same thing
  24443. 16:42:20tool nodes. Okay.
  24444. 16:42:22Now uh this this is my uh connector that
  24445. 16:42:25means my checkp pointer for the
  24446. 16:42:27persistence memory checkp pointer.
  24447. 16:42:32Uh this part I already taught you. Okay.
  24448. 16:42:33Um this is common for all. Now we'll try
  24449. 16:42:36to define the graph.
  24450. 16:42:44Okay. We'll try to define the graph. So
  24451. 16:42:46as you can see this is our graph. If we
  24452. 16:42:48are adding the nodes where this is the
  24453. 16:42:49edge connection we are using the tools
  24454. 16:42:51condition and at the last we are just
  24455. 16:42:54doing this uh this uh edge connection as
  24456. 16:42:56well that means whatever tool output
  24457. 16:42:58we'll be getting we'll try to send it to
  24458. 16:42:59the chat node that means in the same
  24459. 16:43:01tools demo.ip IP 1B file I showed you
  24460. 16:43:03the same thing okay I just copy pasted
  24461. 16:43:05the code only okay nothing change the
  24462. 16:43:07same code I copy pasted that's it once
  24463. 16:43:09it is done I think this function you
  24464. 16:43:11remember this is the helper function for
  24465. 16:43:13this streamlend
  24466. 16:43:15we used okay uh this that means uh with
  24467. 16:43:18this function we are getting the traits
  24468. 16:43:19okay for this streaml we created I think
  24469. 16:43:21in my previous video I think remember so
  24470. 16:43:23yes guys this is the modification we
  24471. 16:43:24have to do in the back endpy
  24472. 16:43:28now uh everything is fine I think let me
  24473. 16:43:31check
  24474. 16:43:33H everything is fine now we are ready to
  24475. 16:43:36uh test inside our front end as well so
  24476. 16:43:38now I'll just write another front end
  24477. 16:43:40file
  24478. 16:43:42so here I'll copy this file as it is
  24479. 16:43:46and the last file was the DB right
  24480. 16:43:52yeah last file was the DB so I'll just
  24481. 16:43:55copy and paste it
  24482. 16:43:58and I'll just rename it
  24483. 16:44:05app tool.py.
  24484. 16:44:12Okay. So, it has the DB with tools uh
  24485. 16:44:15tools code as well. Okay. Now, here the
  24486. 16:44:18change you just need to do which is um
  24487. 16:44:25yeah if you don't change it's completely
  24488. 16:44:27fine. You can use it as it is. Okay. uh
  24489. 16:44:29there won't be any kinds of problem but
  24490. 16:44:31one uh I think UI update you won't be
  24491. 16:44:33able to see I think at uh whenever I
  24492. 16:44:36show you my application for the first
  24493. 16:44:38time right as a demo that time you saw
  24494. 16:44:40whenever I was executing my agent it was
  24495. 16:44:42showing it is using some kinds of tool
  24496. 16:44:44okay see right now if I uh ex execute my
  24497. 16:44:47app so what will happen let me show you
  24498. 16:44:48first of all okay one more uh just
  24499. 16:44:51modification you have to do uh this
  24500. 16:44:53import okay uh previously I'm importing
  24501. 16:44:55from agentic chatbot DB back end now I
  24502. 16:44:57have to import from agentic
  24503. 16:45:00chatbot tool back end. Okay,
  24504. 16:45:03so this update only and make sure you
  24505. 16:45:07have your
  24506. 16:45:08uh langismith
  24507. 16:45:10uh langismith uh environment variable
  24508. 16:45:12that means uh the langismith API key and
  24509. 16:45:15everything because uh it will trace
  24510. 16:45:17everything in the langismith. Let me
  24511. 16:45:18open my langismith platform.
  24512. 16:45:29And uh let me execute uh completely
  24513. 16:45:33fresh. So what I can do I can delete
  24514. 16:45:35this one.
  24515. 16:45:40I can delete this project and let me
  24516. 16:45:42execute completely fresh.
  24517. 16:45:47And now I will execute my app
  24518. 16:45:51my app tool.py. Okay, this file
  24519. 16:46:00stream
  24520. 16:46:02let run
  24521. 16:46:06app
  24522. 16:46:08tool.py Fine.
  24523. 16:46:18Now this is our chatbot. Now let's give
  24524. 16:46:22the prompt. I'll give hello.
  24525. 16:46:28See it's working. Now I'll give um tell
  24526. 16:46:31me the latest news in AI
  24527. 16:46:44see right now you are getting the output
  24528. 16:46:46like that but you didn't see it is using
  24529. 16:46:49the tool okay which tool it is using but
  24530. 16:46:51previously in the demo itself you saw it
  24531. 16:46:53is using some kinds of tool even in the
  24532. 16:46:54chart also if you're asking you will be
  24533. 16:46:57able to uh see some tool calling. Okay,
  24534. 16:46:59some tool calling is happening, right?
  24535. 16:47:01So let's say if I ask the same question
  24536. 16:47:03in
  24537. 16:47:04chart JPT, you'll see some kinds of tool
  24538. 16:47:08calling is happening. See here, it will
  24539. 16:47:10tell like okay, I'll search for the
  24540. 16:47:12internet. See searching for the
  24541. 16:47:14internet. It is using some kinds of
  24542. 16:47:15search tool. So I want to also see this
  24543. 16:47:17kinds of uh interface. Uh whenever my
  24544. 16:47:20agent is using the tool, I'll be able to
  24545. 16:47:22see that okay, this is using some kinds
  24546. 16:47:24of tool. Okay. So if you want to see
  24547. 16:47:26that you just need to do little bit UI
  24548. 16:47:28update. So in the streamllet app you
  24549. 16:47:30just need to do some little bit
  24550. 16:47:31modification. So here uh itself you just
  24551. 16:47:35need to do the modification. Let me show
  24552. 16:47:36you.
  24553. 16:47:38H So here you just need [clears throat]
  24554. 16:47:39to do the modification whenever you are
  24555. 16:47:42uh sending the user input right and
  24556. 16:47:43whenever you are uh just hitting the uh
  24557. 16:47:46agent that means here here you just need
  24558. 16:47:48to do the modification. So what I have
  24559. 16:47:50done guys, I just given this code to the
  24560. 16:47:52chart GPT and I asked I just need to see
  24561. 16:47:55this uh tool progress uh tool progress
  24562. 16:47:58on my user interface whenever it will
  24563. 16:48:00use any kinds of tool just try to do the
  24564. 16:48:02UI update. So then again chart GPT given
  24565. 16:48:05me this code. Let me show you
  24566. 16:48:11GPT given me this particular code.
  24567. 16:48:18So from here
  24568. 16:48:21um everything needs to be changed
  24569. 16:48:25this part.
  24570. 16:48:28So this is the update uh chat GP given
  24571. 16:48:30me guys. So right now uh basically it
  24572. 16:48:33will automatically understand whenever
  24573. 16:48:35it will uh use any kinds of tool that
  24574. 16:48:38time you will able to see in the user
  24575. 16:48:39interface. Okay. So this code you don't
  24576. 16:48:41need to remember guys. uh you have charg
  24577. 16:48:43you have gemini anytime you can do the
  24578. 16:48:45modification inside at the UI interface
  24579. 16:48:47because this functionality is completely
  24580. 16:48:49user interface uh let's say update okay
  24581. 16:48:52so as a aenti engineer this is not your
  24582. 16:48:54task there are some front- end developer
  24583. 16:48:57they will take care this part okay I
  24584. 16:48:59need to import one tool uh things which
  24585. 16:49:01is tool messes
  24586. 16:49:03uh here only tool masses okay that's it
  24587. 16:49:06now this is the updated code now if I
  24588. 16:49:10execute this code let me show show you
  24589. 16:49:12what will happen. So I'll reexecute my
  24590. 16:49:14app.
  24591. 16:49:20Now if I ask the same question, tell me
  24592. 16:49:24tell me
  24593. 16:49:27the latest news in
  24594. 16:49:32here.
  24595. 16:49:34Now you will see that it will be using
  24596. 16:49:37some kinds of tool.
  24597. 16:49:39Now see it is using tably search tool
  24598. 16:49:41and it is uh doing the realtime search
  24599. 16:49:43operation and the response it is uh
  24600. 16:49:46generating it is again giving to the
  24601. 16:49:48chat nodes and chat node is refining the
  24602. 16:49:51output. Okay, now you are able to see
  24603. 16:49:53the okay uh refinement result and you
  24604. 16:49:58can also see the tool execution that
  24605. 16:50:00means in the behind the tool what is exe
  24606. 16:50:02what the execution is happening this is
  24607. 16:50:04also available okay like charg
  24608. 16:50:07you can also see the uh behind execution
  24609. 16:50:09process like what the website it has
  24610. 16:50:11referred and everything you will be able
  24611. 16:50:13to also see here okay this also possible
  24612. 16:50:16now let me ask another question I'll
  24613. 16:50:18tell um
  24614. 16:50:22calculate
  24615. 16:50:30this number.
  24616. 16:50:32Now you'll see that it will use my
  24617. 16:50:33calculator tool.
  24618. 16:50:36See calculated tool done. Okay. Now here
  24619. 16:50:39I will ask now here I will give another
  24620. 16:50:41prompt. Uh what is the current weather
  24621. 16:50:43in New York?
  24622. 16:50:48Uh okay guys, one problem I found it is
  24623. 16:50:50not able to use my uh current weather
  24624. 16:50:52tools. Okay, why if I show you the code,
  24625. 16:50:55see whenever I did the bind operation,
  24626. 16:50:58right? So here I didn't add my uh
  24627. 16:51:00current weather tool here. So this is
  24628. 16:51:02the problem. So what I will do? I'll
  24629. 16:51:04just try to copy that code. Uh that's
  24630. 16:51:06why I'm telling why it's not working. Uh
  24631. 16:51:10yeah. So I'll copy this code as it is
  24632. 16:51:13and paste it here.
  24633. 16:51:17Okay. Now I think it should work. Let's
  24634. 16:51:18see. I'll reexecute my app.
  24635. 16:51:29Now here you can ask the same question.
  24636. 16:51:39What is the current weather in New York
  24637. 16:51:40or any other city?
  24638. 16:51:51Now see it is using get current weather
  24639. 16:51:53tool and this is the current weather in
  24640. 16:51:55New York right now. Okay. And you can
  24641. 16:51:57also ask any other question as well.
  24642. 16:51:59Tell me
  24643. 16:52:04give me all the movie
  24644. 16:52:08list.
  24645. 16:52:15in 20 26.
  24646. 16:52:26See it is using table rule and it will
  24647. 16:52:29realtime search over the internet and
  24648. 16:52:30this will give you the result.
  24649. 16:52:38See this is the entire result. I'm
  24650. 16:52:40getting all the latest movie information
  24651. 16:52:42I'm getting here. Amazing. Right now my
  24652. 16:52:45uh aentic chatbot is working like chart
  24653. 16:52:48GPT. So chart GPT has this kinds of tool
  24654. 16:52:50as well. That's why it is giving you
  24655. 16:52:51realtime informations. Okay. And our
  24656. 16:52:54chatbot is also working in that way. Now
  24657. 16:52:56if I open up my um uh Langmith
  24658. 16:53:00dashboard. So if I go to my project now
  24659. 16:53:02here all of the trades has executed.
  24660. 16:53:04Even you can see trade wise. Okay. Trade
  24661. 16:53:07wise you can see. Now let's I will see
  24662. 16:53:09this particular trades. I will open it
  24663. 16:53:11up and you can see the execution. Now
  24664. 16:53:14here you can see guys I have added the
  24665. 16:53:15tool and automatically this tools has
  24666. 16:53:18integrated inside my language dashboard
  24667. 16:53:20as well. Now see this is my chat node.
  24668. 16:53:26Okay. And uh whenever you given this
  24669. 16:53:29message it will go to the chat node.
  24670. 16:53:30Chat node will uh hit the invoke the LLM
  24671. 16:53:33and LLM has the tool condition
  24672. 16:53:35integrated. Okay. Now tool condition has
  24673. 16:53:37decided. Okay. It has to use the get
  24674. 16:53:39current weather tool because what was
  24675. 16:53:41the question? The question was what is
  24676. 16:53:43the current uh weather in New York. So
  24677. 16:53:45it will go to the tools condition. Tool
  24678. 16:53:47condition will decide okay it has to use
  24679. 16:53:48the tool and which tool it will call get
  24680. 16:53:51current weather tool. Okay. This tool it
  24681. 16:53:53will call. Now tool condition will try
  24682. 16:53:55to redirect this this thing to the tool
  24683. 16:53:58nodes. Okay. And now tool nodes will uh
  24684. 16:54:01select this get current weather tool and
  24685. 16:54:04uh what would be the location Newark.
  24686. 16:54:05And if you pass this network to the get
  24687. 16:54:07weather uh get weather function, this
  24688. 16:54:10will return you the current weather
  24689. 16:54:11information in New York. You can see
  24690. 16:54:12this is the output. Okay. And this
  24691. 16:54:14output we are sending again to the chat
  24692. 16:54:16node. Okay. You can see say again
  24693. 16:54:18sending to the chat node. Now this is
  24694. 16:54:20the input as well as the user input we
  24695. 16:54:23are sending it and AI is generating this
  24696. 16:54:26refine output. Okay. So that's how the
  24697. 16:54:28entire system is working right now.
  24698. 16:54:30Okay. Now I think you can see guys what
  24699. 16:54:32is the use of lang as well because in
  24700. 16:54:34the lang itself you can debug everything
  24701. 16:54:37after which note which node is executing
  24702. 16:54:39whether it is able to select the right
  24703. 16:54:40tool or not okay so that's how you can
  24704. 16:54:42understand each and everything I hope it
  24705. 16:54:44is clear guys okay so yes guys uh this
  24706. 16:54:46is all about of our agentic chatbot now
  24707. 16:54:49uh this aentic chatbot is uh not a
  24708. 16:54:52simple chatbot okay this has the tool
  24709. 16:54:54connection it it can perform different
  24710. 16:54:56different actions now uh I can tell this
  24711. 16:54:59is more advanc advanced agentic chatbot
  24712. 16:55:01we have created. Now uh some other
  24713. 16:55:03functionality also needs to be added in
  24714. 16:55:04this agentic chatbot. We'll also try to
  24715. 16:55:06add the RG functionality that is you can
  24716. 16:55:08upload any kinds of document you can
  24717. 16:55:09apart from the chat operation. So yes
  24718. 16:55:12this is all about from this
  24719. 16:55:13implementation. I hope you liked it. So
  24720. 16:55:14if you like this implementation guys
  24721. 16:55:16please try to subscribe to my channel
  24722. 16:55:17and share this video with your friends
  24723. 16:55:19friends and family. So guys uh this is
  24724. 16:55:21our agentic chatbot we have developed so
  24725. 16:55:23far and we have integrated lots of
  24726. 16:55:25features with this agentic chatbot. Now
  24727. 16:55:27this is not a simple chatbot right now.
  24728. 16:55:29This has uh like um uh conversation um
  24729. 16:55:33like uh trades. It has uh tool
  24730. 16:55:36integrations. It has streaming features.
  24731. 16:55:39Even it has the persistence memory with
  24732. 16:55:41the permanent database. Okay. So this is
  24733. 16:55:43not a simple chatbot right now. Now the
  24734. 16:55:46functionality I have added here this RG
  24735. 16:55:48functionality that means rag
  24736. 16:55:49functionality. Now in this chatbot in
  24737. 16:55:51this aentic chatbot you can upload any
  24738. 16:55:53kinds of documents. Okay. And you can
  24739. 16:55:55start uh doing the conversation on top
  24740. 16:55:57of that like chat GP. Okay. So, chart
  24741. 16:55:59GPT also has the same features. If I
  24742. 16:56:02show you the chart GPT. So, in chart GPT
  24743. 16:56:04also you can upload any kinds of
  24744. 16:56:05documents and you can perform chat on
  24745. 16:56:07top of that. So, first of all, let's see
  24746. 16:56:09our application. Okay. So, here let's
  24747. 16:56:10say I will upload a documents.
  24748. 16:56:14Let's say this is the documents I will
  24749. 16:56:16upload. So, this is a research paper
  24750. 16:56:17actually I published um uh this research
  24751. 16:56:20paper. So, as you can see this is the
  24752. 16:56:21paper guys. The paper name is um
  24753. 16:56:24development of multiple combined
  24754. 16:56:26regression method for rainfall
  24755. 16:56:28measurement. Okay. So here you can see I
  24756. 16:56:31was uh I was the author. Okay. So I
  24757. 16:56:33contributed in this paper. So this paper
  24758. 16:56:35covers uh about the uh rainfall
  24759. 16:56:39measurement. Okay. Uh by uh by using
  24760. 16:56:42some regression methods. Okay. You can
  24761. 16:56:44go through the paper. This is also
  24762. 16:56:45available on the research gate. Okay.
  24763. 16:56:48Now what I'll do I'll just upload this
  24764. 16:56:49paper on my aentic chatbot. I'll select
  24765. 16:56:52this paper. I will upload it.
  24766. 16:56:57See it is uh getting uploaded and it is
  24767. 16:56:59processing. Okay. So once it is done now
  24768. 16:57:02see here you can see the successful
  24769. 16:57:04message. Now I can perform the chat
  24770. 16:57:06operation. Now I'll just ask what is
  24771. 16:57:09rainfall
  24772. 16:57:11measurement
  24773. 16:57:14based on
  24774. 16:57:18the uploaded PDF.
  24775. 16:57:25Now see it is using my rack tool. Okay.
  24776. 16:57:28So internally I created a rack tool. It
  24777. 16:57:30is utilizing my rack tool and it is
  24778. 16:57:33giving you some kinds of response. As
  24779. 16:57:34you can see the document highlight that
  24780. 16:57:36uh predicting the amount of rainfall
  24781. 16:57:38recorded in millimeter uh is uh crucial.
  24782. 16:57:42It it uh notes that uh conventional
  24783. 16:57:46methods for forecast uh for for seeing
  24784. 16:57:49rainfall using equipment based on
  24785. 16:57:52climate coordinate uh coordinations like
  24786. 16:57:54temperature, humidity and weights are
  24787. 16:57:57not productive. Okay. Instead of uh
  24788. 16:57:59instead the paper process using the
  24789. 16:58:01machine learning uh pro uh procedure and
  24790. 16:58:05specifically
  24791. 16:58:07predictive regression analysis
  24792. 16:58:08technique. Okay. So yes uh if you go
  24793. 16:58:11through the paper guys you will be able
  24794. 16:58:12to see the same things this paper paper
  24795. 16:58:14covers actually we proposed some
  24796. 16:58:16regression method for this uh rainfall
  24797. 16:58:18measurement technique. Okay. Now we can
  24798. 16:58:21you can also ask any other things like
  24799. 16:58:23say what is the methology
  24800. 16:58:30uh methodology
  24801. 16:58:33of
  24802. 16:58:35this paper
  24803. 16:58:40in methodology.
  24804. 16:58:44Okay. Now I'll send this prompt.
  24805. 16:58:48Now see it is again using the rag tool
  24806. 16:58:51and it is uh it is giving you the entire
  24807. 16:58:54methodology uh we have written in the
  24808. 16:58:56paper. You can see uh this is the entire
  24809. 16:58:58methodology. So if you go through our
  24810. 16:59:00paper methodology you will able to see
  24811. 16:59:02the same things we are discussing there.
  24812. 16:59:04Okay. So that means like chart GPT we
  24813. 16:59:06are able to upload any kinds of
  24814. 16:59:08documents. Okay. And we can perform the
  24815. 16:59:10conversation. So in charge also you can
  24816. 16:59:12try you can upload your documentation.
  24817. 16:59:14Okay. And you can do the conversation on
  24818. 16:59:16top of that. And we have also integrated
  24819. 16:59:18the uh tracing features with our agentic
  24820. 16:59:21chatbot. That means it will continuously
  24821. 16:59:23monitor our agentic chatbot. Okay. And
  24822. 16:59:25we are continuously tracing the
  24823. 16:59:27execution on the Langismith platform
  24824. 16:59:30guys. As you can see these are all of my
  24825. 16:59:33trace. Okay. And you can monitor the
  24826. 16:59:35entire trace entire let's say
  24827. 16:59:37application uh in this Langismith
  24828. 16:59:39dashboard only. Okay. So this part I
  24829. 16:59:42also showed uh in my playlist uh just go
  24830. 16:59:44through and check that that how we can
  24831. 16:59:46add this langismith functionality inside
  24832. 16:59:48our um application. Okay. So yes uh this
  24833. 16:59:52is the features guys I have added uh
  24834. 16:59:54inside our agentic chatbot and trust me
  24835. 16:59:56this is uh very much important whenever
  24836. 16:59:58you are creating aentic system. Nowadays
  24837. 17:00:00all the agentic uh applications are you
  24838. 17:00:03uh applications are having this kinds of
  24839. 17:00:05RG functionality that means uh you not
  24840. 17:00:08only you can um do the conversation with
  24841. 17:00:10the tools and the um default large
  24842. 17:00:13language model instead of that you can
  24843. 17:00:15upload your private documents and you
  24844. 17:00:17can continue the conversation on top of
  24845. 17:00:19that okay everything is possible here so
  24846. 17:00:22uh yes guys this is the application and
  24847. 17:00:24apart from that this application uh can
  24848. 17:00:26also um handle different different
  24849. 17:00:28conversation let's say if I'm asking
  24850. 17:00:30Tell me the latest. Okay. Latest news
  24851. 17:00:37uh of FIFA.
  24852. 17:00:41Okay. 2026
  24853. 17:00:45did uh Brazil
  24854. 17:00:48on the game.
  24855. 17:00:50Now see this is the question. This is
  24856. 17:00:52the latest information I'm asking and my
  24857. 17:00:55agentic chatbot will be using some kinds
  24858. 17:00:57of search tool and it will give me the
  24859. 17:00:59response. Now see it is using tably
  24860. 17:01:01search tool. I already told you about
  24861. 17:01:03what is tab right and it is doing the
  24862. 17:01:05internet search tool. Uh it is doing the
  24863. 17:01:07internet search and it is giving you the
  24864. 17:01:08realtime response as you can see. Yeah.
  24865. 17:01:11So this is the answer. In the FIFA World
  24866. 17:01:13Cup 2026
  24867. 17:01:16a group C match which ended in a one by
  24868. 17:01:18one draw. Okay. Then uh Venicius Junior
  24869. 17:01:22scored Brazil in this uh simulated game.
  24870. 17:01:25Okay. So this was the like match guys.
  24871. 17:01:28If you have already watched that Brazil
  24872. 17:01:30match, you saw like uh this was a draw
  24873. 17:01:32match actually and this uh Venicius
  24874. 17:01:36Junior actually scored um uh one goal
  24875. 17:01:39for the Brazil. So yes guys that's how
  24876. 17:01:41our agentic uh chatbot works and uh you
  24877. 17:01:44can upload any kinds of documents right
  24878. 17:01:46now and you can uh start the
  24879. 17:01:48conversation on top of that apart from
  24880. 17:01:50that whatever functionality we have
  24881. 17:01:51created so far whatever tools we have
  24882. 17:01:53integrated so far it will be working
  24883. 17:01:55like a same right so now let's start
  24884. 17:01:57implementing this uh functionality
  24885. 17:01:59inside our agentic chatbot but before
  24886. 17:02:01that first of all I want to give you the
  24887. 17:02:03idea about uh rag what is retable
  24888. 17:02:06augmented generation techniques and uh
  24889. 17:02:09why it is useful. Okay. And how this
  24890. 17:02:12system works. Okay. First of all, we'll
  24891. 17:02:13try to understand then we'll start the
  24892. 17:02:16development guys. So guys uh as you can
  24893. 17:02:18see uh rag in aentic chatbot it's a very
  24894. 17:02:21important features uh not only in
  24895. 17:02:24agentic chatbot uh whenever you are
  24896. 17:02:26working with the uh generative AI
  24897. 17:02:29technology especially with the large
  24898. 17:02:30language model this rag is very
  24899. 17:02:33important uh like component of that. uh
  24900. 17:02:35if you have already studied about JNA I
  24901. 17:02:37think you already work with rag concept
  24902. 17:02:40right so rag helps us actually in three
  24903. 17:02:43majors uh uh actually field one is the
  24904. 17:02:46outdated knowledge so I think you know
  24905. 17:02:48whatever large language model you are
  24906. 17:02:51using it has a knowledge cut off right
  24907. 17:02:53so if I'm talking about the let's say
  24908. 17:02:56GPT 4 or GPT 3.5 right uh it has a
  24909. 17:03:00knowledge cut off till 2021 uh this
  24910. 17:03:03model got trained
  24911. 17:03:05And after that actually whatever um new
  24912. 17:03:08data came in the internet this model
  24913. 17:03:10doesn't have the access to that data
  24914. 17:03:13right because it has a knowledge cutoff
  24915. 17:03:15that means if you are asking anything
  24916. 17:03:16regarding after that date this model
  24917. 17:03:19won't be able to give you the response.
  24918. 17:03:21So it's not like that again you have to
  24919. 17:03:22fine-tune that model okay on the new
  24920. 17:03:24data because finetuning at the end it's
  24921. 17:03:26a costly task. uh for this you need a
  24922. 17:03:29good um instance, you need good
  24923. 17:03:31infrastructure, you need lots of money,
  24924. 17:03:33you need you need lots of data, right?
  24925. 17:03:35So that's why researcher introduced the
  24926. 17:03:37rack concept and with the help of rag
  24927. 17:03:39actually you can give external data to
  24928. 17:03:43the large language model as a knowledge
  24929. 17:03:45base and your LM will be able to
  24930. 17:03:48generate the response uh you are asking
  24931. 17:03:51about the latest information you have
  24932. 17:03:53already given right so this is the
  24933. 17:03:55concept of the rag so that's why if if
  24934. 17:03:57your model has outdated knowledge that
  24935. 17:04:00time rag is very important for that and
  24936. 17:04:03only things you have to create a detail
  24937. 17:04:05knowledge base, okay, with your custom
  24938. 17:04:07data. Now, the second thing is the
  24939. 17:04:09private data. Okay, so what is private
  24940. 17:04:11data? Uh private data means let's say um
  24941. 17:04:14uh just I showed you one example. I
  24942. 17:04:16uploaded my paper, right? I uploaded my
  24943. 17:04:18research paper. So this research paper
  24944. 17:04:20is my private data and I want to perform
  24945. 17:04:23some conversation on on top of my
  24946. 17:04:25private data. I want to understand about
  24947. 17:04:27my private data. Not only research
  24948. 17:04:29paper, you can upload any kinds of
  24949. 17:04:31private documents of yourself. You can
  24950. 17:04:33upload about your life story. You can
  24951. 17:04:35upload about your let's say any kinds of
  24952. 17:04:38inventory list. Okay. Anything you can
  24953. 17:04:39upload and you can perform the
  24954. 17:04:41conversation on top of that. Okay. So
  24955. 17:04:43this private data actually is not
  24956. 17:04:45available in the LLM. Okay. The default
  24957. 17:04:48LLM we are using. So that's why uh we
  24958. 17:04:51have to create this rack technique so
  24959. 17:04:52that I can upload any kinds of private
  24960. 17:04:54documents and I can start uh doing the
  24961. 17:04:56conversation on top of that. Okay. I can
  24962. 17:04:59ask anything. I can get any kinds of
  24963. 17:05:01feedback from my um like chatbot. Then
  24964. 17:05:04the third is the hallucination.
  24965. 17:05:05Hallucination uh happens let's say
  24966. 17:05:07whenever uh you are uh asking your agent
  24967. 17:05:11uh uh to do something. Let's say you are
  24968. 17:05:13asking give me some um give me some
  24969. 17:05:16let's say uh research topic link. Okay.
  24970. 17:05:20Uh for that particular topic let's say
  24971. 17:05:22this topic your u um agentic uh chatbot
  24972. 17:05:26doesn't know right. uh let's say this is
  24973. 17:05:28completely new topic uh this is not
  24974. 17:05:30available uh in the um in the large
  24975. 17:05:34language model knowledge base so that
  24976. 17:05:35time what will happen uh it might
  24977. 17:05:37generate some wrong URL right it might
  24978. 17:05:39generate some wrong URL and if you go to
  24979. 17:05:41the URL you will be able to see this URL
  24980. 17:05:43is not working this research article is
  24981. 17:05:45not working right so instead of what you
  24982. 17:05:47can do maybe you can uh give some of the
  24983. 17:05:50uh resources okay you can give some of
  24984. 17:05:52the document uh to your agentic chatbot
  24985. 17:05:55uh as a external knowledge and you and
  24986. 17:05:58uh tell like okay now refer this uh
  24987. 17:06:00actually knowledge and you can generate
  24988. 17:06:02some um like research topics or let's
  24989. 17:06:04say URL okay on top of that so that time
  24990. 17:06:07actually your LLM will not do the
  24991. 17:06:09hallucination but if you are not doing
  24992. 17:06:10that uh there is a possibility your um
  24993. 17:06:13chatbot will do the hallucination okay
  24994. 17:06:16uh it might generate something wrong
  24995. 17:06:18information for you so that's why this
  24996. 17:06:20RZ technique is super important whenever
  24997. 17:06:22you are creating this kinds of system
  24998. 17:06:24that's why nowadays all of the
  24999. 17:06:25application you have seen like charg
  25000. 17:06:27GPT, Gemini. Okay. Uh these are the
  25001. 17:06:29application are using this uh RA concept
  25002. 17:06:32in their um application. Uh that means
  25003. 17:06:34you can upload any kinds of documents.
  25004. 17:06:36Okay. PDF whatever and you can perform
  25005. 17:06:38the conversation on top of that. Now
  25006. 17:06:41let's try to understand how this uh rag
  25007. 17:06:43works. So this rag came from actually in
  25008. 17:06:45context learning techniques. So in in
  25009. 17:06:47context learning what happens. So this
  25010. 17:06:49is the like highle diagram of this in
  25011. 17:06:52context learning. So here we not only
  25012. 17:06:54pass a query okay to the large lang
  25013. 17:06:56based model uh with the help of with
  25014. 17:06:59this query we also give some kinds of
  25015. 17:07:00external context okay then we prepare a
  25016. 17:07:03prompt and this prompt will try to send
  25017. 17:07:05to the large language model and large
  25018. 17:07:07language model will uh generate some
  25019. 17:07:09kinds of response now let's try to see
  25020. 17:07:11this part in action so what I'm going to
  25021. 17:07:13do I'm going to give you one example
  25022. 17:07:14let's say uh here you are asking about
  25023. 17:07:18your um let's say paper so I uploaded
  25024. 17:07:22one paper I you remember called rainfall
  25025. 17:07:23measurement paper. So if I ask directly
  25026. 17:07:26this question okay to my large language
  25027. 17:07:29model let's say here I'm using very old
  25028. 17:07:30large language model and this large
  25029. 17:07:32language model trained till let's say
  25030. 17:07:342019
  25031. 17:07:36okay and if you see my paper guys this
  25032. 17:07:39paper I published around 2021 okay so
  25033. 17:07:43this paper information definitely it's
  25034. 17:07:45not available inside my large language
  25035. 17:07:47model so if I'm asking about this uh
  25036. 17:07:49let's say paper let's say tell me about
  25037. 17:07:50this rainfall measurement paper okay
  25038. 17:07:53rainfall
  25039. 17:07:56rainfall paper. Okay, let's say I'm
  25040. 17:07:58asking my large language model. This is
  25041. 17:08:01my entire prompt. I'm passing to the
  25042. 17:08:03large language model. That time large
  25043. 17:08:05language model will definitely not uh
  25044. 17:08:07provide the response because it doesn't
  25045. 17:08:09have the information. Okay. So in in
  25046. 17:08:11context learning what happens instead of
  25047. 17:08:13giving the direct query you can also
  25048. 17:08:15pass the context. Context means here you
  25049. 17:08:17can give the entire paper. Okay. You can
  25050. 17:08:19pass the entire paper. Okay. you can
  25051. 17:08:22extract all of the uh content or you can
  25052. 17:08:24directly uh give the paper okay as a
  25053. 17:08:26context and you can combine a prompt.
  25054. 17:08:28Let's say uh tell me about rainfall uh
  25055. 17:08:31measurement paper and here is the
  25056. 17:08:37uh here is the
  25057. 17:08:41paper
  25058. 17:08:42content.
  25059. 17:08:44Okay, content and you are already
  25060. 17:08:46passing the paper here, right? You're
  25061. 17:08:47already passing the paper here. That
  25062. 17:08:49means you are giving the query as well.
  25063. 17:08:52Okay, you are also giving the paper.
  25064. 17:08:55Okay, then you are asking tell me about
  25065. 17:08:56the rainfall measurement. Now your LLM
  25066. 17:08:59has the context as well as the query.
  25067. 17:09:01Now it can generate the response. Okay,
  25068. 17:09:04you are ask uh it it can generate the
  25069. 17:09:06response the question you are asking by
  25070. 17:09:08using this particular context. Okay. In
  25071. 17:09:10real life also let's say if I'm asking
  25072. 17:09:12you anything which is completely new and
  25073. 17:09:15let's say if you don't don't know that
  25074. 17:09:17information if you don't know that let's
  25075. 17:09:18say question that time you will directly
  25076. 17:09:20say okay I don't know but if I give you
  25077. 17:09:22some kinds of context let's say I will
  25078. 17:09:24ask about uh tell me about um let's say
  25079. 17:09:28uh Brazil team okay uh so what you will
  25080. 17:09:31do um if I give you some context let's
  25081. 17:09:34say if I give you list of the uh Brazil
  25082. 17:09:36uh player uh uh let's say name list then
  25083. 17:09:39you'll be able to uh give me okay these
  25084. 17:09:41are the player players are available in
  25085. 17:09:44Brazil team right it's it's like that
  25086. 17:09:46that means you are not only giving the
  25087. 17:09:48query but also you are providing the
  25088. 17:09:50answer that means the context okay the
  25089. 17:09:52entire paper now is referring that paper
  25090. 17:09:55and it is generating the question you
  25091. 17:09:57are asking let's say you are asking
  25092. 17:09:58about rainfall measurement it will be
  25093. 17:10:00able to uh understand about the rainfall
  25094. 17:10:02measurement from the paper and it will
  25095. 17:10:04give you some kinds of refined response
  25096. 17:10:05so that's how in context learning works
  25097. 17:10:07okay but the problem with in context
  25098. 17:10:09learning is so let's say here the paper
  25099. 17:10:11I'm uploading it might have lots of
  25100. 17:10:14content right it might have lots of
  25101. 17:10:15content content means if you see the
  25102. 17:10:19paper all of the words you can consider
  25103. 17:10:21as a token right and if you count all of
  25104. 17:10:23the token uh there is a chance this
  25105. 17:10:25token okay number of token um might
  25106. 17:10:29increase than your uh input length of
  25107. 17:10:33the model input limit
  25108. 17:10:36of lm okay so every model has a input
  25109. 17:10:39input limit right uh token limit if you
  25110. 17:10:41open any kinds of model right uh in uh
  25111. 17:10:44Google you will see that it has a input
  25112. 17:10:45limit token limit let's say uh the model
  25113. 17:10:48we are using this model can take uh
  25114. 17:10:501,000 okay 1,000 token input at a time
  25115. 17:10:54but if you're passing uh the entire
  25116. 17:10:56paper let's say the paper token I have
  25117. 17:10:58counted it is around 5,000 token okay
  25118. 17:11:025,000 token that time definitely this
  25119. 17:11:04token is um um bigger than your input
  25120. 17:11:07token limit that time that would be an
  25121. 17:11:09error. Okay, there would be some kinds
  25122. 17:11:11of input error. That means you can't
  25123. 17:11:12pass uh that many of token as an input
  25124. 17:11:14to the model. Okay, so this was the
  25125. 17:11:16problem with the in context learning. So
  25126. 17:11:18that's why from the in context learning
  25127. 17:11:21one concept has introduced the concept
  25128. 17:11:23name is rag. Okay, so in rag actually
  25129. 17:11:26what we do instead of giving the entire
  25130. 17:11:28documents directly we perform something
  25131. 17:11:30called chunking we perform something
  25132. 17:11:31called splitting. Okay, we uh divide our
  25133. 17:11:35entire content in a different chunk,
  25134. 17:11:36different split and we pass this uh
  25135. 17:11:40different chunk, okay, one by one to the
  25136. 17:11:43model. So this is the like updated
  25137. 17:11:44architecture as you can see. Let's say
  25138. 17:11:46here I am having an entire documents.
  25139. 17:11:48First of all, we'll try to uh extract
  25140. 17:11:50all of the content from the document
  25141. 17:11:52itself. Okay, we'll load the documents
  25142. 17:11:54and we'll extract all of the content
  25143. 17:11:55from the documents as you can see. Okay,
  25144. 17:11:58and once it is done, we'll try to
  25145. 17:11:59perform some kinds of chunking
  25146. 17:12:01operation. We also call it as a speeder
  25147. 17:12:03text splitter. Split means let's say
  25148. 17:12:04this is my entire docs, right? This is
  25149. 17:12:06my entire content and I'll just try to
  25150. 17:12:09create a different different chunk. I'll
  25151. 17:12:11try to divide this content okay in a
  25152. 17:12:12different different part. This is called
  25153. 17:12:14text splitter. Okay. Now let's say if
  25154. 17:12:16your original documents it is around
  25155. 17:12:195,000 token. Okay. Now after doing this
  25156. 17:12:22splitter or chunking every uh every
  25157. 17:12:24let's say chunk will have let's say
  25158. 17:12:271,000 token. Okay. 1,000 token. That's
  25159. 17:12:30how you can create five uh five actually
  25160. 17:12:33chunk here or let's say four chunk here
  25161. 17:12:34or six chunk here. It's completely up to
  25162. 17:12:36you. Okay. But it uh this input should
  25163. 17:12:39be uh less than your model input. So
  25164. 17:12:42once you have created the chunk then you
  25165. 17:12:45will be using some kinds of embedding
  25166. 17:12:46model. I think you know about embedding
  25167. 17:12:48model. What embedding model does?
  25168. 17:12:49Basically embedding model we use to
  25169. 17:12:51convert our text to the number because
  25170. 17:12:53the large language model we are using
  25171. 17:12:55right it can't take directly the English
  25172. 17:12:57text as an input. Okay. Okay, internally
  25173. 17:12:59because this is some kinds of
  25174. 17:13:00mathematical equation. So we have to
  25175. 17:13:02convert as a number, right? We'll be
  25176. 17:13:04using this embedding model and we'll
  25177. 17:13:05generate some kinds of vector embedding.
  25178. 17:13:07This is called vector embedding, right?
  25179. 17:13:09This called vector embedding. Now this
  25180. 17:13:11vector embedding we have to store
  25181. 17:13:12somewhere. This is called actually
  25182. 17:13:14vector database and we call also call it
  25183. 17:13:15as a vector store. Okay, especially in
  25184. 17:13:18rag uh you will be using vector database
  25185. 17:13:20not a traditional normal database. Okay,
  25186. 17:13:23here you have to use vector database
  25187. 17:13:24because there's a concept called
  25188. 17:13:25similarity search or semantic search you
  25189. 17:13:28have to perform and this is only
  25190. 17:13:29possible in vector database only right
  25191. 17:13:31then you'll be storing all of this
  25192. 17:13:32vector in the vector database okay now
  25193. 17:13:35this will become your knowledge base
  25194. 17:13:36this will become your knowledge base
  25195. 17:13:38guys okay now this knowledge base we
  25196. 17:13:40have to connect with our large language
  25197. 17:13:41model right now okay now this part
  25198. 17:13:43actually we perform the retar operation
  25199. 17:13:46that means if user is asking about a
  25200. 17:13:48question about the let's say the paper I
  25201. 17:13:50have uploaded rainfall measurement so
  25202. 17:13:52First of all, this question will go to
  25203. 17:13:54the knowledge base. Okay, because
  25204. 17:13:56knowledge base has all of the okay all
  25205. 17:13:59of the uh information about the rainfall
  25206. 17:14:02measurement because I have uploaded the
  25207. 17:14:03entire paper. It is available here,
  25208. 17:14:04right? So then uh this retriever it will
  25209. 17:14:07go here and it will perform a semantic
  25210. 17:14:08source operation and it will only
  25211. 17:14:10extract that part which is required for
  25212. 17:14:12the query. Let's say here I'm asking
  25213. 17:14:14about what is rainfall measurement. But
  25214. 17:14:16if you open the paper instead of
  25215. 17:14:17rainfall measurement, it it has lots of
  25216. 17:14:19like uh see topic. It has the related
  25217. 17:14:22works. It has the methodology. Okay.
  25218. 17:14:24Then it has some comparison. It has some
  25219. 17:14:26data set introduction. Okay. It has some
  25220. 17:14:28diagram pre-processing section. So I
  25221. 17:14:30don't need all of the information. I
  25222. 17:14:32only need that part where it covers what
  25223. 17:14:34is rainfall measurement exactly. Okay.
  25224. 17:14:36So with the help of the similarity
  25225. 17:14:37search, it will only found that
  25226. 17:14:39information. Okay. Which is you are
  25227. 17:14:41asking in the query and it will give you
  25228. 17:14:43that particular uh relevant response. So
  25229. 17:14:46here you can see this question will go
  25230. 17:14:47to the knowledge base and knowledge base
  25231. 17:14:49will return some relevant response based
  25232. 17:14:51on the query you are asking most
  25233. 17:14:52relevant chunk okay we call it as a most
  25234. 17:14:54relevant chunk or context then you are
  25235. 17:14:56combining the query also here you can
  25236. 17:14:58see the query you are also combining
  25237. 17:15:00then you are preparing the final prompt
  25238. 17:15:01that means you can you are combining
  25239. 17:15:03this query with the prompt let's say uh
  25240. 17:15:05uh this my query is what is rainfall
  25241. 17:15:07measurement and you got the rainfall
  25242. 17:15:09measurement answer now we are combining
  25243. 17:15:11the prompt uh what is tell me about
  25244. 17:15:15rainfall measure measurement and here is
  25245. 17:15:16the context then you are generating a
  25246. 17:15:19entire prompt and this prompt you are
  25247. 17:15:20passing to the LLM. Now LM has the query
  25248. 17:15:23as well as the context. Okay, the
  25249. 17:15:25question you are asking then LLM will
  25250. 17:15:27try to read that it will understand and
  25251. 17:15:29it will refine some kinds of uh final
  25252. 17:15:32response and it will uh show you this
  25253. 17:15:35particular response. Okay, so that's how
  25254. 17:15:36the entire RG system works. Okay, so
  25255. 17:15:39this is the better version of the in
  25256. 17:15:41context learning because in context
  25257. 17:15:43learning we pass the entire documents.
  25258. 17:15:44Okay, and what is the problem with the
  25259. 17:15:46entire documents? because it has a input
  25260. 17:15:48limit. But here uh if you are giving
  25261. 17:15:51let's say thousands of thousands token
  25262. 17:15:53input as well, it doesn't matter because
  25263. 17:15:55it perform the chunking operation. It
  25264. 17:15:57perform the splitting operation and all
  25265. 17:15:59of the entire documents would be
  25266. 17:16:00splitted into different chunk and it
  25267. 17:16:02will store in the vector database. Then
  25268. 17:16:04you can perform any kinds of uh ret
  25269. 17:16:06operation. Okay, similarity search
  25270. 17:16:08operation and you can perform this kinds
  25271. 17:16:10of question and answer on top of your
  25272. 17:16:12private documents. So that's how this RG
  25273. 17:16:15system works guys. Okay, I hope this
  25274. 17:16:16part is clear to all of you. Now, we'll
  25275. 17:16:18try to implement this system guys inside
  25276. 17:16:21our aentic chatbot. But before that, I
  25277. 17:16:23want to show you the notebook
  25278. 17:16:24experiment. Okay, like uh let's say I
  25279. 17:16:27will uh show you the step-by-step
  25280. 17:16:29procedure how we can implement this.
  25281. 17:16:32Okay, with our uh agentic chatbot uh
  25282. 17:16:35because we are using langraph how we can
  25283. 17:16:37do it with the help of langraph. I'll
  25284. 17:16:38show you the entire experiment and once
  25285. 17:16:40our experiment is working then I'll try
  25286. 17:16:42to integrate inside our actual code. So
  25287. 17:16:45guys uh as you can see this is our
  25288. 17:16:47entire code and this code I have already
  25289. 17:16:49uploaded in my GitHub and link is given
  25290. 17:16:51in the description. So here in the
  25291. 17:16:53notebook folder guys I added another
  25292. 17:16:55notebook called rag demo. Okay just open
  25293. 17:16:57this notebook and here I already written
  25294. 17:16:59all of this code uh required to
  25295. 17:17:02implement this functionality right
  25296. 17:17:04instead of writing from scratch because
  25297. 17:17:05it will take lots of time instead of
  25298. 17:17:07that maybe I can go through my
  25299. 17:17:09implementation right. So here just try
  25300. 17:17:11to select your environment. After that
  25301. 17:17:13uh first of all you have to import all
  25302. 17:17:15the necessary libraries. Okay. So here I
  25303. 17:17:17have already imported all the necessary
  25304. 17:17:19libraries guys. As you can see open AI
  25305. 17:17:21open embeddings. Okay. Even I have also
  25306. 17:17:24um imported this uh Google generate. uh
  25307. 17:17:27because uh if you don't have openi API
  25308. 17:17:30key if you don't have openi let's say uh
  25309. 17:17:33provider that time you can use uh
  25310. 17:17:35alternative uh way uh for running this
  25311. 17:17:37project you can use gemini model and
  25312. 17:17:39gemini model by default you will be
  25313. 17:17:41getting some free uh free access okay
  25314. 17:17:43you can use that particular model so
  25315. 17:17:44that's why I'm importing this uh gemini
  25316. 17:17:46and if you want to use this gemini you
  25317. 17:17:48have to import this chat Google generate
  25318. 17:17:50functionality and I have already
  25319. 17:17:52installed this in my requirement as you
  25320. 17:17:54can see this uh this library I have
  25321. 17:17:55already installed there apart from that
  25322. 17:17:57you have to also uh import this Google
  25323. 17:17:59generate API embeddings because I don't
  25324. 17:18:01have uh open AAI embedding model right I
  25325. 17:18:04don't have open API key that time I can
  25326. 17:18:05use uh Gemini embedding model okay so
  25327. 17:18:08that's why both I have imported let's
  25328. 17:18:10say whichever you have you can use them
  25329. 17:18:12okay then load ENB pi PDF loader see if
  25330. 17:18:15you are implementing RG that time this
  25331. 17:18:18thing is required if you are uploading
  25332. 17:18:19the PDF document that time from langen
  25333. 17:18:22community you can uh import this pi PDF
  25334. 17:18:25loader this is already available in
  25335. 17:18:26document loaded and for this you have to
  25336. 17:18:28install some library like uh langen
  25337. 17:18:31community uh then you have to install
  25338. 17:18:34fire CPU fire is a vector database okay
  25339. 17:18:36apart from fi actually there are some
  25340. 17:18:38other vector database are available like
  25341. 17:18:40uh web is there chromad is there pine
  25342. 17:18:42cone is there okay maybe in future
  25343. 17:18:44project we'll try to use but uh in this
  25344. 17:18:46project I'm going to use fires okay fs
  25345. 17:18:48vector database and fires is a in um in
  25346. 17:18:51storage database that means uh it will
  25347. 17:18:53create uh the database inside your uh uh
  25348. 17:18:56computer. Okay, inside your computer
  25349. 17:18:58computer um hard drive and uh there are
  25350. 17:19:01some cloud-based uh uh vector database
  25351. 17:19:03are available like web 8 is there then
  25352. 17:19:05pine cone is there you can store all of
  25353. 17:19:07your vectors in cloud okay this part I
  25354. 17:19:08will also show you later on then pipe
  25355. 17:19:10vdf you have to also install because uh
  25356. 17:19:12we'll be uploading PDF documents here so
  25357. 17:19:14in this project guys uh only just to
  25358. 17:19:16show you I I'll be considering the PDF
  25359. 17:19:18documents but if you want you can also
  25360. 17:19:20upload docs format you can upload excel
  25361. 17:19:22format okay this part you can go through
  25362. 17:19:24the simply length documentation Okay,
  25363. 17:19:26there you will try to see how to load
  25364. 17:19:27the documents, how to load the Excel
  25365. 17:19:29documents. Okay, each and everything
  25366. 17:19:30they have given. But here I'm going to
  25367. 17:19:31only consider PDF documents. Then one
  25368. 17:19:34another uh library you have to install
  25369. 17:19:36called langent text splitter. And this
  25370. 17:19:38langent text splitter we'll be using for
  25371. 17:19:40this uh for this actually chunking
  25372. 17:19:42operation. Okay. Uh from the entire
  25373. 17:19:44document will perform different
  25374. 17:19:45different chunk right and with the help
  25375. 17:19:46of this langent text splitter will be
  25376. 17:19:48doing this particular part. And here I
  25377. 17:19:51have already specified the version.
  25378. 17:19:52These are the version you have to
  25379. 17:19:53install. And how to install? Open your
  25380. 17:19:55terminal and just execute pip installer
  25381. 17:19:58requirement.txt. Okay, if you do that it
  25382. 17:20:01will install in your system. Okay, so I
  25383. 17:20:03have already installed all of the
  25384. 17:20:04necessary library guys. I don't need to
  25385. 17:20:06install again.
  25386. 17:20:09But if you're doing it for the first
  25387. 17:20:10time, you have to install these other
  25388. 17:20:12library. Okay, I mean all the comment I
  25389. 17:20:14have also given in my readmi.mmd file.
  25390. 17:20:16So once it is done guys, let's import
  25391. 17:20:18all of the necessary library. You can
  25392. 17:20:19see I'm importing this uh recursive
  25393. 17:20:22character text splitter from langent
  25394. 17:20:24text splitter and with the help of that
  25395. 17:20:26we'll be performing the chunking. Then
  25396. 17:20:29uh we are also importing a vector
  25397. 17:20:30database. It is also available inside
  25398. 17:20:32langen community vector store. I'm
  25399. 17:20:34importing fires. Okay. And fires has
  25400. 17:20:36implemented by meta team. Okay. By
  25401. 17:20:39Facebook uh this uh vector database has
  25402. 17:20:42implemented. Then um we are importing
  25403. 17:20:45tools graph then annotated type dick.
  25404. 17:20:47These are the things are common add
  25405. 17:20:49messages, human message based messages.
  25406. 17:20:51Okay. And from lang graph we are also
  25407. 17:20:53importing some pre-built uh let's say
  25408. 17:20:56node like tool node and tool condition.
  25409. 17:20:58So these are the things are common.
  25410. 17:21:00Okay. So this is our entire import.
  25411. 17:21:01Let's import them one by one.
  25412. 17:21:04So see guys I have imported
  25413. 17:21:06successfully. Now we have to load the
  25414. 17:21:08environment variable. So as you can see
  25415. 17:21:10we already have the environment variable
  25416. 17:21:11here. And here I have already added all
  25417. 17:21:14of my API key. Uh I used TA API key. I
  25418. 17:21:18used open weather API key, Google API
  25419. 17:21:21key. Okay. And this API key I collected
  25420. 17:21:22from Google AI studio. If you want to
  25421. 17:21:24use Gemini model. So in my previous
  25422. 17:21:26video guys, I showed you showed you this
  25423. 17:21:28part. Okay. How to collect all the API
  25424. 17:21:30key. Uh you can go through that
  25425. 17:21:31recording. Then from Langmith tracing
  25426. 17:21:34guys, we have added these three uh four
  25427. 17:21:36things. And here you have to pass the
  25428. 17:21:38LSmith API key as well from the lang
  25429. 17:21:40platform. Okay. So these are the
  25430. 17:21:42credential you need. Now let's load all
  25431. 17:21:44of them. Now if you're if you are
  25432. 17:21:46already having this open API key you can
  25433. 17:21:48uncomment this line and you can use uh
  25434. 17:21:50open API model open AI model and if you
  25435. 17:21:53don't have open AIP key if you have only
  25436. 17:21:55Gemini key that time you can use this
  25437. 17:21:57definition okay so here we are using
  25438. 17:21:59Gemini model so let's load the Gemini
  25439. 17:22:01model now we'll try to uh load my paper
  25440. 17:22:05okay one of my documents so here I
  25441. 17:22:07already kept my documents my paper that
  25442. 17:22:09means this paper I already
  25443. 17:22:12uh I already copied in the folder Okay,
  25444. 17:22:14you can use any other documents as well.
  25445. 17:22:17So this is the name of the PDF. So I
  25446. 17:22:19have to load this particular PDF. Now
  25447. 17:22:21for loading it, I'm using PI PDF loader
  25448. 17:22:23because this is a PDF file. Now let's
  25449. 17:22:25load that. Okay. So once you do the
  25450. 17:22:27loaded dotload operation, you will be
  25451. 17:22:29able to see the entire documents. Now
  25452. 17:22:30let me show you the entire documents. So
  25453. 17:22:32this is the documents. Now by default
  25454. 17:22:34langen loads uh your documents into
  25455. 17:22:36document format, okay, as a page by
  25456. 17:22:39page. So how many page this is having? I
  25457. 17:22:41think this uh PDF is having 15 pages.
  25458. 17:22:44Okay. 15 pages content I have extracted.
  25459. 17:22:47Okay. And you can see some metadatas are
  25460. 17:22:48available but the main part is that the
  25461. 17:22:50content. So let me show you uh here is
  25462. 17:22:54the content page content. Okay. And in
  25463. 17:22:56the past content you will have all of
  25464. 17:22:57the uh text. Okay. I have in my PDF uh
  25465. 17:23:01and these are some meta information. Now
  25466. 17:23:04we'll try to perform this this
  25467. 17:23:05operation. That means we have extracted
  25468. 17:23:07the entire document. Now we have to
  25469. 17:23:08perform the chunking guys. Okay. we have
  25470. 17:23:10to perform the chunking. Now this part
  25471. 17:23:12actually performs the chunking
  25472. 17:23:13operation. We are importing recursive
  25473. 17:23:15character explainer and here we are
  25474. 17:23:16defining the chunk size. Okay, that
  25475. 17:23:18means each of the chunk will have how
  25476. 17:23:20many token. Okay, here we have defined
  25477. 17:23:22each of the chunk will have 1,000 token.
  25478. 17:23:25Okay, uh and there is a um another
  25479. 17:23:28parameter you have to provide called
  25480. 17:23:29chunk overlap. This chunk overlap
  25481. 17:23:31basically uh means that uh there it has
  25482. 17:23:34to add some overlapping. Okay, over
  25483. 17:23:36overlappinging means let's say let's say
  25484. 17:23:39it is uh it is extracting 1,000 token.
  25485. 17:23:42Okay, let's say till here you have 1,000
  25486. 17:23:44token. Okay. Now, next again it will
  25487. 17:23:47create another chunk, right? Uh let's
  25488. 17:23:48say from here it will start. But if
  25489. 17:23:50there is a chunk overlap, let's say 200,
  25490. 17:23:52what it will do? It will go back 200
  25491. 17:23:55word. Let's say 200 word uh starts here,
  25492. 17:23:57then it will create uh again uh 1,000
  25493. 17:24:00tokens from here. Okay, that means from
  25494. 17:24:02your previous chunk, okay, there is a
  25495. 17:24:05overlap I am creating so that my model
  25496. 17:24:07can understand, okay, after this token,
  25497. 17:24:09after this let's say chunk, this chunk
  25498. 17:24:11is starting. Okay, so that's why this
  25499. 17:24:13overlapping is important. And this is
  25500. 17:24:14the concept of rag. Okay, I already
  25501. 17:24:16covered in my um YouTube channel. There
  25502. 17:24:19is a dedicated generative playlist I'm
  25503. 17:24:21having. You can go through that
  25504. 17:24:22playlist. There I covered this rank
  25505. 17:24:25concept in detail. Okay, you can
  25506. 17:24:26understand these are the concept there.
  25507. 17:24:28Then after that we are splitting the
  25508. 17:24:30documents. We are passing the entire
  25509. 17:24:31documents and you can see we are
  25510. 17:24:33creating the chunk. Now total I got 44
  25511. 17:24:37chunks here. Okay, that means I got 44
  25512. 17:24:39chunks here. Okay. By divide uh by um
  25513. 17:24:42doing the splitting of my entire
  25514. 17:24:44content. Okay. And each of the chunk
  25515. 17:24:47will have 1,000 token because our chunk
  25516. 17:24:49size was 1,000 token. And this this is
  25517. 17:24:52completely hyperparameter number. You
  25518. 17:24:54can also change this number as per your
  25519. 17:24:56requirement. Now guys, we'll be u
  25520. 17:24:59defining the embedding model right now.
  25521. 17:25:00And here if you have openi uh API guys,
  25522. 17:25:03you can execute this code. uh this code
  25523. 17:25:06actually loads the openi embedding model
  25524. 17:25:08and it stores in the files uh vector
  25525. 17:25:10database but if you don't have openi you
  25526. 17:25:13can execute this code and this code uses
  25527. 17:25:15gemini embedding model here we you can
  25528. 17:25:17see I'm using this gemini importing
  25529. 17:25:18model and we're storing our vectors okay
  25530. 17:25:21you are storing our vectors inside my
  25531. 17:25:23files vector database okay files vector
  25532. 17:25:25database and for this this is the code
  25533. 17:25:27files from document and you have to give
  25534. 17:25:28all of the chunk and your embedding
  25535. 17:25:30model as well okay now if you execute
  25536. 17:25:32this code
  25537. 17:25:34now See here you will be able to see um
  25538. 17:25:38one uh one database but uh this is only
  25539. 17:25:43visible if you write this line.
  25540. 17:25:47Huh? Vector store save local. Okay. And
  25541. 17:25:50here you have to give the name. Now if I
  25542. 17:25:52execute
  25543. 17:25:54again
  25544. 17:25:58now see it has created the files
  25545. 17:26:01database here. Okay. In your computer.
  25546. 17:26:03Okay. Okay, that's why I told you this
  25547. 17:26:04is a incomputer database. It will store
  25548. 17:26:06inside your computer storage. Okay, now
  25549. 17:26:09we'll uh see the vector store. So this
  25550. 17:26:12is the object of the files vector store.
  25551. 17:26:14Now we'll just try to create a uh
  25552. 17:26:16retriever. Okay, retriever means if you
  25553. 17:26:18want to perform this semantic s
  25554. 17:26:20operation, you have to create a
  25555. 17:26:21retriever of the entire database you
  25556. 17:26:23have created because user will give a
  25557. 17:26:25question and this question will first of
  25558. 17:26:27all go to the vector tree. It will uh
  25559. 17:26:29extract the most relevant chunk and it
  25560. 17:26:31will combine your query. Then it will
  25561. 17:26:33prepare a prompt. Okay, for this
  25562. 17:26:34operation, you have to create this
  25563. 17:26:35retriever object. How to get the
  25564. 17:26:36retriever object? You just need to write
  25565. 17:26:38vector store as ret. Okay, uh then here
  25566. 17:26:42you have to provide the search type. And
  25567. 17:26:43here we'll be using similarity search
  25568. 17:26:45operation. And the search keyword is
  25569. 17:26:46four. That means it will extract four
  25570. 17:26:49relevant response at a time. Okay. Let's
  25571. 17:26:50say if you're asking about what is
  25572. 17:26:52rainfall measurement, it will go to the
  25573. 17:26:53vector store and four relevant chunk it
  25574. 17:26:56will try to extract. Okay. So this is
  25575. 17:26:58the parameter. If you make it as five,
  25576. 17:26:59it will extract five chunk. It will if
  25577. 17:27:01you uh give let's say two it will only
  25578. 17:27:04extract uh two chunks. Okay, that's how
  25579. 17:27:05this things works. Now we'll try to
  25580. 17:27:07create the retr. So once ret is created
  25581. 17:27:10guys now these things we want to
  25582. 17:27:13integrate inside of agentic chatbot and
  25583. 17:27:15agentic chatbot if you're using rag
  25584. 17:27:17concept you have to uh you have to
  25585. 17:27:19actually create a tool of your entire
  25586. 17:27:22rag you have created right but in simple
  25587. 17:27:24rag we don't create the tool we just
  25588. 17:27:26directly perform uh the question and
  25589. 17:27:28answer on my retriever with my large
  25590. 17:27:30language model okay but here we we have
  25591. 17:27:32created agentic chatbot and aentic
  25592. 17:27:34chatbot works with the tool so guys uh
  25593. 17:27:36as you can see I have uh written this
  25594. 17:27:38retriever functionality as a tool and
  25595. 17:27:41this is the function I have created and
  25596. 17:27:43I made it as a custom tool. So before uh
  25597. 17:27:46showing you this one first of all I want
  25598. 17:27:47to show you how retr works. Let's
  25599. 17:27:49execute retr independently. So I'll copy
  25600. 17:27:52this one
  25601. 17:27:54uh retinvoke and here let's pass a
  25602. 17:27:57query. I'll give uh what is
  25603. 17:28:01rainfall
  25604. 17:28:04measurement. Okay. Now see this will uh
  25605. 17:28:07return you
  25606. 17:28:09uh this will return you actually four
  25607. 17:28:13relevant information
  25608. 17:28:19see four relevant information why
  25609. 17:28:21because this s keyword you have set it
  25610. 17:28:23as four this k parameter is four right
  25611. 17:28:25now that's why four relevant response it
  25612. 17:28:27is giving you see these are my four
  25613. 17:28:30relevant chunk I am getting about the
  25614. 17:28:32rainfall measurement now this will go to
  25615. 17:28:34the my and this will go to the my uh
  25616. 17:28:38query uh that means I'll add the query
  25617. 17:28:39here and we'll prepare a prompt and this
  25618. 17:28:41will go to the lm now lm has the context
  25619. 17:28:44as well as the question and lm will able
  25620. 17:28:46to generate the final response for me
  25621. 17:28:48okay so that's how this uh uh this
  25622. 17:28:51system is working okay that's how this
  25623. 17:28:53ret is working now have to make it as a
  25624. 17:28:55tool because here we are creating a
  25625. 17:28:57aentic chatbot and agentic chatbot works
  25626. 17:28:59with a tool okay now here you can see I
  25627. 17:29:02have written the same thing just in a
  25628. 17:29:04function
  25629. 17:29:04it will take the query. I'm doing the
  25630. 17:29:06invoke operation. Whatever documents I'm
  25631. 17:29:08getting, first of all, I'm checking if
  25632. 17:29:10uh document not found. So no no relevant
  25633. 17:29:13information was found and if it is found
  25634. 17:29:15then I'm extracting the u documents. So
  25635. 17:29:18here you can see some metadata
  25636. 17:29:19information are available. So from this
  25637. 17:29:21metadata I'm uh extracting the document
  25638. 17:29:23sources. Okay, sources means which PDF
  25639. 17:29:25it is uh referring. You can see here
  25640. 17:29:28there is a section called source
  25641. 17:29:32title is there, source is there. You can
  25642. 17:29:33see source. Okay. So that's how I'm
  25643. 17:29:35extracting. These are the meta
  25644. 17:29:36information page and content. So these
  25645. 17:29:38information I'm extracting and we are
  25646. 17:29:41joining in this u um like um list and we
  25647. 17:29:45are returning it. That's it. Okay. So
  25648. 17:29:47this is the function I have written and
  25649. 17:29:49we made it as a tool because this is our
  25650. 17:29:51custom function and if you want to make
  25651. 17:29:52it as a custom function u as a tool then
  25652. 17:29:55you have to use this length and tools.
  25653. 17:29:57Okay. Decorator there. Uh we have
  25654. 17:29:59already learned it learned this
  25655. 17:30:00previously right. So this is my tool
  25656. 17:30:02right now and I named it as a rack tool.
  25657. 17:30:05Now further step will be same that means
  25658. 17:30:07we'll be adding the tools inside a list
  25659. 17:30:10and we'll try to bind that with our
  25660. 17:30:12large language model. So you can see I'm
  25661. 17:30:14binding binding my large language model
  25662. 17:30:16with my tools. Execute. First of all
  25663. 17:30:19I'll execute this code then execute
  25664. 17:30:22this. Okay. Now we have to define the
  25665. 17:30:25state. Now this is our state and see
  25666. 17:30:27here I haven't added other tools because
  25667. 17:30:29I want to only show you the rag
  25668. 17:30:31functionality that's why I'm only using
  25669. 17:30:32one tool but in my actual code I have
  25670. 17:30:34also some other tool like calculator web
  25671. 17:30:36search tool then uh weather tool then
  25672. 17:30:39stock market tool okay I think remember
  25673. 17:30:41then this is our nodes so in the node
  25674. 17:30:43itself I'm using my lm with the tools
  25675. 17:30:46okay this particular u updated one and
  25676. 17:30:49here is another node which is tool node
  25677. 17:30:52now here I am defining my graph
  25678. 17:30:53structure and we are adding the edges
  25679. 17:30:55And I think this part you already know
  25680. 17:30:57how to add the tool nodes and tool
  25681. 17:30:59conditions there. Now finally this is
  25682. 17:31:01our graph and this graph we also saw in
  25683. 17:31:03my previous implementation.
  25684. 17:31:05Now guys we'll try to invoke our uh
  25685. 17:31:07chatbot. Now see this is our regular
  25686. 17:31:09message here. I'm just doing um
  25687. 17:31:11chatbot.invoke. I'm giving a message
  25688. 17:31:13hello. And for this it doesn't need any
  25689. 17:31:15kinds of rack tool. Uh it will generate
  25690. 17:31:17the answer from the large language model
  25691. 17:31:19only. Hello. I'm here to uh answer your
  25692. 17:31:22question about the PDF document. Okay.
  25693. 17:31:24Now uh here I'm uh passing my uh here
  25694. 17:31:28I'm passing my prompt as you can see. So
  25695. 17:31:31here I'll just try to tell um using the
  25696. 17:31:34PDF u notes explain about the rainfall
  25697. 17:31:38measurement technique in a conscious
  25698. 17:31:39way. Okay. Now you'll see that uh it
  25699. 17:31:42will use the rack tool and it will
  25700. 17:31:44retrieve the information from the
  25701. 17:31:45knowledge base and it is giving you the
  25702. 17:31:47final response. As you can see, the
  25703. 17:31:48provided documents primarily discuss
  25704. 17:31:50rainfall prediction techniques using
  25705. 17:31:51machine learning regression analysis
  25706. 17:31:53rather than uh detailing specifically uh
  25707. 17:31:56specific rainfall measurement
  25708. 17:31:58techniques. Okay. And blah blah blah.
  25709. 17:32:00Now if I only want to get the text, I'll
  25710. 17:32:02just extract the text from here. Now see
  25711. 17:32:04this is now final answer guys I'm
  25712. 17:32:06getting. Okay. So that's how guys now we
  25713. 17:32:08can perform any kinds of chat operation
  25714. 17:32:10on my PDF I have loaded here. Okay. That
  25715. 17:32:12means this architecture we have
  25716. 17:32:14implemented in my notebook. Okay. I hope
  25717. 17:32:17you clear guys. Now we'll try to uh add
  25718. 17:32:20this functionality okay inside our app.
  25719. 17:32:22So as you can see this is our app we
  25720. 17:32:23created so far. Uh this was this was our
  25721. 17:32:26final app. Uh final app I think last app
  25722. 17:32:30we created this one app tool. Okay we
  25723. 17:32:32integrated the tool. Okay. Now what I'm
  25724. 17:32:34going to do guys I'm going to add this
  25725. 17:32:37uh rag features with our actual
  25726. 17:32:39application and we'll try to conclude
  25727. 17:32:41this particular video. So guys uh we
  25728. 17:32:43have seen the entire notebook experiment
  25729. 17:32:45of the rag like how uh how to implement
  25730. 17:32:48the rag functionality inside our aentic
  25731. 17:32:50chatbot and main thing we have learned
  25732. 17:32:52this tool right now we have to create
  25733. 17:32:54this uh retriever as a tool and uh this
  25734. 17:32:57tool we'll be using inside our aentic
  25735. 17:32:59chatbot. So now guys we'll be
  25736. 17:33:01integrating this features inside our
  25737. 17:33:03actual agentic chatbot we have created
  25738. 17:33:05so far. Now this was the last file I
  25739. 17:33:07created apptools.py. Okay, this was the
  25740. 17:33:09front end and the back end was uh this
  25741. 17:33:12one aentic chatbot tools back end. Okay,
  25742. 17:33:15this was my back end code. Now here what
  25743. 17:33:18I'm going to do, I'm going to create u
  25744. 17:33:22create another file. Maybe I can make a
  25745. 17:33:24copy of this file.
  25746. 17:33:26Copy.
  25747. 17:33:29And I'm going to just paste it now. I'll
  25748. 17:33:32just rename it. Okay, instead of tool
  25749. 17:33:35back end, I'll give rag back end.
  25750. 17:33:39Okay, I I'm keeping my old code as well
  25751. 17:33:41so that you can get a reference. Okay,
  25752. 17:33:42you can um you will have this code so
  25753. 17:33:45that in future whenever you are
  25754. 17:33:46practicing all of the code will remain
  25755. 17:33:48same. Uh so agentic chatbot rag
  25756. 17:33:51backend.py.
  25757. 17:33:53Okay. So this is my updated code.
  25758. 17:33:55Updated back end I'm going to write
  25759. 17:33:56here. Okay. And in this code I'll just
  25760. 17:33:59do the modification. And for front end
  25761. 17:34:01also uh I'll just create another one
  25762. 17:34:04this app tool. Right. Instead of app
  25763. 17:34:07tool, I'll copy
  25764. 17:34:09and I'll paste it first of all. Then
  25765. 17:34:12let's rename it. Instead of tool, I'm
  25766. 17:34:14going to give rag.py.
  25767. 17:34:22Okay. Now, first of all, let's uh update
  25768. 17:34:25our back end. So, I'll open my back end.
  25769. 17:34:29And here update would be
  25770. 17:34:32first of all we'll uh import all the
  25771. 17:34:34necessary library
  25772. 17:34:36whatever we have imported in my
  25773. 17:34:38notebook. So this is my updated library
  25774. 17:34:41guys as you can see pipdf loader
  25775. 17:34:42recursive character splitter google
  25776. 17:34:44generative uh yeah embedding okay files
  25777. 17:34:46and all we are importing everything
  25778. 17:34:48right then after that we'll be
  25779. 17:34:52uh we'll be just loading our embedding
  25780. 17:34:54model.
  25781. 17:34:56So after large language model definition
  25782. 17:34:58we'll just try to load our embedding
  25783. 17:35:00model. Okay the embedding model I was
  25784. 17:35:02using in my notebook. So here I think
  25785. 17:35:04remember I was using this embedding
  25786. 17:35:06model.
  25787. 17:35:08Okay let me close some of the file. This
  25788. 17:35:11file this file
  25789. 17:35:13also this file.
  25790. 17:35:23Now after that we'll just write a
  25791. 17:35:25function. Uh this function will
  25792. 17:35:28basically u take a PDF file and it will
  25793. 17:35:32extract the documents. It will perform
  25794. 17:35:34the chunking and after chunking it will
  25795. 17:35:36store all of the chunk in my vector
  25796. 17:35:38database. Okay that means this step I
  25797. 17:35:40perform right this step I perform. Okay
  25798. 17:35:43separately I'll just do inside a
  25799. 17:35:45function. So let me show you this
  25800. 17:35:47function I have already written
  25801. 17:35:52after this embedding model.
  25802. 17:36:00Just a minute.
  25803. 17:36:08Uh here I have defined this model two
  25804. 17:36:10times. Right? Okay. So I have to remove
  25805. 17:36:20So what I can do I can
  25806. 17:36:23remove and rewrite again. Okay, now I
  25807. 17:36:25think it's fine. Now I have imported all
  25808. 17:36:27the necessary library. This is my model.
  25809. 17:36:29This is my embedding function. Sorry,
  25810. 17:36:31this is my embedding model. Now we'll
  25811. 17:36:33just write this function.
  25812. 17:36:37So this is the function. I named it in
  25813. 17:36:39this track document. This will take a
  25814. 17:36:41file path and we are defining the
  25815. 17:36:43database path that means it will create
  25816. 17:36:45a folder called uh files database.
  25817. 17:36:47Inside that uh all of the vector would
  25818. 17:36:49be saved. Now we are loading the like
  25819. 17:36:52file extracting the document performing
  25820. 17:36:54the chunking operation. You can see
  25821. 17:36:56chunking operation. After that we're
  25822. 17:36:58storing everything in the files vector
  25823. 17:36:59database and then we are saving this
  25824. 17:37:01database inside our local. Okay. So this
  25825. 17:37:03is the function we'll be using and this
  25826. 17:37:05function we have to use from the front
  25827. 17:37:06end. So whenever I'll upload any file
  25828. 17:37:08from the front end that time I have to
  25829. 17:37:10execute this function and this function
  25830. 17:37:11will create my knowledge base. Okay.
  25831. 17:37:13This knowledge base should be created.
  25832. 17:37:16Okay. Now I'll just write another
  25833. 17:37:17function for the retriever.
  25834. 17:37:21Okay. So this function what it does
  25835. 17:37:23basically it loads your uh vector
  25836. 17:37:26database. Okay. That means the database
  25837. 17:37:27we are creating knowledge base we are
  25838. 17:37:28creating. First of all it will load with
  25839. 17:37:30the help of files.load local we'll be
  25840. 17:37:31loading this and we'll pass the
  25841. 17:37:33embedding model. And there is another
  25842. 17:37:35parameter you have to provide called
  25843. 17:37:36allow dangerous dialization is equal to
  25844. 17:37:38true. Then we'll create the ret again.
  25845. 17:37:40So vector store as retr. We are giving
  25846. 17:37:42the similarity s and this k parameter
  25847. 17:37:45like that. Okay. This this part we are
  25848. 17:37:47doing. Then we are creating the ret
  25849. 17:37:49object. Now with the help of this retr
  25850. 17:37:51object I'll be able to perform the
  25851. 17:37:52inbuck operation. That means I'll be
  25852. 17:37:54able to do the source operation.
  25853. 17:37:56Similarity s operation. Okay. Now we'll
  25854. 17:37:58just write our rag tool. React tool as a
  25855. 17:38:01function.
  25856. 17:38:05So this is our act to guys. As you can
  25857. 17:38:06see we created the same same function.
  25858. 17:38:09We copy pasted the same function from
  25859. 17:38:10here. Okay this one. Now this will take
  25860. 17:38:13the query. We are doing the first of all
  25861. 17:38:15we're getting the ret. We're calling
  25862. 17:38:16this function. Get retr. This will give
  25863. 17:38:19me my ret object. I will do the invoke
  25864. 17:38:21operation. Whatever document I will get
  25865. 17:38:22I'll extract all of the content from
  25866. 17:38:24here. Okay. Then I will return it.
  25867. 17:38:26That's it.
  25868. 17:38:32It's coming.
  25869. 17:38:36Now after that we'll be defining all of
  25870. 17:38:39our tools as it is. Okay, this will
  25871. 17:38:41remain same. You don't need to change
  25872. 17:38:42anything. Our search tool, our
  25873. 17:38:44calculator tool, then our get stock
  25874. 17:38:48price tool, then our get current uh
  25875. 17:38:51current weather information tool.
  25876. 17:38:53Everything will remain same. Only the
  25877. 17:38:55change I have to do here.
  25878. 17:39:00Okay. Here I have to add another tool
  25879. 17:39:02which is my rag tool
  25880. 17:39:08rag tool the function I have created
  25881. 17:39:12okay this one this function I have to
  25882. 17:39:15pass as a tool
  25883. 17:39:18then we are doing the bind operations
  25884. 17:39:20then we are defining the state and one
  25885. 17:39:23more change we'll be doing inside our
  25886. 17:39:25chat node uh now this is a simple chat
  25887. 17:39:27node we created previously it doesn't
  25888. 17:39:29have any kind of system prompt. Now
  25889. 17:39:31we'll add a system prompt here. Let me
  25890. 17:39:33show you my updated notes I have
  25891. 17:39:35created.
  25892. 17:39:38So this is my updated notes guys. Okay.
  25893. 17:39:41So here I added a detail system prompt
  25894. 17:39:43as you can see. Uh this is my system
  25895. 17:39:45message. Um has you are a helpful
  25896. 17:39:47agentic chatbot with access to several
  25897. 17:39:49tools. Use tools uh you uh tool uses
  25898. 17:39:52instruction. Use rack tool for a
  25899. 17:39:54question about uploaded PDF or
  25900. 17:39:56documents. Always retrieve relevant
  25901. 17:39:58documents content before answering the
  25902. 17:39:59PDF related questions. Use search tool
  25903. 17:40:02for current events, recent information
  25904. 17:40:04or or informations
  25905. 17:40:07that requires the internet search. Use
  25906. 17:40:09calculator uh tools for mathematical
  25907. 17:40:11calculation. Do not calculate complex
  25908. 17:40:13expression manually when calculator is
  25909. 17:40:15available. Then get stock use whenever
  25910. 17:40:18user asking about any kind of a stock
  25911. 17:40:20price and get weather whenever user is
  25912. 17:40:22asking about latest weather informations
  25913. 17:40:24and answer general questions directly.
  25914. 17:40:26uh when no tools is required do not
  25915. 17:40:28invent informations from the uploaded
  25916. 17:40:30documents. If the user ask about the PDF
  25917. 17:40:33but no documents is available ask them
  25918. 17:40:35to upload the PDF. Okay. After receiving
  25919. 17:40:37a tool result provide a clear and
  25920. 17:40:39helpful final answer. So that's how guys
  25921. 17:40:41we defined a clear system message to our
  25922. 17:40:44chatbot right now. Okay. So every aentic
  25923. 17:40:47chatbot you will see it has a message.
  25924. 17:40:49Okay. Okay, it has a prompt system uh
  25925. 17:40:50system we call it as a system prompt and
  25926. 17:40:52with the system prompt basically it uh
  25927. 17:40:54performs all the operation that means
  25928. 17:40:56whenever you are asking anything uh
  25929. 17:40:58inside a chatbot okay it uh it works
  25930. 17:41:01like a step by step how it works because
  25931. 17:41:03it has a proper system prompt and this
  25932. 17:41:05thing you have to provide okay so far we
  25933. 17:41:07haven't given but now we have given a
  25934. 17:41:09detailed system prompt because now we
  25935. 17:41:11have made it more advanced now I want my
  25936. 17:41:13chatbot to be work like a professional
  25937. 17:41:15way okay that's why we have we have
  25938. 17:41:17added this entire system prompt Now in
  25939. 17:41:20the message you will give the system
  25940. 17:41:21prompt as well as the state message user
  25941. 17:41:23is giving then we are invoking it and
  25942. 17:41:26whatever response we are getting just
  25943. 17:41:27returning it. Okay. So this is a simple
  25944. 17:41:29modification you have to do inside your
  25945. 17:41:30chat node and all of the node will
  25946. 17:41:32remain same your tool node then we are
  25947. 17:41:34defining my checkpointter SQLite
  25948. 17:41:36database. Then this is our graph. Okay.
  25949. 17:41:39All the graph definition everything will
  25950. 17:41:40remain same. No need to change anything.
  25951. 17:41:42As well as my helper function for
  25952. 17:41:44streaml front end this will also remain
  25953. 17:41:45same. Okay. So this is the change guys
  25954. 17:41:47you have to do in the back end file.
  25955. 17:41:49Okay. So this is the change you have to
  25956. 17:41:51do in the back end file. Let me check
  25957. 17:41:52whether anything is required or not. I
  25958. 17:41:55think everything is fine. Okay fine. Now
  25959. 17:41:58I have to change my front end. Now what
  25960. 17:42:00I will do? I'll just try to open my
  25961. 17:42:01front end app rag.py. Now see what I
  25962. 17:42:05have done guys. I just copied my
  25963. 17:42:07existing front-end code to chat GPT and
  25964. 17:42:10I asked I need a document uploader
  25965. 17:42:13function features on my uh chatbot. So
  25966. 17:42:17try to create uh streaml uh user
  25967. 17:42:19interface for that. Okay. So then I got
  25968. 17:42:22this code. Let me show you.
  25969. 17:42:25This is the updated code I got.
  25970. 17:42:31This is the updated code I got. So
  25971. 17:42:33basically this has the document upload
  25972. 17:42:36features. Okay. So if you don't know
  25973. 17:42:37about front end design and all don't
  25974. 17:42:39need to worry. So this is the work of a
  25975. 17:42:40front- end developer. So I also took the
  25976. 17:42:43help from charg uh created this front
  25977. 17:42:46end. But only the change you have to do
  25978. 17:42:48here. Okay. First of all you have to
  25979. 17:42:50change this uh import operation that
  25980. 17:42:53means right now we are importing from
  25981. 17:42:54agentic chatbot rag back end. So from
  25982. 17:42:57aentic
  25983. 17:42:58chatbot rag back end. Okay, we are
  25984. 17:43:01importing chatbot. Then get all threads.
  25985. 17:43:06Uh
  25986. 17:43:08get all threads. Okay, this one and uh
  25987. 17:43:11we are also importing ingest rack
  25988. 17:43:13documents. Okay, that means this
  25989. 17:43:15function this function I need whenever I
  25990. 17:43:16will upload any kinds of documents on my
  25991. 17:43:18streaml. So this function will be
  25992. 17:43:20executed and my vector store would be
  25993. 17:43:22ready. Okay, that time then everything
  25994. 17:43:24will remain same only the change here it
  25995. 17:43:27has done. Let me show you.
  25996. 17:43:29See this is the new code it has added.
  25997. 17:43:31If you if you compare with your previous
  25998. 17:43:34code so this part has changed. Okay. So
  25999. 17:43:36here in the uploaded um section that
  26000. 17:43:39mean in in the user input section it has
  26001. 17:43:41added another one called uploaded file.
  26002. 17:43:42So basically here it is taking a PDF
  26003. 17:43:44file upload and uh we are taking this
  26004. 17:43:47PDF file we saving as a temporary file.
  26005. 17:43:50Then we are calling this in just drag
  26006. 17:43:51documents. We are passing inside this
  26007. 17:43:53function. Okay. And this function is
  26008. 17:43:54creating my knowledge base. this
  26009. 17:43:56knowledge base will be created. That
  26010. 17:43:57means this uh uh vector store would be
  26011. 17:44:00created. Once my vector store is
  26012. 17:44:02created, now you'll be able to perform
  26013. 17:44:04the chart operation. Again, we are uh
  26014. 17:44:06taking the user input and doing the
  26015. 17:44:08chart operation. Okay, that means all
  26016. 17:44:09the code are common. Only that pass uh
  26017. 17:44:11that part is changed. Okay, that means
  26018. 17:44:13upload document part is changed. Now,
  26019. 17:44:15let me show you my updated uh front end
  26020. 17:44:17how it look like. So streamllet
  26021. 17:44:22run
  26022. 17:44:24app
  26023. 17:44:26rag.py.
  26024. 17:44:37So as you can see this is my updated
  26025. 17:44:39front end. Now we can perform the chat
  26026. 17:44:42operation. Now let's perform the simple
  26027. 17:44:44chat initially. So let's say I'll give
  26028. 17:44:47hello
  26029. 17:44:50I am BP and this is happen happening in
  26030. 17:44:53a like new trades. Okay, completely new
  26031. 17:44:56trades
  26032. 17:44:59and internally it is also tracing our
  26033. 17:45:02application. Okay, it is also tracing
  26034. 17:45:04our application with the help of
  26035. 17:45:05linesmith.
  26036. 17:45:07Now I'll give uh tell me about
  26037. 17:45:12let's say
  26038. 17:45:15Python. So this is a simple chart.
  26039. 17:45:20So it is telling you about Python. Okay.
  26040. 17:45:23Now here I will ask uh what is
  26041. 17:45:35what is the answer of
  26042. 17:45:41this equation. Let's say I'll give a
  26043. 17:45:42mathematical equation.
  26044. 17:45:54I'll see it will use my calculator tool.
  26045. 17:45:56See calculator tool it is using and this
  26046. 17:45:58is the final result I'm getting. Okay.
  26047. 17:46:00Now I'll ask uh what is the
  26048. 17:46:06current
  26049. 17:46:09weather
  26050. 17:46:13in let's say
  26051. 17:46:17Dhaka.
  26052. 17:46:22Now it will use my get current weather
  26053. 17:46:24tool and this is the current weather in
  26054. 17:46:26Dhaka right now. Okay. And now I will
  26055. 17:46:28ask about the latest information. Tell
  26056. 17:46:30me the
  26057. 17:46:33latest
  26058. 17:46:35news.
  26059. 17:46:40Okay. Latest news
  26060. 17:46:44of FIFA. FIFA World Cup
  26061. 17:46:522026.
  26062. 17:47:01Now see it is using tab search tool
  26063. 17:47:05and here is the
  26064. 17:47:08answer I got. Okay about the FIFA World
  26065. 17:47:10Cup. Okay. Now I will ask uh I will
  26066. 17:47:13upload a documents. Let's say I'll
  26067. 17:47:15upload documents
  26068. 17:47:17the same documents. Let's say I'll
  26069. 17:47:18upload my paper.
  26070. 17:47:26My paper got uploaded. Now I'll tell
  26071. 17:47:29uh tell me about
  26072. 17:47:33rainfall
  26073. 17:47:35measurement
  26074. 17:47:38uh based on
  26075. 17:47:41the PDF
  26076. 17:47:44loaded.
  26077. 17:47:48Now see it is using rack tool and it is
  26078. 17:47:51giving you the entire response about the
  26079. 17:47:54rainfall measurement. Okay, this
  26080. 17:47:55amazing. Now I'll tell her tell me
  26081. 17:47:59about
  26082. 17:48:03the
  26083. 17:48:05abstract
  26084. 17:48:07paper.
  26085. 17:48:21Now see again it is using rag tool and
  26086. 17:48:23this is giving you the inter
  26087. 17:48:24abstruction. Okay. Now I'll ask uh who
  26088. 17:48:28is Bier Ahmed Bi
  26089. 17:48:34mentioned
  26090. 17:48:37in the paper.
  26091. 17:48:42Now again it is using react tool and now
  26092. 17:48:45it is telling Bkt Ahmed Bi is one of the
  26093. 17:48:48six author of the paper development of
  26094. 17:48:50multiple combined regression method for
  26095. 17:48:51reinforce measurement. And uh here is
  26096. 17:48:54the address and email address. Okay.
  26097. 17:48:56Amazing, right? So that's how guys our
  26098. 17:48:58agentic chatbot right now it's working
  26099. 17:49:00and it has it has lots of advanced
  26100. 17:49:03feature right now and the current one we
  26101. 17:49:05have added this rag functionality. Now
  26102. 17:49:07you can upload any kinds of document and
  26103. 17:49:09you can perform the conversation on top
  26104. 17:49:11of that. Okay. Like chat GPT like chat
  26105. 17:49:13GPT also you can upload any kinds of
  26106. 17:49:16documents. Okay. And you can start doing
  26107. 17:49:18the conversation here. Okay. This is
  26108. 17:49:20also possible. And one more thing I want
  26109. 17:49:23to show you. So if I go to my langispit
  26110. 17:49:25right now. So if I go to my trades.
  26111. 17:49:29So I'll go to this trades
  26112. 17:49:32and here all the conversation I have
  26113. 17:49:34done. So the last conversation I did uh
  26114. 17:49:37this one. Now if I go to the two
  26115. 17:49:40condition
  26116. 17:49:44okay I'm happy. I think last
  26117. 17:49:45conversation was that. Okay. This one.
  26118. 17:49:48Yeah. Now you can see here uh whenever I
  26119. 17:49:50did the conversation first of all it it
  26120. 17:49:52went to the chat node then large
  26121. 17:49:54language model then um it was redirected
  26122. 17:49:57to the tool condition tool condition was
  26123. 17:49:58selected the tool now it selected the
  26124. 17:50:01rack tool okay and inside rack tool we
  26125. 17:50:03are using this vector search ret
  26126. 17:50:05operation okay and with the help of that
  26127. 17:50:06it is doing the vector search and it
  26128. 17:50:09found actually four relevant response
  26129. 17:50:10you can see okay from my knowledge base
  26130. 17:50:12and this four relevant response went to
  26131. 17:50:14my chat nodes again that means my llm
  26132. 17:50:17with the prompt
  26133. 17:50:18and then uh it was generating the final
  26134. 17:50:21response. Okay. So that's how this
  26135. 17:50:22entire system is working and in the
  26136. 17:50:24Langmith platform itself you can monitor
  26137. 17:50:26the entire system. Okay. This is the
  26138. 17:50:28best part of this uh of this actually
  26139. 17:50:30application is. So yes guys uh this is
  26140. 17:50:33the um like uh chatbot we have created
  26141. 17:50:37so far. This is our agentic chatbot we
  26142. 17:50:38have created so far and everything is
  26143. 17:50:41working fine and all the codes I will be
  26144. 17:50:42sharing in my description section. from
  26145. 17:50:44there you can check it out and uh let me
  26146. 17:50:46know how this uh learning is okay
  26147. 17:50:49whether you are able to learn uh the
  26148. 17:50:51agent TKI concept from my playlist or
  26149. 17:50:52not. So if you found my content useful
  26150. 17:50:55guys please try to subscribe to my
  26151. 17:50:56channel and share this with your friends
  26152. 17:50:58and family okay your support is
  26153. 17:50:59required. So if you're supporting me
  26154. 17:51:01guys, I'll get lots of motivation to
  26155. 17:51:03bring this kinds of content. Okay. In
  26156. 17:51:05this video, we'll be learning one very
  26157. 17:51:07interesting concept called human in the
  26158. 17:51:09loop HIT L inside our agentic chatbot
  26159. 17:51:13with the help of Langraph. If you are
  26160. 17:51:15following my entire playlist guys from
  26161. 17:51:17the beginning, I think you remember uh
  26162. 17:51:20in my introduction uh video, I already
  26163. 17:51:22talked about this HITL that means human
  26164. 17:51:24in the loop concept. uh that means uh
  26165. 17:51:27this is the uh component of an AI agent.
  26166. 17:51:30Whenever you are implementing any kinds
  26167. 17:51:33of AI agents uh whenever you need any
  26168. 17:51:36sensitive task, you need this HITL
  26169. 17:51:38concept that means human in the loop
  26170. 17:51:40concept. Okay. Uh so in this video guys,
  26171. 17:51:42we'll try to uh learn this entire HITL
  26172. 17:51:46concept. We'll also see the practical
  26173. 17:51:48and we'll also try to integrate this
  26174. 17:51:51functionality inside our agentic
  26175. 17:51:52chatbot. So before I start this uh
  26176. 17:51:56implementation guys, first of all I want
  26177. 17:51:57to show you the demo how this uh hit uh
  26178. 17:52:01looks like and uh after adding this
  26179. 17:52:04inside our agentic chatbot how uh it is
  26180. 17:52:07going to work. Okay, we'll try to see
  26181. 17:52:09the demo after seeing the demo we'll try
  26182. 17:52:11to understand this concept in a
  26183. 17:52:12theoretical manner then we'll see the
  26184. 17:52:15practical implementation as well. So
  26185. 17:52:17guys this is our agentic chatbot that's
  26186. 17:52:19how this chatbot looks like. So right
  26187. 17:52:21now you can upload any kinds of document
  26188. 17:52:23and you can start a conversation okay on
  26189. 17:52:25top of your documents this is possible.
  26190. 17:52:27So let's try to test our chatbot and I
  26191. 17:52:30already integrated this hit with this
  26192. 17:52:33agentic chatbot. I'm first of all going
  26193. 17:52:35to um show you the demo then after that
  26194. 17:52:37we'll try to see the practical
  26195. 17:52:38development. So here uh you can perform
  26196. 17:52:41the simple chat operation. Let's say if
  26197. 17:52:43I give hello so your chatbot will return
  26198. 17:52:45something. See hello can help you today.
  26199. 17:52:48Now we'll ask uh what is the
  26200. 17:52:54what is the
  26201. 17:52:56current weather
  26202. 17:52:59in Dhaka
  26203. 17:53:03you will see that it will be using uh
  26204. 17:53:05different different tools okay that
  26205. 17:53:07means it will use uh weather tools and
  26206. 17:53:09it will give me current weather
  26207. 17:53:10informations okay uh given any kinds of
  26208. 17:53:12location even you can upload any kinds
  26209. 17:53:15of documents let's say I will upload one
  26210. 17:53:17of my documents ments. Let's I will
  26211. 17:53:19upload these documents.
  26212. 17:53:21Okay.
  26213. 17:53:28Okay. Now this is uh one of my resume I
  26214. 17:53:31have uploaded. Now I'll ask some
  26215. 17:53:32question on top of this uh PDF. So tell
  26216. 17:53:35me about Boktier
  26217. 17:53:40Ahmed
  26218. 17:53:45By
  26219. 17:53:47based on
  26220. 17:53:51the PDF.
  26221. 17:53:54Okay. Upload it.
  26222. 17:54:02Now we'll see that it will be using rag
  26223. 17:54:03tool and it is giving you the entire uh
  26224. 17:54:07entire actually introduction of bkirhmed
  26225. 17:54:09bpi is a data scientist over 5 years of
  26226. 17:54:12uh working experience in the field of
  26227. 17:54:14generative loops autonomous AI system
  26228. 17:54:17okay and blah blah blah you can see the
  26229. 17:54:19entire summary uh of me okay so that's
  26230. 17:54:22how guys uh you can perform any kinds of
  26231. 17:54:24conversation uh on any kinds of
  26232. 17:54:26documents okay now here let me show you
  26233. 17:54:29this uh hit functionality I have added
  26234. 17:54:31added in this agentic chatbot. So
  26235. 17:54:33basically here I have added this hit for
  26236. 17:54:37one sensitive task. Okay, sensitive task
  26237. 17:54:39means I think you know that uh with the
  26238. 17:54:41help of this agentic chatbot I can see
  26239. 17:54:43any kinds of stock price, right? So
  26240. 17:54:45let's say if I asking uh let's say what
  26241. 17:54:48is the
  26242. 17:54:51stock
  26243. 17:54:53price
  26244. 17:54:55of
  26245. 17:54:57Apple? Okay. So I think you know that it
  26246. 17:55:00has a tool uh that tool actually real
  26247. 17:55:02time f the stock prices. Okay. Given any
  26248. 17:55:05kinds of company. So if I let's say send
  26249. 17:55:07this prompt you'll see that it will use
  26250. 17:55:09that tool using get stock price tool.
  26251. 17:55:11Okay. And this is the current uh stock
  26252. 17:55:13price we are getting of the Apple. Now I
  26253. 17:55:16want to perform a sensitive task with
  26254. 17:55:19this uh aentic chatbot. Basically I want
  26255. 17:55:21to purchase a stock of Apple. Okay. I
  26256. 17:55:24want to let's say purchase 10 stock of
  26257. 17:55:25Apple. Now this task required actually
  26258. 17:55:28human observation that means human
  26259. 17:55:30approval. It's not like that you want um
  26260. 17:55:33you are giving your agents uh the 100%
  26261. 17:55:36authority to perform all of the task.
  26262. 17:55:38It's not like that because there are
  26263. 17:55:39some sensitive things you have to
  26264. 17:55:41monitor okay manually and this is this
  26265. 17:55:44needs actually human approval. So here
  26266. 17:55:45let's see if I am asking to my agents uh
  26267. 17:55:49purchase
  26268. 17:55:53okay purchase let's say 10 stock
  26269. 17:56:00of apple
  26270. 17:56:05okay let's say I'm asking this question
  26271. 17:56:07and this is a sensitive task and for
  26272. 17:56:09this you will see that it will ask for
  26273. 17:56:11human approval okay now if I send this
  26274. 17:56:13prompt
  26275. 17:56:16Now see it is asking for the human
  26276. 17:56:18approval. Human approval required.
  26277. 17:56:20Approve buying 10 shares of Apple. Yes
  26278. 17:56:23or no? Do you want to give me the
  26279. 17:56:25permission? Um if you want I can buy. So
  26280. 17:56:28for this you have to provide yes
  26281. 17:56:30otherwise you can reject this particular
  26282. 17:56:32uh approval. Okay. So let's see if I am
  26283. 17:56:35giving yes. I will approach this approve
  26284. 17:56:36this purchase. Now you'll see that it
  26285. 17:56:39will use my purchase stock tool and it
  26286. 17:56:40will purchase the shares of the Apple.
  26287. 17:56:43Okay. Now if I'm again asking this thing
  26288. 17:56:46let's say
  26289. 17:56:49um purchase 10 stock of
  26290. 17:56:54Google.
  26291. 17:56:59Now see again it is asking for human
  26292. 17:57:01approval. Now right now let's say if I'm
  26293. 17:57:02rejecting the purchase you'll see that
  26294. 17:57:05it will not purchase that. Okay your
  26295. 17:57:07request to purchase 10 shares of Google
  26296. 17:57:09was declined. Okay. So this is called
  26297. 17:57:11actually HITL that means human in the
  26298. 17:57:14loop. Uh basically if you have already
  26299. 17:57:16used any kinds of agentic system guys.
  26300. 17:57:19Okay. Uh you will see that this kinds of
  26301. 17:57:21functionality they are having they will
  26302. 17:57:22ask for human approval. Uh if you are
  26303. 17:57:25already using any kinds of code editor
  26304. 17:57:27also like uh um this uh anti-gravity or
  26305. 17:57:30cursor AI. Okay. There also you will see
  26306. 17:57:32that whenever you want to generate
  26307. 17:57:33something generate some code or if you
  26308. 17:57:36want to create any project you will it
  26309. 17:57:37will ask for the human permission. Okay.
  26310. 17:57:39If it required that time you if you are
  26311. 17:57:41giving the permission okay that time
  26312. 17:57:44actually it will perform all of the task
  26313. 17:57:45otherwise it will decline that okay so
  26314. 17:57:48this functionality guys we have
  26315. 17:57:49integrated inside our agentic chatbot
  26316. 17:57:51and now this chatbot is super advanced
  26317. 17:57:53okay now it can do all of the task and
  26318. 17:57:56uh uh you can actually integrate this
  26319. 17:58:00not only in this stock price purchase uh
  26320. 17:58:04but also you can integrate uh these
  26321. 17:58:06things in any kinds of let's say task
  26322. 17:58:08you are performing. I'll show you okay
  26323. 17:58:10how to do that. And uh you can uh feel
  26324. 17:58:13free to add uh so many tools here. Okay.
  26325. 17:58:15Uh so many autonomous tool you can add
  26326. 17:58:17here. Let's say you want to send
  26327. 17:58:18automatically email you can add the
  26328. 17:58:20emailing tool. If you want to uh check
  26329. 17:58:22uh your Google drive, okay, how many
  26330. 17:58:24files are present and if you want to
  26331. 17:58:26upload any file so you can also add
  26332. 17:58:28these kinds of tools. Okay, I already
  26333. 17:58:29talked about the tools and this video is
  26334. 17:58:31already available over my channel. You
  26335. 17:58:33can see that. Okay, how to add different
  26336. 17:58:34different tools. So yes guys uh this is
  26337. 17:58:36the demo of this u u hitl human in the
  26338. 17:58:39loop. Now we'll try to see this human in
  26339. 17:58:42the loop u uh what is this human in the
  26340. 17:58:45loop? Okay why it is required in a
  26341. 17:58:46theoretical manner then I'm going to
  26342. 17:58:48show you the practical implementation of
  26343. 17:58:50that. So guys if you are completely new
  26344. 17:58:52to my channel and if you haven't
  26345. 17:58:53subscribed yet please try to subscribe
  26346. 17:58:55to my channel. Uh if you found my
  26347. 17:58:57content useful uh please support me if
  26348. 17:58:59uh if I get your support. So definitely
  26349. 17:59:02I will get lots of motivation and I will
  26350. 17:59:04bring this kinds of content more. So
  26351. 17:59:06please try to subscribe to my channel
  26352. 17:59:08and hit the like and please try to share
  26353. 17:59:09this with your friends and family as
  26354. 17:59:11well. So guys first of all let's try to
  26355. 17:59:13understand what is this HITL is. As you
  26356. 17:59:16can see from from the definition itself,
  26357. 17:59:18HITL that means human in the loop is a
  26358. 17:59:21design approach in agentic systems where
  26359. 17:59:23a human actively participates at
  26360. 17:59:26critical points of the AI workflow uh
  26361. 17:59:29either to supervise, approve, correct or
  26362. 17:59:32guide the model's output. Okay. So this
  26363. 17:59:35is the concept actually it's required
  26364. 17:59:38whenever you are performing any kinds of
  26365. 17:59:40uh sensitive task. Whenever you are
  26366. 17:59:42performing any kinds of let's say very
  26367. 17:59:44critical task that time this HITL is
  26368. 17:59:47required and if you are creating this
  26369. 17:59:49kinds of agentic system I think you know
  26370. 17:59:51that where you need to exactly add this
  26371. 17:59:53HITL feature because inside agentic
  26372. 17:59:57project actually there would be multiple
  26373. 17:59:58kinds of task let's say uh here uh
  26374. 18:00:01inside our chatbot we have added
  26375. 18:00:02different different task let's say our
  26376. 18:00:04chatbot can perform internet source
  26377. 18:00:05operation it can give you the weather
  26378. 18:00:08information okay so for these kinds of
  26379. 18:00:10task actually I don't need this hit
  26380. 18:00:12features. Okay. But let's say I showed
  26381. 18:00:14you one demo. I need to purchase a stock
  26382. 18:00:17price. This is a critical and sensitive
  26383. 18:00:20task. Okay. And definitely needs human
  26384. 18:00:22approval. Otherwise, if I give the full
  26385. 18:00:24authority to my AI agents, uh it it may
  26386. 18:00:27actually uh do something wrong. Okay.
  26387. 18:00:29Let's say uh I will tell uh please
  26388. 18:00:32purchase 10 shares of Apple. Okay. So,
  26389. 18:00:35what it can do? It can let's say
  26390. 18:00:37purchase 20 shares of Apple. Okay. uh it
  26391. 18:00:40can let's say spend more money okay of
  26392. 18:00:43me so that's why this human uh uh in the
  26393. 18:00:46loop is required in this kinds of
  26394. 18:00:48critical task that's how inside an
  26395. 18:00:50agentic AI project there would be
  26396. 18:00:52multiple uh like scenario uh you might
  26397. 18:00:55need to add this HITL okay it's not
  26398. 18:00:57necessary to add this HL to all of your
  26399. 18:01:00features all of your task okay wherever
  26400. 18:01:03you feel like okay this is required for
  26401. 18:01:05me you can add add it there okay so
  26402. 18:01:07that's why you can see this HL L it's a
  26403. 18:01:10design approach in AI agentic AI system.
  26404. 18:01:12Okay, where a human actively part
  26405. 18:01:14participates at a critical point of the
  26406. 18:01:16AI workflow. Okay, that means this is
  26407. 18:01:19your completely uh your design uh
  26408. 18:01:21philosophy here. Okay, you will be
  26409. 18:01:23designing this kinds of HITL uh
  26410. 18:01:25functionality inside your project. Now
  26411. 18:01:28you can see think of a HLTL uh as
  26412. 18:01:31putting a human checkpoints inside an AI
  26413. 18:01:33pipeline uh so that important decisions
  26414. 18:01:36are not made automate autonomously by
  26415. 18:01:38the model. Okay, that is what I told
  26416. 18:01:40you. So whenever you need this kinds of
  26417. 18:01:42uh critical task handling uh you are not
  26418. 18:01:45going to give the full authority to your
  26419. 18:01:47uh agent. So that time it will not
  26420. 18:01:49automatically take the decision okay uh
  26421. 18:01:52by your agent that time you will be
  26422. 18:01:54available okay in this particular loop
  26423. 18:01:56and if you approve that particular task
  26424. 18:01:58uh this will perform otherwise this will
  26425. 18:02:00not perform okay this is what actually
  26426. 18:02:02this definition says now you can see why
  26427. 18:02:06exist uh as I already told you to help
  26428. 18:02:08agentic system that means whenever you
  26429. 18:02:10are creating any kind of agentic system
  26430. 18:02:12so to help the agentic system you need
  26431. 18:02:14this kinds of hitl for an example let's
  26432. 18:02:17say you want to imple element an agent
  26433. 18:02:18uh that will uh prepare a post okay that
  26434. 18:02:22will prepare a LinkedIn post and uh it
  26435. 18:02:24will uh post over the LinkedIn platform
  26436. 18:02:27okay so here to create the LinkedIn post
  26437. 18:02:30it doesn't need any kinds of human
  26438. 18:02:32approval but whenever it will post that
  26439. 18:02:35uh let's say on the LinkedIn platform
  26440. 18:02:37that time this human approval is
  26441. 18:02:38required because human will review the
  26442. 18:02:41entire post if the post is fine then
  26443. 18:02:44they will approve this post and this
  26444. 18:02:46post would be published list over the
  26445. 18:02:47Ling platform. Okay. So here basically
  26446. 18:02:50this HITL helping the agentic system.
  26447. 18:02:53Okay. Uh to perform the complete task.
  26448. 18:02:56Okay. Uh I think you can understand what
  26449. 18:02:59I'm trying to say. Then the second to
  26450. 18:03:01add the accountability. Accountability
  26451. 18:03:04means let's say I already told you
  26452. 18:03:06agentic system can make mistake. So
  26453. 18:03:08let's say if you are telling I need to
  26454. 18:03:10purchase 20 stock of Apple. Okay. So
  26455. 18:03:13there is a possibility your agent will
  26456. 18:03:16uh your agent will uh will try to
  26457. 18:03:18purchase let's say four 40 stock of
  26458. 18:03:21Apple. Okay. So there is a problem
  26459. 18:03:23right? So before purchasing that stock
  26460. 18:03:26first of all you will try to review that
  26461. 18:03:28whether uh the amount you want to
  26462. 18:03:31purchase it is fine or not. The price uh
  26463. 18:03:33Apple is having for the stock it is fine
  26464. 18:03:35or not. If everything goes fine then you
  26465. 18:03:37will try to give the approval otherwise
  26466. 18:03:39you will try to reject. Okay. So that's
  26467. 18:03:41why this uh HITL is exist. Uh it will
  26468. 18:03:44help you to help the agentic system and
  26469. 18:03:47uh to add the accountability as well.
  26470. 18:03:49Okay. Now you can see HITL ensures
  26471. 18:03:53accuracy definitely uh if you are
  26472. 18:03:55implementing this HITL inside your
  26473. 18:03:57agents uh there would be uh higher
  26474. 18:04:00accuracy inside your agentic system. Um
  26475. 18:04:02otherwise uh there are some problem. I
  26476. 18:04:04think I have already explained that okay
  26477. 18:04:06what would be the problem. uh so if you
  26478. 18:04:08are adding this one so definitely
  26479. 18:04:09accuracy will increase inside your
  26480. 18:04:11agentic system that's why in charge GPT
  26481. 18:04:13Google gemini whatever agentic system
  26482. 18:04:15you are using all of the applications
  26483. 18:04:17are having this kinds of hit
  26484. 18:04:19functionality okay in charge also maybe
  26485. 18:04:21you have observed uh it will tell you
  26486. 18:04:23okay uh do I need to perform the uh
  26487. 18:04:25perform this task or not okay if you
  26488. 18:04:27give yes then it will perform otherwise
  26489. 18:04:29it will not perform okay then safety
  26490. 18:04:31definitely safety is required uh as I
  26491. 18:04:34already given you one example that stock
  26492. 18:04:36price uh purchase this demo. So there
  26493. 18:04:38let's say if I'm not giving this kinds
  26494. 18:04:39of hits features that that times that is
  26495. 18:04:42a possibility our agents will purchase
  26496. 18:04:45more stock which I which I don't need.
  26497. 18:04:47Okay. So definitely this is one kinds of
  26498. 18:04:49safety. Then the next thing uh is
  26499. 18:04:52ethical alignment. Let's say um if you
  26500. 18:04:55are doing a task that have some kinds of
  26501. 18:04:58ethical alignment. Let's say we are
  26502. 18:05:00preparing a post for the LinkedIn and
  26503. 18:05:02that post should not have any kinds of
  26504. 18:05:05let's say sexual content or let's say
  26505. 18:05:08abusive content. Uh so uh that time
  26506. 18:05:11actually you can have this kinds of
  26507. 18:05:12ethics. Um you can uh basically review
  26508. 18:05:15that and uh if you approve that kinds of
  26509. 18:05:17content
  26510. 18:05:19uh then your agent uh agent will
  26511. 18:05:21basically uh post that otherwise it will
  26512. 18:05:24not post that. That means if your
  26513. 18:05:25content is having this kinds of uh uh
  26514. 18:05:27these kinds of uh sexual and abusive
  26515. 18:05:29content you will reject and uh if if it
  26516. 18:05:32doesn't have that that time you will try
  26517. 18:05:34to approve that. Okay. So these kinds of
  26518. 18:05:35ethical alignment um also ensures this
  26519. 18:05:38HITL then better user experience as I
  26520. 18:05:41already told you um if you are adding
  26521. 18:05:43these kinds of things so definitely
  26522. 18:05:45there would be better user experience uh
  26523. 18:05:47as you already observed inside our app
  26524. 18:05:49right so it was giving some kinds of uh
  26525. 18:05:52approved uh let's say input and if
  26526. 18:05:54you're approving that the task was
  26527. 18:05:56happening if you are not approving the
  26528. 18:05:57task was not happening so this is kinds
  26529. 18:05:59of better user experience okay you are
  26530. 18:06:01providing with the help of this HITL
  26531. 18:06:03then some common HITL patterns as you
  26532. 18:06:06can see action approval patterns approve
  26533. 18:06:08reject before execution uh as I already
  26534. 18:06:10told uh showed you one demo right so
  26535. 18:06:12basically whenever you want to perform
  26536. 18:06:14any task and uh if it needs any kinds of
  26537. 18:06:16action so here you you can perform with
  26538. 18:06:19the help of this HITL you can approve or
  26539. 18:06:21reject uh before the execution then
  26540. 18:06:23output review and edit pattern so maybe
  26541. 18:06:25you have seen um any kinds of uh uh
  26542. 18:06:29block generation let's say agent so what
  26543. 18:06:31it does basically it generates some
  26544. 18:06:32kinds of output then it It's for the
  26545. 18:06:34human review. Okay. Uh human review and
  26546. 18:06:37edit. So if they review and edit and
  26547. 18:06:39approve this kinds of output then it
  26548. 18:06:41will finalize that otherwise it will not
  26549. 18:06:43finalize that. Then ambiguity
  26550. 18:06:45clarification pattern. So sometimes your
  26551. 18:06:47agent is asking let's say uh your your
  26552. 18:06:51agent is getting confused right. Let's
  26553. 18:06:52say you are asking your agent schedule a
  26554. 18:06:54meeting on Friday. So let's say in this
  26555. 18:06:56week also you have the Friday and next
  26556. 18:06:58week also you have the Friday. So that
  26557. 18:07:00time your agent needs a clarification.
  26558. 18:07:02Now which Friday it needs to schedule
  26559. 18:07:04the meeting. So again it will ask you uh
  26560. 18:07:06actually I'm a little bit confused which
  26561. 18:07:08Friday you are u like talking about this
  26562. 18:07:11Friday or the next Friday. So this is
  26563. 18:07:13called ambiguity clarification pattern.
  26564. 18:07:14Then escalation pattern let's say
  26565. 18:07:16sometimes what happens in some kinds of
  26566. 18:07:18chatbot. So it uh talks with the
  26567. 18:07:20customer and when it feels like okay it
  26568. 18:07:22cannot handle this kinds of scenario it
  26569. 18:07:25will redirect to the actual actually um
  26570. 18:07:29actual owner of that uh company and they
  26571. 18:07:32will basically handle this kinds of
  26572. 18:07:33scenario. Okay, this is called
  26573. 18:07:34escalation pattern and that can be also
  26574. 18:07:36implemented with the help of this HITL.
  26575. 18:07:38Okay, so yes uh this is the entire idea
  26576. 18:07:41of this uh HITL. I think you have
  26577. 18:07:43understood. Now uh we'll try to see how
  26578. 18:07:46this HITL works. Okay. Uh in a practical
  26579. 18:07:49uh way. First of all, I will uh I will
  26580. 18:07:51show you this uh diagram wise how this
  26581. 18:07:54hit will work. So for this here I have
  26582. 18:07:56taken an example. So here I have taken a
  26583. 18:07:59basic workflow guys. As you can see this
  26584. 18:08:01workflow you can consider this is a post
  26585. 18:08:04generation workflow. Let's say uh you
  26586. 18:08:07can generate any kinds of LinkedIn post.
  26587. 18:08:09So you can see uh it has the start node.
  26588. 18:08:12First of all, user will pass a topic and
  26589. 18:08:14if submits the topic, it will go to the
  26590. 18:08:16um your langraph workflow. Okay. And it
  26591. 18:08:19will execute the start node. Then it
  26592. 18:08:21will uh perform the resource operation
  26593. 18:08:23of that particular topic. And once it
  26594. 18:08:25found the content, it will prepare the
  26595. 18:08:27content. And here it will uh post that
  26596. 18:08:30particular content over the LinkedIn.
  26597. 18:08:31But here we'll try to add this hit
  26598. 18:08:33feature. Okay? Because before posting
  26599. 18:08:35that definitely it needs the human
  26600. 18:08:37approval. It will ask me whether I have
  26601. 18:08:40to post or not. Okay? So if I review
  26602. 18:08:42that, if I approve that then it will
  26603. 18:08:44post otherwise it will not post then
  26604. 18:08:45this workflow is getting ended. So let's
  26605. 18:08:47try to understand this agit um with this
  26606. 18:08:50particular example. So see what is
  26607. 18:08:52happening. Let's say you are passing a
  26608. 18:08:53topic name here. Let's see what topic uh
  26609. 18:08:55you are passing a topic name of machine
  26610. 18:08:58learning. Let's say ML. Let me take this
  26611. 18:09:00color. Let's giving ML topic. Okay. So
  26612. 18:09:04this ML topic you are submitting here
  26613. 18:09:06and it will go to your langraph
  26614. 18:09:09workflow. So this is the lang graph
  26615. 18:09:11workflow we have created let's say. So
  26616. 18:09:13first of all here it will prepare a
  26617. 18:09:15state. I think you know that we have to
  26618. 18:09:16prepare a state right. And here what
  26619. 18:09:18would be the state? State would be the
  26620. 18:09:19topic and as well as the draft that
  26621. 18:09:22means draft post it is generating.
  26622. 18:09:25Okay. So it will uh first of all uh
  26623. 18:09:28invoke this uh uh workflow and it will
  26624. 18:09:31go to the research node and research
  26625. 18:09:33node will perform the research
  26626. 18:09:34operation. It will try to find ML
  26627. 18:09:36related uh latest uh let's say
  26628. 18:09:39information and it will prepare a post.
  26629. 18:09:41Okay. Once post is prepared then here
  26630. 18:09:43we'll try to add this HITL feature.
  26631. 18:09:45Okay. Hi TL feature. Human in the loop
  26632. 18:09:47features. Okay. Now how human in the
  26633. 18:09:49loop feature works. Let me give you as a
  26634. 18:09:51highle uh like uh high level idea. Uh
  26635. 18:09:55definitely we'll try to see in practical
  26636. 18:09:56manner how to write in the code. But I
  26637. 18:09:58will give you this one highle code
  26638. 18:09:59diagram how it will work. Okay. So see
  26639. 18:10:02whenever you are implementing this HITL
  26640. 18:10:05inside any kinds of node right uh that
  26641. 18:10:08time you will be using one function
  26642. 18:10:11called interrupt okay this is already
  26643. 18:10:12available inside langraph uh inside
  26644. 18:10:14langraph actually this hit
  26645. 18:10:16implementation is super easy so there is
  26646. 18:10:18a function called inter in uh interrupt
  26647. 18:10:20okay interrupt
  26648. 18:10:23interrupt function okay so once you will
  26649. 18:10:25use this interrupt function this
  26650. 18:10:27execution will pause here okay this
  26651. 18:10:29execution will pause here unless and
  26652. 18:10:31until you are not giving any kinds of
  26653. 18:10:32input. So let's say here I I'll take a
  26654. 18:10:35variable called decision.
  26655. 18:10:37Decision
  26656. 18:10:43decision is equal to okay interrupt. Now
  26657. 18:10:47here user will pass something. Let's say
  26658. 18:10:49if user pass this decision
  26659. 18:10:53decision is equal is equal to yes that
  26660. 18:10:56time post will happen. Okay. Else
  26661. 18:11:00it will reject.
  26662. 18:11:02Okay. So this is the highle code diagram
  26663. 18:11:04you can understand. That's how actually
  26664. 18:11:06lang graph will work. Okay. So here
  26665. 18:11:08we'll try to use uh one function called
  26666. 18:11:10interrupt and this function will
  26667. 18:11:11basically pause the execution unless and
  26668. 18:11:14until human not human is not giving any
  26669. 18:11:16kinds of input. Okay. Now you can define
  26670. 18:11:19your input like what kinds of input you
  26671. 18:11:21need from the user. This kinds of
  26672. 18:11:22functionality also you can add here.
  26673. 18:11:24Okay. Then after getting the input you
  26674. 18:11:27can uh execute your workflow. And one
  26675. 18:11:30more thing which is very important
  26676. 18:11:32whenever you are implementing this HITL
  26677. 18:11:35you have to add the checkpointer. Okay,
  26678. 18:11:37you have to add the persistence memory.
  26679. 18:11:40Uh we we have already seen the
  26680. 18:11:41persistence memory. Okay. Uh persistent
  26681. 18:11:43memory basically saves all of your state
  26682. 18:11:45right inside a memory whether you can
  26683. 18:11:47use any uh inmemory saver that means in
  26684. 18:11:50in your RAM or any kinds of permanent
  26685. 18:11:52database you have to use that because
  26686. 18:11:54whenever it will perform the pause
  26687. 18:11:56operation right uh let's say here it is
  26688. 18:11:58performing the pause operation so to
  26689. 18:12:00execute it again let's say whenever user
  26690. 18:12:02is giving the input okay after getting
  26691. 18:12:04the input this will execute right so
  26692. 18:12:07whenever it will execute it's not like
  26693. 18:12:08that it will execute from the beginning
  26694. 18:12:10it will execute while it has passed that
  26695. 18:12:12particular execution and how it will
  26696. 18:12:14understand by seeing the state because
  26697. 18:12:16state is saving all of the information
  26698. 18:12:18and where it is getting loaded it is
  26699. 18:12:20getting loaded in the database okay in
  26700. 18:12:22the persistent memory and from the
  26701. 18:12:24persistent memory it will load that and
  26702. 18:12:25it will see that okay I stopped in the
  26703. 18:12:27post uh nodes and now I have to continue
  26704. 18:12:30from the post node instead of continuing
  26705. 18:12:32from the beginning okay that's why the
  26706. 18:12:33checkpointer you have to define the
  26707. 18:12:36state uh persistence memory you have to
  26708. 18:12:38define whenever you are implementing
  26709. 18:12:39this hit concept inside langraph
  26710. 18:12:43Okay, line graph it is super important.
  26711. 18:12:46Okay, I hope you clear guys. So that's
  26712. 18:12:48how this uh HITL will hit will work um
  26713. 18:12:52in practical and uh you can implement
  26714. 18:12:55this HITL in any kinds of node. Okay,
  26715. 18:12:58any kinds of node or any kinds of tool
  26716. 18:12:59you are using you can define that. We'll
  26717. 18:13:02try to see that. And one more thing
  26718. 18:13:03whenever you are uh giving this input
  26719. 18:13:06right uh let's say this interrupt is
  26720. 18:13:08waiting for the human input and whatever
  26721. 18:13:11input you are passing let's say here you
  26722. 18:13:13are passing this yes input okay so this
  26723. 18:13:15yes input will consider as a command
  26724. 18:13:17okay it will consider as a command uh so
  26725. 18:13:20this command actually will u uh go to
  26726. 18:13:22the again your uh let's say node that
  26727. 18:13:26means your chat node and uh if uh your
  26728. 18:13:29chat node is getting this yes command
  26729. 18:13:31that time it actually it will uh it will
  26730. 18:13:33uh feel like okay now user wants to post
  26731. 18:13:36that okay then your posting will be
  26732. 18:13:38happening okay so that uh that means
  26733. 18:13:40this command is required a command
  26734. 18:13:43keyword is required whenever you are
  26735. 18:13:45using this interrupt function and
  26736. 18:13:47whatever let's say user input you are
  26737. 18:13:49getting uh you have to store in the
  26738. 18:13:51command okay now this thing I will also
  26739. 18:13:53show you in the code uh I think by
  26740. 18:13:55seeing the code I think this concept
  26741. 18:13:57would be more clear in your mind right
  26742. 18:13:59but before uh the code uh implementation
  26743. 18:14:01I have given you high table overview so
  26744. 18:14:03that whenever I will explain the code
  26745. 18:14:05you won't be having any kinds of
  26746. 18:14:06confusion. Now guys, we'll try to
  26747. 18:14:08implement this hitl with the help of
  26748. 18:14:11lang graph. Uh for this actually first
  26749. 18:14:13of all we'll try to see a simple
  26750. 18:14:15example. Uh I think you remember uh the
  26751. 18:14:18aentic chatbot uh we are creating so
  26752. 18:14:20far. Uh from the very beginning I have
  26753. 18:14:23taken this simple workflow. Okay. So
  26754. 18:14:26this workflow has one node which is chat
  26755. 18:14:28node. So if you basically give a input
  26756. 18:14:30uh it will generate the output of that
  26757. 18:14:32uh given input and you will be able to
  26758. 18:14:34see the output of that. Okay. So here uh
  26759. 18:14:36what I'm going to do guys I'm going to
  26760. 18:14:38add a simple
  26761. 18:14:40uh simple actually example of this HITL.
  26762. 18:14:43So basically here whatever input is
  26763. 18:14:45coming right in this particular node. So
  26764. 18:14:48here we'll just try to add a HITL
  26765. 18:14:50feature. Okay HITL feature. So here
  26766. 18:14:52we'll try to first of all uh ask the
  26767. 18:14:55user do you want to really ask the
  26768. 18:14:57question okay uh do you want to really
  26769. 18:14:59ask the questions to the model if user
  26770. 18:15:01sends yes okay I want to perform then
  26771. 18:15:04the answer would be generated otherwise
  26772. 18:15:06answer won't be generated okay it it
  26773. 18:15:08looks like very funny but just to make
  26774. 18:15:10you understand actually I have taken
  26775. 18:15:12this example first of all let's try to
  26776. 18:15:14see the HITL implementation with this
  26777. 18:15:16very simple example then I'm going to
  26778. 18:15:18show you with the advanced example as
  26779. 18:15:19well we'll uh we'll use our agent NTI
  26780. 18:15:22code the code we have implemented so far
  26781. 18:15:24and we'll try to integrate this uh
  26782. 18:15:25things okay there but before that I want
  26783. 18:15:27to show you the implementation part how
  26784. 18:15:29it can be done that's why this uh
  26785. 18:15:31example I'll be taking okay so I think
  26786. 18:15:33you have understood what I want to do so
  26787. 18:15:35whatever question is coming first of all
  26788. 18:15:37here we'll just try to add a hit feature
  26789. 18:15:41uh it will ask for the human review do
  26790. 18:15:43you want to really ask the question if
  26791. 18:15:44user gives yes then um this question
  26792. 18:15:47would be uh going to the chat node and
  26793. 18:15:50user will be able to see the output
  26794. 18:15:51Otherwise user won't be able to see the
  26795. 18:15:53output. Okay, this is the implementation
  26796. 18:15:55we'll try to do. Now for this here I
  26797. 18:15:58already prepared a notebook. So inside
  26798. 18:16:00notebooks folder I already kept uh kept
  26799. 18:16:02a notebook as you can see demo. Let's
  26800. 18:16:04open it up. Okay. So I think uh this
  26801. 18:16:06code is pretty much common. I have taken
  26802. 18:16:08the same uh this uh this example. I
  26803. 18:16:11think you know that I created a simple
  26804. 18:16:13chat workflow. Okay. I copy pasted the
  26805. 18:16:15same code and I added this HITL
  26806. 18:16:17functionality there. Okay. So first of
  26807. 18:16:18all here we are importing all the
  26808. 18:16:20necessary library. As you can see here
  26809. 18:16:22we have taken both model. If you don't
  26810. 18:16:23have openi you can use uh gemini model.
  26811. 18:16:25For this we are using this uh this
  26812. 18:16:27library and uh some other library we're
  26813. 18:16:30also importing. And uh we are also
  26814. 18:16:32importing the checkpointter because I I
  26815. 18:16:34already told you if you are implementing
  26816. 18:16:36this hil you need this uh persistence
  26817. 18:16:38memory. Okay. Then uh one new import I
  26818. 18:16:42have done which is this from langraph
  26819. 18:16:43types I have imported interrupt function
  26820. 18:16:46and command. Okay. Because I already
  26821. 18:16:47told you uh here if you want to add any
  26822. 18:16:50kinds of HTL HITL functionality you need
  26823. 18:16:53this interrupt function. Okay. So this
  26824. 18:16:54should be interrupt sorry there should
  26825. 18:16:56be a T. Okay interrupt function. So this
  26826. 18:16:59interrupt function is required. So with
  26827. 18:17:01the help of this interrupt you will try
  26828. 18:17:02to pause the execution and you will take
  26829. 18:17:04the input from the user and this input
  26830. 18:17:07will basically become your command.
  26831. 18:17:09Okay. So you can see this command is
  26832. 18:17:10also required. Then load envirated
  26833. 18:17:14and the base message. So let's import
  26834. 18:17:16all of the necessary library
  26835. 18:17:18and make sure inside your environment
  26836. 18:17:20variable all of the key are present.
  26837. 18:17:22Okay, whatever key we're using so far.
  26838. 18:17:25Now let's load the environment variable
  26839. 18:17:27and after that here I don't have open
  26840. 18:17:30API key that's why I'll be using Gemini
  26841. 18:17:32model and for this I already collected
  26842. 18:17:33my Google API key. Let's uh initialize
  26843. 18:17:36my model and here we are preparing the
  26844. 18:17:38state guys. As you can see this is our
  26845. 18:17:40state the same state we're using and
  26846. 18:17:42here you can see in this chat note we
  26847. 18:17:45have added this interrupt functionality
  26848. 18:17:47that means HITL functionality okay that
  26849. 18:17:49means here okay here we have added this
  26850. 18:17:51HITL functionality so if you want to add
  26851. 18:17:53this functionality you have to use this
  26852. 18:17:55interrupt function I already told you
  26853. 18:17:57you can see inside chat node see this is
  26854. 18:17:58what this was our previous chat node
  26855. 18:18:00right now this is the update I have done
  26856. 18:18:02so here I am I'm using this interrupt
  26857. 18:18:04function and in this interrupt function
  26858. 18:18:06you have to give some like uh u metadata
  26859. 18:18:09That means the first mate you have to
  26860. 18:18:10give the type. So type should be
  26861. 18:18:12approval. Reason model is about to
  26862. 18:18:14answer a question. Okay. Then question
  26863. 18:18:16whatever question user is asking this
  26864. 18:18:18question you have to pass in the
  26865. 18:18:19question section and the instruction.
  26866. 18:18:21Okay. Approve this question yes or no.
  26867. 18:18:23That means this instruction user will be
  26868. 18:18:24able to see. Okay. Once he will execute
  26869. 18:18:26the node this this message actually
  26870. 18:18:28would be visible to the user. Do you
  26871. 18:18:30want to approve this question? Yes or
  26872. 18:18:32no. Okay. If user pass yes then this
  26873. 18:18:34question would be going to the chat node
  26874. 18:18:36and user will able to see the output and
  26875. 18:18:38if he sends let's say no and that time
  26876. 18:18:40it will be rejected. Now here we are
  26877. 18:18:42checking you can see decision
  26878. 18:18:45okay decision and here we'll try to
  26879. 18:18:48expect a parameter expect a key called
  26880. 18:18:51approve okay so if this approve is is
  26881. 18:18:54equal to is equal to no let's see if
  26882. 18:18:55user has given no that time I'll simply
  26883. 18:18:57return the uh message okay that should
  26884. 18:19:00be the AI message no approved okay not
  26885. 18:19:02approved if user gives yes that means
  26886. 18:19:06I'll simply invoke my large name base
  26887. 18:19:08model I'll pass the message and user
  26888. 18:19:10will be able to see the output So this
  26889. 18:19:12is the simple things you have to add and
  26890. 18:19:14the main thing here the interrupt as
  26891. 18:19:15well as the command okay command uh
  26892. 18:19:18functionality I'll show you the command
  26893. 18:19:19where to add but here we are basically
  26894. 18:19:22using the interrupt to pause the
  26895. 18:19:23execution here okay and from the front
  26896. 18:19:26end size that mean from the front end
  26897. 18:19:28side that means from the user side we'll
  26898. 18:19:30get this approved okay approved key I'll
  26899. 18:19:32show you this part now let's execute
  26900. 18:19:33this note now here we are building the
  26901. 18:19:36entire graph guys you can see we're
  26902. 18:19:38taking the graph we are adding the node
  26903. 18:19:39we have only have one node
  26904. 18:19:41We are doing the edge connection and we
  26905. 18:19:43are preparing the checkpointer. So here
  26906. 18:19:45just to show you I am using this
  26907. 18:19:47inmemory server checkpointter and we are
  26908. 18:19:49building the entire graph. Okay and
  26909. 18:19:50we're passing the checkpointer and
  26910. 18:19:52that's how your workflow looks like.
  26911. 18:19:54Okay. So this is the same workflow. Now
  26912. 18:19:56to execute the workflow guys you need uh
  26913. 18:19:58this uh config you need this thread. I
  26914. 18:20:00think remember if you are using
  26915. 18:20:02persistence memory you need this thread.
  26916. 18:20:04So here I created a dummy thread and we
  26917. 18:20:06are initializing a input explain the
  26918. 18:20:08gradient descent in a very simple terms.
  26919. 18:20:10Okay, this is let's say our user input.
  26920. 18:20:12So this input will uh invoke with this
  26921. 18:20:16uh workflow we have created and the
  26922. 18:20:18workflow object is app. So you can see
  26923. 18:20:20we're invoking this input and we're
  26924. 18:20:22passing the configuration. Now let's
  26925. 18:20:24execute. Now see guys here you will uh
  26926. 18:20:27get one result. Uh this is the result.
  26927. 18:20:30Okay. Uh you can see this is the result
  26928. 18:20:32you are getting. So here you can see
  26929. 18:20:34this is the human message explain the
  26930. 18:20:36gradient descent in a very simple term.
  26931. 18:20:39And whenever uh it is going to the chat
  26932. 18:20:42node there we added that hit. Okay that
  26933. 18:20:45means here the interruption is
  26934. 18:20:46happening. It is pausing the execution.
  26935. 18:20:48Okay you can see you cannot see any
  26936. 18:20:50kinds of output. Okay the model output
  26937. 18:20:52you cannot see unless and until you are
  26938. 18:20:54not providing any kinds of input. Now if
  26939. 18:20:56you want to provide the input. So first
  26940. 18:20:58of all let me show you the interrupt
  26941. 18:21:00message. So this is the interrupt
  26942. 18:21:01message you can see and this is the
  26943. 18:21:03interaction uh instruction approve this
  26944. 18:21:06question yes or no and some other
  26945. 18:21:08metadata we have provided this is also
  26946. 18:21:09coming here. Okay now what I'll do guys
  26947. 18:21:12I'll take the user input. So here I am
  26948. 18:21:14preparing the user input. I'm showing
  26949. 18:21:16the same message to the user and here
  26950. 18:21:18I'm taking yes or no from the user.
  26951. 18:21:20Okay. So let's say this is my user
  26952. 18:21:22input. So now user is giving let's say
  26953. 18:21:24yes. Okay. Uh uh let's say user wants to
  26954. 18:21:28see the message. Uh that means the
  26955. 18:21:29output. Now if I give yes. Now inside uh
  26956. 18:21:32user input what will be present? Yes.
  26957. 18:21:34Okay. It will present yes. Now how this
  26958. 18:21:36present uh uh how this uh input we have
  26959. 18:21:39to return to the uh hit as a command.
  26960. 18:21:43Okay. Now right now you can see we are
  26961. 18:21:45again invoking this uh workflow. But
  26962. 18:21:48right now inside invoke uh functionality
  26963. 18:21:51we are giving this command keyword.
  26964. 18:21:52Okay. We are giving this command
  26965. 18:21:53keyword. Inside that we're telling
  26966. 18:21:55resume is equal to approved. So you have
  26967. 18:21:57to pass a dictionary. You can see we're
  26968. 18:21:59giving approved and user input. Okay, so
  26969. 18:22:01that means approved should be user
  26970. 18:22:03input. So that's why here I have written
  26971. 18:22:05this condition. Uh where is that? Yeah,
  26972. 18:22:08if decision approved because it uh this
  26973. 18:22:10approved uh key is getting created
  26974. 18:22:12newly, right? If approved is equal to is
  26975. 18:22:13equal to uh no, that means it will
  26976. 18:22:15reject otherwise it will approve that.
  26977. 18:22:17So that is what actually we're doing
  26978. 18:22:18here.
  26979. 18:22:20Okay, that that is what we are doing
  26980. 18:22:22here. Then we are again passing the
  26981. 18:22:24configuration and we are again invoking
  26982. 18:22:26our workflow.
  26983. 18:22:29Okay. Now one error I'm getting. Okay.
  26984. 18:22:32So guys uh we are getting this error
  26985. 18:22:34because uh inside our env we haven't set
  26986. 18:22:36our environment variable yet. Okay. Uh
  26987. 18:22:39so let's try to set all of my
  26988. 18:22:40environment variable. All of the key. So
  26989. 18:22:42this is my updated key I have uh added
  26990. 18:22:46here. Now let me save and let me
  26991. 18:22:48re-execute this notebook. Okay. So again
  26992. 18:22:50what I will do I'll just try to execute
  26993. 18:22:52from the beginning. So let me restart.
  26994. 18:22:58Now let's execute all of this code.
  26995. 18:23:05Now interrupt uh interrupt message we're
  26996. 18:23:07getting. Now we're taking the user.
  26997. 18:23:08Let's say user is passing yes.
  26998. 18:23:13Now we'll try to invoke this workflow
  26999. 18:23:15again.
  27000. 18:23:24Now see this execution is complete. Now
  27001. 18:23:27we'll see the final message. You can see
  27002. 18:23:30this is the final message we're getting
  27003. 18:23:31about the gradient descent. But let's
  27004. 18:23:34say if user is giving no that time what
  27005. 18:23:36will happen. Let's say again I will
  27006. 18:23:38execute this uh code.
  27007. 18:23:45user is giving no
  27008. 18:23:50okay I have to re-execute from beginning
  27009. 18:23:52because
  27010. 18:23:55here I have running as a cell by cell
  27011. 18:23:57right that's why
  27012. 18:24:03now I'll give no
  27013. 18:24:05if I execute my final
  27014. 18:24:09uh final result now you'll see the
  27015. 18:24:12output now you can see not approved
  27016. 18:24:14because user has given Okay. So that's
  27017. 18:24:16how guys you can add this HITL uh
  27018. 18:24:18features inside any of your node. Okay.
  27019. 18:24:21It's not necessary to add inside your
  27020. 18:24:22node. Always you can also add this
  27021. 18:24:24inside the tools. Okay. This part I will
  27022. 18:24:26also show you uh after this demo. Okay.
  27023. 18:24:29So yes guys, this is how we can um add
  27024. 18:24:32this HITL and we have seen the simple
  27025. 18:24:35demo. Now let's try to see the advanced
  27026. 18:24:37example with our agentic chatbot we have
  27027. 18:24:40created so far. And this is the uh this
  27028. 18:24:42is the actually workflow we have
  27029. 18:24:43created. I can remember uh because uh
  27030. 18:24:45inside our workflow we are using some
  27031. 18:24:47kinds of tools right and uh this is our
  27032. 18:24:49workflow final workflow and this code we
  27033. 18:24:52have already written as you can see this
  27034. 18:24:53is the code we have written in my
  27035. 18:24:55previous uh video if you haven't checked
  27036. 18:24:57that please try to go through the
  27037. 18:24:58recording so here actually I added the
  27038. 18:25:00rag functionality and we added uh lots
  27039. 18:25:02of tool here previously right you can
  27040. 18:25:04see we have added lots of tool now guys
  27041. 18:25:06first of all uh I want to show you uh
  27042. 18:25:09this this uh agentic chatbot execution
  27043. 18:25:13without using HITL. Okay, let's say if
  27044. 18:25:16I'm not using HITL, uh what will happen
  27045. 18:25:18that time? Let's try to see an example.
  27046. 18:25:21So here I'm going to create a file. I'm
  27047. 18:25:23going to name it as chatbot.
  27048. 18:25:26Chatbot without
  27049. 18:25:33HITL
  27050. 18:25:36human in the loop. Okay. So after seeing
  27051. 18:25:38that we'll try to add the HITL and we'll
  27052. 18:25:40see the benefit of that. Okay. So
  27053. 18:25:42chatbot without HITL. So what I'll do?
  27054. 18:25:44So the code I have written the previous
  27055. 18:25:46code that means the rag back end. Uh I
  27056. 18:25:49think you have seen my previous video.
  27057. 18:25:50I'll copy this entire code as it is. And
  27058. 18:25:53here I'm going to paste it. Okay. So
  27059. 18:25:55here I'm not going to change anything
  27060. 18:25:56only the things I have to add um a new
  27061. 18:26:00tool here. Okay. So here I going to add
  27062. 18:26:02a new tool. So I think you remember um
  27063. 18:26:05in this particular in this particular
  27064. 18:26:07chatbot the sensitive uh the sensitive
  27065. 18:26:10part is the stock price. Okay let's
  27066. 18:26:14consider the stock price. So here we are
  27067. 18:26:16getting the stock price right given any
  27068. 18:26:18kinds of company. So here we'll try to
  27069. 18:26:20add a new tool. So that tool will
  27070. 18:26:23basically uh purchase the stock for me.
  27071. 18:26:27So here I have written a simple uh dummy
  27072. 18:26:29let's say uh tool. So uh it will it will
  27073. 18:26:32only do the print statement that means
  27074. 18:26:34return statement but in actual chatbot
  27075. 18:26:37definitely uh here you have to use some
  27076. 18:26:39kinds of API that API will uh connect
  27077. 18:26:42the uh Apple let's say stock company and
  27078. 18:26:46uh it will purchase the stock for you
  27079. 18:26:48but just to show you here I have taken a
  27080. 18:26:50dummy function so this function what it
  27081. 18:26:52does it takes the symbol as well as the
  27082. 18:26:54quantity like how how much quantity you
  27083. 18:26:56want to purchase and which company you
  27084. 18:26:59want to purchase and based on that it
  27085. 18:27:01will give you some kinds of success
  27086. 18:27:03statement. Let's say you have
  27087. 18:27:04successfully purchased this uh stock.
  27088. 18:27:06Okay. So this thing I have converted as
  27089. 18:27:08a tool and I named it as a purchase
  27090. 18:27:10stock. Okay. Purchase stock tool. Now
  27091. 18:27:12what I have to do uh I have added a new
  27092. 18:27:15tool and this tool I have to add inside
  27093. 18:27:17my tool list. So I'll go below and here
  27094. 18:27:21I have to add this tool. The tool name
  27095. 18:27:23is par stock. Okay. Then we are binding
  27096. 18:27:26this tool. Everything will remain
  27097. 18:27:27common. No need to change anything.
  27098. 18:27:31Uh
  27099. 18:27:36just a minute let me check. Huh. So
  27100. 18:27:38everything is fine.
  27101. 18:27:42We have added this in the list. Now
  27102. 18:27:47I will go below to list. Uh this is my
  27103. 18:27:51checkp pointer. We are using SQLite
  27104. 18:27:52database and we are creating the entire
  27105. 18:27:55graph. And this is our helper function.
  27106. 18:27:58It's completely fine. But here at the
  27107. 18:28:00last I will add a
  27108. 18:28:03simple CLI code. Okay, this is my simple
  27109. 18:28:06CLI code. Basically I want to execute
  27110. 18:28:09this file. Okay, in my uh terminal.
  27111. 18:28:11Okay, that's why I have added this code.
  27112. 18:28:12First of all, I am printing some
  27113. 18:28:14message. That means this is a chatbot
  27114. 18:28:16CLA. And here I have taken a demo trade.
  27115. 18:28:19Okay, because if you know that if I want
  27116. 18:28:21to uh because you know that if I want to
  27117. 18:28:23execute my chatbot uh workflow, I need
  27118. 18:28:26this trade. So that's why I created a
  27119. 18:28:28demo trade and here I'm running a while
  27120. 18:28:30loop. Okay, in this while loop I'm
  27121. 18:28:31taking the user user input from the user
  27122. 18:28:33and if user is giving let's say exit or
  27123. 18:28:35quite I'm telling goodbye and breaking
  27124. 18:28:36the loop otherwise I'm taking the user
  27125. 18:28:39input. Okay, and preparing inside my
  27126. 18:28:42state then we are invoking our chatbot.
  27127. 18:28:44Okay, we are passing the trade ID then
  27128. 18:28:47whatever response we are getting we are
  27129. 18:28:48just printing uh in the terminal. So
  27130. 18:28:50this is a simple CLI code I have
  27131. 18:28:52written. Okay, just to execute my entire
  27132. 18:28:54workflow. Now let me show you how this
  27133. 18:28:56thing will work. So I will open up my
  27134. 18:28:59terminal and I will execute this file
  27135. 18:29:01chatbot without HITL. I'll just write
  27136. 18:29:04Python
  27137. 18:29:05chatbot
  27138. 18:29:07without
  27139. 18:29:09HITL. Okay. Now see if I execute
  27140. 18:29:14now see it is uh asking for the input.
  27141. 18:29:18Let's say here I will give hello.
  27142. 18:29:22It's giving hello, how I can help you?
  27143. 18:29:24Today I will ask uh what is the
  27144. 18:29:28stock
  27145. 18:29:29price
  27146. 18:29:31of
  27147. 18:29:33Apple?
  27148. 18:29:36Now it will use that get stock price
  27149. 18:29:38tool and it will extract the uh stock
  27150. 18:29:41price of the Apple. Now see the stock
  27151. 18:29:43price of Apple is uh okay that much. Now
  27152. 18:29:46I'll tell uh purchase
  27153. 18:29:53Okay. Purchase
  27154. 18:29:5510 stock
  27155. 18:29:58of
  27156. 18:30:02Apple.
  27157. 18:30:05Okay. Now see if I uh if I send this
  27158. 18:30:09prompt,
  27159. 18:30:10it will directly purchase the stock. It
  27160. 18:30:12will use that tool, right? Uh like a
  27161. 18:30:15purchase stock tool and it will purchase
  27162. 18:30:17the stock. And here you can see the
  27163. 18:30:19message. I have successfully placed the
  27164. 18:30:21order to purchase 10 stock of Apple. Now
  27165. 18:30:23see here it is not asking any kinds of
  27166. 18:30:25user input. Right? Although this is a
  27167. 18:30:27sensitive task we are performing but it
  27168. 18:30:30is not asking any kinds of input. So
  27169. 18:30:33there is a possibility it may do some
  27170. 18:30:35mistake right? Instead of purchasing 10
  27171. 18:30:37stock maybe it can purchase 20 stock
  27172. 18:30:39right let's say instead of pinging
  27173. 18:30:41purchasing um stock in Apple it will
  27174. 18:30:44purchase the stock in Google. Okay. So
  27175. 18:30:46these kinds of mistake my agent can
  27176. 18:30:48perform. I think you know this is
  27177. 18:30:49completely large language model and it
  27178. 18:30:51can perform any kinds of wrong uh wrong
  27179. 18:30:53task. It can do hallucination. I think
  27180. 18:30:55you know that right? It's not always
  27181. 18:30:57perfect. So here definitely I need a
  27182. 18:31:00human approval here. Okay. If I want to
  27183. 18:31:01perform this kinds of sensitive and
  27184. 18:31:03critical task. So this is the execution
  27185. 18:31:06you have seen without HITL and this is
  27186. 18:31:08the problem here. Okay. Right now I'm
  27187. 18:31:10going to show you if I add this HITL
  27188. 18:31:13with this chatbot what will happen right
  27189. 18:31:15now? Let's try to see. So I will exit
  27190. 18:31:17this terminal
  27191. 18:31:20H. Now here I'm going to create another
  27192. 18:31:22file
  27193. 18:31:25and I'm going to name it as chatbot.
  27194. 18:31:30Chatbot uh with
  27195. 18:31:34HITL.
  27196. 18:31:40Okay. And here what I'm going to do I'm
  27197. 18:31:43going to
  27198. 18:31:45I'm going to copy paste the same code
  27199. 18:31:50okay from my previous file and I'm going
  27200. 18:31:51to paste it here and the modification I
  27201. 18:31:54will do here in this particular tool.
  27202. 18:31:58Okay in this particular tool
  27203. 18:32:00uh this
  27204. 18:32:03um stock price tool. Okay. Yeah. So here
  27205. 18:32:06I'll do the modification. Why here I
  27206. 18:32:08will do the modification? Because in
  27207. 18:32:10this tool only I need the human
  27208. 18:32:12approval. Okay. Whenever user is asking
  27209. 18:32:14to purchase a stock right that time here
  27210. 18:32:17only I need to perform the interrupt
  27211. 18:32:19operation and whenever user is giving
  27212. 18:32:21okay you just need to purchase it user
  27213. 18:32:23is giving yes uh yes command that time
  27214. 18:32:26this tool will execute otherwise this
  27215. 18:32:27tool will not execute okay it will not
  27216. 18:32:29purchase the stock for me. So for this
  27217. 18:32:32I'll do a simple modification.
  27218. 18:32:35See instead of this this function I have
  27219. 18:32:38modified with this function.
  27220. 18:32:40Now just try to see okay and most of the
  27221. 18:32:42code I think this is common to you
  27222. 18:32:44because I already explained previously.
  27223. 18:32:46Okay in that uh simple demo right here
  27224. 18:32:48I'm using interrupt function and uh here
  27225. 18:32:51I just done a check statement here. Okay
  27226. 18:32:55now I have to import this uh interrupt
  27227. 18:32:57function as and common function. So
  27228. 18:33:00let's import it as well.
  27229. 18:33:07I'll import it here from langraph types.
  27230. 18:33:10I'm importing interrupt and command. And
  27231. 18:33:12I will go to my tool again. So this is
  27232. 18:33:16the tool. Okay. Yeah.
  27233. 18:33:22So see here I'm not adding this hit
  27234. 18:33:25inside my chat node. Okay. Here I don't
  27235. 18:33:27need to add inside my chat node because
  27236. 18:33:29here I'm using a tool lots of tool okay
  27237. 18:33:31and inside only get uh sorry purchase
  27238. 18:33:34stock price in that tool only I need
  27239. 18:33:36this HITL functionality okay always
  27240. 18:33:39remember whenever you are using tools
  27241. 18:33:41and you are creating this kinds of
  27242. 18:33:43advanc advanc application right in chat
  27243. 18:33:47node you don't need to add it you will
  27244. 18:33:49be adding inside the tool that means
  27245. 18:33:50with the tool you are performing some
  27246. 18:33:52kinds of task you are performing some
  27247. 18:33:53kinds of action and there this hit
  27248. 18:33:56should be integrated okay not in chat
  27249. 18:33:58node but in my previous example the
  27250. 18:34:00simple example I have given you just to
  27251. 18:34:02show you I added the hit in my chat node
  27252. 18:34:04okay I hope you cleared now inside tools
  27253. 18:34:07only I will add this functionality so
  27254. 18:34:09this is the code for that
  27255. 18:34:12I'll close some of the window
  27256. 18:34:18chat with htl okay now this is the uh
  27257. 18:34:21this is the tool guys I have written uh
  27258. 18:34:23this is the update I have done so here
  27259. 18:34:26Whenever it will uh use this uh use this
  27260. 18:34:28tool that means my agent will use this
  27261. 18:34:30tool that time you will uh it will see
  27262. 18:34:32the interrupt function here and it will
  27263. 18:34:34pause the execution here okay and user
  27264. 18:34:36will able to see one message approve
  27265. 18:34:38buying uh that means what how much how
  27266. 18:34:40much quantity user will provide let's
  27267. 18:34:42say user is provide uh 10 10 stock okay
  27268. 18:34:44I want to purchase 10 stock of Apple so
  27269. 18:34:47this 10 will come here so 10 shares of
  27270. 18:34:49symbol means the company okay that's I'm
  27271. 18:34:52giving Apple so apple will come here so
  27272. 18:34:54do you want to purchase it yes or no.
  27273. 18:34:56Okay, user will see this message. Okay,
  27274. 18:34:58in interrupt only you can directly show
  27275. 18:35:00the message. Then once user will pass
  27276. 18:35:03this yes and no, it will store inside
  27277. 18:35:05the decision. Okay, and right now I'm
  27278. 18:35:07not storing inside uh as a dictionary.
  27279. 18:35:10But previously the previous example I
  27280. 18:35:11showed you right in the notebook
  27281. 18:35:14in the notebook here I was storing as a
  27282. 18:35:16dictionary. Okay, that's why I was uh
  27283. 18:35:19checking the condition like that because
  27284. 18:35:21here I was passing as a dictionary.
  27285. 18:35:23Okay, I was passing as a dictionary but
  27286. 18:35:25right now here I'm taking as a simple
  27287. 18:35:27string. Okay, yes or no. So here I'm
  27288. 18:35:30checking if this decision is a string
  27289. 18:35:33and I'm doing the lower operation. If it
  27290. 18:35:35is yes, then I'm returning this
  27291. 18:35:37statement. Starter should be success
  27292. 18:35:39message purchased order placed for
  27293. 18:35:41quantity shares of symbol. Okay, uh
  27294. 18:35:44symbol uh should be symbol and quantity
  27295. 18:35:45should be quantity. That means here I'm
  27296. 18:35:47giving a success message. Your uh order
  27297. 18:35:49has been placed. Okay, let's see you
  27298. 18:35:51have successfully purchased the stock.
  27299. 18:35:53Otherwise if user is giving no. Okay. In
  27300. 18:35:55the else block you can see purchase of
  27301. 18:35:57shares of the symbol was declined by the
  27302. 18:36:00human. Okay. And strategies canled right
  27303. 18:36:02now. Okay. So this kinds of statement we
  27304. 18:36:06have written inside our tool. Okay. And
  27305. 18:36:08this thing you have to follow if you
  27306. 18:36:10want to implement this HITL in any kinds
  27307. 18:36:13of tool or any kinds of task you are
  27308. 18:36:15implementing going forward. Okay. Now I
  27309. 18:36:17want to give a task. Instead of purchase
  27310. 18:36:20stock maybe you can add another tool
  27311. 18:36:23that will perform some kinds of
  27312. 18:36:24sensitive and critical task. Okay. And
  27313. 18:36:26in that task you just might need to add
  27314. 18:36:28this hit functionality. Okay. This
  27315. 18:36:30should be your task after this
  27316. 18:36:31implementation. Just try to make this
  27317. 18:36:33aentic chatboard more advanced. You can
  27318. 18:36:36u add some more advanced task which
  27319. 18:36:38needs human approval and you can add
  27320. 18:36:40this functionality here. Okay. Now this
  27321. 18:36:43this is the update I have done. Now the
  27322. 18:36:45next update you have to do
  27323. 18:36:47next update
  27324. 18:36:50if I go below
  27325. 18:36:53already this tool is added inside the
  27326. 18:36:54tool I don't need to add now your chat
  27327. 18:36:56node will also remain same no need to
  27328. 18:36:58add anything
  27329. 18:37:00uh only this CLI CLI code you have to
  27330. 18:37:04change okay right now uh user is giving
  27331. 18:37:07the
  27332. 18:37:08uh user is giving the interruption
  27333. 18:37:10message that means the command so this
  27334. 18:37:12thing you have to add uh take from the
  27335. 18:37:13user So here
  27336. 18:37:16this is the CLI code I have written
  27337. 18:37:24because this this CLI doesn't have any
  27338. 18:37:27um HITL input right now this has the
  27339. 18:37:30HITL input so again the same loop I have
  27340. 18:37:32written print statement demo trade while
  27341. 18:37:36loop I'm taking the user input if user
  27342. 18:37:38is giving exit and quite I'm like just
  27343. 18:37:41breaking the loop then uh I'm preparing
  27344. 18:37:44my state okay with the help of user
  27345. 18:37:46input then I'm invoking my workflow okay
  27346. 18:37:51and I'm passing my trade now we'll check
  27347. 18:37:54this uh interrupt let's say whenever you
  27348. 18:37:56are invoking the workflow and user is
  27349. 18:37:58given let's say hello that time just let
  27350. 18:38:00me know whether this interrupt interrupt
  27351. 18:38:03uh interrupt will happen or not
  27352. 18:38:04definitely there won't be any kinds of
  27353. 18:38:06interrupt when interrupt will happen
  27354. 18:38:08whenever you will ask purchase 10 stock
  27355. 18:38:10or let's say purchase any stock of any
  27356. 18:38:12company Right? That time that tool will
  27357. 18:38:14be executed. I can okay uh that means
  27358. 18:38:16our purchase tool will be executed and
  27359. 18:38:19whenever that tool will be executed that
  27360. 18:38:21time this interruption okay you will get
  27361. 18:38:23the interruption that means you will get
  27362. 18:38:25something in the interruption variable
  27363. 18:38:27okay otherwise you will not get anything
  27364. 18:38:29in the interruption variable that's why
  27365. 18:38:30we're checking if interruption variable
  27366. 18:38:32has something that means if interruption
  27367. 18:38:34happens definitely some message you will
  27368. 18:38:37get okay in the interrupt interrupt
  27369. 18:38:39variable if you got the message that
  27370. 18:38:40time you will feel like okay there right
  27371. 18:38:43now there is interruption has happen
  27372. 18:38:45inside my code then it will ask the
  27373. 18:38:47human okay so what is the interruption
  27374. 18:38:50okay you will show this prompt you can
  27375. 18:38:52see I'm showing this prompt as a hit
  27376. 18:38:54message okay whether uh he has to
  27377. 18:38:57approved or uh uh approved or not so
  27378. 18:39:00this thing I will take inside my
  27379. 18:39:02decision I'm taking the input from the
  27380. 18:39:04user your decision okay I'm just making
  27381. 18:39:06it as lower then whatever decision user
  27382. 18:39:09is giving I'm again reinvoking my ch
  27383. 18:39:12chatbot okay and right now I'm giving
  27384. 18:39:14the command and we are giving this
  27385. 18:39:16resume parameter is equal to our
  27386. 18:39:17decision okay which we are giving as a
  27387. 18:39:19command then we are passing the
  27388. 18:39:20configuration again and whatever result
  27389. 18:39:22we are getting we are showing the
  27390. 18:39:23message and we are also printing in the
  27391. 18:39:26terminal so this is a simple code I have
  27392. 18:39:27written now let me show you the
  27393. 18:39:29execution so again I will open up my
  27394. 18:39:30terminal and right now I'll execute this
  27395. 18:39:34chatbot with
  27396. 18:39:37hittl
  27397. 18:39:40now see here I will give Hello.
  27398. 18:39:46Hello. How how I can help you today? I
  27399. 18:39:49will tell what is the
  27400. 18:39:54stock
  27401. 18:39:57of Apple?
  27402. 18:40:00Stock price of Apple.
  27403. 18:40:08Now see this is the stock price of the
  27404. 18:40:09Apple as you can see. Now I'll tell
  27405. 18:40:12purchase
  27406. 18:40:14okay 20 stock
  27407. 18:40:19of Apple.
  27408. 18:40:21Okay purchase uh 20 stock of Apple. Now
  27409. 18:40:24it will use that purchase tool right and
  27410. 18:40:27there would be interruption that will uh
  27411. 18:40:29basically happen the interruption that
  27412. 18:40:30means hitl will apply uh in that
  27413. 18:40:33particular tool and it will ask for the
  27414. 18:40:34human input. Now hi
  27415. 18:40:37uh TL has been triggered and it is
  27416. 18:40:39asking for the human improve improved
  27417. 18:40:42approved buying 20 shares of Apple. Do
  27418. 18:40:44you want to approve? Yes or no. So here
  27419. 18:40:46I will tell yes I want to purchase it.
  27420. 18:40:48Now if I execute this code you'll see
  27421. 18:40:50that I have successfully purchased an
  27422. 18:40:52order to purchase 20 shares of Apple.
  27423. 18:40:54That means uh this tool has been
  27424. 18:40:57executed and uh this tool has purchased
  27425. 18:40:59the shares for you. Okay. Of the Apple.
  27426. 18:41:02Now again if I let's say reexecute this
  27427. 18:41:04code let's say
  27428. 18:41:07um
  27429. 18:41:10purchase
  27430. 18:41:13let's say purchase
  27431. 18:41:1820 stock of Google
  27432. 18:41:24now again it is asking for the human
  27433. 18:41:26approval approved buying 20 shares of
  27434. 18:41:28Google yes or no. Now if I let's say
  27435. 18:41:30give no now it will decline okay
  27436. 18:41:33declined so you can see I'm sorry your
  27437. 18:41:35request was purchase 20 shares of Google
  27438. 18:41:37was declined because you've given no
  27439. 18:41:40okay right now just tell me which one is
  27440. 18:41:42better okay for this kinds of sensitive
  27441. 18:41:44task this kinds of critical task without
  27442. 18:41:46HITL or with HITL definitely with HITL
  27443. 18:41:50it is more accurate and more secured
  27444. 18:41:53okay secured version of our agentic
  27445. 18:41:55chatbot okay now guys I think you have
  27446. 18:41:57got it how to integrate this HITL inside
  27447. 18:42:00our agentic chatbot. Okay. Now guys, uh
  27448. 18:42:03let's try to add this functionality
  27449. 18:42:04inside our user interface. So what I
  27450. 18:42:06have done guys, I just copy pasted the
  27451. 18:42:09same code. Okay. I just copy pasted the
  27452. 18:42:11same code and I uh given to the chart
  27453. 18:42:14GPT and I asked I just need to add this
  27454. 18:42:17HITL uh uh HITL functionality on my user
  27455. 18:42:20interface and charge GPT has given me
  27456. 18:42:23one updated code. Let me show you. Only
  27457. 18:42:25you just need to uh update inside your
  27458. 18:42:27front end. So maybe I'll create a
  27459. 18:42:30separate file of the front end. Let's
  27460. 18:42:31I'll tell it as app
  27461. 18:42:34hi ll okay.py
  27462. 18:42:38and this is the updated code I got from
  27463. 18:42:40the chgpd guys. Again if you don't know
  27464. 18:42:42about the front- end design no need to
  27465. 18:42:44worry there are some front-end developer
  27466. 18:42:47um uh in your uh would be in your
  27467. 18:42:49company. So they will handle this kinds
  27468. 18:42:51of scenario. Okay. But uh again if you
  27469. 18:42:53don't know you can take the help from
  27470. 18:42:54chat GPT and this is the updated version
  27471. 18:42:57of our front end. Okay this has the uh
  27472. 18:43:00hit u that means approval uh user
  27473. 18:43:03interface. Okay that means the uh uh
  27474. 18:43:05first time I showed you a demo right it
  27475. 18:43:07was asking for a human approval yes or
  27476. 18:43:09no button. So it has added that
  27477. 18:43:10particular functionality here. Okay.
  27478. 18:43:12Otherwise my back end code will remain
  27479. 18:43:14same. There won't be any kinds of
  27480. 18:43:15change. So what I'll do again I'll
  27481. 18:43:17create another file here. Let's say um
  27482. 18:43:21I'll copy the name
  27483. 18:43:25and I'll create a new file. I'm going to
  27484. 18:43:27name it as agentic chatbot hitl backend.
  27485. 18:43:30Hitl
  27486. 18:43:32backend. Okay. Backend.py sorry
  27487. 18:43:37back end.py. Okay. And whatever code I
  27488. 18:43:39have written inside chatbot with HITL
  27489. 18:43:41I'll just try to copy paste as it is.
  27490. 18:43:44Okay. So here from here I just need to
  27491. 18:43:46copy chatbot with HITL. I'll just try to
  27492. 18:43:48copy the same code and I'll paste inside
  27493. 18:43:50my aentic chatbot. HITL backend.py.
  27494. 18:43:53Okay. And uh no need to change anything
  27495. 18:43:55only. You just need to remove this line.
  27496. 18:43:58Okay. This CLA is not required. I'll
  27497. 18:44:00just uh remove that code and everything
  27498. 18:44:03will
  27499. 18:44:05remain as it is.
  27500. 18:44:07H now uh here in this app hit you just
  27501. 18:44:12need to change this import. Okay. So now
  27502. 18:44:14the import is agentic chatbot HITL back
  27503. 18:44:16end. So agentic
  27504. 18:44:19chatbot hit back end. Okay. So from here
  27505. 18:44:21we're importing all the functionality
  27506. 18:44:23and this is the updated code. Now let me
  27507. 18:44:25execute and show you this execution. So
  27508. 18:44:28here I'll stop the execution. Clear and
  27509. 18:44:31I will run streamlit
  27510. 18:44:34run
  27511. 18:44:36uh
  27512. 18:44:38app
  27513. 18:44:40hl. Okay.
  27514. 18:44:43Now this is your interface. Okay. The
  27515. 18:44:46same interface I think you saw. Now here
  27516. 18:44:49you can perform any kinds of chat
  27517. 18:44:51operation. Tell me the
  27518. 18:44:57latest
  27519. 18:44:59news
  27520. 18:45:02uh
  27521. 18:45:04in AI. You will see that it will use
  27522. 18:45:07some kinds of search tool.
  27523. 18:45:10So see it is using tably search tool and
  27524. 18:45:12it will give you the uh latest news in
  27525. 18:45:14AI.
  27526. 18:45:16You can see uh this is the latest new uh
  27527. 18:45:19news I got and this is the news of
  27528. 18:45:21Andropics. Okay, latest news. Now here I
  27529. 18:45:23will ask u um I will try to check my
  27530. 18:45:27HITL code uh HITL functionality. So here
  27531. 18:45:30I'll tell uh what is the
  27532. 18:45:33latest or let's say what is the stock
  27533. 18:45:39price of Apple.
  27534. 18:45:47It is using my get stock price and it is
  27535. 18:45:50giving you the latest uh uh stock price
  27536. 18:45:52of Apple. Now we tell purchase
  27537. 18:45:58purchase let's say 20 stock
  27538. 18:46:02of Apple.
  27539. 18:46:09Now you'll see that it will ask for the
  27540. 18:46:11human verification. Now see human
  27541. 18:46:13approval is required and this is the
  27542. 18:46:14user interface uh we have added with the
  27543. 18:46:16help of charge GPT. Now if I approve
  27544. 18:46:18this purchase now you see it will use
  27545. 18:46:20purchase tool and it will purchase that
  27546. 18:46:22uh that shares for me. You can see your
  27547. 18:46:24order to purchase 20 shares of Apple has
  27548. 18:46:27been placed successfully. Okay. Now if I
  27549. 18:46:29let's say give another one
  27550. 18:46:33uh process 20 stock of let's say Google.
  27551. 18:46:38Now again it will ask for the human
  27552. 18:46:39verification.
  27553. 18:46:41Okay. Now if I reject this purchase now
  27554. 18:46:44see it will tell your request to
  27555. 18:46:46purchase 20 shares of Google was
  27556. 18:46:47declined. Okay. So that's how this
  27557. 18:46:49system is working right now and we have
  27558. 18:46:51successfully added this hit
  27559. 18:46:53functionality inside our agentic chatbot
  27560. 18:46:56and you can also see the live tracing on
  27561. 18:46:58the lang lang platform. You can go to
  27562. 18:47:01the trades and you can open up your
  27563. 18:47:05trades and you can see all of the
  27564. 18:47:06execution. Okay. Now you can see guys uh
  27565. 18:47:08it hit your hit functionality. This is
  27566. 18:47:12also available here. Okay, you can see
  27567. 18:47:14that. So guys, our agentic chatbot is
  27568. 18:47:16ready and we have added all of the
  27569. 18:47:18functionality. Okay, we have discussed
  27570. 18:47:20previously in my introduction video in
  27571. 18:47:22my um theoretical video. Okay, I think
  27572. 18:47:25remember if you are following this
  27573. 18:47:26playlist from the beginning, I think you
  27574. 18:47:27know that we have already explained
  27575. 18:47:29about all of the core component of
  27576. 18:47:31agentic application. We have added all
  27577. 18:47:33of these core component inside our
  27578. 18:47:35aentic application and now this is like
  27579. 18:47:36more advanced. Now the only part is left
  27580. 18:47:40uh the deployment part. Uh in my next
  27581. 18:47:42video guys I'm going to show you how we
  27582. 18:47:45can deploy this uh agentic chatbot. Okay
  27583. 18:47:48over the cloud platform and I'm not
  27584. 18:47:50going to show you the simple deployment.
  27585. 18:47:51I'm going to show you the CI/CD
  27586. 18:47:53deployment. Okay that means continuous
  27587. 18:47:55integration and continuous uh delivery.
  27588. 18:47:57So there I will try to set up the entire
  27589. 18:47:59CI/CD pipeline and we'll try to deploy
  27590. 18:48:01this project over the um AWS cloud.
  27591. 18:48:04Okay. Uh I'm going to show you another
  27592. 18:48:05deployment on the render cloud. Render
  27593. 18:48:07is another cloud and there you can also
  27594. 18:48:09do the deployment. Uh first of all I'm
  27595. 18:48:11going to show the AWS deployment. Then
  27596. 18:48:12I'm going to show you the render
  27597. 18:48:13deployment as well. Okay means right now
  27598. 18:48:16this uh bot is running on my local host.
  27599. 18:48:18This agentic chatbot is running on my
  27600. 18:48:19local host and it cannot access um by
  27601. 18:48:23any kinds of people, right? You can only
  27602. 18:48:24execute this bot. But let's say if you
  27603. 18:48:26want to make it live right uh if you
  27604. 18:48:28want to make make it live to the entire
  27605. 18:48:29world that time you have to deploy this
  27606. 18:48:31application. So this uh uh deployment
  27607. 18:48:33part I'm going to show you in my next
  27608. 18:48:35video guys. So yes guys this is all
  27609. 18:48:36about and I hope you liked my content
  27610. 18:48:39guys. If you like my content please try
  27611. 18:48:40to subscribe to my channel and hit the
  27612. 18:48:42like and please try to comment in the
  27613. 18:48:44comment section if you have any
  27614. 18:48:45question. Uh in this video I'm going to
  27615. 18:48:48show you the uh final deployment of that
  27616. 18:48:51identic chatbot. So guys, as I already
  27617. 18:48:53told you here, we'll be doing something
  27618. 18:48:54called CI/CD deployment, right? And I
  27619. 18:48:57already told you what is uh CI/CD full
  27620. 18:48:59form. It's continuous integration,
  27621. 18:49:01continuous delivery or deployment,
  27622. 18:49:02right? So inside continuous integration,
  27623. 18:49:04continuous delivery, what happens? Let's
  27624. 18:49:06say you are the developer. Okay, let's
  27625. 18:49:09say you are the developer.
  27626. 18:49:11So what is your task? Your task is to
  27627. 18:49:14develop a project in the development
  27628. 18:49:17let's say environment. So development
  27629. 18:49:19environment means like your local
  27630. 18:49:21system. Let's say you are using your
  27631. 18:49:22laptop or computer. Let's say local
  27632. 18:49:24computer. Okay, local
  27633. 18:49:27computer.
  27634. 18:49:30Fine. Then what we are doing? I think
  27635. 18:49:33you remember we are committing this code
  27636. 18:49:35to the GitHub, right? We are doing the
  27637. 18:49:36code management. I think remember that
  27638. 18:49:38means that means whenever I was adding
  27639. 18:49:39some new feature, I was pushing this
  27640. 18:49:41code to the GitHub. Yes or no? Okay.
  27641. 18:49:44With the help of G client, we are
  27642. 18:49:46pushing the code in the GitHub GitHub
  27643. 18:49:47server. Now what happens actually let's
  27644. 18:49:50say after deployment so this is called
  27645. 18:49:52actually development server or I can
  27646. 18:49:54write uh this is actually development
  27647. 18:49:55environment
  27648. 18:49:59okay development environment so after
  27649. 18:50:02implementing this project what we have
  27650. 18:50:04to do we have to deploy this project yes
  27651. 18:50:06or no let's say um somehow you have
  27652. 18:50:09deployed this project on the AWS cloud
  27653. 18:50:11let's say this is your AWS cloud fine so
  27654. 18:50:14let's say you have deployed this project
  27655. 18:50:16to the AWS cloud
  27656. 18:50:19manually manually you just created a
  27657. 18:50:21let's say instance there you create uh
  27658. 18:50:23you just took a machine there a KC2
  27659. 18:50:25machine and you manually deployed this
  27660. 18:50:27project now it will give you some
  27661. 18:50:28endpoint okay endpoint so with the help
  27662. 18:50:33of this endpoint any of the user
  27663. 18:50:37okay user can access your application
  27664. 18:50:39now let's say after 4 month or let's say
  27665. 18:50:426 month you want to add some more
  27666. 18:50:44features in this let's say uh
  27667. 18:50:46application Let's say you are deploying
  27668. 18:50:48medical chatbot. Let's say you want to
  27669. 18:50:50add some more data. You want to add some
  27670. 18:50:52more knowledge base and you want to add
  27671. 18:50:53some more features in this application.
  27672. 18:50:55Then what you have to do? You have to
  27673. 18:50:56again develop this let's say features in
  27674. 18:50:59your code. Then what you will be doing
  27675. 18:51:00again you'll be deploying this
  27676. 18:51:02application to the as cloud. Now just
  27677. 18:51:04try to see whenever you are deploying
  27678. 18:51:05the project for the second time. Let's
  27679. 18:51:08say this is the first time you have
  27680. 18:51:09deployed then you are trying to deploy
  27681. 18:51:10for the second time. Then what you have
  27682. 18:51:12to do? First of all, you have to stop
  27683. 18:51:14this application in the AWS. Okay, stop
  27684. 18:51:17this application. Then you'll be
  27685. 18:51:18uploading your updated code. Then this
  27686. 18:51:20code will reflect to the endpoint. Then
  27687. 18:51:22user will able to access that. Now let's
  27688. 18:51:24say in between whenever you stop this
  27689. 18:51:26AWS server, let's say your uh
  27690. 18:51:29application, let's say it took 3 hours.
  27691. 18:51:32It took 3 hours to change the entire
  27692. 18:51:34source code. That means uh change the
  27693. 18:51:36entire features, okay, of your
  27694. 18:51:38application. So what will happen? 3
  27695. 18:51:40hours user won't be able to access your
  27696. 18:51:41application. So they will come your
  27697. 18:51:43website and they will see server error.
  27698. 18:51:45Okay, server error actually they will
  27699. 18:51:47get. So if user is getting this kinds of
  27700. 18:51:50experience so definitely it would be a
  27701. 18:51:51negative let's say uh effect okay on
  27702. 18:51:54your application. So next time actually
  27703. 18:51:55they are not going to use your
  27704. 18:51:57application yes or no. Let's say if
  27705. 18:51:58charg is down for the uh let's say 3
  27706. 18:52:01hours definitely people will move to the
  27707. 18:52:03Google b or any other let's say software
  27708. 18:52:06whatever actually we are having. Okay.
  27709. 18:52:08So now see chart GP is also updating
  27710. 18:52:10their let's say application day by day.
  27711. 18:52:13But did you ever observe this server is
  27712. 18:52:15down? No even not seeing this server is
  27713. 18:52:17down but still they're able to make the
  27714. 18:52:18changes in their application. How?
  27715. 18:52:20Because they are following something
  27716. 18:52:21called CI/CD approach. Continuous
  27717. 18:52:22integration, continuous delivery. That
  27718. 18:52:24means this application is keep on
  27719. 18:52:26running but in the back end they're
  27720. 18:52:28pushing their source code. They're
  27721. 18:52:29pushing their let's say new features and
  27722. 18:52:31this feature is automatically getting
  27723. 18:52:32updated. Okay. So this is collected
  27724. 18:52:34CI/CD that means you are not going to
  27725. 18:52:36deploy this application manual. Instead
  27726. 18:52:38of that what you have to do you have to
  27727. 18:52:39follow the CI/CD. That means what will
  27728. 18:52:40happen? Let's say you have changed
  27729. 18:52:42something in your code. You will push
  27730. 18:52:44the code to the GitHub. Okay. GitHub
  27731. 18:52:46will automatically uh let's say deploy
  27732. 18:52:48your code to the AWS cloud. It will
  27733. 18:52:51automatically push your code to the AWS
  27734. 18:52:53cloud and your endpoint would be
  27735. 18:52:55automatically updated. Okay.
  27736. 18:52:57automatically updated so that if user is
  27737. 18:52:59using your application okay they won't
  27738. 18:53:01be filling any kinds of let's say server
  27739. 18:53:03down issue okay server down issue
  27740. 18:53:06actually they won't be failing got it so
  27741. 18:53:08this is what actually uh we have to do
  27742. 18:53:10that means we'll be creating the entire
  27743. 18:53:11pipeline entire let's say CI/CD pipeline
  27744. 18:53:14so we'll be just pushing the code in our
  27745. 18:53:16GitHub and GitHub will automatically
  27746. 18:53:18trigger uh this uh action and my code
  27747. 18:53:21will update it to the AWS cloud and AWS
  27748. 18:53:23will update the endpoint okay now see
  27749. 18:53:26the automated process we'll be doing now
  27750. 18:53:28whenever we we'll let's say push our
  27751. 18:53:29code to the GitHub GitHub will
  27752. 18:53:31automatically trigger how it will
  27753. 18:53:32trigger for this you have to use some
  27754. 18:53:34CI/CD tool okay CI/CD tool CI/CD
  27755. 18:53:37automation tool so here there are
  27756. 18:53:38different kinds of CI/CD tool so the
  27757. 18:53:40first tool you can use something called
  27758. 18:53:41GitHub action okay GitHub action you can
  27759. 18:53:44use then you can use something called
  27760. 18:53:45genkins okay genkins then you can use
  27761. 18:53:48something called circleci
  27762. 18:53:52so these actually three famous tool
  27763. 18:53:54actually we are having in the market
  27764. 18:53:55right now so people are using more this
  27765. 18:53:58GitHub action because GitHub action you
  27766. 18:53:59don't need to set up anything. It is
  27767. 18:54:00already set up everything in the GitHub.
  27768. 18:54:02But if you're using Genkins and CircleCI
  27769. 18:54:04you have to set up this server manually.
  27770. 18:54:06Okay. So here we'll be using GitHub
  27771. 18:54:07action because it is already inbuilt
  27772. 18:54:08with the GitHub. We don't need to set up
  27773. 18:54:10anything. Going forward I will also show
  27774. 18:54:11you how we can uh let's say use Genkins
  27775. 18:54:13CircleCI. These are the services as
  27776. 18:54:15well. Fine. So yes guys this is the
  27777. 18:54:17complete uh highle architecture of our
  27778. 18:54:19deployment. So guys uh here you can see
  27779. 18:54:21this is our application code and uh we
  27780. 18:54:24have written actually so many files but
  27781. 18:54:27uh if you see the final files here which
  27782. 18:54:30is this app hittl
  27783. 18:54:33and this uh agentic chatbot hittl back
  27784. 18:54:36end okay because this was our last uh
  27785. 18:54:38last update we have done right so
  27786. 18:54:40instead of like uh deploying all of
  27787. 18:54:43these file guys uh what I'm going to do
  27788. 18:54:45I'm only going to copy the final file
  27789. 18:54:48okay the final code and I'm going to
  27790. 18:54:50create a new uh folder and inside that
  27791. 18:54:52I'm going to keep these are the code
  27792. 18:54:54okay uh just to explain you all the
  27793. 18:54:57concept guys I have kept all of my
  27794. 18:54:59previous code and this is not required
  27795. 18:55:01actually to run my final uh project so
  27796. 18:55:04my final project is uh right now this
  27797. 18:55:06app um app hittl let me show you so
  27798. 18:55:09let's say if I execute this one
  27799. 18:55:12streamlit
  27800. 18:55:15uh run
  27801. 18:55:17app
  27802. 18:55:19hittl okay.py Pi. Now you'll see that uh
  27803. 18:55:22my agentic chatbot uh application will
  27804. 18:55:25be opening.
  27805. 18:55:27So guys as you can see this is our
  27806. 18:55:29application we have u implemented so
  27807. 18:55:32far. So here uh what I'm going to do uh
  27808. 18:55:35instead of moving all of these file I'm
  27809. 18:55:37only going to take my final file which
  27810. 18:55:40is this uh front end app hit and my back
  27811. 18:55:43end which is agentic chart. HITL back
  27812. 18:55:46end. Okay. Apart from that I need this
  27813. 18:55:48requirement.xt txt file. Uh yeah, so I
  27814. 18:55:51think if I have these are the file then
  27815. 18:55:52I'll be able to run my final application
  27816. 18:55:55and I also need this file because inside
  27817. 18:55:57that you have all of the credential. So
  27818. 18:55:59what I can do I can maybe create a new
  27819. 18:56:01folder here and uh let's create this
  27820. 18:56:04folder
  27821. 18:56:07or I'll just create a GitHub repository.
  27822. 18:56:09Okay, because here we have to do the
  27823. 18:56:11CI/CD deployment and for this first of
  27824. 18:56:14all uh you have to create a GitHub repo
  27825. 18:56:16and you have to uh push all of your
  27826. 18:56:19code, okay, in that particular
  27827. 18:56:20repository. So what I'm going to do
  27828. 18:56:22guys, I'm going to open up my GitHub. So
  27829. 18:56:24here what I'm going to do, I'm going to
  27830. 18:56:26create a new repository.
  27831. 18:56:29Let's name it as uh aentic
  27832. 18:56:33chatbot.
  27833. 18:56:36Okay. Aentic chatbot using lang graph
  27834. 18:56:45lang graph.
  27835. 18:56:47Okay. Now uh what I'm going to do I'm
  27836. 18:56:50going to simply add a readmi file.
  27837. 18:56:55Then I'm going to take this g ignode
  27838. 18:56:57here. I'm using python programming.
  27839. 18:56:59Let's select the python. Uh you can also
  27840. 18:57:01take any kinds of license. Let's take
  27841. 18:57:03this apache license. You can also take
  27842. 18:57:04any other license is completely fine.
  27843. 18:57:07Now let's create the repository.
  27844. 18:57:13Okay. Once repo is created, uh click on
  27845. 18:57:15this code and copy this link address and
  27846. 18:57:18open up your uh local folder. Inside
  27847. 18:57:20that open up your terminal. Okay. You
  27848. 18:57:23can also open up your git bash. It's
  27849. 18:57:24completely fine. Now here simply write
  27850. 18:57:26get clone
  27851. 18:57:29and paste your uh URL you have copied
  27852. 18:57:32from the GitHub and clone this
  27853. 18:57:34repository here. Okay. Now you can see I
  27854. 18:57:36have successfully cloned this
  27855. 18:57:37repository. So now what I'm going to do
  27856. 18:57:39I'm going to simply redirect this
  27857. 18:57:40folder. So cd
  27858. 18:57:43aentic
  27859. 18:57:47chatbot using lang graph. Okay. Now I'm
  27860. 18:57:49inside this particular folder. If I show
  27861. 18:57:51you see I'm inside this particular
  27862. 18:57:53folder right now. Now here I have to
  27863. 18:57:55move my code file. Okay, my final code
  27864. 18:57:57file. So what is my final code file?
  27865. 18:57:59I'll take this appl
  27866. 18:58:02then uh this agentic chatbot hit back
  27867. 18:58:06end as well as this env file and I need
  27868. 18:58:09this requirement.txt. Okay. Yeah, I
  27869. 18:58:12think these are the file I need only.
  27870. 18:58:13Now I'll copy this and I'll try to paste
  27871. 18:58:16inside this uh new uh folder I have
  27872. 18:58:19created. Okay. Now if I open up with my
  27873. 18:58:22uh Visual Code Studio, let me open up.
  27874. 18:58:25So this is my Okay, this is my old code.
  27875. 18:58:27Now I'll try to open it with my Visual
  27876. 18:58:29Code Studio.
  27877. 18:58:31Yeah. So you can see guys, this is my uh
  27878. 18:58:34final code. Okay, I have copied from my
  27879. 18:58:36previous code. Yeah, this is my final
  27880. 18:58:38version of the code. Now uh what I can
  27881. 18:58:41do, I can maybe rename these are the
  27882. 18:58:43file instead of keeping this file name
  27883. 18:58:45like that, I can rename it. So first of
  27884. 18:58:47all let's try to change this backend
  27885. 18:58:49file name. So here let's rename it. So
  27886. 18:58:53here I'm only going to name this file as
  27887. 18:58:55backend.py.
  27888. 18:59:00Okay backend.py
  27889. 18:59:02and this app hit I'm going to name it as
  27890. 18:59:07only app.py.
  27891. 18:59:11Okay app.py. Now make sure uh whenever
  27892. 18:59:15you uh you have renamed this file you
  27893. 18:59:18also need to uh change the import. Okay.
  27894. 18:59:20So it has automatically changed because
  27895. 18:59:22I'm using one extension that extension
  27896. 18:59:25automatically will uh like uh trigger uh
  27897. 18:59:29whenever I'm changing any kinds of file
  27898. 18:59:31name. It will automatically change that
  27899. 18:59:32uh input in my other file as well. Now
  27900. 18:59:35you can see I'm importing all everything
  27901. 18:59:37and it's coming one warning because I
  27902. 18:59:40have to select my original environment
  27903. 18:59:42which is langraph test. Okay, this
  27904. 18:59:43environment now I think everything is
  27905. 18:59:45fine. Okay, now here uh what I have to
  27906. 18:59:47do guys, I have to
  27907. 18:59:50uh I have to
  27908. 18:59:52um
  27909. 18:59:54let me check again. Huh. So everything
  27910. 18:59:57is fine. Let me show you whether it's
  27911. 18:59:58working or not. So what I can do I can
  27912. 19:00:01stop my previous execution and let's
  27913. 19:00:04open up my new terminal.
  27914. 19:00:08Now I'll execute this app. So cond
  27915. 19:00:15list.
  27916. 19:00:18So this is the name of the environment.
  27917. 19:00:20I'll copy
  27918. 19:00:24and I'll just write conduct activate
  27919. 19:00:29my environment.
  27920. 19:00:31Now after that let's execute my app.py.
  27921. 19:00:33So streamllet
  27922. 19:00:36run
  27923. 19:00:37app.py Pi.
  27924. 19:00:42Now see this is the application. Now
  27925. 19:00:44let's uh test this application. Uh see
  27926. 19:00:47right now you can't see any uh any of my
  27927. 19:00:49old trades because completely right now
  27928. 19:00:52I have copied my uh chatbot in a new uh
  27929. 19:00:56new actually folder. Okay. And right now
  27930. 19:00:58all of the execution will be happening
  27931. 19:00:59from the beginning. So let me test this
  27932. 19:01:02chatbot whether it's working or not. So
  27933. 19:01:04here I'll pass hello.
  27934. 19:01:07See it's working. Okay. Hello, I can uh
  27935. 19:01:10help you today. That means everything is
  27936. 19:01:11fine. That means uh this is our final
  27937. 19:01:13code we can utilize right now for the
  27938. 19:01:15deployment. Now guys, let me write all
  27939. 19:01:18the deployment step actually we'll be
  27940. 19:01:20following for this CI/CD deployment. Um
  27941. 19:01:24let me write here
  27942. 19:01:28this is the [clears throat]
  27943. 19:01:31this is the entire step. Okay, you can
  27944. 19:01:34see this is this enter step I have
  27945. 19:01:36already prepared for this deployment. So
  27946. 19:01:37let me open the preview. Yeah, now you
  27947. 19:01:40can see here. So see this is a streaml
  27948. 19:01:43app and uh we have to deploy the
  27949. 19:01:46streamlit app over the AWS cloud as a
  27950. 19:01:48CI/CD and for CI/CD tool-wise we'll be
  27951. 19:01:52using GitHub actions. Okay. And GitHub
  27952. 19:01:54action is already uh already actually
  27953. 19:01:57let's say uh built-in CI/CD like uh
  27954. 19:02:01tool. You don't need to set up this
  27955. 19:02:03GitHub action server separately. This is
  27956. 19:02:05already running on the GitHub. Okay, you
  27957. 19:02:07just need to um you just need to
  27958. 19:02:09actually configure that GitHub actions
  27959. 19:02:12by adding some commands. Okay, by adding
  27960. 19:02:15some commands inside a file. We call it
  27961. 19:02:17as a CI/CD. ML file. This file I'm also
  27962. 19:02:20going to show you how you can write
  27963. 19:02:21that. But as you can see, this is the
  27964. 19:02:24deployment step we'll be following.
  27965. 19:02:25First of all, we'll try to build the
  27966. 19:02:27Docker image of our source code. Okay.
  27967. 19:02:30uh we'll try to dockerize entire for
  27968. 19:02:32source code. Then we'll try to push this
  27969. 19:02:34docker image to the docker hub. Okay.
  27970. 19:02:36Then I'm going to launch a EC2 machine
  27971. 19:02:38on AWS server. Uh then I'm going to pull
  27972. 19:02:41my Docker image. Okay. From the Docker
  27973. 19:02:44hub to EC2. Then I'm going to launch my
  27974. 19:02:47um like image. That means I'm going to
  27975. 19:02:50execute my application as a Docker
  27976. 19:02:52container inside EC2 machine. Okay. Then
  27977. 19:02:54I'll do some port mapping. Then you'll
  27978. 19:02:56be able to access your application.
  27979. 19:02:58Okay. uh from the remote URL. Now for
  27980. 19:03:02this Docker knowledge is definitely
  27981. 19:03:04required and I am expecting you are
  27982. 19:03:06already familiar with Docker but if you
  27983. 19:03:08don't know about Docker and all so don't
  27984. 19:03:10worry I have a complete uh like let's
  27985. 19:03:13say tutorial on my channel as you can
  27986. 19:03:15see I have a complete um video ultimate
  27987. 19:03:18MLOps full course in a one video. So
  27988. 19:03:20this is around 11 uh almost 12 hours of
  27989. 19:03:23recording and this course covers
  27990. 19:03:25everything about the MLOps. uh I have
  27991. 19:03:27already covered Linux. Okay. Then um
  27992. 19:03:30some other tools as well. You can see in
  27993. 19:03:32the description section. See lots of
  27994. 19:03:34like MLOps tools I have covered. And
  27995. 19:03:36here we'll be seeing uh one section uh I
  27996. 19:03:39think from this uh hour itself you can
  27997. 19:03:42uh start watching uh docker concept.
  27998. 19:03:44Okay. You can see the docker concept I
  27999. 19:03:46have also covered in this particular
  28000. 19:03:47course itself. Now if you are completely
  28001. 19:03:49new to the docker and if you want to
  28002. 19:03:50learn the docker okay how do works and
  28003. 19:03:52why do required I'm going to suggest you
  28004. 19:03:54go through this recording. I'm going to
  28005. 19:03:56add this uh video in my description.
  28006. 19:03:58From there you can check it out. Okay,
  28007. 19:03:59you don't need to watch from the
  28008. 19:04:01beginning. Maybe you can only complete
  28009. 19:04:02the docker part at least so that you can
  28010. 19:04:05um you can u see the deployment part.
  28011. 19:04:08Okay, you can um understand like how
  28012. 19:04:10doer is helping for the CI/CD deployment
  28013. 19:04:12and all. Okay. So yeah, this is the
  28014. 19:04:14requirement. Then uh here I have added
  28015. 19:04:17this step. First of all, we have to
  28016. 19:04:19login to the AWS console. Then we'll be
  28017. 19:04:22creating the IM user. Okay. Then after
  28018. 19:04:24creating the IM user, we'll try to set
  28019. 19:04:25the policy. Then we'll try to create the
  28020. 19:04:27EC2 uh machine. Okay, we'll be taking
  28021. 19:04:30open Ubuntu instance. After that, we'll
  28022. 19:04:32try to open the EC2 instance and we'll
  28023. 19:04:34try to set up uh docker there. Okay,
  28024. 19:04:36because by default in the EC2 there
  28025. 19:04:38won't be any kinds of docker. You have
  28026. 19:04:39to set up it. Once the setup is
  28027. 19:04:41complete, then uh you will be um able to
  28028. 19:04:44set the port. Okay, that means by
  28029. 19:04:46default streaml runs on port number
  28030. 19:04:488501. Okay, so we'll try to do the port
  28031. 19:04:50mapping. Then we'll try to set up our
  28032. 19:04:53entire project as a self-hosted runner.
  28033. 19:04:55That means we'll try to connect our AWS
  28034. 19:04:58with our GitHub. That means once let's
  28035. 19:05:00say we will try to push something in the
  28036. 19:05:02GitHub automatically my CI/CD pipeline
  28037. 19:05:04will trigger and all of the new changes
  28038. 19:05:07will be available over my AWS. Okay,
  28039. 19:05:09that means automatically my deployment
  28040. 19:05:11will be happening. So these kinds of
  28041. 19:05:12pipeline we have to create by creating
  28042. 19:05:14the self-ostraed runner. Okay, I'm going
  28043. 19:05:16to also show you how to create that.
  28044. 19:05:17Then once everything is complete then
  28045. 19:05:19I'll try to uh like set up all of my
  28046. 19:05:21secret. Okay. So you can see uh if you
  28047. 19:05:24want to run this project you need these
  28048. 19:05:25are the secret. Uh apart from that some
  28049. 19:05:27additional secret is also required like
  28050. 19:05:29um registry docker username docker
  28051. 19:05:31password. Okay. Image name AWS access
  28052. 19:05:34key ID as secret key uh secret access
  28053. 19:05:36key. Okay as region. So these are the
  28054. 19:05:39thing additionally you need because if
  28055. 19:05:40you want to uh authenticate with AWS
  28056. 19:05:43account uh programmatically you need
  28057. 19:05:44these are the credential. Okay. I will
  28058. 19:05:46try to create this credential as well.
  28059. 19:05:47I'm going to show you okay how to do do
  28060. 19:05:49that and I am going to push my uh uh
  28061. 19:05:52docker image uh to the docker hub for
  28062. 19:05:54this docker credential is also required
  28063. 19:05:56and you should have also account in the
  28064. 19:05:58docker hub and uh after that whatever
  28065. 19:06:00credential I'm having I think you
  28066. 19:06:02already know that these are the
  28067. 19:06:03credential I need to execute my entire
  28068. 19:06:05agents okay like if you're using openi
  28069. 19:06:07model you can set the open api key tab
  28070. 19:06:09API key open weather google okay if
  28071. 19:06:11you're using gemini you can set the
  28072. 19:06:13google api key lang smmith lang smith
  28073. 19:06:15endpoint lang smmith API then lang
  28074. 19:06:17speedit project. Okay. So yeah, this is
  28075. 19:06:19the step guys we'll be following for uh
  28076. 19:06:22deployment. Okay, for this CI/CD
  28077. 19:06:24deployment now first of all guys here
  28078. 19:06:26I'm going to create a docker file. So
  28079. 19:06:29let's create a docker file here. So to
  28080. 19:06:32dockerize your entire application you
  28081. 19:06:34need this docker file. Okay. And inside
  28082. 19:06:35this docker file you have to write some
  28083. 19:06:37docker related command. Now what are the
  28084. 19:06:40command you have to write. So this is
  28085. 19:06:41the command guys and this thing you will
  28086. 19:06:43be able to understand uh from that
  28087. 19:06:45particular video I suggested you because
  28088. 19:06:47in that video I have covered like what
  28089. 19:06:49is this uh uh beige image okay uh what
  28090. 19:06:52is this environment what is this working
  28091. 19:06:53directory okay each and everything I
  28092. 19:06:55have explained there if you are
  28093. 19:06:57completely new to the docker first of
  28094. 19:06:58all try to complete that recording I
  28095. 19:07:00think that would be easy for you okay
  28096. 19:07:02but if you're already familiar with
  28097. 19:07:03docker and you know that these are the
  28098. 19:07:05command we need to create uh the docker
  28099. 19:07:07image that means to containerize entire
  28100. 19:07:09our application Right. So yeah, we are
  28101. 19:07:11setting this um command inside the
  28102. 19:07:14docker file and here you can see we have
  28103. 19:07:16to install the requirement.txt. Okay,
  28104. 19:07:18we're also uh installing in this
  28105. 19:07:20particular command. Uh and I have
  28106. 19:07:22already commented out. See now this uh
  28107. 19:07:24part you need uh to prevent python cache
  28108. 19:07:27file and enable immediate uh container
  28109. 19:07:29logs. Okay. Then this code you need to
  28110. 19:07:32build the essential supports package
  28111. 19:07:33that required uh compilations. then lib
  28112. 19:07:38uh gum gum one is a commonly required by
  28113. 19:07:42fire CPU that means here I am using fire
  28114. 19:07:45CPU for the vector database right that's
  28115. 19:07:47why this library you also need to
  28116. 19:07:50install okay whenever you are upgrading
  28117. 19:07:51this machine then you need this
  28118. 19:07:54requirement txt um it has to copy in the
  28119. 19:07:58root folder then um you can see uh we
  28120. 19:08:01will be installing this requirement txt
  28121. 19:08:03and this is the command we are writing
  28122. 19:08:05then we are copying all of our source
  28123. 19:08:07code inside the root directory. Then
  28124. 19:08:08we're exposing the port and by default
  28125. 19:08:11streamllet runs on port number 8501.
  28126. 19:08:13We're exposing the port and this is the
  28127. 19:08:15final command to launch the streamlit
  28128. 19:08:16server. Okay. So yeah, this is the
  28129. 19:08:18docker file and with this docker file
  28130. 19:08:20you need another file which is dot
  28131. 19:08:22docker ignore
  28132. 19:08:26ignore. Okay. So inside this dot uh
  28133. 19:08:28docker ignic node uh you have to write
  28134. 19:08:30some of the unnecessary files and folder
  28135. 19:08:33which you don't need to uh integrate
  28136. 19:08:36inside uh your docker image let's say if
  28137. 19:08:39you have your virtual environment okay
  28138. 19:08:41in this particular folder itself that uh
  28139. 19:08:43you don't need okay whenever you are
  28140. 19:08:44creating the docker file right so that
  28141. 19:08:46time you can ignore this one so that
  28142. 19:08:48means whatever file and folder you will
  28143. 19:08:50be keeping inside dot docker ignore it
  28144. 19:08:52will ignore during building the docker
  28145. 19:08:54image okay like uh this get ignore and
  28146. 19:08:56you know get ignore what it does it
  28147. 19:08:58ignores the files and folder whatever
  28148. 19:08:59you will be adding inside this get
  28149. 19:09:01ignore okay so that it won't be pushing
  28150. 19:09:03inside our um github repositories okay
  28151. 19:09:06so these are the things uh actually I
  28152. 19:09:08don't need inside my um docker image
  28153. 19:09:11that's why I'm ignoring inside dot uh do
  28154. 19:09:13docker ignore so once it is done uh then
  28155. 19:09:16I'll try to add this cicdl file for the
  28156. 19:09:20github actions acd deployment so for
  28157. 19:09:22this you have to create a folder the
  28158. 19:09:24folder name should be github Okay. So
  28159. 19:09:27this is the folder name we usually use
  28160. 19:09:28and this folder name you don't need to
  28161. 19:09:30change. If you are changing it will not
  28162. 19:09:32work. So by default if you're using u
  28163. 19:09:34this uh GitHub actions for this
  28164. 19:09:37deployment you have to create this dot
  28165. 19:09:39GitHub folder. Inside that I'm uh you
  28166. 19:09:41will be creating another folder called
  28167. 19:09:42workflows.
  28168. 19:09:44Okay workflows. Make sure you are using
  28169. 19:09:47the same name otherwise it will not
  28170. 19:09:49work.
  28171. 19:09:50Okay workflows. And inside this
  28172. 19:09:53workflows you will be creating a file
  28173. 19:09:54called cicd
  28174. 19:09:56dot
  28175. 19:09:58yml uh okay yl okay this is a yl file
  28176. 19:10:03inside that you have to mention all of
  28177. 19:10:05the command you need for the cicd
  28178. 19:10:07deployment okay now just verify whether
  28179. 19:10:11everything is fine or not inside github
  28180. 19:10:13workflows and cic.ml file is available
  28181. 19:10:15okay now guys uh what I'm going to do um
  28182. 19:10:19I'm going to maybe close this file this
  28183. 19:10:21is not required. Yeah, I'm going to open
  28184. 19:10:24up my new code. Yeah, now what I'm going
  28185. 19:10:26to do guys, I'm going to add all of the
  28186. 19:10:28CI/CD related command and these are the
  28187. 19:10:31CI/CD related command you will be
  28188. 19:10:33getting in the internet itself. Okay. Uh
  28189. 19:10:35you can simply search I want to perform
  28190. 19:10:38um CI/CD deployment. Okay. Uh on AWS and
  28191. 19:10:43I have a streaml application for that. I
  28192. 19:10:45need this uh CI/CD. ML file. So you will
  28193. 19:10:48be able to see this YML file is
  28194. 19:10:50available okay over the internet you
  28195. 19:10:52don't need to memorize it you will be
  28196. 19:10:53getting this thing in the internet only
  28197. 19:10:55and if you have the chart GPT gemini
  28198. 19:10:57simply you can open the chart GP and
  28199. 19:10:58Gemini you can ask okay I need a CI/CDML
  28200. 19:11:01file commands uh I have to do this
  28201. 19:11:03deployment okay streamllet app on the
  28202. 19:11:05AWS as a CI/CD so I have already
  28203. 19:11:08prepared the CICDML command so let me
  28204. 19:11:10show you so this is the
  28205. 19:11:12uh command and most of the command you
  28206. 19:11:14can see this is a Linux command uh if
  28207. 19:11:16you are completely new to the Linux
  28208. 19:11:17command So again in my MLOps course okay
  28209. 19:11:21on my YouTube channel I already covered
  28210. 19:11:23the Linux okay relaxated command you can
  28211. 19:11:25see uh Linux is also covered okay you
  28212. 19:11:27can go through the Linux video as well
  28213. 19:11:29to understand how this command works
  28214. 19:11:31okay so yes uh this is the like uh uh
  28215. 19:11:34structured command you need to execute
  28216. 19:11:37uh whenever you want to perform CI/CD
  28217. 19:11:38with the help of GitHub actions so first
  28218. 19:11:40of all you have to define a name of your
  28219. 19:11:42application so here I have given
  28220. 19:11:44streamlit AWS CICD you can change the
  28221. 19:11:46name anytime Then on push okay that
  28222. 19:11:48means if you're pushing on the main
  28223. 19:11:50branch that means right now I have the
  28224. 19:11:53GitHub right this is the GitHub and here
  28225. 19:11:55I am using main branch that means
  28226. 19:11:57whatever push I'm going to do on my main
  28227. 19:11:58branch this pipeline will trigger okay
  28228. 19:12:02only it will ignore if you're changing
  28229. 19:12:04the readmi file because readmi is not a
  28230. 19:12:06feature okay readmi is kinds of file
  28231. 19:12:08there I just try to write some metadata
  28232. 19:12:10for my project right so if I'm changing
  28233. 19:12:12anything in my readmi that time our cd
  28234. 19:12:14pipeline should not be triggered that's
  28235. 19:12:16why path not ignore we are writing
  28236. 19:12:18readmi file otherwise if you're changing
  28237. 19:12:20in any file this pipeline will start
  28238. 19:12:22okay this cd pipeline will start and
  28239. 19:12:24your deployment will be happening then
  28240. 19:12:27uh we are giving some other like uh
  28241. 19:12:29parameter as well like workflow dispatch
  28242. 19:12:32concurrency okay permissions we are
  28243. 19:12:34giving each and everything and this is
  28244. 19:12:35already uh I mean uh predefined actually
  28245. 19:12:39workflows you have to write if you're
  28246. 19:12:41using this uh GitHub actions for the
  28247. 19:12:43CI/CD deployment okay this is not our
  28248. 19:12:45code So CI/CD uh uh with the GitHub
  28249. 19:12:49actions documentation if you check so
  28250. 19:12:51they have written these are the commands
  28251. 19:12:52should be added inside your CIC dol. Now
  28252. 19:12:56here the main thing is the jobs. So here
  28253. 19:12:58first of all continuous integration will
  28254. 19:12:59be happening inside continuous
  28255. 19:13:01integration we are just only eing the
  28256. 19:13:02command. Okay we are taking a Ubuntu
  28257. 19:13:04instance and we are only eing the
  28258. 19:13:05command. Then the second step we are
  28259. 19:13:08building and pushing the image to the
  28260. 19:13:09docker hub. So here first of all we are
  28261. 19:13:12verifying with the uh docker hub
  28262. 19:13:14account. So make sure you have the
  28263. 19:13:15Docker Hub account. So if you don't have
  28264. 19:13:17you can create. So simply search for
  28265. 19:13:19DockerHub. Okay, Docker Hub. Go to the
  28266. 19:13:21first website and make sure you have a
  28267. 19:13:24account here. Okay, I already have the
  28268. 19:13:25account that's why it it got login.
  28269. 19:13:28Okay, but if you don't have account
  28270. 19:13:29guys, please try to create an account.
  28271. 19:13:31So let's say I will sign out.
  28272. 19:13:36So here you can sign up. Okay, sign up.
  28273. 19:13:38You can fill your information. After
  28274. 19:13:40filling you will be able to create the
  28275. 19:13:41account. So I already have the account.
  28276. 19:13:42I'll just try to sign up.
  28277. 19:13:45sign in.
  28278. 19:13:47So this is my email and password. I'm
  28279. 19:13:48going to sign in with my Docker Hub.
  28280. 19:13:52Okay. And this is how your Docker Hub
  28281. 19:13:55will look like. Okay. Previously I
  28282. 19:13:57already pushed some of the image that's
  28283. 19:13:58why it's available. But for you it would
  28284. 19:14:00be completely empty. Okay. So Docker Hub
  28285. 19:14:02is a service that you can store all of
  28286. 19:14:03your Docker image. Okay. You are
  28287. 19:14:05creating. You can also use AWS ECR
  28288. 19:14:08service but this is fine. Uh I can use
  28289. 19:14:10Docker Hub also. It's completely fine.
  28290. 19:14:12Okay. Okay, in AWS also to store your
  28291. 19:14:14docker image there is a service called
  28292. 19:14:16AWS ECR elastic container registry.
  28293. 19:14:18Okay, you can also use that this one but
  28294. 19:14:20I'm going to use docker hub for this
  28295. 19:14:21particular project. Maybe in future I'm
  28296. 19:14:22also going to show you that elastic
  28297. 19:14:24container registry how to use that
  28298. 19:14:27because I want to uh minimize my cloud
  28299. 19:14:29cost that's why I'm using these are the
  28300. 19:14:31free uh free to use actually hub okay to
  28301. 19:14:33push my image
  28302. 19:14:35and uh yeah so here you can see we are
  28303. 19:14:38authenticating with the docker hub and
  28304. 19:14:40after that we are building the image
  28305. 19:14:42okay we are building our docker image
  28306. 19:14:45then after building we are pushing this
  28307. 19:14:46image to the docker hub then once my uh
  28308. 19:14:50second step done Then it will start the
  28309. 19:14:52third step. There you will try to deploy
  28310. 19:14:54your image to AWS EC2 instance. Okay. As
  28311. 19:14:58a self hosted runner. For this this is
  28312. 19:15:00the command. So it will again
  28313. 19:15:01authenticate with your docker hub and it
  28314. 19:15:03will uh take that image and it will run
  28315. 19:15:06on your EC2 instance. Okay. And to run
  28316. 19:15:08your app you need some credential. I
  28317. 19:15:10think you remember you need Google API
  28318. 19:15:12key API key open a open weather API.
  28319. 19:15:15Okay. So whatever let's say API you have
  28320. 19:15:17used right you have to write all of the
  28321. 19:15:19API here. You can see uh what is that?
  28322. 19:15:22Yeah, but you are not going to directly
  28323. 19:15:24give the value. So this value you'll be
  28324. 19:15:26reading from the secret. Okay, we call
  28325. 19:15:28it as a GitHub secret. I'm going also
  28326. 19:15:29going to show you how to add this
  28327. 19:15:30secret. But make sure whatever API key
  28328. 19:15:32you are using, you have to write here.
  28329. 19:15:34Okay, and here we are checking all of
  28330. 19:15:36the API keys are available or not. If
  28331. 19:15:38not available, we are uh just uh like
  28332. 19:15:41launching a message called secret is
  28333. 19:15:42missing. Okay. Then uh this is the code
  28334. 19:15:45and finally we are running our docker
  28335. 19:15:47image and it is starting the server.
  28336. 19:15:49Okay. And some other necessary command
  28337. 19:15:52we are also running. Okay. Everything
  28338. 19:15:54will be running in that docker video I
  28339. 19:15:56have already given you. Okay. In my
  28340. 19:15:57MLOps course. Now this is the cicd.
  28341. 19:16:00Mamel file guys you need for this uh
  28342. 19:16:02deployment. Now everything is ready. Now
  28343. 19:16:05let's try to create the server. Okay.
  28344. 19:16:08Server means I will follow this step.
  28345. 19:16:10Okay. First of all here what I'm going
  28346. 19:16:12to do? I'm going to login with my AWS
  28347. 19:16:14console. So let's try to login. I
  28348. 19:16:17already logged in with my AWS console.
  28349. 19:16:18Make sure you have the AWS account. If
  28350. 19:16:20you don't have the account guys, please
  28351. 19:16:22try to create one account. I already
  28352. 19:16:23logged in with my AWS console and that's
  28353. 19:16:25how your console looks like. Now here
  28354. 19:16:27the first thing you have to search for
  28355. 19:16:28the IM user. Okay, IM user that means
  28356. 19:16:31identity access management. Um then I
  28357. 19:16:34will go to the IM user section and here
  28358. 19:16:36you have to create an user. Okay, let's
  28359. 19:16:38create a user. So I'm going to name it
  28360. 19:16:40as uh let's say agentic.
  28361. 19:16:46Okay, agentic user. You can give any
  28362. 19:16:48name it's up to you. Now I'll click on
  28363. 19:16:50next. Then you have to add the policies.
  28364. 19:16:52Okay. And which policies you have to
  28365. 19:16:53add. So here I think I have already
  28366. 19:16:55written.
  28367. 19:16:57Uh yeah. So after login to the console
  28368. 19:16:59we are creating the IM user and this is
  28369. 19:17:00the policy you have to add. Okay. AD
  28370. 19:17:02Amazon EC2 full access. So here uh let
  28371. 19:17:07me check again. Amazon EC2 full access.
  28372. 19:17:09Okay. Huh? Because you only need the EC2
  28373. 19:17:11instance. Okay. So I'll copy this and uh
  28374. 19:17:14here I'm going to search it here. Okay.
  28375. 19:17:17Okay. So, Amazon EC2 full access. I'll
  28376. 19:17:18provide this access and I'll click on
  28377. 19:17:21next. Okay. See why we are giving this
  28378. 19:17:23permission because in my AWS account
  28379. 19:17:25there are lots of services we are having
  28380. 19:17:27right [snorts] and it's not like that
  28381. 19:17:29I'm going to give all of the services
  28382. 19:17:31access to my um like project to my code.
  28383. 19:17:35Instead of that I'm only going to give
  28384. 19:17:36the access the service actually I'm
  28385. 19:17:38using otherwise there is a possibility
  28386. 19:17:40uh it might use some other service and I
  28387. 19:17:42will end up with lots of cost right? But
  28388. 19:17:44I don't need that. So that's why I am
  28389. 19:17:46only giving the access the services I'm
  28390. 19:17:48using. So here I'll be using EC2
  28391. 19:17:50instance. EC2 is a virtual machine
  28392. 19:17:52inside AWS. Okay. Once it is done, let's
  28393. 19:17:54create the user.
  28394. 19:17:58Okay. So some error is coming.
  28395. 19:18:03The specific username is invalid. Must
  28396. 19:18:05contain. Okay. So I think the name we
  28397. 19:18:07have given this is not uh okay. There I
  28398. 19:18:10have given a space, right? But it should
  28399. 19:18:11not be having any kind of a space. So
  28400. 19:18:14I'll give this hyphen sign. Now let's
  28401. 19:18:16click on next. Now I'll provide this um
  28402. 19:18:22Amazon EC2 full access. Click on next.
  28403. 19:18:25Everything is fine. Create the user.
  28404. 19:18:28Okay. So my user creation is done. Now
  28405. 19:18:30I'll go inside the user and there is a
  28406. 19:18:32option called security credential. Just
  28407. 19:18:34try to click here
  28408. 19:18:36and uh here you will see this one access
  28409. 19:18:40keys. Okay. Now I'll click on this
  28410. 19:18:43create access keys. Now select this
  28411. 19:18:45command line interface CLI and just do
  28412. 19:18:47the confirmation. Okay. Once everything
  28413. 19:18:49is done, now click on the next. Then I
  28414. 19:18:51will uh click on this create access
  28415. 19:18:53keys. Okay. Now this is our access keys
  28416. 19:18:56and secret access keys. Guys, you need
  28417. 19:18:57to authenticate with your AWS because
  28418. 19:18:59I'm going to access my AWS account from
  28419. 19:19:02my Python code, right? Um uh from my
  28420. 19:19:05actually GitHub actions.
  28421. 19:19:07Uh that's why this credential is
  28422. 19:19:09required. Okay. Now you can download as
  28423. 19:19:12a CSV file as well. Let's try to
  28424. 19:19:13download this thing. I need later on.
  28425. 19:19:15Now this service is creation done. Okay.
  28426. 19:19:18Now this this is creation done. Um we
  28427. 19:19:21have successfully created the IM user
  28428. 19:19:24and we have given the policy and we
  28429. 19:19:26collected our access key and secret
  28430. 19:19:28access key. Now the next step you have
  28431. 19:19:29to create the EC2 machine Ubuntu
  28432. 19:19:31machine. Okay. Now let's do that. I will
  28433. 19:19:33go to my home and here I will search for
  28434. 19:19:37uh EC2 instance. Okay. Let's open this
  28435. 19:19:40EC2 instance. And EC2 instance is a
  28436. 19:19:43virtual uh virtual computer service.
  28437. 19:19:46Okay. Inside AWS. Now I'll just try to
  28438. 19:19:50click on launch instance. Uh launch
  28439. 19:19:52without a walk through. Okay. Now you
  28440. 19:19:54have to give a name. So I'll give
  28441. 19:19:56aentic.
  28442. 19:19:58Okay. Agentic chatbot
  28443. 19:20:04machine. Okay. You can give any name.
  28444. 19:20:06It's up to you. And make sure you select
  28445. 19:20:08this Ubuntu instance. Okay. There are
  28446. 19:20:09some other instances available like Mac
  28447. 19:20:11OS, Windows, Red Hat. But I will take
  28448. 19:20:13this Ubuntu instance because this is the
  28449. 19:20:15most used instance whenever you are
  28450. 19:20:17doing the production grade deployment.
  28451. 19:20:19Now once it is done you can uh select
  28452. 19:20:21the instance type that means how much
  28453. 19:20:23memory how much CPU you need. You can
  28454. 19:20:26select the configuration here. So for
  28455. 19:20:27this project at least 4 GB RAM is
  28456. 19:20:30required. Okay. And I'm going to take 2
  28457. 19:20:32vcpu. I think this T2 medium is fine for
  28458. 19:20:35me. Okay. But if you are creating a
  28459. 19:20:37heavy project that needs lots of
  28460. 19:20:38computation that time you can also take
  28461. 19:20:40some bigger instance as well. Some
  28462. 19:20:42bigger instance are also available like
  28463. 19:20:4332 GB memory 16 GB memory. Okay you can
  28464. 19:20:47see everything is available. Now I'll
  28465. 19:20:48take this T2 medium. Okay this is fine
  28466. 19:20:50for me. Now here you have to create a
  28467. 19:20:53key value pair uh key pair. Now you can
  28468. 19:20:55give the name. I'll give aentic.
  28469. 19:20:58Let's create the key. And once it is
  28470. 19:21:01created you can select it from here.
  28471. 19:21:03Okay. agentic
  28472. 19:21:05huh this one so this uh key you need
  28473. 19:21:08whenever let's say you want to access
  28474. 19:21:10your uh this EC2 machine from any third
  28475. 19:21:12party tools like putty and mobile
  28476. 19:21:14extreme that time it is required but for
  28477. 19:21:16our case we'll try to launch in the uh
  28478. 19:21:18same uh Google chrome only okay there uh
  28479. 19:21:20you can launch the uh terminal okay your
  28480. 19:21:24uh easy to inst terminal this is also
  28481. 19:21:25possible now here you have to uh check
  28482. 19:21:29mark these two option allow https and
  28483. 19:21:31allow http traffic from the internet and
  28484. 19:21:33here you can take the storage at least
  28485. 19:21:36try to take 32GB storage and uh
  28486. 19:21:39everything is fine no need to change
  28487. 19:21:40anything simply launch the instance
  28488. 19:21:48okay so I'll go below and click on view
  28489. 19:21:51all instance now see my instance has
  28490. 19:21:54created and it is running okay make sure
  28491. 19:21:55it is running otherwise you can keep on
  28492. 19:21:56refreshing this page now simply I'll
  28493. 19:21:59click on my instance ID and here you
  28494. 19:22:01will get one option call this connect
  28495. 19:22:03button. Okay, but before connect button
  28496. 19:22:05I think you remember what I told you. I
  28497. 19:22:07told you to do the port mapping as you
  28498. 19:22:09can see. Uh
  28499. 19:22:13okay, port mapping I think we can also
  28500. 19:22:15do do later on but you can do the port
  28501. 19:22:17mapping right now. Uh if you want just
  28502. 19:22:20do the port mapping otherwise we'll do
  28503. 19:22:22do it later on. Okay. So simply I'm
  28504. 19:22:24going to connect my instance. Okay. So
  28505. 19:22:26there is a connect button. Just try to
  28506. 19:22:28click on the connect button and uh make
  28507. 19:22:30sure you select everything as default.
  28508. 19:22:32If you want to connect this uh this uh
  28509. 19:22:34let's say EC2 instance from any third
  28510. 19:22:36partyy tool that time you can use HSS
  28511. 19:22:37client and you can use mobile extreme
  28512. 19:22:39putty. These are the tools to connect.
  28513. 19:22:41Okay. But I'm going to connect from my
  28514. 19:22:44uh same AWS CLI only. I'm going to
  28515. 19:22:46simply click on connect. Now see in a
  28516. 19:22:48different tab it will open up your this
  28517. 19:22:51uh EC2 instance terminal. Okay. This
  28518. 19:22:53will be your uh Linux terminal and there
  28519. 19:22:56you have to execute all the command to
  28520. 19:22:57set up your entire server. Okay. Now see
  28521. 19:22:59this is the Linux server we are getting
  28522. 19:23:01guys that's cleared and for this you
  28523. 19:23:03need some idea about Linux command
  28524. 19:23:06Ubuntu Ubuntu operating system and this
  28525. 19:23:08thing I have already covered in my
  28526. 19:23:10ultimate MLOps full course okay there I
  28527. 19:23:12have already covered about the Linux you
  28528. 19:23:13can study about that okay for the
  28529. 19:23:15deployment guys you need little bit of
  28530. 19:23:17understanding MLOps if you know about
  28531. 19:23:19MLOps it would be easy for you to do the
  28532. 19:23:21deployment now guys what I'm going to do
  28533. 19:23:23I'm going to set up all of the
  28534. 19:23:27uh all of the package I need here So for
  28535. 19:23:29this I mention all of the command as you
  28536. 19:23:31can see. Uh first of all you have to
  28537. 19:23:34upgrade your machine. So for this just
  28538. 19:23:36copy this command and execute it here.
  28539. 19:23:42Right click and paste and execute. Then
  28540. 19:23:45I'll copy the next one. See you just
  28541. 19:23:47need to copy this command one after one
  28542. 19:23:50and just execute inside the terminal.
  28543. 19:23:53Done. Now I'll coph paste this second
  28544. 19:23:56command. So see this is a completely new
  28545. 19:23:59create newly created machine and here
  28546. 19:24:00you have to upgrade the package manager.
  28547. 19:24:03Okay. So we are upgrading and for this
  28548. 19:24:04we're using pseudo get upgrade this
  28549. 19:24:06command. Now I'll give yes permission
  28550. 19:24:09and upgrade this machine
  28551. 19:24:15and that's how your production server
  28552. 19:24:17looks like. Okay. That's why you you may
  28553. 19:24:19be heard of in production you need to
  28554. 19:24:22know about Linux. Okay. because every
  28555. 19:24:24production server they're using Linux
  28556. 19:24:27especially the Ubuntu instance okay
  28557. 19:24:28they're using now this is also done I
  28558. 19:24:31will clear the terminal now let me see
  28559. 19:24:33the next command next command you have
  28560. 19:24:35this um
  28561. 19:24:37you have to install this docker okay now
  28562. 19:24:39to install the docker this is the
  28563. 19:24:41command first of all let's download the
  28564. 19:24:43docker
  28565. 19:24:44there's a hs file you have to download.
  28566. 19:24:55Then after that we'll try to install.
  28567. 19:25:08I'll copy this command one by one.
  28568. 19:25:23paste the next command.
  28569. 19:25:26And this is the last command you have to
  28570. 19:25:28execute.
  28571. 19:25:33Now see docker successfully got
  28572. 19:25:35installed inside our Linux instance. You
  28573. 19:25:37can check it. For this you can run this
  28574. 19:25:39command docker version. So you'll see
  28575. 19:25:42that Docker is running right now. Okay.
  28576. 19:25:43But previously Docker was missing. Okay.
  28577. 19:25:46I can maybe close my local local host
  28578. 19:25:49execution.
  28579. 19:25:51Let's close it.
  28580. 19:25:53Uh terminal is also running. I'll stop
  28581. 19:25:55it. H.
  28582. 19:25:58So fine. Uh we have successfully
  28583. 19:26:00installed Docker. Now the next step I
  28584. 19:26:01have to uh configure my EC2 as a
  28585. 19:26:05self-hosted runner. For this just open
  28586. 19:26:07up your GitHub and go to the settings.
  28587. 19:26:10Okay. Make sure you are using your
  28588. 19:26:11GitHub, okay? Not my GitHub. Go to the
  28589. 19:26:13settings and uh left hand side you will
  28590. 19:26:16see one option called uh actions. Now go
  28591. 19:26:19to the runner.
  28592. 19:26:23Okay. Here just try to select this new
  28593. 19:26:25self-hosted runner
  28594. 19:26:30and you will see this Linux uh operating
  28595. 19:26:32system. Just try to select that and uh
  28596. 19:26:35these are the command you have to
  28597. 19:26:36execute inside your EC2 instance. I'll
  28598. 19:26:38copy the first command and execute in
  28599. 19:26:40the terminal.
  28600. 19:26:43Then I'll copy the second command. I'll
  28601. 19:26:46execute in my terminal.
  28602. 19:26:51I'll copy the third command and let's
  28603. 19:26:53execute it here.
  28604. 19:26:56That means you are connecting your AWS
  28605. 19:26:58with your GitHub. Okay, that means
  28606. 19:27:00whatever change you will uh let's say
  28607. 19:27:02push in your GitHub automatically uh
  28608. 19:27:04this will be um uh this will be like
  28609. 19:27:07let's say available inside your AWS.
  28610. 19:27:10Uh then I'll copy the last command
  28611. 19:27:15and execute.
  28612. 19:27:21Okay, so two more command you have to
  28613. 19:27:22execute. So inside configure this
  28614. 19:27:24command.
  28615. 19:27:29Now see GitHub action is getting
  28616. 19:27:31initialized and it is it is already
  28617. 19:27:33connected with my GitHub. Now here it is
  28618. 19:27:35asking for the internal name of the
  28619. 19:27:37runner group. I don't need to give any
  28620. 19:27:39runner group name. I'll simply press
  28621. 19:27:40enter.
  28622. 19:27:42Then it is telling enter the name of the
  28623. 19:27:44runner. So here make sure you give the
  28624. 19:27:46same name self-enhosted.
  28625. 19:27:49Okay. That means in this uh YML file I
  28626. 19:27:53think you remember here you have given
  28627. 19:27:55this name okay continuous deployment you
  28628. 19:27:58have given ransom self hosted you have
  28629. 19:28:00to give the same name here self-en
  28630. 19:28:02hosted okay so make sure you are giving
  28631. 19:28:03the same name otherwise it will not work
  28632. 19:28:05now I'll press enter now it is asking uh
  28633. 19:28:08there would be any following labels uh I
  28634. 19:28:11don't need any label I will skip it
  28635. 19:28:12press enter then it is telling enter the
  28636. 19:28:14name of the work working folder I'm
  28637. 19:28:17going to again press enter okay now it's
  28638. 19:28:19Now simply you have to copy this last
  28639. 19:28:22command and you have to execute and you
  28640. 19:28:24will be able to see that uh your u AWS
  28641. 19:28:27will be connected to your GitHub.
  28642. 19:28:30See connected to the GitHub and
  28643. 19:28:32listening for the jobs. Now you can test
  28644. 19:28:34it here. So simply you can again click
  28645. 19:28:36on the runners. Now see your self-hosted
  28646. 19:28:39runner it is already idle. That means
  28647. 19:28:41your AWS is connected with your GitHub
  28648. 19:28:43and it is listening for the jobs. Now
  28649. 19:28:45right now if you push anything in your
  28650. 19:28:48uh in your let's say repository right if
  28651. 19:28:50you push any any code automatically it
  28652. 19:28:52will get deployed over the AWS um AWS
  28653. 19:28:56cloud okay how because you have written
  28654. 19:28:58this YML file and inside this YML file
  28655. 19:29:00all the commands are available for the
  28656. 19:29:02deployment operations okay but one more
  28657. 19:29:04thing I have to do which is this secret
  28658. 19:29:06credential I have to add other without
  28659. 19:29:08this secret it will it will not work
  28660. 19:29:09okay so definitely this secret needs to
  28661. 19:29:11be added so let's add the secret Now if
  28662. 19:29:15you see the last step uh last step is
  28663. 19:29:18that you have to add the secret key in
  28664. 19:29:20the GitHub actions. Okay. So let's do
  28665. 19:29:23that. I'll go to the GitHub again. Go to
  28666. 19:29:26the settings.
  28667. 19:29:28Left hand side you will see one option
  28668. 19:29:29called secret and variable and go to
  28669. 19:29:32this action section. Okay.
  28670. 19:29:35Now here you have to create a new
  28671. 19:29:37repository secret.
  28672. 19:29:39So first of all you have to
  28673. 19:29:42create this registry.
  28674. 19:29:47Registry should be docker.io because we
  28675. 19:29:51are using docker hub.
  28676. 19:29:55So make sure this is the key name and
  28677. 19:29:56this is the value name. Okay. Inside
  28678. 19:29:57secret you have to give the value and
  28679. 19:29:59add the secret.
  28680. 19:30:01Okay. Done. You can see we have added
  28681. 19:30:04this uh secret. Now I'll uh create
  28682. 19:30:07another one new repository secret and
  28683. 19:30:10I'll do it for the next one. I'll add my
  28684. 19:30:12docker username.
  28685. 19:30:18So what is what is my docker username?
  28686. 19:30:20If you go to my docker hub. So this is
  28687. 19:30:23my hub. If you just click on my account
  28688. 19:30:26here, you will be able to see the
  28689. 19:30:28username. Okay. So make sure you check
  28690. 19:30:29your username in your docker hub and
  28691. 19:30:31copy the same name and give it here.
  28692. 19:30:38Now the next thing I have to add the
  28693. 19:30:41docker password that means docker hub
  28694. 19:30:43password. So make sure you are giving
  28695. 19:30:45your docker hub password. Okay. So let
  28696. 19:30:47me give my password guys. So this is uh
  28697. 19:30:49this is like secret password. I don't
  28698. 19:30:51want to show you. So that's why I'm
  28699. 19:30:53going to pause the video after adding
  28700. 19:30:55the password. I'm going to show you the
  28701. 19:30:56next step.
  28702. 19:30:59So yeah guys I have successfully set my
  28703. 19:31:01docker password. Okay. So that's how you
  28704. 19:31:03have to add all of the secret inside
  28705. 19:31:05this secret variable. Now let's try to
  28706. 19:31:07add the next one the image name.
  28707. 19:31:14So image name I'm going to let's say
  28708. 19:31:17give the same name like aentic chatbot.
  28709. 19:31:20So with this name actually your docker
  28710. 19:31:22image would be created. Okay. You can
  28711. 19:31:23also change this name as per your
  28712. 19:31:24requirement. I I have given aentic
  28713. 19:31:26chatbot. Now let's add this secret.
  28714. 19:31:29Now next I have
  28715. 19:31:31this AWS access key ID.
  28716. 19:31:35Now why you will get this AWS access key
  28717. 19:31:37ID? I think remember we downloaded one
  28718. 19:31:40CSV file. Okay, this CSV file. Let's
  28719. 19:31:42open it up. I'll open in my Notepad++.
  28720. 19:31:45So this is the secret and secret access
  28721. 19:31:47key. So first of all, let's copy this
  28722. 19:31:49access key ID. So before this comma,
  28723. 19:31:51this is your access key ID. Okay, I'll
  28724. 19:31:53copy and paste it here. And make sure
  28725. 19:31:58you don't share this credential with
  28726. 19:31:59anyone otherwise they will be able to
  28727. 19:32:00access your account. Okay, I'm going to
  28728. 19:32:01remove after this recording. Don't use
  28729. 19:32:04my one. Okay, try to use your one. Now
  28730. 19:32:06AWS access key is done. Now let next I'm
  28731. 19:32:09going to add AWS secret access key
  28732. 19:32:16secret access key. Okay, now where you
  28733. 19:32:18get the secret address key? So this part
  28734. 19:32:20is your secret address key. Okay, that
  28735. 19:32:21means after this comma whatever you have
  28736. 19:32:24this is your secret access key. Let's
  28737. 19:32:25copy and paste it here.
  28738. 19:32:31Done. Now next you have the AWS region.
  28739. 19:32:39So right now I'm inside you will see
  28740. 19:32:40that I'm inside US East one region North
  28741. 19:32:43Virginia US East one. Okay. If you're in
  28742. 19:32:45other region you can give this name.
  28743. 19:32:47Okay. But right now I'm inside US East
  28744. 19:32:49one. I will give the same name here.
  28745. 19:32:52Why is that? Yeah. Let's copy.
  28746. 19:32:58So all the command I have given in my
  28747. 19:33:00readmi file you can check from there
  28748. 19:33:02guys.
  28749. 19:33:06Done. Now next I have to add
  28750. 19:33:09the open API key. If you're using open
  28751. 19:33:12API key guys you have to add the open
  28752. 19:33:14API key. Okay. And make sure you add
  28753. 19:33:17your value here. So I'm using Google
  28754. 19:33:20Gemini model because I don't have open
  28755. 19:33:22API key. So that's why I'm not going to
  28756. 19:33:24pass my open API key. But I just showed
  28757. 19:33:26you, okay, how to add your open API key.
  28758. 19:33:27So make sure you pass your open API key
  28759. 19:33:29here. Okay.
  28760. 19:33:32Now here I'm using Google API key. That
  28761. 19:33:35means I'm using Gemini model. I'll be
  28762. 19:33:37using my Google API key instead of
  28763. 19:33:38OpenAI. You can also remove this part if
  28764. 19:33:40you are not using OpenAI. But I have
  28765. 19:33:42showed you if you're using OpenAI, you
  28766. 19:33:44can add it. Add this. Now I'm going to
  28767. 19:33:46add the table API key.
  28768. 19:33:51Tablely and where is your table API key?
  28769. 19:33:54It is available inside your environment
  28770. 19:33:58variable. So this is your table API key.
  28771. 19:34:00Let's copy
  28772. 19:34:03and give it here.
  28773. 19:34:08Then next you have this
  28774. 19:34:11um
  28775. 19:34:14open weather API key.
  28776. 19:34:20Just copy my open open weather API key
  28777. 19:34:22from this env.
  28778. 19:34:31Okay. Now next I have to add
  28779. 19:34:38after open weather Google API key.
  28780. 19:34:47So here I have my Google Google API key.
  28781. 19:35:00Now next
  28782. 19:35:02you have this
  28783. 19:35:07lang smmith tracing
  28784. 19:35:09because we're also using lang lang
  28785. 19:35:11smmith for monitoring our entire
  28786. 19:35:12application right to trace all of the
  28787. 19:35:14execution
  28788. 19:35:16and this secret would be true.
  28789. 19:35:21You can also verify from your
  28790. 19:35:23environment. So tracing should be true.
  28791. 19:35:25Okay. And don't give any quotation.
  28792. 19:35:28Okay. Quotation you don't need to give.
  28793. 19:35:31Now next [clears throat] I have this
  28794. 19:35:36Langmith endpoint.
  28795. 19:35:44This is the end point.
  28796. 19:35:52Now next I have this
  28797. 19:35:58lang API key.
  28798. 19:36:05And here is your lang API key.
  28799. 19:36:14Done. Now next you have
  28800. 19:36:18this
  28801. 19:36:20lang project name. Okay, that's how
  28802. 19:36:23whatever API key you are using you have
  28803. 19:36:25to add inside the secret. Okay, that's
  28804. 19:36:28how you have to prepare the secret
  28805. 19:36:30variable. So what is the name? Aentic AI
  28806. 19:36:34project agentic chatbot project. This is
  28807. 19:36:37name I think I was using
  28808. 19:36:39even you can also open up your language
  28809. 19:36:41platform. You can verify
  28810. 19:36:46Yeah. So, aentic chatbot project. Okay.
  28811. 19:36:48If you want to create a new one, you can
  28812. 19:36:49also create an uh uh it's completely
  28813. 19:36:51fine. But here I'm tracing all of my
  28814. 19:36:53execution. All right. So, all of the
  28815. 19:36:55secret I have added guys. Uh let me
  28816. 19:36:57check if I'm having anything else. No, I
  28817. 19:37:01think everything is added. Okay. Now,
  28818. 19:37:02see all of the secret we have added. So,
  28819. 19:37:04right now this secret is not visible uh
  28820. 19:37:06to the public. Okay. So, this is
  28821. 19:37:09available inside my account inside my
  28822. 19:37:11secret. Okay. and my application will
  28823. 19:37:13pick up from this particular secret
  28824. 19:37:14only. That's why everywhere I have given
  28825. 19:37:17secret dot your API name or let's say
  28826. 19:37:20key name. Okay. So that's how you don't
  28827. 19:37:22need to expose your API key u I mean to
  28828. 19:37:24the audience. Just try to make sure you
  28829. 19:37:26are adding inside the secret. Okay. This
  28830. 19:37:28is super important. Now everything is
  28831. 19:37:30done. Now we are ready for the
  28832. 19:37:31deployment. So right now our server is
  28833. 19:37:33connected. My GitHub is connected. My
  28834. 19:37:37self-hosted runner runner is running.
  28835. 19:37:39Everything is done. Now simply I'm going
  28836. 19:37:41to push the changes. Okay. Now let's try
  28837. 19:37:42to push the changes. I'll commit the
  28838. 19:37:44changes. So here I'm going to open up my
  28839. 19:37:46terminal. I'm going to write g add. So
  28840. 19:37:49see these are the file I'm going to
  28841. 19:37:52push.
  28842. 19:37:56Yeah. So everything is fine. But let's
  28843. 19:37:58let's delete these are the file. This is
  28844. 19:38:00actually created uh because I have
  28845. 19:38:02executed this uh project right. And it
  28846. 19:38:03has created the persistence memory. But
  28847. 19:38:05I want to delete it. Okay. I want to
  28848. 19:38:08like push completely new new project
  28849. 19:38:10okay to the cloud. So I'll delete this
  28850. 19:38:13at the file.
  28851. 19:38:15So everything is fine. [clears throat]
  28852. 19:38:16Now let me push the changes. So I'll
  28853. 19:38:18open up my terminal. I'll just write g
  28854. 19:38:20add space dot then get commit type m
  28855. 19:38:29uh I'll give let's say updated
  28856. 19:38:33and I'll just write get push
  28857. 19:38:40origin
  28858. 19:38:42main.
  28859. 19:38:46Now push is done. Now if I go to my
  28860. 19:38:49GitHub.
  28861. 19:38:53Okay. Now see everything is updated in
  28862. 19:38:55my GitHub and your workflows is running.
  28863. 19:38:58Okay. You can go to the action and you
  28864. 19:39:00can see your first comet is running.
  28865. 19:39:02This is your first uh attempt to the
  28866. 19:39:04CI/CD deployment. Okay. And this is a
  28867. 19:39:06one-time setup guys. This uh setup you
  28868. 19:39:08have to do one time and going forward
  28869. 19:39:10you don't need to do this setup. Okay.
  28870. 19:39:12Going forward you will only just try to
  28871. 19:39:13change your upgrade and automatically it
  28872. 19:39:15will be getting deployed. Now see
  28873. 19:39:18three-step it is running continuous
  28874. 19:39:19integration building and pushing image
  28875. 19:39:21uh push docker image and deploying to
  28876. 19:39:23the AWS EC2. So continuous integration
  28877. 19:39:25is already completed. Now building and
  28878. 19:39:28pushing image is running. Okay. So right
  28879. 19:39:30now my image is getting builded. Okay.
  28880. 19:39:32You can see it is setting everything all
  28881. 19:39:33the package and everything. So this
  28882. 19:39:35process may take some time. Let's wait.
  28883. 19:39:38Now see requirement got installed
  28884. 19:39:39successfully. After that it will push
  28885. 19:39:41the image to the docker hub. Now you can
  28886. 19:39:43see in the docker hub I don't have any
  28887. 19:39:45kinds of image name with the help of
  28888. 19:39:47agentic chatbot. Okay. Now you'll see
  28889. 19:39:48that after some times this image would
  28890. 19:39:50be available.
  28891. 19:39:52Everything is happening automatically
  28892. 19:39:54guys. Okay. Because I have set up the
  28893. 19:39:55entire server. I have written that YL
  28894. 19:39:57file and all of this command is
  28895. 19:39:59available. So everything would be
  28896. 19:40:00automatically. This is the beauty of
  28897. 19:40:02CI/CD deployment.
  28898. 19:40:04Only one time effort. Okay. One time
  28899. 19:40:06configuration, one time setup and rest
  28900. 19:40:08of the life you can enjoy.
  28901. 19:40:12And that's how production deployment
  28902. 19:40:14happens. Um, whatever application you
  28903. 19:40:17can see, right? Everything is connected
  28904. 19:40:19with CI/CD pipeline and that's how
  28905. 19:40:21they're setting up the server. You can
  28906. 19:40:24also use any other cloud like GCP,
  28907. 19:40:25Azure. Uh, it's completely fine. The
  28908. 19:40:28step will remain same. Maybe some
  28909. 19:40:30functionality would be different. Okay.
  28910. 19:40:31In that cloud.
  28911. 19:40:39Now see uh build and push is complete.
  28912. 19:40:43See the green tick mark that means
  28913. 19:40:45complete. Now deploying this image to
  28914. 19:40:47the AWS EC2. Now it is pulling the image
  28915. 19:40:50and it will run on my EC2 instance.
  28916. 19:41:17Okay. See all the three steps are
  28917. 19:41:20complete. All the three steps are
  28918. 19:41:21getting green tick mark. That means
  28919. 19:41:23everything is fine. There is no error
  28920. 19:41:24inside our workflow. Okay. We have
  28921. 19:41:27successfully uh deployed. Now I will go
  28922. 19:41:30to my instance and there you will see
  28923. 19:41:32one option called public DNS. Okay. Just
  28924. 19:41:34try to copy this URL and paste over the
  28925. 19:41:38new tab. And if I execute, see uh right
  28926. 19:41:41now this uh application uh is not going
  28927. 19:41:44to open because we haven't done the port
  28928. 19:41:46mapping. Okay, port mapping is required
  28929. 19:41:48because by default our application is
  28930. 19:41:50running on port number 8501. Okay, so we
  28931. 19:41:53have to do the port mapping.
  28932. 19:41:55So to perform the port mapping, you can
  28933. 19:41:57go back to your instance and there is a
  28934. 19:41:59option called security. Just go to the
  28935. 19:42:02security.
  28936. 19:42:03There is option called security groups.
  28937. 19:42:05I'll click on security groups. And here
  28938. 19:42:07you will see one option called edit
  28939. 19:42:09inbound rules. Okay. Now here you can
  28940. 19:42:11see your uh port number is not defined
  28941. 19:42:14here. That means 850 uh 0 um 8501 is not
  28942. 19:42:18defined here. So just try to add the
  28943. 19:42:20rules and port number you have to write
  28944. 19:42:228501. Okay. This is the port of streaml.
  28945. 19:42:24You can also verify in the cicd. Mamel
  28946. 19:42:28at the last whenever you are running
  28947. 19:42:30your image, right? So there you said
  28948. 19:42:32that yeah see you are doing the port
  28949. 19:42:35mapping to 8501. This is the port. Okay.
  28950. 19:42:38By default stream application runs port
  28951. 19:42:40uh 8501. Now you have to select this 00.
  28952. 19:42:43Okay. Uh that means you can access from
  28953. 19:42:45anywhere and simply save this rules.
  28954. 19:42:48Done. Now I'll go to this instance
  28955. 19:42:50again. Instance ID. Now I'll copy this
  28956. 19:42:52public DNS again.
  28957. 19:42:55Okay. And make sure after this URL you
  28958. 19:42:57are you are giving this uh clone port
  28959. 19:43:01number 8501.
  28960. 19:43:03Okay 8501. Now if I execute I'll see
  28961. 19:43:06your application will be running and
  28962. 19:43:10this is completely live right now. Okay.
  28963. 19:43:12Now if I share this URL with anyone they
  28964. 19:43:14will be able to access my agent.
  28965. 19:43:18See this is running on the AWS server
  28966. 19:43:21right now and this is completely live.
  28967. 19:43:22Okay. Now you can purchase any kinds of
  28968. 19:43:24domain name. Okay. Uh then you can
  28969. 19:43:27change this name with your domain name.
  28970. 19:43:28On domain name this is also possible.
  28971. 19:43:30Okay. But if you know till here I think
  28972. 19:43:33it's completely fine. Uh the domain uh
  28973. 19:43:36part I think this will take care by the
  28974. 19:43:37front- end developer. So right now our
  28975. 19:43:40chatbot is running live. Okay. We can
  28976. 19:43:42test whether it's working or not. So
  28977. 19:43:44let's say I will give hello.
  28978. 19:43:48See how I can help you today. Then I
  28979. 19:43:50have given another message. I am BP. Now
  28980. 19:43:52it is telling nice to meet you bi. Now
  28981. 19:43:54it'll tell tell me the current
  28982. 19:43:59weather.
  28983. 19:44:04Okay. In Dhaka.
  28984. 19:44:11Now see it is using my get weather uh
  28985. 19:44:13tool and it is giving you the kind of
  28986. 19:44:15weather in Dhaka. Now we'll ask uh
  28987. 19:44:19uh latest
  28988. 19:44:22news
  28989. 19:44:25uh in FIFA.
  28990. 19:44:31Now see it is using tably search tool
  28991. 19:44:33and this is giving you the latest news
  28992. 19:44:35on FIFA. Okay. So this is the latest
  28993. 19:44:38news you're getting. Now you can ask any
  28994. 19:44:43other thing. Let's say you can ask about
  28995. 19:44:44the um stock price.
  28996. 19:44:48Tell me
  28997. 19:44:51tell me the stock
  28998. 19:44:55price of
  28999. 19:44:58Apple.
  29000. 19:45:02Okay, this is the current stock price of
  29001. 19:45:04Apple. Now you can also purchase any
  29002. 19:45:07stock. So you can just write purchase
  29003. 19:45:13uh let's say 20 stock
  29004. 19:45:19of Apple.
  29005. 19:45:30Okay. Now again we have added this HITL
  29006. 19:45:33features that means that means human in
  29007. 19:45:34the loop. It will ask for the human
  29008. 19:45:36verification.
  29009. 19:45:38Now see asking for the human
  29010. 19:45:39verification. Now if I approve now my
  29011. 19:45:43share would be purchased. Okay. Now you
  29012. 19:45:45can even upload any kinds of document.
  29013. 19:45:46You can start the conversation. You can
  29014. 19:45:48also create a new trades. This is also
  29015. 19:45:50possible. Let's say I have created a new
  29016. 19:45:52trades. Okay. Now here I will ask upload
  29017. 19:45:54any kinds of documents. Let's I will
  29018. 19:45:56upload my resume and I will ask tell me
  29019. 19:46:00about
  29020. 19:46:01Bir Ahmed
  29021. 19:46:04Bi based on
  29022. 19:46:08the
  29023. 19:46:09PDF
  29024. 19:46:11uploaded.
  29025. 19:46:16Now see it is using rag tool
  29026. 19:46:19and it is giving you about myself. Okay.
  29027. 19:46:22Based on the resume I'm having. Okay. So
  29028. 19:46:25that means everything is working fine
  29029. 19:46:27and this is completely live right now.
  29030. 19:46:28You can share this URL with your friends
  29031. 19:46:30and family. They'll be able to use that.
  29032. 19:46:33Okay. So amazing guys. We have seen how
  29033. 19:46:35to perform the deployment. Now the u I
  29034. 19:46:38mean good part I want to show you about
  29035. 19:46:40the CI/CD deployment is that now let's
  29036. 19:46:42see in future if you want to add any new
  29037. 19:46:44change here. Okay let's say if you want
  29038. 19:46:45to add any new features you don't need
  29039. 19:46:47to manually let's say uh set up
  29040. 19:46:50everything again in the cloud server.
  29041. 19:46:53Okay, you don't need to manually copy
  29042. 19:46:54paste your code and set up everything.
  29043. 19:46:56Only you just need to change and upload
  29044. 19:46:58inside your GitHub. Automatically this
  29045. 19:47:00deployment will be happening. Let me
  29046. 19:47:01show you. Let's say in this app.py
  29047. 19:47:04um let's say right now let me show you
  29048. 19:47:06one like a small features. Okay, I'll be
  29049. 19:47:08adding here. Let's I'll refresh my app.
  29050. 19:47:12H. So right now you can see it is
  29051. 19:47:13agentic chat but with langraph. Okay,
  29052. 19:47:15let's say I want to add a emoji here.
  29053. 19:47:17Okay, let's say I want to add a emoji.
  29054. 19:47:19So what I'm going to do, I'll go I'll go
  29055. 19:47:22to that part that I'm creating this
  29056. 19:47:24title.
  29057. 19:47:26I think here I'm creating the title
  29058. 19:47:28right here. So let's say I'm going to
  29059. 19:47:29add a emoji. So simply let's add an
  29060. 19:47:32emoji. So let's say I'm going to add
  29061. 19:47:34this uh this robotic emoji. Okay. So I'm
  29062. 19:47:36going to add this robotic emoji.
  29063. 19:47:38Refresh.
  29064. 19:47:40And uh yeah, save it. And now we have to
  29065. 19:47:43commit it again. Okay. You have to
  29066. 19:47:44commit your change again. So let's
  29067. 19:47:46commit our change again. So I'll just
  29068. 19:47:49write
  29069. 19:47:53get add space dot
  29070. 19:47:56get commit hyphen m let's say I'll give
  29071. 19:48:02new feature
  29072. 19:48:04addit
  29073. 19:48:06okay and get push
  29074. 19:48:09origin
  29075. 19:48:12main
  29076. 19:48:16now push is done now again I I'll go to
  29077. 19:48:18the GitHub and I will see that your
  29078. 19:48:20pipeline will automatically
  29079. 19:48:23uh get triggered.
  29080. 19:48:25Now see again action is running. I'll go
  29081. 19:48:27to the action. Now see new feature
  29082. 19:48:28added. This pipeline is running again.
  29083. 19:48:31Okay. And this version is having a new
  29084. 19:48:33update. Okay. Again it will build the
  29085. 19:48:34docker image. Push the docker image to
  29086. 19:48:36the docker hub. So you can see in the
  29087. 19:48:38docker hub itself you will see your
  29088. 19:48:40application
  29089. 19:48:42that is your image. See aentic chatbot.
  29090. 19:48:45So right now it is having only
  29091. 19:48:49uh one image. Okay. And it is uploading
  29092. 19:48:51the next image here. So let's wait.
  29093. 19:48:58See again all of the execution is
  29094. 19:49:00happening. And you don't need to do
  29095. 19:49:01anything. Okay. And still your server is
  29096. 19:49:03live. See if you refresh here, if you
  29097. 19:49:05start the conversation, it will run.
  29098. 19:49:07Okay. It will not uh it will not
  29099. 19:49:09actually shut down. Okay. But if you're
  29100. 19:49:11not creating CI/CD pipeline that time
  29101. 19:49:13there is a possibility it will get shut
  29102. 19:49:15down. Okay. And user will feel uh this
  29103. 19:49:18application is not working and then you
  29104. 19:49:20may lose your user. Right? So that's why
  29105. 19:49:22CST is required
  29106. 19:49:25in the back end all of the deployment is
  29107. 19:49:27happening but you are not going to uh
  29108. 19:49:29you are not going to see anything right
  29109. 19:49:31now. If I come here see deployment is uh
  29110. 19:49:33completed. Now if I come here now if I
  29111. 19:49:35refresh my application
  29112. 19:49:37now see that new update has added here.
  29113. 19:49:41Now see this uh emoji has been added
  29114. 19:49:44here. Okay. So this is called actually
  29115. 19:49:46CI/CD deployment and that's how you can
  29116. 19:49:49continuously add new features without
  29117. 19:49:51shut down your application. Okay,
  29118. 19:49:53without let's say stopping your
  29119. 19:49:54application and this is what actually we
  29120. 19:49:56use inside the industry inside the
  29121. 19:49:59production deployment. Okay, I hope
  29122. 19:50:01everything is clear guys. So if you
  29123. 19:50:03found this content useful, please try to
  29124. 19:50:04subscribe to my channel and share this
  29125. 19:50:06video with your friends friends and
  29126. 19:50:07family and please try to like on my
  29127. 19:50:10video guys. Okay. And if you have any
  29128. 19:50:12question, please try to comment in the
  29129. 19:50:14comment section. Uh I would like to see
  29130. 19:50:15your comment and I would like to see
  29131. 19:50:17your opinion. Okay. Whether um this
  29132. 19:50:20playlist is helpful or not because I
  29133. 19:50:22have covered each and everything. I have
  29134. 19:50:23implemented the project. I showed you
  29135. 19:50:25the end to end implement uh end to end
  29136. 19:50:27deployment. Everything I showed you.
  29137. 19:50:28Okay. And lots of things are coming as
  29138. 19:50:30well. So guys, yeah, we have seen the
  29139. 19:50:32deployment. Now we will see that how we
  29140. 19:50:35can uh terminate all of the server
  29141. 19:50:37because if you keep on running it, it
  29142. 19:50:38will charge you. So let's say once uh we
  29143. 19:50:40have deployed everything, our learning
  29144. 19:50:42is over. Now I'm going to show you how
  29145. 19:50:45we can stop the server. Okay, let's say
  29146. 19:50:47you want to stop the server, how to do
  29147. 19:50:49that. So for this, okay, one more thing
  29148. 19:50:50I want to show you that say if I close
  29149. 19:50:52this terminal, okay, if I close this
  29150. 19:50:53terminal also, still my application will
  29151. 19:50:55be working.
  29152. 19:50:57Okay, see still my application is
  29153. 19:50:58working. Okay. So now if you want to uh
  29154. 19:51:02let's let's say delete this instance
  29155. 19:51:04first of all you have to select it. Then
  29156. 19:51:06there is a option called instance state
  29157. 19:51:09and there you will see called terminate
  29158. 19:51:10and delete instance. Okay. So if you do
  29159. 19:51:12terminate and delete it will delete uh
  29160. 19:51:14everything. Okay. But if you stop it it
  29161. 19:51:16will stop again. You can restart it but
  29162. 19:51:18I'm going to delete everything because
  29163. 19:51:19my learning is over. Uh I'm going to
  29164. 19:51:21terminate and delete. Now after some
  29165. 19:51:24time it will be uh deleted. Okay. Now
  29166. 19:51:26you have to delete your IM user as well.
  29167. 19:51:30So let's go to the IM user. Left hand
  29168. 19:51:32side IM user is available. Select the IM
  29169. 19:51:35user and delete it from here. Deactive
  29170. 19:51:37the keys and just write confirm.
  29171. 19:51:41So it will be deleted.
  29172. 19:51:46Okay. If you want you can also delete
  29173. 19:51:48your uh docker image you have uploaded
  29174. 19:51:50in your hub. Okay. This is also
  29175. 19:51:52possible. You can also delete here. But
  29176. 19:51:53I'll keep this uh uh image. Okay. in my
  29177. 19:51:56docker repository so that later on I can
  29178. 19:51:59use it anytime. Okay. So yes guys that's
  29179. 19:52:01how we can do the CI/CD deployment and
  29180. 19:52:03we have completed our deployment. Okay.
  29181. 19:52:05So right now you can see our application
  29182. 19:52:07will not run because I have deleted all
  29183. 19:52:09the instance and this is offline right
  29184. 19:52:11now.
  29185. 19:52:15So see this is offline right now. Okay.
  29186. 19:52:17So yeah you can try I will share all the
  29187. 19:52:19resources all the code in my
  29188. 19:52:20description. From there you can try and
  29189. 19:52:22please try to support my channel guys.
  29190. 19:52:24If you support me definitely I will
  29191. 19:52:25bring this kinds of content more in
  29192. 19:52:27future. So yes uh this is all about for
  29193. 19:52:30this uh deployment I have showed you on
  29194. 19:52:32the uh AWS cloud. Now in the next video
  29195. 19:52:34I'm going to show you how we can deploy
  29196. 19:52:36this project over the render cloud.
  29197. 19:52:37Okay, render is another cloud there you
  29198. 19:52:40can also uh deploy this project as a
  29199. 19:52:42CI/CD. So what is render? Render is a
  29200. 19:52:44cloud platform. So there you can deploy
  29201. 19:52:46any kinds of web application. Okay. uh
  29202. 19:52:49this is the like a very fastest uh and
  29203. 19:52:53uh very easy to use cloud platform. So
  29204. 19:52:55here you don't need to do so many
  29205. 19:52:57configuration. Okay. Uh with some few
  29206. 19:52:59clicks actually you can do the
  29207. 19:53:00deployment. I'm going to show you okay
  29208. 19:53:02how to do that and um definitely for
  29209. 19:53:04this you have to create one account on
  29210. 19:53:06render and render is not completely free
  29211. 19:53:08but they have a free instance. In that
  29212. 19:53:10free instance you can at least deploy
  29213. 19:53:12some application. Okay. But if you want
  29214. 19:53:14to do the production grade deployment
  29215. 19:53:16okay with some uh higher infrastructure
  29216. 19:53:19and higher instance that time you have
  29217. 19:53:21to take the subscription. Okay. But I
  29218. 19:53:23think uh uh this is fine um as a
  29219. 19:53:25learning purpose and uh just to uh just
  29220. 19:53:28to actually live our app okay just to
  29221. 19:53:31test our app we'll be using the free
  29222. 19:53:32instance. So free instance is having
  29223. 19:53:34like very low configuration like machine
  29224. 19:53:37and I think this is completely fine for
  29225. 19:53:39us so we can manage that. Okay. So if
  29226. 19:53:42you found my content useful guys please
  29227. 19:53:44do uh try to subscribe to my channel and
  29228. 19:53:46please try to share and please try to
  29229. 19:53:48hit the like. uh I need your support if
  29230. 19:53:50you provide the support guys so I can
  29231. 19:53:52bring this kinds of content more in
  29232. 19:53:54future. So uh well let's start with the
  29233. 19:53:56deployment guys. First of all here you
  29234. 19:53:58have to create an account. If you don't
  29235. 19:53:59have account guys please try to create
  29236. 19:54:01an account with your Google um uh Google
  29237. 19:54:03address. You can create your account. So
  29238. 19:54:05I already have the account. I'll just
  29239. 19:54:06try to sign in.
  29240. 19:54:10So here I'll just try to sign in with my
  29241. 19:54:12Google.
  29242. 19:54:15So after sign in guys you will be able
  29243. 19:54:17to see this kinds of interface. So this
  29244. 19:54:19is the rendered dashboard and previously
  29245. 19:54:21I deployed some app that's why it's
  29246. 19:54:23coming okay like that but for you it
  29247. 19:54:25would be completely empty. So here uh
  29248. 19:54:27what I have to do guys uh first of all I
  29249. 19:54:30have to uh I have to actually commit my
  29250. 19:54:33code to the GitHub. Okay. And uh in my
  29251. 19:54:35previous deployment video I already
  29252. 19:54:37pushed this code in my GitHub. So this
  29253. 19:54:39is already available in my GitHub repo.
  29254. 19:54:41As you can see this is the repository we
  29255. 19:54:42created aentic chatbot using langraph.
  29256. 19:54:45So we can utilize that and one best part
  29257. 19:54:47is that if you're using render so render
  29258. 19:54:50uh it is already having the CI/CD
  29259. 19:54:52integrated you don't need to set up the
  29260. 19:54:54CI/CD separately okay like we did in on
  29261. 19:54:57AWS right here CI/CD uh it is included
  29262. 19:55:00okay only you just need to connect your
  29263. 19:55:03repository and automatically this CI/CD
  29264. 19:55:07uh pipeline would be created you don't
  29265. 19:55:08need to manually create that that part
  29266. 19:55:10I'm going to show you so first of all um
  29267. 19:55:12here just try to copy this URL Okay,
  29268. 19:55:15copy your GitHub URL and in on render
  29269. 19:55:18you will see one option called new.
  29270. 19:55:20Okay, just click on new and here is a
  29271. 19:55:22service called web service. Okay, just
  29272. 19:55:23click on web service
  29273. 19:55:26and uh here you can see G provider is
  29274. 19:55:28available. Okay, just try to paste your
  29275. 19:55:30URL. Okay, or you can go to this public
  29276. 19:55:34uh g repository and you can provide the
  29277. 19:55:36URL. Okay, and if you want you can also
  29278. 19:55:38pass your existing let's say docker
  29279. 19:55:40image. So I think you remember uh in my
  29280. 19:55:42last video I like pushed my uh docker
  29281. 19:55:45image in my docker hub. So you can also
  29282. 19:55:47provide that image URL that uh and with
  29283. 19:55:50the help of that you can also perform
  29284. 19:55:51the deployment. You can also use your
  29285. 19:55:53GitHub to do the deployment. Okay. But
  29286. 19:55:55make sure you have this docker file
  29287. 19:55:56here. So I already have the docker file
  29288. 19:55:58and pre uh in my last video I already
  29289. 19:56:00created this docker file. So docker file
  29290. 19:56:02should be available. Okay. So we have
  29291. 19:56:04the docker file. It's completely fine.
  29292. 19:56:05Now simply what I'm going to do I'm
  29293. 19:56:08going to just paste this URL here and
  29294. 19:56:10I'll just connect this repository. Okay,
  29295. 19:56:13once you have connected, you can provide
  29296. 19:56:15the name the name you want to provide uh
  29297. 19:56:17for this deployment. But I will keep the
  29298. 19:56:19same name and the language you have to
  29299. 19:56:21select the docker. Okay, if you don't
  29300. 19:56:23have the docker, you can also select the
  29301. 19:56:24simple python. But I have the docker.
  29302. 19:56:26I'll try to select the docker. Okay,
  29303. 19:56:28language. Then everything will remain
  29304. 19:56:30same as it is. No need to change
  29305. 19:56:31anything. And here in the instance type,
  29306. 19:56:33see they have some plan. You can take
  29307. 19:56:36the plan as per your requirement. If you
  29308. 19:56:38have let's say very high configuration
  29309. 19:56:41project that needs lots of computation
  29310. 19:56:42that time you can take these are the
  29311. 19:56:44like uh plan but uh we'll be using this
  29312. 19:56:47u free plan for the hobby project. Okay
  29313. 19:56:50just to show you I'm using this free
  29314. 19:56:52plan and it is having 512 MB RAM and uh
  29315. 19:56:560.1 CPU core. Okay, it is uh it would be
  29316. 19:56:59a little bit slow lagging but uh just to
  29317. 19:57:01I mean make our project live it's
  29318. 19:57:03completely fine because nowadays none of
  29319. 19:57:05the cloud provides the free uh free
  29320. 19:57:07let's say instance right to uh do the
  29321. 19:57:10deployment but at least they're
  29322. 19:57:11providing I think this is fine for us
  29323. 19:57:12right so I'll select this free instance
  29324. 19:57:14then here you have to set all of your
  29325. 19:57:16environment variable uh you have inside
  29326. 19:57:18your project so I think remember inside
  29327. 19:57:20our project these are the environment
  29328. 19:57:21variable is required so try to set one
  29329. 19:57:23by one so uh I'm not using openi so I
  29330. 19:57:27will not set the open I'll select set
  29331. 19:57:30from tably
  29332. 19:57:31so tably API key here you have to give
  29333. 19:57:33the value
  29334. 19:57:40okay then the next one you have
  29335. 19:57:44this open weather API key
  29336. 19:57:52that's how I'll try to add all of the
  29337. 19:57:54environment variable I have here you can
  29338. 19:57:55also upload your NV file that will also
  29339. 19:57:58load but let's try to add like that
  29340. 19:58:02Google API key because I'm using Gemini
  29341. 19:58:05model.
  29342. 19:58:14Now next I have this languid tracing
  29343. 19:58:28Smith endpoint
  29344. 19:58:40then uh Langmith API
  29345. 19:58:53then we have Langmith project.
  29346. 19:59:03So yeah, all of the API key has set
  29347. 19:59:05successfully. Now uh in adv advanc part,
  29348. 19:59:09you don't need to do anything. uh just
  29349. 19:59:10keep it same as it is. Now let's try to
  29350. 19:59:13deploy our web service.
  29351. 19:59:18Okay. Now it will start building your
  29352. 19:59:20docker. Okay. Uh all of the setup
  29353. 19:59:23everything will uh uh going on here.
  29354. 19:59:29So we have to wait for some times. Okay.
  29355. 19:59:31So this will set up and prepare
  29356. 19:59:33everything and once this starter should
  29357. 19:59:35be live, you'll be able to access your
  29358. 19:59:36application.
  29359. 19:59:39Now let's wait guys. So what I'm going
  29360. 19:59:41to do, I'm going to pause the video once
  29361. 19:59:43this u um docker building is complete
  29362. 19:59:46then I will come back.
  29363. 19:59:59So as you can see guys our application
  29364. 20:00:01is live right now and all of the um
  29365. 20:00:04setup has complete successfully. Now we
  29366. 20:00:06can access this application. So this is
  29367. 20:00:08the URL. Just try to copy this URL and
  29368. 20:00:11open in a new tab. So you'll be able to
  29369. 20:00:13see that your application will open.
  29370. 20:00:22Yeah. So it has loaded my application.
  29371. 20:00:25So this is our agentic chatbot. Now
  29372. 20:00:28let's test this chatbot. Uh let me zoom
  29373. 20:00:31out so that you can see the entire
  29374. 20:00:32screen. Yeah. So now let's uh test this
  29375. 20:00:35chatbot. So here I will give hi.
  29376. 20:00:41So see it's giving you hello I can
  29377. 20:00:43assist you. Now I'll tell um what is the
  29378. 20:00:50current weather
  29379. 20:00:55in
  29380. 20:00:57Bengaluru.
  29381. 20:01:04So this is the current weather in
  29382. 20:01:06Bengaluru. Now I will ask
  29383. 20:01:09tell me
  29384. 20:01:12the latest
  29385. 20:01:17score of
  29386. 20:01:20FIFA. Okay. Today.
  29387. 20:01:30Yeah. So this is the score it has given.
  29388. 20:01:33Now you can um you can check about this
  29389. 20:01:37um stock price. What is the
  29390. 20:01:42stock
  29391. 20:01:45price of Google?
  29392. 20:01:58Okay. So the API I was using uh so the
  29393. 20:02:01rate rate limit has been uh over. Okay.
  29394. 20:02:04So I have to create another API key.
  29395. 20:02:06It's completely fine. Now let me test uh
  29396. 20:02:08with my documents upload. So I'll just
  29397. 20:02:11try to
  29398. 20:02:13provide my resume and ask who is
  29399. 20:02:18Btier Ahmed
  29400. 20:02:21Bi
  29401. 20:02:24based on the
  29402. 20:02:26PDF uploaded.
  29403. 20:02:36Now it is giving you the entire uh
  29404. 20:02:38answer about me, right? So yeah uh it's
  29405. 20:02:41working perfectly. So only the issue we
  29406. 20:02:42found uh our uh API key we're using
  29407. 20:02:45right for this stock price uh this has
  29408. 20:02:47been I think limit is over. So I have to
  29409. 20:02:49create an uh another API key and I have
  29410. 20:02:51to set there uh because we are using the
  29411. 20:02:53free one right and free one definitely
  29412. 20:02:55has some limitation that's completely
  29413. 20:02:57fine. Yeah. So it's working fine. Then
  29414. 20:02:58you can also create a new trades. Okay.
  29415. 20:03:01You can create a new trades and you can
  29416. 20:03:03uh again do the conversation. Let's say
  29417. 20:03:04hi I am Alex. Okay. See everything is
  29418. 20:03:08working fine. Okay. Now this application
  29419. 20:03:10is completely live. You can share this
  29420. 20:03:12with your friends and family. They will
  29421. 20:03:14be able to access your application and
  29422. 20:03:17uh this will not uh charge you. Okay.
  29423. 20:03:19Because this is running completely on
  29424. 20:03:21the free instance and uh that's how you
  29425. 20:03:23can deploy any kinds of project. Okay.
  29426. 20:03:25Uh just for the uh testing purpose.
  29427. 20:03:28Okay. But if you want to do the
  29428. 20:03:29production grade deployment that time
  29429. 20:03:30just try to make sure you are taking the
  29430. 20:03:32subscription plan. Now guys uh one best
  29431. 20:03:35part uh I will show you uh which is this
  29432. 20:03:37uh CI/CD. Okay. Uh that means if you are
  29433. 20:03:40changing something inside your code and
  29434. 20:03:42if you are again committing to the
  29435. 20:03:44GitHub, so what will happen? So let's
  29436. 20:03:46say right now uh here I have an emoji.
  29437. 20:03:49Okay. So I want to remove this emoji. Uh
  29438. 20:03:51as of now let's try to consider this is
  29439. 20:03:53our features. Okay. We are adding inside
  29440. 20:03:54this chatbot. Uh where
  29441. 20:03:58is that part? Yeah. So here so let's say
  29442. 20:04:00I will delete this uh emoji. Okay. And I
  29443. 20:04:03will uh again push my changes to the
  29444. 20:04:06GitHub. So let's say app file updated.
  29445. 20:04:13Now I'll push the changes.
  29446. 20:04:17Done. Now if I go to my GitHub,
  29447. 20:04:22see this comet is over. Okay. Um have
  29448. 20:04:25file added. Uh now here if I come to
  29449. 20:04:28this uh uh I mean render and if I go to
  29450. 20:04:32this event. So you have to go to this
  29451. 20:04:34event and there is a option called
  29452. 20:04:36manual deploy. Just try to click here.
  29453. 20:04:39Okay. And there is a option called
  29454. 20:04:40deploy last commit. Okay. So you can
  29455. 20:04:43also like make it as automated. There is
  29456. 20:04:45a setting you can turn on that. Uh but
  29457. 20:04:48if you just click here deploy latest
  29458. 20:04:50commit. Now if I let's say deploy latest
  29459. 20:04:52commit.
  29460. 20:04:57So you'll see that uh automatically um
  29461. 20:05:00my new features should be added.
  29462. 20:05:04See still my application is running.
  29463. 20:05:12See still my application is running and
  29464. 20:05:14my deployment is going on. Okay. So
  29465. 20:05:17that's how they have integrated this
  29466. 20:05:18inbuilt CI/CD uh and all of this. Okay.
  29467. 20:05:21Whatever we have learned in my previous
  29468. 20:05:23deployment. So here uh you don't need uh
  29469. 20:05:25that much of configuration only few
  29470. 20:05:27clicks you can do the deployment. Okay.
  29471. 20:05:29So this is the best part uh on this
  29472. 20:05:31render cloud. Uh let's see.
  29473. 20:05:41So see our application is live. Now if I
  29474. 20:05:43go to my application refresh.
  29475. 20:05:51So see this emoji got removed. Okay. So
  29476. 20:05:54that's how uh we can add uh our new
  29477. 20:05:56features. uh and you just need to commit
  29478. 20:05:58the code on GitHub and you can uh just
  29479. 20:06:00uh trigger that pipeline. Okay. And you
  29480. 20:06:02can also make it automated. There is a
  29481. 20:06:04settings you can run on. So yes guys uh
  29482. 20:06:06that's how we can do the deployment. Now
  29483. 20:06:07I'll show you how we can delete the
  29484. 20:06:09instance. Okay. Let's say this project I
  29485. 20:06:11have deployed. Now how we can delete
  29486. 20:06:12this instance. Okay. So for this you
  29487. 20:06:14just need to go to the settings
  29488. 20:06:17and go below there is a option called
  29489. 20:06:20delete web service and you have to copy
  29490. 20:06:22this command
  29491. 20:06:26and give it here and delete the web
  29492. 20:06:28service. Okay. So if you delete it so
  29493. 20:06:30this service would be deleted and your
  29494. 20:06:31application would be offline. Okay. So
  29495. 20:06:34yeah that's how we can do that. So if
  29496. 20:06:35you found my content useful guys please
  29497. 20:06:37try to support me and this is my
  29498. 20:06:40LinkedIn profile. Uh if you want to
  29499. 20:06:41connect me guys, you can connect on my
  29500. 20:06:43LinkedIn. You can follow me on LinkedIn
  29501. 20:06:45and uh please let me know how you are
  29502. 20:06:47enjoying this uh complete list. If you
  29503. 20:06:49found this useful, so please try to tag
  29504. 20:06:51me on LinkedIn. Okay, I'll happy to see
  29505. 20:06:53that and just try to implement uh
  29506. 20:06:55something from your end and please try
  29507. 20:06:56to tag me. So if you are tagging me on
  29508. 20:06:58LinkedIn, I would be happy to see your
  29509. 20:07:00work and definitely I will put my uh
  29510. 20:07:02feedback and comments. Okay. So guys, as
  29511. 20:07:04you know, I started a complete agenti
  29512. 20:07:07playlist on my YouTube channel and uh I
  29513. 20:07:11completed our first orchestration
  29514. 20:07:12framework which is langraph. So we have
  29515. 20:07:15studied uh about this langraph in depth.
  29516. 20:07:18We have seen each and every component of
  29517. 20:07:20langraph. Even I showed you one amazing
  29518. 20:07:23uh end toend project implementation
  29519. 20:07:25which is one agentic chatbot. If you
  29520. 20:07:28haven't uh checked those uh videos guys,
  29521. 20:07:30this is already available in my playlist
  29522. 20:07:33guys. It is already available on my
  29523. 20:07:34YouTube channel uh DS with BP. So all
  29524. 20:07:37the recordings are available uh you can
  29525. 20:07:40go through all of these recording. Okay.
  29526. 20:07:42Uh then I told you uh after completing
  29527. 20:07:45like our uh first orchestration
  29528. 20:07:47framework we'll be implementing some
  29529. 20:07:49amazing project. Okay. And one project
  29530. 20:07:51we have already developed in this uh
  29531. 20:07:53playlist itself. Okay. So as you can see
  29532. 20:07:55uh our first project was around uh uh 8
  29533. 20:07:59plus hours of recording. uh we have uh
  29534. 20:08:02implemented the entire agentic chartbot
  29535. 20:08:04with the help of lang graph database
  29536. 20:08:06languid tools rag hittl AWS and render.
  29537. 20:08:10So guys uh in this video what I'm going
  29538. 20:08:12to do uh I'm going to utilize the same
  29539. 20:08:15concept we have learned so far inside
  29540. 20:08:17our agenti playlist and we'll be
  29541. 20:08:20implementing one very interesting and
  29542. 20:08:22amazing project in this video. Okay. And
  29543. 20:08:25in this video, we are not only going to
  29544. 20:08:27develop this project. Uh we'll also show
  29545. 20:08:29you how we can uh deploy this project
  29546. 20:08:32over the cloud platform as a CI/CD.
  29547. 20:08:34Okay. That means first of all, we'll try
  29548. 20:08:36to implement the entire project uh
  29549. 20:08:38completely end to end. Then after
  29550. 20:08:40implementing, I will also show you how
  29551. 20:08:42we can deploy this project and we'll be
  29552. 20:08:44using CI/CD pipeline for that. So the
  29553. 20:08:46project name is BPGpt.
  29554. 20:08:49So [gasps] this sounds uh seems to be
  29555. 20:08:51funny but uh yes actually I'm going to
  29556. 20:08:53implement uh one uh project here called
  29557. 20:08:57buppy GPT and this would be kinds of
  29558. 20:09:00your chart GPT. So basically we'll try
  29559. 20:09:02to recreate this chat GPT okay uh with
  29560. 20:09:05our own workflow. So I think you have
  29561. 20:09:08already used chat GPT right uh chat GPT
  29562. 20:09:11uh it's an agentic AI chatbot. So here
  29563. 20:09:14you can perform the chat operation you
  29564. 20:09:16can upload your documents. Okay. Then
  29565. 20:09:18you can also activate the voice mode.
  29566. 20:09:21Then um you can see the conversation
  29567. 20:09:24trades. Okay. Then it has also connected
  29568. 20:09:26with different different tools like you
  29569. 20:09:28can perform realtime source operation.
  29570. 20:09:30You can uh solve complex math problem.
  29571. 20:09:33You can generate the codes. Okay. Each
  29572. 20:09:35and everything you can do here. So yes
  29573. 20:09:37uh in this video guys we'll be
  29574. 20:09:39developing our own chat GPT. So I
  29575. 20:09:42already named it as BPGT. So let me uh
  29576. 20:09:45show you first of all the application
  29577. 20:09:46demo how this application uh will work
  29578. 20:09:49and how this application uh will look
  29579. 20:09:51like. Then after that we'll start the
  29580. 20:09:53development guys. So as you can see guys
  29581. 20:09:55uh this is the application we'll be
  29582. 20:09:57developing named buppy GPT. You can give
  29583. 20:09:59any name okay as per your needs. I have
  29584. 20:10:02given buppy GPT and I think first time
  29585. 20:10:05someone is creating uh chat GPT with the
  29586. 20:10:08Gemini model.
  29587. 20:10:10[laughter] Why I I have used Gemini
  29588. 20:10:12model because uh I wanted to use free
  29589. 20:10:15resources. Um I I didn't wanted to use
  29590. 20:10:18the paid one. Uh I could have used the
  29591. 20:10:20open AI model here. But for openi model
  29592. 20:10:23you need open subscription but uh there
  29593. 20:10:26are many learners they don't have the
  29594. 20:10:27open key that's why I thought let's try
  29595. 20:10:29to integrate any free model. Okay, open
  29596. 20:10:32source model and uh Gemini actually you
  29597. 20:10:34can use freely. Okay, there are some
  29598. 20:10:36free limits you can utilize that. But if
  29599. 20:10:39you want you can also integrate any
  29600. 20:10:40other model. You can also integrate
  29601. 20:10:41OpenAI model. It's completely up to you.
  29602. 20:10:43Okay. But the main things here we have
  29603. 20:10:45to learn this uh concept like um the way
  29604. 20:10:48they have created the chart GPT. Okay.
  29605. 20:10:50You can see all the functionality like
  29606. 20:10:52tradings the documents uploaded this
  29607. 20:10:55model selection. Okay. Then uh you can
  29608. 20:10:57also uh open this V voice mode. You can
  29609. 20:11:00uh uh give your voice and automatically
  29610. 20:11:02your voice would be recognized and you
  29611. 20:11:04can perform the chat operation here.
  29612. 20:11:06Okay. And it has also connected with
  29613. 20:11:08different different tools. But here I
  29614. 20:11:09tried to integrate u actually few tools
  29615. 20:11:12here um uh because um here I want to uh
  29616. 20:11:16show you okay uh this uh project
  29617. 20:11:18implementation. So you can add as much
  29618. 20:11:21as tool you can okay you can add all
  29619. 20:11:23kinds of tool. I already um told you
  29620. 20:11:25about the tool in my playlist. I think
  29621. 20:11:27you remember right if you go through the
  29622. 20:11:28playlist I already discussed about the
  29623. 20:11:30tool. So you can uh integrate as much as
  29624. 20:11:32tool you can okay whatever tool you need
  29625. 20:11:34but I added few tools here just to show
  29626. 20:11:36you the working demo. Now first of all
  29627. 20:11:39uh let me show you the working demo how
  29628. 20:11:40this will work and one thing guys I
  29629. 20:11:42think you have seen uh in charge GPT you
  29630. 20:11:44can also create the account you can
  29631. 20:11:45login with different account okay this
  29632. 20:11:47is a full fully stack application but
  29633. 20:11:49here we avoided this part we didn't
  29634. 20:11:52added any kinds of account fun u I mean
  29635. 20:11:54login functionality here we just uh
  29636. 20:11:56created the interface okay of the charge
  29637. 20:11:58apt I think this is fine uh for learning
  29638. 20:12:00purpose this is completely fine if you
  29639. 20:12:02want you can also uh use full stack uh
  29640. 20:12:04let's say framework you can also create
  29641. 20:12:06uh this kinds of account functionality
  29642. 20:12:08and all. Okay, this is completely up to
  29643. 20:12:09you. So yes guys this is the interface
  29644. 20:12:11as you can see it has the trading
  29645. 20:12:13features that means you can switch
  29646. 20:12:14between any of the trades and and you
  29647. 20:12:16can see the older conversation you have
  29648. 20:12:17done even you can also create a new
  29649. 20:12:19conversation you can upload any kinds of
  29650. 20:12:21documents you can select your model okay
  29651. 20:12:24then you can also activate the voice
  29652. 20:12:25mode uh if you want to speak with your
  29653. 20:12:29chat u GPT okay and here I have also
  29654. 20:12:32given some suggestion you can also see
  29655. 20:12:34that okay I think you can't see uh the
  29656. 20:12:37interface because of my video so what I
  29657. 20:12:39can do I and turn off my video. Now I
  29658. 20:12:41think you can see the full uh
  29659. 20:12:43application. So here is the voice mode
  29660. 20:12:44and everything, right? So guys, now
  29661. 20:12:46let's uh test our BPGPT. Okay. Uh I'll
  29662. 20:12:50provide some prompt. Let's say first of
  29663. 20:12:51all I'll tell hi
  29664. 20:12:57um I am
  29665. 20:13:00BP here.
  29666. 20:13:04So as you can see it is giving hello BY.
  29667. 20:13:06It's nice to meet you. How I can assist
  29668. 20:13:07you today? So tell tell me about
  29669. 20:13:13gradient
  29670. 20:13:15descent
  29671. 20:13:16in simpler
  29672. 20:13:21word.
  29673. 20:13:33Now it is telling you about gradient
  29674. 20:13:35descent. Now I will ask something um
  29675. 20:13:38something about latest information.
  29676. 20:13:43So I will give this prompt. What was the
  29677. 20:13:45score today for Argentina in FIFA World
  29678. 20:13:47Cup? So let's see. Now you can see it is
  29679. 20:13:50using realtime web search tool and it
  29680. 20:13:54will find out the latest information.
  29681. 20:14:00So you can see based on the website
  29682. 20:14:01result Argentina defeated uh Austria two
  29683. 20:14:06by zero in FIFA World Cup match today.
  29684. 20:14:08Leonel Messi scored both goal making him
  29685. 20:14:12uh the alltime legend leading scorer in
  29686. 20:14:16World Cup history. Okay, I think if you
  29687. 20:14:18have already watched the la last match
  29688. 20:14:20of Argentina, you'll see that uh um this
  29689. 20:14:23was happened. Okay, last match. Last
  29690. 20:14:24match. So yeah, it's working uh fine.
  29691. 20:14:27You can also switch uh any other model
  29692. 20:14:28if you want. Okay. Let's say I will take
  29693. 20:14:30this um pro model. Okay. Now I ask
  29694. 20:14:34something. Let's say
  29695. 20:14:36uh I want to do some calculation. Let's
  29696. 20:14:39say what is the
  29697. 20:14:42result of
  29698. 20:14:46so I'll give a complex mathematics here.
  29699. 20:14:59Now you can see it is using calculated
  29700. 20:15:00tool and it will solve that.
  29701. 20:15:04Now you can see this is the result.
  29702. 20:15:06Okay. Now here what I can do I can
  29703. 20:15:08upload any kinds of documents. So let's
  29704. 20:15:10say here I will upload uh any kinds of
  29705. 20:15:12documents. Let's say I upload my resume
  29706. 20:15:16and I can do the conversation here. Now
  29707. 20:15:19see it's getting uploaded. Now you can
  29708. 20:15:20see you can ask the question about the
  29709. 20:15:22document and I'll tell
  29710. 20:15:25uh who is
  29711. 20:15:31Bier
  29712. 20:15:36Ahmed Baki
  29713. 20:15:38based on PDF.
  29714. 20:15:41Now you can see it is using document
  29715. 20:15:43search tool and uh this will use my
  29716. 20:15:46document to give the response. So this
  29717. 20:15:48is the rag features you have in this
  29718. 20:15:51kinds of agenti chatbot. Now you can see
  29719. 20:15:53based on the provided PDF Ber Ahmed B is
  29720. 20:15:57a data scientist with five years of
  29721. 20:15:59working experience specializing
  29722. 20:16:00generative AI. Okay. And it he is um and
  29723. 20:16:05you can see it is telling each and
  29724. 20:16:06everything about me. Okay. Now you can
  29725. 20:16:08also continue the conversation. Uh
  29726. 20:16:12how
  29727. 20:16:13many
  29728. 20:16:15projects he
  29729. 20:16:17has done?
  29730. 20:16:20Give me
  29731. 20:16:25all the name.
  29732. 20:16:33Okay. Okay, you can see based on the
  29733. 20:16:34documents uh BP uh has worked with uh uh
  29734. 20:16:39worked on four main project as you can
  29735. 20:16:41see these are the project actually I
  29736. 20:16:43have mentioned in that resume okay
  29737. 20:16:46amazing it's working great now you can
  29738. 20:16:48uh see it has also voice mode I can also
  29739. 20:16:50activate the voice mode and I can um ask
  29740. 20:16:53something let's say
  29741. 20:16:57tell me about Python programming and
  29742. 20:16:59give me the hello world program.
  29743. 20:17:03See tell me about Python programming and
  29744. 20:17:05give me the hello world program. Now if
  29745. 20:17:06I send this prompt
  29746. 20:17:17see it's giving you the entire response
  29747. 20:17:20okay with the hello world program as
  29748. 20:17:22well. Okay. So yes uh that's how guys uh
  29749. 20:17:25chart GPT works. Uh even in charge GPT
  29750. 20:17:28also you can give this kinds of prompt
  29751. 20:17:29and it will be working. But yes u charg
  29752. 20:17:33is like a very u very actually advanced
  29753. 20:17:36uh agentic application because u inside
  29754. 20:17:39that they have added so many
  29755. 20:17:41functionality okay deep resource and all
  29756. 20:17:43but again yeah we have just tried to
  29757. 20:17:46create recreated that um application
  29758. 20:17:48here okay by focusing on some major
  29759. 20:17:51component okay whatever we have learned
  29760. 20:17:54so far I think this is very much
  29761. 20:17:55interesting okay if you want you can
  29762. 20:17:57also upgrade uh this project as per your
  29763. 20:18:00requirement
  29764. 20:18:01And you can add uh new new features like
  29765. 20:18:03chart GP okay if you want and uh going
  29766. 20:18:06forward I'm also going to create some
  29767. 20:18:08other project as well uh so that you
  29768. 20:18:10will be learning some more concept okay
  29769. 20:18:12so yes guys this is the entire demo of
  29770. 20:18:14the application we have seen and
  29771. 20:18:16throughout the entire implementation
  29772. 20:18:17guys we'll try to uh recreate uh this uh
  29773. 20:18:21application okay I think this would be
  29774. 20:18:23fun so make sure you watch this video
  29775. 20:18:24till the end and uh if you found my
  29776. 20:18:27content useful please try to subscribe
  29777. 20:18:28to my channel and uh share this video
  29778. 20:18:30with your friends and family. Now I'm
  29779. 20:18:32also going to show you the memory
  29780. 20:18:34features. Uh I also educated the memory
  29781. 20:18:36here. That means it can remember my
  29782. 20:18:39previous conversation. So I think you
  29783. 20:18:40remember uh at the very first I told uh
  29784. 20:18:43yes uh my name is BP. Okay. Like hi I'm
  29785. 20:18:46Buppy here. So let's see whether it is
  29786. 20:18:48able to remember my name or not. So what
  29787. 20:18:51is my name?
  29788. 20:19:01So as you can see you introduced
  29789. 20:19:02yourself as a buppy earlier is it
  29790. 20:19:04correct? Yes.
  29791. 20:19:10Okay. Now uh I will remember that uh
  29792. 20:19:13it's nice to chat with you. That means
  29793. 20:19:15it has also long-term memory
  29794. 20:19:17integration. If you uh want your chatbot
  29795. 20:19:19to remember something, it will remember.
  29796. 20:19:21Okay. This will save that information in
  29797. 20:19:23the long-term u memory. Okay. uh this
  29798. 20:19:26thing will also try to add with a
  29799. 20:19:27database. So yes guys uh that's how uh
  29800. 20:19:30you can implement this uh this amazing u
  29801. 20:19:34agenti chatbot uh named bgptt or you can
  29802. 20:19:37give any kinds of name if you want like
  29803. 20:19:39chat gpt and if you go to the homepage
  29804. 20:19:41here also you can um directly give
  29805. 20:19:44something let's say I'll give u search
  29806. 20:19:46the latest uh so if you click here uh it
  29807. 20:19:48will automatically come search the web
  29808. 20:19:50uh for latest EI news okay so you can
  29809. 20:19:54directly send this prompt
  29810. 20:20:03Okay, that's how I added some prompt
  29811. 20:20:05here. Summarize the uploaded documents.
  29812. 20:20:07Save something to the memory. Use
  29813. 20:20:09calculated tool. Okay, if you want, you
  29814. 20:20:10can also give some more suggestion here.
  29815. 20:20:12Okay, it's completely up to you. So
  29816. 20:20:15guys, now we'll start the development of
  29817. 20:20:17BGPT. uh before starting the development
  29818. 20:20:20first of all I want to show you the
  29819. 20:20:22highle um architecture diagram like what
  29820. 20:20:24are the component we'll be implementing
  29821. 20:20:27in this um uh in this project so as you
  29822. 20:20:30have seen u this has already one front
  29823. 20:20:33end server um it is running on basically
  29824. 20:20:36um HTML CSS and JavaScript so the entire
  29825. 20:20:41front end you can see right I have
  29826. 20:20:43created with the help of HTML CSS and
  29827. 20:20:45JavaScript uh if you want you can also
  29828. 20:20:47use any front- end framework like NexJS,
  29829. 20:20:50React, okay, it's completely up to you.
  29830. 20:20:52But again, if you don't know about
  29831. 20:20:53front- end development, it's completely
  29832. 20:20:55fine. There would be a separate team for
  29833. 20:20:56that. They will try to design this front
  29834. 20:20:58end. But okay, for you and if you don't
  29835. 20:21:00know about HTML, CSS, Javcape, don't
  29836. 20:21:02worry. This thing you can easily
  29837. 20:21:03generate from uh chat GPT even you can
  29838. 20:21:06also generate from puppy GPT if you
  29839. 20:21:08want. Um so you just try to ask I need
  29840. 20:21:10this kinds of interface it will create
  29841. 20:21:12you can use that readym made template
  29842. 20:21:13and you can uh edit okay uh as per your
  29843. 20:21:16requirement uh but chart GPT actually
  29844. 20:21:19they're using some kinds of front- end
  29845. 20:21:21framework uh for this kinds of user
  29846. 20:21:23interface so every application has this
  29847. 20:21:26kinds of front- end server okay then it
  29848. 20:21:29is connected uh with a backend uh server
  29849. 20:21:32and the backend framework wise we're use
  29850. 20:21:35we'll be using here fast API that means
  29851. 20:21:37the application we have created it is
  29852. 20:21:38running on fast API. Okay. And fast API
  29853. 20:21:41is a production ready uh backend
  29854. 20:21:43framework you can use. Uh we'll be also
  29855. 20:21:46using fast API here. Okay. We'll try to
  29856. 20:21:48handle all of the get request, post
  29857. 20:21:50request, everything with the help of
  29858. 20:21:51fast API. Charg also running on some
  29859. 20:21:53kinds of u backend server. Okay. Maybe
  29860. 20:21:57they have used fast API. We don't know
  29861. 20:21:59that. Then uh you can see uh this
  29862. 20:22:02backend server is connected with a
  29863. 20:22:04workflow. Okay. That means some agentic
  29864. 20:22:06workflow. So here we'll be using
  29865. 20:22:08langraph to implement this entire
  29866. 20:22:10workflow. Um I think charg they might be
  29867. 20:22:14using any other agentic framework. Okay.
  29868. 20:22:17Um I don't know which framework they're
  29869. 20:22:19using but here we'll be using this
  29870. 20:22:21langraph because we have completed lang
  29871. 20:22:23graph so far inside our playlist. Okay.
  29872. 20:22:24We'll try to use the langraph for the
  29873. 20:22:27entire aentic workflow. Okay. We'll try
  29874. 20:22:29to create our entire agents. Um we'll
  29875. 20:22:32try to create the nodes. We'll try to
  29876. 20:22:33create the tools. Okay. each and
  29877. 20:22:34everything we'll try to create with the
  29878. 20:22:36help of edge uh lang graph. Then this uh
  29879. 20:22:39workflow will be connected with lots of
  29880. 20:22:41tools okay like uh we'll be using some
  29881. 20:22:45separate tools we'll be using rag tools
  29882. 20:22:47okay for document search we'll be using
  29883. 20:22:49memory tools as you saw it has also
  29884. 20:22:52remembered okay my conversation even you
  29885. 20:22:54can also retrieve the old conversation
  29886. 20:22:56how it is happening with help of memory
  29887. 20:22:57tools then some external uh API tools
  29888. 20:23:00will be using like web search tool okay
  29889. 20:23:03um then uh if you want you can also
  29890. 20:23:05integate uh current weather informations
  29891. 20:23:07okay it's and everything you can
  29892. 20:23:08integrate here. then it will have one
  29893. 20:23:10node tools uh tools node then uh it has
  29894. 20:23:14also database connection that means uh
  29895. 20:23:16for the I think if you have already
  29896. 20:23:18understood about this uh langraph it has
  29897. 20:23:20a concept of state okay the state uh uh
  29898. 20:23:23checkpointter saving we have to use some
  29899. 20:23:25kinds of database and here we'll be
  29900. 20:23:26using SQLite database okay for this
  29901. 20:23:28state tracking and uh for long-term
  29902. 20:23:32uh long-term conversation storage we'll
  29903. 20:23:34be using SQL uh alchemy okay uh this
  29904. 20:23:37will store basically my um um like
  29905. 20:23:40long-term conversation in that
  29906. 20:23:42particular database and whatever state
  29907. 20:23:45information we are having we'll try to
  29908. 20:23:46save inside this scale database and for
  29909. 20:23:49rag pipeline guys we'll be using chromb
  29910. 20:23:51vector database and we'll try to
  29911. 20:23:53generate the vector embeddings and here
  29912. 20:23:55we have used gemini embeddings uh
  29913. 20:23:57because gemini is free to use uh you can
  29914. 20:23:59also use any other embedding model it's
  29915. 20:24:00up to you okay with the help of Gemini
  29916. 20:24:02embeddings we'll try to generate the
  29917. 20:24:04embeddings and we'll store in the chrom
  29918. 20:24:06and it's it's not necessary to use the
  29919. 20:24:07chrom if you want you can also use fires
  29920. 20:24:10pine cone but pine cone is a paid one
  29921. 20:24:12you have to take the subscription then
  29922. 20:24:13you will be able to use that then web
  29923. 20:24:15also wit is also there it is also like a
  29924. 20:24:18paid one so in this project I tried to
  29925. 20:24:21use all the services as free okay that's
  29926. 20:24:22why I'm using chromb okay chrom is in
  29927. 20:24:25storage vector database that you can
  29928. 20:24:27store all of your vectors then some
  29929. 20:24:29external APIs we'll be using like tab
  29930. 20:24:31API okay then Google gemini API for the
  29931. 20:24:33lm and embeddings and if you want you
  29932. 20:24:35can also integrate any other API as well
  29933. 20:24:37here Okay. So yes, this is the highle
  29934. 20:24:40architecture of this um BPGT. Now we'll
  29935. 20:24:44try to follow this architecture. We'll
  29936. 20:24:46try to develop each and every component
  29937. 20:24:48in detail. So first of all uh we'll be
  29938. 20:24:51creating a GitHub repository for this
  29939. 20:24:53project. Uh so here I will open up my
  29940. 20:24:55GitHub.
  29941. 20:24:57Let's create a new repository here.
  29942. 20:25:01I'll create a new repository.
  29943. 20:25:04Um, I'm going to name it as uh
  29944. 20:25:07Buppy
  29945. 20:25:11GPT.
  29946. 20:25:16Buppy GPT
  29947. 20:25:19then uh here I will make it as public
  29948. 20:25:23repo and add the readmi file. I'll also
  29949. 20:25:28add the git ignore and here we'll be
  29950. 20:25:30using python and license. You can take
  29951. 20:25:33any license. I'll take this Apache
  29952. 20:25:34license. Okay. Now let's create the
  29953. 20:25:36repository here.
  29954. 20:25:42Okay. Once you have created uh this
  29955. 20:25:44repository, now just click on code, copy
  29956. 20:25:47this link. Make sure you copy the HTTP
  29957. 20:25:49link and uh open up your local folder.
  29958. 20:25:51And here let's try to clone that.
  29959. 20:25:56So get clone
  29960. 20:26:04paste the URL.
  29961. 20:26:07Okay. So cloning is complete. Now I'll
  29962. 20:26:09go inside that. So cd b gpt. Okay. Now
  29963. 20:26:13I'm inside this folder and here I'm
  29964. 20:26:16going to open up my um I'm going to open
  29965. 20:26:19up my uh VS code. So let's open up my VS
  29966. 20:26:24code.
  29967. 20:26:27So this is my VS code.
  29968. 20:26:30Let me zoom
  29969. 20:26:32everything is fine. Yeah. So here the
  29970. 20:26:35first thing guys uh what I have to do I
  29971. 20:26:37have to create a virtual environment and
  29972. 20:26:40uh after creating we have to um install
  29973. 20:26:44some of the library for this project
  29974. 20:26:46then we'll be creating the folder stack
  29975. 20:26:47set. So let's do it uh quickly and uh if
  29976. 20:26:51you are uh implementing this project
  29977. 20:26:53guys um I have implemented uh a similar
  29978. 20:26:57kinds of agentic chatbot in my previous
  29979. 20:26:59project. Uh if you go through that
  29980. 20:27:01recording uh all of the concept I
  29981. 20:27:03explained in detail like tools rag okay
  29982. 20:27:06then um memory each and everything I
  29983. 20:27:10explain in detail. So if you are
  29984. 20:27:12completing that uh video it would be
  29985. 20:27:14easy for you to implement this project.
  29986. 20:27:16Okay, if you're completely new but if
  29987. 20:27:18you already watch that video, if you
  29988. 20:27:20already know these are the concept then
  29989. 20:27:21it will be easy for you. So here I'm not
  29990. 20:27:23going to focus on the theoretical
  29991. 20:27:25explanation. Instead of that I'm more
  29992. 20:27:27going to focus on the practical
  29993. 20:27:28development because I'm expecting you
  29994. 20:27:30are already familiar with those concept.
  29995. 20:27:32Okay. So yeah make sure if you
  29996. 20:27:34[clears throat] are completely new go
  29997. 20:27:35through that uh previous recording.
  29998. 20:27:36Okay. I have on my playlist.
  29999. 20:27:39Now
  30000. 20:27:40>> [gasps]
  30001. 20:27:40>> uh here the first thing we'll be
  30002. 20:27:41creating the
  30003. 20:27:44um creating the
  30004. 20:27:48environment.
  30005. 20:27:50So let's create the environment. So how
  30006. 20:27:52to
  30007. 20:27:56run
  30008. 20:27:58BPG?
  30009. 20:28:10Yeah. First of all, you have to clone
  30010. 20:28:12the repository.
  30011. 20:28:30Okay. Then after that you have to create
  30012. 20:28:33the environment.
  30013. 20:28:40Yeah. So you have to navigate the
  30014. 20:28:41project directory first. Then you have
  30015. 20:28:43to create the environment.
  30016. 20:28:46So all of this step I'm writing so that
  30017. 20:28:47it would be easy for you uh to set up
  30018. 20:28:50okay later on
  30019. 20:28:54create virtual environment.
  30020. 20:28:59So to create environment you need to run
  30021. 20:29:01this command. So ponda
  30022. 20:29:04create
  30023. 20:29:06hyphen n bgptt python is equal to we'll
  30024. 20:29:08be using python 3.11 and hyphen y we're
  30025. 20:29:11giving the yes permission. Then once
  30026. 20:29:13involvement is created, we have to
  30027. 20:29:15activate the environment
  30028. 20:29:18then we have to install the
  30029. 20:29:20requirements.
  30030. 20:29:23Okay, once requirement installation done
  30031. 20:29:25then you'll be running the app.py.
  30032. 20:29:29Okay, app.py should be our endpoint
  30033. 20:29:31here. So now let's uh refer this uh file
  30034. 20:29:36and install everything one by one. Okay.
  30035. 20:29:38So, first of all, we have already inside
  30036. 20:29:41my bgptt folder and I'll create the
  30037. 20:29:42environment here. So, I'll copy this
  30038. 20:29:44command. Open up my terminal.
  30039. 20:29:51Let's create the environment.
  30040. 20:30:02Then we we have to activate that. This
  30041. 20:30:04is the command.
  30042. 20:30:13Okay, activation is complete. Now here
  30043. 20:30:16uh we have to add a requirement file
  30044. 20:30:25requirement.txt file inside that we'll
  30045. 20:30:28be mentioning all of the requirement we
  30046. 20:30:29need here.
  30047. 20:30:32So I already prepared all of the
  30048. 20:30:34requirement guys.
  30049. 20:30:36with the specific version I will be
  30050. 20:30:38installing here. See these are the
  30051. 20:30:40requirement I need for this project. I
  30052. 20:30:42need fast API for the backend server and
  30053. 20:30:45to run the fast API you need uon then
  30054. 20:30:47ginga okay and then python multipart. So
  30055. 20:30:50these are the dependency of fast api
  30056. 20:30:52then python.enb I need for environment
  30057. 20:30:55management that means uh whatever api
  30058. 20:30:57I'm going to mention I'm going to
  30059. 20:30:58mention inside this dot env file.
  30060. 20:31:04Okay.
  30061. 20:31:05Then uh I'll be installing the
  30062. 20:31:09orchestration framework like lang chain.
  30063. 20:31:11Then we'll be using gemini model. For
  30064. 20:31:13this you have to install this langen
  30065. 20:31:15google ji. Then lang chain core. Then
  30066. 20:31:18we'll be in uh using lang graph
  30067. 20:31:19orchestration framework for this agent
  30068. 20:31:21workflow. Then langent text splitter. I
  30069. 20:31:23need uh I will be integrating feature
  30070. 20:31:26rag feature. And to parse our documents
  30071. 20:31:29we need that. Then lang graph checkp
  30072. 20:31:30pointer skqli. That means uh to save
  30073. 20:31:33this uh persistence memory I need SQLite
  30074. 20:31:36um saber. Okay. Then langent chroma I
  30075. 20:31:39need uh because for vector database I'll
  30076. 20:31:41be using chromb. Then chromad you have
  30077. 20:31:43to install pi pdf. Here we'll be only
  30078. 20:31:46considering the pdf document. But if you
  30079. 20:31:48want you can also use uh like docs file.
  30080. 20:31:51You can also use excel file. Okay. This
  30081. 20:31:53part you can add simply go to the length
  30082. 20:31:55documentation. You will able to see
  30083. 20:31:56that. Then langent tab. So internet
  30084. 20:31:59search operation will be using tably
  30085. 20:32:00search. Okay. Then tab python. This is
  30086. 20:32:03the dependency for langent tab and SQL
  30087. 20:32:06um alchemy we'll be using for this uh
  30088. 20:32:10long-term uh conversation storage. Okay.
  30089. 20:32:13We'll be creating a database and there
  30090. 20:32:14we'll try to save everything. Okay. So
  30091. 20:32:16yes uh these are the requirements I
  30092. 20:32:18need. Now we have to install this
  30093. 20:32:19requirement and this is the command for
  30094. 20:32:21that. Let's copy
  30095. 20:32:23and uh we'll install everything here.
  30096. 20:32:49Let's wait. This process may take some
  30097. 20:32:51time.
  30098. 20:33:21So in between what I can do I can
  30099. 20:33:23collect all of the API key I need uh for
  30100. 20:33:26this development.
  30101. 20:33:29So here
  30102. 20:33:32uh what I'm going to do I'm going to
  30103. 20:33:34first of all collect the uh Gemini API.
  30104. 20:33:36Okay, this is available inside Google
  30105. 20:33:39AI studio.
  30106. 20:33:45Go to the Google AI studio
  30107. 20:33:52and uh here we'll just click on get
  30108. 20:33:55started and left hand side you will see
  30109. 20:33:56this API key.
  30110. 20:34:00And here you have to create an API key.
  30111. 20:34:02Okay. So I already have my API key. I'll
  30112. 20:34:04just copy that. If you don't have you
  30113. 20:34:06just try to create from here. Okay. So
  30114. 20:34:08after that you just need to add it here.
  30115. 20:34:11So this is my Google API key.
  30116. 20:34:15Okay. This is my Google API key I
  30117. 20:34:17collected. And don't use my API key
  30118. 20:34:19guys. I'll be removing after this
  30119. 20:34:20recording. And once it is done then you
  30120. 20:34:24have to mention the Google model which
  30121. 20:34:26model you want you want to use as
  30122. 20:34:28default. Okay. Let's see if user is not
  30123. 20:34:30selecting the model that means the by
  30124. 20:34:33default model I'll be using Gemini 2.5
  30125. 20:34:35flash model. Okay. And this model has
  30126. 20:34:37some free access limit you can use that.
  30127. 20:34:39Okay. So we'll be adding this model. If
  30128. 20:34:42you want to use any other model you can
  30129. 20:34:44simply do do that. Okay. You can go to
  30130. 20:34:45the chat GP. You can ask I want to use
  30131. 20:34:47this model. What should be the model
  30132. 20:34:48name? You can use that. Then the next uh
  30133. 20:34:52API key I need for internet search
  30134. 20:34:55operation because as you see uh we'll be
  30135. 20:34:57integrating the tools. Okay. And for
  30136. 20:34:58real time search operation we need a
  30137. 20:35:02tool called tably search. So tab search
  30138. 20:35:04uh needs the API key. So let's collect
  30139. 20:35:06that API key as well. So here what I'm
  30140. 20:35:09going to do I'm going to search for
  30141. 20:35:10tably API key.
  30142. 20:35:18Okay. Now let's
  30143. 20:35:22open this.
  30144. 20:35:26Here you have to login with your
  30145. 20:35:28account. Let's login with my account.
  30146. 20:35:33And here you have the API key. Okay. So
  30147. 20:35:35previously I already created the API
  30148. 20:35:36key. I'll just try to copy. But if you
  30149. 20:35:38don't have just create from here. So
  30150. 20:35:40let's add the table API key here.
  30151. 20:35:46Table API key. Okay.
  30152. 20:35:48Yes. Now uh tab is also done. Now what I
  30153. 20:35:52have done guys uh for this development I
  30154. 20:35:55also integrated lang here
  30155. 20:35:59that means I can continuously monitor my
  30156. 20:36:02chatbot the bub pgbt. Okay we are
  30157. 20:36:05tracing on langsmith platform. Let's log
  30158. 20:36:08in my lang. So if you don't have the
  30159. 20:36:10account just create an account in lang.
  30160. 20:36:12You can continue with your Google.
  30161. 20:36:18Okay. So here you can see uh we created
  30162. 20:36:20a aentic chatbot test.
  30163. 20:36:23So here uh we are tracing everything.
  30164. 20:36:25Okay. Whatever chat we have done here it
  30165. 20:36:28is tracing everything. You can monitor
  30166. 20:36:30from here. Okay. You can monitor from
  30167. 20:36:32here. Even you can also see the trades.
  30168. 20:36:36Okay. You can also see the trades
  30169. 20:36:38different different trades. Okay.
  30170. 20:36:39Everything is visible. So we'll be
  30171. 20:36:42integrating the this lang also uh inside
  30172. 20:36:44this uh project. So for this you need
  30173. 20:36:46lang langsmith API key. Okay. So where
  30174. 20:36:49you will get this API key? It is
  30175. 20:36:51available in settings API key. Okay. Now
  30176. 20:36:53just create an API key. So I already
  30177. 20:36:55created my API key. I'll just try to use
  30178. 20:36:57that. So for langid tracing guys you
  30179. 20:36:59need to add this four four variable
  30180. 20:37:02here.
  30181. 20:37:08Okay. The first thing langid tracing is
  30182. 20:37:10equal to would be true. Then lang
  30183. 20:37:14endpoint um this is the endpoint api
  30184. 20:37:17smith.langjen.com
  30185. 20:37:19then lang API key. So this is the API
  30186. 20:37:21key I have given and here you have to
  30187. 20:37:23give the project name. So here I'll give
  30188. 20:37:25let's say
  30189. 20:37:27bpg
  30190. 20:37:31bgt. So this is the project. Okay you
  30191. 20:37:33can give any name. Uh so it will
  30192. 20:37:35basically create that name here uh that
  30193. 20:37:38name here and it will trace all of the
  30194. 20:37:40informations there. Okay. So yeah so
  30195. 20:37:42these are the API key as of now I need
  30196. 20:37:44uh for this uh project but if you want
  30197. 20:37:47you can also use uh any other API key
  30198. 20:37:49you can use realtime weather uh weather
  30199. 20:37:52let's say API key to get the weather
  30200. 20:37:53information you want you can also use
  30201. 20:37:56any kind of stock price u uh stock price
  30202. 20:37:59API key if you want to get the latest
  30203. 20:38:01stock okay of any company. So this thing
  30204. 20:38:03I have already added inside my previous
  30205. 20:38:05uh uh chatbot. So this part I want to uh
  30206. 20:38:09I want to leave it to you. I want you to
  30207. 20:38:11integrate these are the features okay
  30208. 20:38:13inside this uh puppy GPT. So just try to
  30209. 20:38:16add realtime weather information s and
  30210. 20:38:18uh real time stock price. Okay these are
  30211. 20:38:20the thing just try to add and for this
  30212. 20:38:22you can use any any other open open
  30213. 20:38:24source let's say API provider for that.
  30214. 20:38:27So yes these are my environment
  30215. 20:38:29variable. Now let me see my installation
  30216. 20:38:30is complete or not. Yeah. So,
  30217. 20:38:31installation is completed. There is no
  30218. 20:38:33error. Okay. It's completely fine.
  30219. 20:38:36So, yeah. Now, uh what I'm going to do,
  30220. 20:38:39I'm going to just push the changes.
  30221. 20:38:42Okay. So, here you can just write
  30222. 20:38:45requirement
  30223. 20:38:50requirements
  30224. 20:38:52and uh
  30225. 20:38:57API addit.
  30226. 20:39:05Now if I go to my GitHub
  30227. 20:39:08refresh
  30228. 20:39:10see everything is up to date. Now
  30229. 20:39:14uh what I have to do guys I have to
  30230. 20:39:15create the uh folder structure
  30231. 20:39:18um what whatever folders and file you
  30232. 20:39:21need I'll just try to create then I'll
  30233. 20:39:23just uh uh implement all of the
  30234. 20:39:26component one by one. So now let's uh
  30235. 20:39:28create the files and folder I need. So
  30236. 20:39:30first of all I need the files here
  30237. 20:39:33called
  30238. 20:39:34agent.py.
  30239. 20:39:36So here I'm going to write my agent
  30240. 20:39:39workflow. Then I'll be creating another
  30241. 20:39:42file called tool.py.
  30242. 20:39:46So here I will be writing all of the
  30243. 20:39:48tools. Okay tools functionality. Then I
  30244. 20:39:51need another one called rag.py.
  30245. 20:39:55So here I'm going to write all of the um
  30246. 20:39:58rag related code that means document
  30247. 20:40:00uploader vector store everything. Then
  30248. 20:40:02I'm going to create another file called
  30249. 20:40:04database
  30250. 20:40:06dopy. So here uh we'll just try to write
  30251. 20:40:10all of the code related database. Okay,
  30252. 20:40:12database integration.
  30253. 20:40:14Then I need um
  30254. 20:40:18anything else. Okay, I need my endpoint
  30255. 20:40:20which is app.py. Okay, so this is going
  30256. 20:40:24to be my endpoint, my first API
  30257. 20:40:26endpoint. And uh for HTML and CSS, I
  30258. 20:40:31need a folder called template
  30259. 20:40:34templates. Okay, inside that I'm going
  30260. 20:40:37to create a file called index
  30261. 20:40:41html.
  30262. 20:40:44Okay, so inside that we'll be writing
  30263. 20:40:46all of the HTML, CSS, JavaScript related
  30264. 20:40:48code in a single file. Okay. And if you
  30265. 20:40:51don't know about HTML is completely
  30266. 20:40:52fine. Even uh I also took the help from
  30267. 20:40:55chat GPT to generate my user interface.
  30268. 20:40:57The user interface you have seen. Okay.
  30269. 20:40:59This user interface.
  30270. 20:41:02So yes uh as of now this thing is
  30271. 20:41:05required
  30272. 20:41:06and uh if I need anything I'll just try
  30273. 20:41:08to create later on. Okay. Now you can
  30274. 20:41:11again commit the changes like folders
  30275. 20:41:17and
  30276. 20:41:21Why had it
  30277. 20:41:34so folders and file added? Okay. Now,
  30278. 20:41:37first of all, guys, uh what I'm going to
  30279. 20:41:39do, I'm going to create my agent
  30280. 20:41:42workflow. So, let's create the agent
  30281. 20:41:44workflow. I'll just try to close this
  30282. 20:41:45out the file.
  30283. 20:41:52So I'll open up my agent.py
  30284. 20:41:55and here we'll be creating our agent
  30285. 20:41:57workflow with the help of lang graph. So
  30286. 20:42:00let's import some necessary library.
  30287. 20:42:07We'll import all the necessary library
  30288. 20:42:09and here make sure you select your
  30289. 20:42:10environment which is this one
  30290. 20:42:14bpg. Okay. And now this error would be
  30291. 20:42:17removed. Now here we are importing
  30292. 20:42:19operating system SQLite uh path from
  30293. 20:42:22path lib then env because we need to
  30294. 20:42:25load these environment variable then
  30295. 20:42:27certify you need uh why certify is
  30296. 20:42:30required because see sometimes if you're
  30297. 20:42:32using Windows operating system there
  30298. 20:42:34would be some kinds of path related
  30299. 20:42:36error. Okay to prevent that this is the
  30300. 20:42:39safer code you have to add. Let me show
  30301. 20:42:42you.
  30302. 20:42:44So this code you have to add okay
  30303. 20:42:46west.in environment SSL uh cert file
  30304. 20:42:50okay uh certified wire and request ca
  30305. 20:42:53bundle certified. You have to add this
  30306. 20:42:55two line. So if you're using Windows uh
  30307. 20:42:57operating system uh you won't be getting
  30308. 20:43:00the error related path issue. So it uh
  30309. 20:43:03doesn't happen to all the operating
  30310. 20:43:04system. Sometimes uh in uh in some
  30311. 20:43:08operating system it happens. Okay.
  30312. 20:43:09That's why I added this code just for a
  30313. 20:43:11safer purpose. That means if you are
  30314. 20:43:13executing my project in future you won't
  30315. 20:43:15be having any kinds of problem. But if
  30316. 20:43:16you're using Linux wind u Mac OS I think
  30317. 20:43:19this line is not required but still if
  30318. 20:43:21you keep it will not uh h uh make harm
  30319. 20:43:24okay in your in your project. So I'll
  30320. 20:43:26just try to add it to prevent the path
  30321. 20:43:28issue.
  30322. 20:43:29Then apart from that I need some other
  30323. 20:43:32um other libraries as well.
  30324. 20:43:35Yeah.
  30325. 20:43:37So these are the library I need
  30326. 20:43:40and I think all the libraries are common
  30327. 20:43:42guys. Uh here I don't need to explain
  30328. 20:43:44these are the library again. Uh we are
  30329. 20:43:46using this chat Google generate API for
  30330. 20:43:47this Gemini model initialization system
  30331. 20:43:50uh message we're importing from lang
  30332. 20:43:52chain. Then from lang graph we importing
  30333. 20:43:54state graph start message state. Okay
  30334. 20:43:56then from pre-built we are importing
  30335. 20:43:58tools node tools condition. Okay. Then
  30336. 20:44:01checkpoint we're using uh SQLite saber
  30337. 20:44:04and from um Okay. Okay. So this line I
  30338. 20:44:07don't need to write as of now because
  30339. 20:44:09whatever tools I'm going to write I'm
  30340. 20:44:11going to import here. Okay. So yes uh
  30341. 20:44:13these are the like uh import I need as
  30342. 20:44:15of now. Now what I'm going to do guys
  30343. 20:44:17first of all I'll just create a
  30344. 20:44:19directory.
  30345. 20:44:21Okay. Here I'll just create a directory.
  30346. 20:44:23So why directory is required? Because uh
  30347. 20:44:26I think you know that uh this uh
  30348. 20:44:28langraph will have a state right? Uh so
  30349. 20:44:31for our uh for our let's say this uh
  30350. 20:44:35workflow what would be the state okay
  30351. 20:44:37state should be the message state that
  30352. 20:44:39means whatever user is giving the input
  30353. 20:44:41message and my chatbot is replying uh
  30354. 20:44:45whatever response so this should be my
  30355. 20:44:46state okay that means uh if I create the
  30356. 20:44:50workflow so how my workflow will look
  30357. 20:44:52like let's try to understand
  30358. 20:44:56so for this I created a demo excalider
  30359. 20:44:58file and here I just uh uh created the
  30360. 20:45:02architecture. So this is the
  30361. 20:45:04architecture guys. So this is my
  30362. 20:45:06langraph workflow. So here uh it will
  30363. 20:45:09have a chat node and this will have a
  30364. 20:45:11tool nodes. Okay. So whatever user will
  30365. 20:45:13give the message it will go to the chat
  30366. 20:45:15node and chat node will decide uh so
  30367. 20:45:17here basically we'll be using something
  30368. 20:45:19called tool condition. This tool
  30369. 20:45:20condition will decide whether it has to
  30370. 20:45:22use any kinds of tool for this question
  30371. 20:45:24or not. If it doesn't need any kinds of
  30372. 20:45:26tool, it will directly go to the end
  30373. 20:45:27node. Otherwise, it will use the tool.
  30374. 20:45:29Now, it will automatically se select the
  30375. 20:45:31tools like which tools is required to
  30376. 20:45:33give the answer and um the response will
  30377. 20:45:35go to the end node. Okay. So, this is my
  30378. 20:45:38uh this is my actually
  30379. 20:45:40uh workflow. Okay. And what should be
  30380. 20:45:42the state for this workflow?
  30381. 20:45:46So, this should be the state. Okay. This
  30382. 20:45:48should be the chart chat state. That
  30383. 20:45:49means whatever input user is giving and
  30384. 20:45:52whatever response it is uh generating.
  30385. 20:45:53Okay. this I we have to add in the chat
  30386. 20:45:56state. So this should be the state.
  30387. 20:45:57Okay. So yeah. So if you want to save
  30388. 20:46:00this state in the uh in the actually
  30389. 20:46:03physical uh database that time we'll be
  30390. 20:46:05using SQLite database because if I'm
  30391. 20:46:07saving uh inside my RAM so if you close
  30392. 20:46:10your application this would be erased.
  30393. 20:46:12Okay. But I don't want that. I want uh
  30394. 20:46:14let's say if I close my application also
  30395. 20:46:16like chart GP still I'll be able to see
  30396. 20:46:18all of my chart history and message.
  30397. 20:46:19Right. So for this we'll be using SQLite
  30398. 20:46:22um SQLite database and to save the
  30399. 20:46:24SQLite database we'll be creating a data
  30400. 20:46:28folder here. Okay. So inside data folder
  30401. 20:46:30we'll try to create the database SQLite
  30402. 20:46:31database and we'll try to save all of
  30403. 20:46:33the checkpoint there. Okay. So for this
  30404. 20:46:35uh this uh data folder is required.
  30405. 20:46:39So to create the data folder I'm going
  30406. 20:46:41to use this code. Uh you can see I'm
  30407. 20:46:44using path library and inside that I'm
  30408. 20:46:46giving data data folder and I'm using
  30409. 20:46:49mkdr command to create the data folder.
  30410. 20:46:52So first of all it will check whether
  30411. 20:46:54this data folder is available or not. If
  30412. 20:46:56available it will not create otherwise
  30413. 20:46:57it will create. That's why I'm giving
  30414. 20:46:58this parameter exist. Okay is equal to
  30415. 20:47:00true. Okay. Yeah. Now uh here we'll just
  30416. 20:47:04try to define the list of the model uh
  30417. 20:47:06we want to uh we want to show to the
  30418. 20:47:09user.
  30419. 20:47:11Um
  30420. 20:47:13yeah so these are the model guys I have
  30421. 20:47:16considered for this project allowed
  30422. 20:47:17model Gemini 2.5 flash Gemini 2.5 Pro
  30423. 20:47:21and so on. If you want to use any other
  30424. 20:47:23model, you just need to um rename this
  30425. 20:47:26this uh dictionary. And the default
  30426. 20:47:29model uh if user is not giving any kinds
  30427. 20:47:31of model, the default model I'm taking
  30428. 20:47:32Jiny 2.5 plus from the environment
  30429. 20:47:34variable. Okay, here we have already
  30430. 20:47:36set. Yeah, this is for the safer
  30431. 20:47:39purpose. Okay, let's say if user is not
  30432. 20:47:40giving any model by chance, that's why
  30433. 20:47:43you can take the safer uh I mean default
  30434. 20:47:45model.
  30435. 20:47:47Okay.
  30436. 20:47:49Yeah. So once it is done now we'll try
  30437. 20:47:51to create a system prompt.
  30438. 20:47:57So this is the
  30439. 20:48:00system prompt guys I have prepared. As
  30440. 20:48:02you can see you are a helpful agent
  30441. 20:48:05assistant named BGPT similar to chart
  30442. 20:48:07GPT. You can answer normal question use
  30443. 20:48:09tools when needed. Okay. Search uploaded
  30444. 20:48:11documents using rack tool. Search web
  30445. 20:48:14for the latest current information using
  30446. 20:48:16tab search. remember important
  30447. 20:48:18informations using memory tool okay
  30448. 20:48:20recall any kinds of old conversation
  30449. 20:48:23using memory and you can also use
  30450. 20:48:26calculator for mathematical operation
  30451. 20:48:28and here I have set some rules okay so
  30452. 20:48:30that's how we can change this prompt as
  30453. 20:48:31per your requirement I have given this
  30454. 20:48:33system prompt now the first thing guys
  30455. 20:48:35uh here what I'm going to do I'm going
  30456. 20:48:37to
  30457. 20:48:39build our agent agent workflow
  30458. 20:48:43um so let's do that I already written
  30459. 20:48:47that function. Let me show you. So here
  30460. 20:48:49I'm not going to write from scratch
  30461. 20:48:51because this code I have already written
  30462. 20:48:53from scratch in my previous uh previous
  30463. 20:48:55project implementation. So most of the
  30464. 20:48:57codes are common. There is no new thing
  30465. 20:48:59we have added yet. That's why I will try
  30466. 20:49:01to copy paste.
  30467. 20:49:03So see this is my
  30468. 20:49:06um function I have written named build
  30469. 20:49:08agent. So this will take the model name.
  30470. 20:49:11Okay. Because to uh to uh create the
  30471. 20:49:16agent you need the model and uh first of
  30472. 20:49:19all what I have to do I have to
  30473. 20:49:20normalize the model and normalize the
  30474. 20:49:21model name means if user sometimes let's
  30475. 20:49:25say he is giving um any other name okay
  30476. 20:49:29let's say it if it is not matching with
  30477. 20:49:31this name so that type um my code will
  30478. 20:49:34give me error so make sure whenever you
  30479. 20:49:36are giving the model ID make sure the ID
  30480. 20:49:38should be same like that you can go to
  30481. 20:49:40the Gemini documentation you'll see that
  30482. 20:49:42they're giving the ID like that. Okay.
  30483. 20:49:44So, we have to give the same ID. So, if
  30484. 20:49:46by chance from the front end I'm getting
  30485. 20:49:48any other different name, I'll just try
  30486. 20:49:50to normalize that first of all. So, for
  30487. 20:49:52this we'll return write a function here
  30488. 20:49:54called normalize model name. It will
  30489. 20:49:55take the model name and it will do the
  30490. 20:49:57normalize. First of all, it will check
  30491. 20:49:58if not model name use the default model
  30492. 20:50:00otherwise first of all it will do the
  30493. 20:50:02strip operation then it will check if
  30494. 20:50:04model name is not not in allowed model
  30495. 20:50:06return the default model otherwise
  30496. 20:50:08return the uh same model user is giving.
  30497. 20:50:10So this function we are applying here
  30498. 20:50:12just to um just to what just to do the
  30499. 20:50:17model name verification the model name
  30500. 20:50:19it is matching here or not. Okay. Yeah.
  30501. 20:50:21So this kinds of simple simple function
  30502. 20:50:24you have to write inside your code so
  30503. 20:50:26that your application would be more
  30504. 20:50:27robust. Okay. Because user can give
  30505. 20:50:29anything. So you have to handle in the
  30506. 20:50:31back end. Now here we are using uh this
  30507. 20:50:35Gemini model chat Google generative way.
  30508. 20:50:37We're giving the model temperature
  30509. 20:50:38streaming is equal to true and we are
  30510. 20:50:40creating the LM object. Then uh before
  30511. 20:50:44creating the chat node first of all you
  30512. 20:50:46remember I think we have to uh bind the
  30513. 20:50:48tools okay with the lm because here
  30514. 20:50:50we'll be using the tools right and for
  30515. 20:50:51this we need list of the tools we'll be
  30516. 20:50:53creating the tools okay just don't worry
  30517. 20:50:55I'll create the tools as of now we
  30518. 20:50:56haven't created so after binding u we'll
  30519. 20:50:59be using this object lm with tools now
  30520. 20:51:01here we have written another function
  30521. 20:51:02called chat node so this is my chat uh
  30522. 20:51:05chat uh chatbot nodes and here preparing
  30523. 20:51:08the system message and we are also
  30524. 20:51:10giving the state Okay. And um um here
  30525. 20:51:14you can see we are using this uh lm with
  30526. 20:51:17tools and we are doing the invoking
  30527. 20:51:19operation and after that we are just
  30528. 20:51:21returning the message. Okay. Then the
  30529. 20:51:23second node we are using the tool tool
  30530. 20:51:25node that means if you see the
  30531. 20:51:26architecture so this node is created now
  30532. 20:51:28we are getting this tool this node.
  30533. 20:51:31Okay tool node. So once tool node is
  30534. 20:51:33created we are creating the workflow
  30535. 20:51:34state uh graph. Uh we are giving the
  30536. 20:51:37message state. Okay. And message state
  30537. 20:51:41is already available inside this
  30538. 20:51:43langraph. Okay, you don't need to
  30539. 20:51:45separately write that. It is already
  30540. 20:51:46inbuilt inside lang graph. If you are
  30541. 20:51:48creating this kinds of chatbot, you can
  30542. 20:51:50directly use this message state. I think
  30543. 20:51:51previous video I already discussed this
  30544. 20:51:53part. So message uh state we are taking.
  30545. 20:51:56Then we are adding the nodes. First of
  30546. 20:51:57all we have to add the um chat node,
  30547. 20:52:00right? Then we have to add the tool
  30548. 20:52:02node. So adding the chat node, then tool
  30549. 20:52:04nodes. Okay. Then we are doing the edge
  30550. 20:52:06connection. First of all start to
  30551. 20:52:08chatbot.
  30552. 20:52:09Start to chat chat note. Okay. Then uh
  30553. 20:52:13we are using conditional edges. Okay.
  30554. 20:52:15Conditional edges that means chatbot to
  30555. 20:52:17tools condition. Chatbot to tool
  30556. 20:52:19condition. Okay. That means there would
  30557. 20:52:21be two condition. Then
  30558. 20:52:24uh tool condition to chatbot
  30559. 20:52:27tool condition to chatbot again that
  30560. 20:52:29means whatever response we'll be getting
  30561. 20:52:30from the uh tools right this should be
  30562. 20:52:33refined with my LLM. That means I may
  30563. 20:52:36again passing to the chat node. So yeah
  30564. 20:52:38this is the connection and now we have
  30565. 20:52:40to give the persistence memory which is
  30566. 20:52:42my
  30567. 20:52:44uh SQLite. So here we are already
  30568. 20:52:47creating the data folder. I think
  30569. 20:52:48remember this data folder. So inside
  30570. 20:52:51data folder we are creating a database
  30571. 20:52:53object called langraph checkpoint.sqlite
  30572. 20:52:56and skqite is a local uh database. You
  30573. 20:52:58can create inside your storage only.
  30574. 20:53:00Okay. If you want you can also use any
  30575. 20:53:02remote database as well. Okay. You can
  30576. 20:53:04set up this this is on any server and
  30577. 20:53:06you can use that. But again for this uh
  30578. 20:53:09you need cloud platform like AWS okay
  30579. 20:53:12then your GCP. So there you can set up
  30580. 20:53:15the database server. You can store all
  30581. 20:53:17of the um uh store all of the uh data
  30582. 20:53:21but again I'm using the free resources.
  30583. 20:53:22That's why I'm using the local one. Okay
  30584. 20:53:25for this you don't need to pay anything.
  30585. 20:53:27Then same trades is equal to false. So
  30586. 20:53:30this thing you have to u make and this
  30587. 20:53:33will become your connection object. Now
  30588. 20:53:34you will be initializing the escalate
  30589. 20:53:36server and this connection object you
  30590. 20:53:38will pass here and this will become your
  30591. 20:53:39checkpointter and this checkpo pointer
  30592. 20:53:41you will be using whenever you will do
  30593. 20:53:42the workflow compilation. Okay done. So
  30594. 20:53:45this is what you have to just write for
  30595. 20:53:48this build agent. Okay. So now guys uh
  30596. 20:53:52it's done. Now the next thing we have to
  30597. 20:53:54prepare the tools. And again I'm telling
  30598. 20:53:56you guys all of this concept I have
  30599. 20:53:59completed in my playlist. Okay, just go
  30600. 20:54:01through one by one all of the concept.
  30601. 20:54:03You can see tools, rag, okay, aentic,
  30602. 20:54:06chatbot, workflow, okay, each and
  30603. 20:54:08everything I have already discussed in
  30604. 20:54:09my playlist. Just try to go through
  30605. 20:54:11that. If you are first time uh in this
  30606. 20:54:14implementation,
  30607. 20:54:15uh you might get difficulties for sure.
  30608. 20:54:17Okay, but if you cover all of this
  30609. 20:54:19recording, you won't be any kinds of uh
  30610. 20:54:21you won't be having any kinds of
  30611. 20:54:22problem. Okay, this is my promise. So
  30612. 20:54:24that's why I'm telling you I'm not going
  30613. 20:54:26to focus on the theoretical part. I'm
  30614. 20:54:28only going to focus on the practical
  30615. 20:54:29development because theory I have
  30616. 20:54:31already covered. Okay. Yes. So yes. So
  30617. 20:54:34now let's work on the tool. Uh so for
  30618. 20:54:37tool guys what I'm going to use I'm
  30619. 20:54:38going to use this tools.py and inside
  30620. 20:54:41that I'm going to mention all of the
  30621. 20:54:42tools I'll be using in this project. So
  30622. 20:54:45first of all let's import all of the
  30623. 20:54:47necessary library.
  30624. 20:54:49Um
  30625. 20:54:51yeah.
  30626. 20:54:53So I'll import math module uh env. Then
  30627. 20:54:56we'll load the environment variable.
  30628. 20:55:00Okay. Then here we have imported tools
  30629. 20:55:05from langen code tools. Then langen tab
  30630. 20:55:08where importing tab search. Okay. Yeah.
  30631. 20:55:12So first of all um here what I'm going
  30632. 20:55:15to do I'm going to initialize some
  30633. 20:55:17tools.
  30634. 20:55:24First of all, I'm going to use this
  30635. 20:55:27web search tool.
  30636. 20:55:32Okay, web search tool. So, I'm using
  30637. 20:55:34tably and here we're giving the some
  30638. 20:55:36parameter like max result, topic. Okay,
  30639. 20:55:39search depth. These are the parameter
  30640. 20:55:40we're giving and this will become your
  30641. 20:55:42tool. And here you don't need to use the
  30642. 20:55:43tool decorator because table is already
  30643. 20:55:45a tool. Okay, so you don't need to give
  30644. 20:55:47that. And uh I need other tool as well
  30645. 20:55:50like I need calculator tool.
  30646. 20:55:54So this is my calculator tools. So you
  30647. 20:55:58can see this is a simple custom function
  30648. 20:55:59we have written for calculator. It will
  30649. 20:56:01take any kinds of expression and it will
  30650. 20:56:03do the um mathematical operation and it
  30651. 20:56:06will return the result. And if you want
  30652. 20:56:08to use as a tool I have to use this tool
  30653. 20:56:10decorator. Okay that means website and
  30654. 20:56:12calculator we have added. Now we'll be
  30655. 20:56:14adding some more tools like uh we'll be
  30656. 20:56:17adding the uh we'll be adding the
  30657. 20:56:23memory tool that means you can save any
  30658. 20:56:25kinds of uh uh information if user is
  30659. 20:56:28giving let's say user is giving remember
  30660. 20:56:30something okay it will use that memory
  30661. 20:56:33tool and it will save that information
  30662. 20:56:35in the long-term memory and for this we
  30663. 20:56:36have to use the database so we'll be
  30664. 20:56:38writing that thing as a tool then if you
  30665. 20:56:41want to search memory that means if you
  30666. 20:56:42want to get any older conversation which
  30667. 20:56:44you did long time ago. It will retrieve
  30668. 20:56:46from the database. Okay. So again for
  30669. 20:56:48this we will be writing a tool. Okay. So
  30670. 20:56:50that's how we'll be writing different
  30671. 20:56:51different tool and one more tool you
  30672. 20:56:52need which is this uh um rag tool. That
  30673. 20:56:55means if user wants to search something
  30674. 20:56:57over the documents you can use the rag
  30675. 20:56:59tool. So this part we'll just try to
  30676. 20:57:01write but before that we'll be writing
  30677. 20:57:03another function called
  30678. 20:57:06trade.
  30679. 20:57:07This trade is required because here I
  30680. 20:57:10think you saw we we'll be using the
  30681. 20:57:11trade right? different different trades.
  30682. 20:57:13Okay. Uh user can create different
  30683. 20:57:15different trades. Okay. And anytime they
  30684. 20:57:17can switch between another trades. So
  30685. 20:57:19for this every time we'll be using the
  30686. 20:57:22trades. So for this here I have written
  30687. 20:57:23another function called set current
  30688. 20:57:25trades. And if user gives any kinds of
  30689. 20:57:27trade ID here it will try to set that
  30690. 20:57:29particular trades and this trade will be
  30691. 20:57:31considered in that particular session.
  30692. 20:57:33And by default if user is not giving any
  30693. 20:57:35trades it will be using the default
  30694. 20:57:36trades. Okay. So this trading concept I
  30695. 20:57:38also discussed in my playlist. You can
  30696. 20:57:40go through that. Now first of all uh
  30697. 20:57:43what I'm going to do guys I'm going to
  30698. 20:57:44use the database related
  30699. 20:57:48database related tools. So for this
  30700. 20:57:51there is a file I have written called
  30701. 20:57:52database.py. Let's open it up and uh let
  30702. 20:57:56me show you
  30703. 20:57:59all of the
  30704. 20:58:02function you need here.
  30705. 20:58:05I already written this code. Let me show
  30706. 20:58:07you very simple only the database
  30707. 20:58:09operation I have written. And here we
  30708. 20:58:11are using SQL uh alchemy database. Okay,
  30709. 20:58:13for this you need the knowledge on SQL
  30710. 20:58:15alchemy. If you don't know, just go
  30711. 20:58:16through any YouTube video and try to
  30712. 20:58:18understand SQL alchemy how it works with
  30713. 20:58:20Python. So here we're importing dead
  30714. 20:58:22time, path leave, SQL alchemy, you're uh
  30715. 20:58:24importing create engine, column,
  30716. 20:58:26integer, string, text, dead time, SQL
  30717. 20:58:28alchemy, you're importing OM. Okay. Uh
  30718. 20:58:31declarative base session maker each and
  30719. 20:58:33everything you will uh see from the
  30720. 20:58:35tutorial itself. I'm not going to
  30721. 20:58:36explain this here because again this is
  30722. 20:58:38a theoretical concept. You can
  30723. 20:58:40understand this thing from a YouTube
  30724. 20:58:42tutorial how SQL Alchemy works. But this
  30725. 20:58:44is a simple code I have written.
  30726. 20:58:45Basically, this uh code will try to
  30727. 20:58:47connect with SQL Alchemy server. So here
  30728. 20:58:50we're creating a local server. You can
  30729. 20:58:51see okay, we'll be creating a local
  30730. 20:58:53server. If you want you can also install
  30731. 20:58:56this SQL Alchemy in the remote server.
  30732. 20:58:58Uh for this again I told you you need to
  30733. 20:59:00use AWS, GCP or any other cloud
  30734. 20:59:02provider. There you can set up that but
  30735. 20:59:04again uh that would be costly. That's
  30736. 20:59:06why I'll be using the local one just to
  30737. 20:59:08show you the free resources. So again uh
  30738. 20:59:10we are creating the data data folder.
  30739. 20:59:12Okay data folder why every time we're
  30740. 20:59:14creating the data folder because if data
  30741. 20:59:16is not data folder is not there first of
  30742. 20:59:18all it will create and inside that it
  30743. 20:59:20will save this uh DB object. Okay. So
  30744. 20:59:23every time you need to check okay uh and
  30745. 20:59:26this parameter you have to provide if
  30746. 20:59:27already available no need to create
  30747. 20:59:29otherwise just try to create. Okay. So
  30748. 20:59:31this is my database URL SQLite clone. uh
  30749. 20:59:35then you have to give / data folder
  30750. 20:59:37inside that chatbot memory db this
  30751. 20:59:39object would be created okay inside that
  30752. 20:59:41we'll try to save all of the information
  30753. 20:59:43first of all we're getting the engine
  30754. 20:59:44okay where we providing the database URL
  30755. 20:59:46and some connection method then we're
  30756. 20:59:49getting a session okay after getting the
  30757. 20:59:51session we are creating some class you
  30758. 20:59:53can see first of all this class will
  30759. 20:59:54return you the schema like table name ID
  30760. 20:59:57trade ID title created at updated okay
  30761. 20:59:59this is called actually uh schema okay
  30762. 21:00:02uh database schema Then chat message.
  30763. 21:00:05For chat message, we are returning the
  30764. 21:00:07schema like ID, trader, ro content,
  30765. 21:00:09created at. Okay, these are the
  30766. 21:00:11information we'll try to uh save inside
  30767. 21:00:13chat message. And for long time uh
  30768. 21:00:15long-term memory that means if user
  30769. 21:00:17wants to save any kinds of long-term
  30770. 21:00:19conversation that time we'll try to set
  30771. 21:00:21ID, trade ID, memory that means the
  30772. 21:00:24conversation and the created when it it
  30773. 21:00:26got created. Okay. And the table name
  30774. 21:00:28should be long-term memory that time.
  30775. 21:00:30And for chat message that means the
  30776. 21:00:31regular message whatever message user
  30777. 21:00:33will perform it will become as a chat
  30778. 21:00:35message table. Okay. Now we are
  30779. 21:00:38initializing the database with this
  30780. 21:00:39function and this is the function for
  30781. 21:00:41create or update conversation. So this
  30782. 21:00:43will take the trade ID and the message.
  30783. 21:00:45Okay. If you give if you give the
  30784. 21:00:47message it will update that conversation
  30785. 21:00:49in the table. Okay. So you can see here
  30786. 21:00:52we have written the code for that. Okay.
  30787. 21:00:55And this code will also help you to
  30788. 21:00:58prepare these traits. Okay, that means
  30789. 21:01:00every time you can see whenever user is
  30790. 21:01:01passing any kinds of message, it is
  30791. 21:01:03taking the message title and it is only
  30792. 21:01:05taking the 40 character of that. So this
  30793. 21:01:07part I'm doing here. Okay, so from the
  30794. 21:01:10user message uh first message, I'm
  30795. 21:01:12taking the first 40 character and I'm
  30796. 21:01:14preparing a title and I'm showing you
  30797. 21:01:17inside the trade message. Okay, so this
  30798. 21:01:19is what actually we have written here in
  30799. 21:01:20this function.
  30800. 21:01:22Then once it is done, we are listing all
  30801. 21:01:24of the conversation. Okay, listing
  30802. 21:01:26conversation means uh whatever
  30803. 21:01:28conversation we have here. Okay, uh we
  30804. 21:01:31are listing all of the conversation with
  30805. 21:01:33this with this function. Okay, then save
  30806. 21:01:38chat messages. Okay, that means if you
  30807. 21:01:40if user wants to save any kinds of
  30808. 21:01:43message, so it will be using this
  30809. 21:01:44function for that. Then if user wants to
  30810. 21:01:47get any kinds of history, previous
  30811. 21:01:48history, it will be using this function
  30812. 21:01:50for that. So it is only doing the
  30813. 21:01:52database operation. You can see it is uh
  30814. 21:01:54uh adding adding the data. It is uh
  30815. 21:01:57retrieving the data. That's how it's
  30816. 21:01:58working. If user wants to save any
  30817. 21:02:00memory
  30818. 21:02:02any kinds of let's say let's say I I'm
  30819. 21:02:05telling my chatbot I am BP. Okay. Try to
  30820. 21:02:07remember me that time it will use this
  30821. 21:02:10function. We'll be using this function
  30822. 21:02:11as a tool. Okay. As a long-term memory
  30823. 21:02:14that's why we're using this schema that
  30824. 21:02:16time. Okay. Now let me go below.
  30825. 21:02:20And [clears throat] if user wants to
  30826. 21:02:21search anything uh about the previous uh
  30827. 21:02:23question that time uh we'll be using
  30828. 21:02:26this function as a tool that time okay
  30829. 21:02:27for a long time long-term memory uh
  30830. 21:02:30concept. So yes uh this is the um
  30831. 21:02:34database related code guys I have
  30832. 21:02:35written and we'll be using uh inside our
  30833. 21:02:38tools right now. Now let me import
  30834. 21:02:41for these are the functionality first of
  30835. 21:02:43all. So see from this database I only
  30836. 21:02:45need to import
  30837. 21:02:47from database
  30838. 21:02:50I need to import save memory and search
  30839. 21:02:53memory. Okay, save memory I'll be using
  30840. 21:02:54to save my conversation and search
  30841. 21:02:58memory I need to uh get my previous
  30842. 21:03:01conversation. Okay, old conversation.
  30843. 21:03:04Now these two things I'll be defining as
  30844. 21:03:06a tool. Let me do that.
  30845. 21:03:10So
  30846. 21:03:14here I'll just try to add after
  30847. 21:03:16calculator
  30848. 21:03:19remember this okay if u user is asking
  30849. 21:03:22um just to remember anything it will use
  30850. 21:03:25this tool that time okay and it will uh
  30851. 21:03:28take the conversation and it will save
  30852. 21:03:29inside the memory and for this we're
  30853. 21:03:31using this save memory
  30854. 21:03:33this function save memory and we are
  30855. 21:03:36defining as a tool and uh one formatting
  30856. 21:03:39we need the recall memory.
  30857. 21:03:44If user wants to let's say
  30858. 21:03:48uh if user is asking about old old
  30859. 21:03:50conversation let's say if user asking
  30860. 21:03:52what is my name or what was my hobby
  30861. 21:03:54that time it will use the equal memory
  30862. 21:03:56tool and it will search the memory that
  30863. 21:03:58means in the database it will search the
  30864. 21:04:00old conversation and it will return that
  30865. 21:04:03okay so these two things I have used as
  30866. 21:04:05a tool I hope you get it and one more uh
  30867. 21:04:09tool I have to create
  30868. 21:04:11Um
  30869. 21:04:14one more tool I'll be creating here
  30870. 21:04:20called uh this rag tool.
  30871. 21:04:23Just a minute. Yeah, one more tool I
  30872. 21:04:25need called rag tool. Okay, rag tool you
  30873. 21:04:27need. Let's say if user is uploading any
  30874. 21:04:29kinds of documents. So this document uh
  30875. 21:04:32um you have stored in the vector
  30876. 21:04:35database. Okay. And from the vector
  30877. 21:04:37database you'll be performing the
  30878. 21:04:38retrieving retrieving operation. That
  30879. 21:04:39means you will try to retrieve the
  30880. 21:04:40informations for this. This tools is
  30881. 21:04:42required. So let's create this rag tool
  30882. 21:04:45here. I'm going to open this rag.py.
  30883. 21:04:48Inside that I'm going to write all of
  30884. 21:04:49the rag related code. And again this rag
  30885. 21:04:52related code is uh uh common from my
  30886. 21:04:54previous implementation. First of all
  30887. 21:04:56let's import the necessary libraries.
  30888. 21:05:00Okay. I'm importing these necessary
  30889. 21:05:02libraries. Then again I need that
  30890. 21:05:07environment related
  30891. 21:05:09um command that means if you are getting
  30892. 21:05:12the path issue that time this code will
  30893. 21:05:14help you to prevent that and uh some
  30894. 21:05:16other library I need
  30895. 21:05:20these are the library like from langen
  30896. 21:05:22we're importing chroma chromadb then
  30897. 21:05:24google generative embeddings we'll be
  30898. 21:05:26using google genative embeddings model
  30899. 21:05:28then documents we're importing from lang
  30900. 21:05:30langen code then recursive character
  30901. 21:05:32text splitter for the chunking
  30902. 21:05:33operation. Okay, what is chunking? What
  30903. 21:05:36is uh why chunk is required in the lag?
  30904. 21:05:38Each and everything I have discussed in
  30905. 21:05:40my rag video. So here, okay, implement
  30906. 21:05:43rag in aentic chatbot. You can go
  30907. 21:05:45through that. Yeah. Then pi PDF reader
  30908. 21:05:48because we'll be considering the PDF
  30909. 21:05:50document. But if you want you can also
  30910. 21:05:51upload any other document as well. Txt,
  30911. 21:05:53docs. Okay, it's completely up to you.
  30912. 21:05:55Then doc to text. Then here we'll be
  30913. 21:05:58creating two more directory.
  30914. 21:06:02one is the uploads. Okay, let's say
  30915. 21:06:04whatever document user is uploading I'll
  30916. 21:06:06try to store in the uploads folder.
  30917. 21:06:08Okay, for this you're creating the
  30918. 21:06:09directory and one more directory you are
  30919. 21:06:12creating called chromad. Okay, let's say
  30920. 21:06:14whenever it is creating the vector
  30921. 21:06:16store, right? Uh um chromod actually use
  30922. 21:06:19your local storage to save the
  30923. 21:06:22information that means the vector store.
  30924. 21:06:23So that time it will create a chrom
  30925. 21:06:25directory inside that it will save
  30926. 21:06:26everything that's two directory we are
  30927. 21:06:28creating. Then we'll be initializing the
  30928. 21:06:30embedding model.
  30929. 21:06:33So this is our embedding model.
  30930. 21:06:36Okay, we are using Gemini uh Gemini
  30931. 21:06:38embedding 001 this model. Now we'll be
  30932. 21:06:41creating the vector store.
  30933. 21:06:44So this is our vector store. We are
  30934. 21:06:45using chromad and this is the name of
  30935. 21:06:48the collection name aentic chatbot docs.
  30936. 21:06:50We are giving the embedding model and we
  30937. 21:06:52are providing the chromadb path
  30938. 21:06:56here. [sighs] You can use any vector
  30939. 21:06:58database. You can use uh pine cone web
  30940. 21:07:00whatever you want. You can use any
  30941. 21:07:01vector database. Okay. It's not like
  30942. 21:07:04that you have to use chrom always. Now
  30943. 21:07:06here I have written a function. So this
  30944. 21:07:09function what it does let me show you
  30945. 21:07:11this function basically reads the uh
  30946. 21:07:14reads reads reads a file text okay that
  30947. 21:07:17means if you provide any file uh it will
  30948. 21:07:19read read that whether it is a PDF or
  30949. 21:07:23whether it's it's in a doc format okay
  30950. 21:07:26so basically uh here uh you can upload
  30951. 21:07:28txt md pi CSV
  30952. 21:07:32okay and you can load that but here we
  30953. 21:07:35are considering the docs and pdf format
  30954. 21:07:37and uh if you want you can also load
  30955. 21:07:39these other documents as well. So once
  30956. 21:07:41it's read everything it will load that
  30957. 21:07:44like if it is PDF it will use the PDF
  30958. 21:07:46reader to uh read that documents. Okay.
  30959. 21:07:49If it is docs it will use the docs uh to
  30960. 21:07:52text and it will load that. Okay. And if
  30961. 21:07:55you want to consider like MDI you can
  30962. 21:07:57write another other condition as well.
  30963. 21:07:59Okay. So it will use that and it will uh
  30964. 21:08:01load that. But here by default I have
  30965. 21:08:03written a code uh I'm using path read.
  30966. 21:08:06Okay. So what it does if you are
  30967. 21:08:07providing this txt, MD, PI, CSV, it can
  30968. 21:08:10still load that documents and it can um
  30969. 21:08:13extract the content from that. Okay. And
  30970. 21:08:16uh there is exception I have given
  30971. 21:08:18unsupported file like upload PDF, docs,
  30972. 21:08:20txt, MD, py or CSV. Uh if user is
  30973. 21:08:23passing any other file format let's
  30974. 21:08:24say.pl or any other file that time I'll
  30975. 21:08:27raise the exception. Okay. So exception
  30976. 21:08:29has handling is also required whenever
  30977. 21:08:31you are doing this kinds of scenario. So
  30978. 21:08:33yeah this is the function to load the
  30979. 21:08:35documents. Now uh we'll be writing the
  30980. 21:08:38final function to create the vector
  30981. 21:08:41store. So this is the function we'll be
  30982. 21:08:43using to create the vector store. As you
  30983. 21:08:45can see
  30984. 21:08:47add documents to rag. It will use the
  30985. 21:08:49file path and the trade ID. Then uh we
  30986. 21:08:52are doing the chunking operation. We're
  30987. 21:08:55giving the chunk size and chunk overlap.
  30988. 21:08:57Creating the chunking. Then we are um we
  30989. 21:08:59are taking the page content. Okay. uh
  30990. 21:09:02that means uh content from the uh
  30991. 21:09:04documents and we're storing in the
  30992. 21:09:06vector store. Okay. And we're returning
  30993. 21:09:07the path. So this function will
  30994. 21:09:09basically create the vector store. Okay.
  30995. 21:09:11Vector database and it will store
  30996. 21:09:12everything in the vector store. Okay.
  30997. 21:09:15Now for retrieve operation that means if
  30998. 21:09:17user is asking anything regarding the
  30999. 21:09:19documents, it will retrieve the
  31000. 21:09:21information by using the similarity s. I
  31001. 21:09:23think you know every vector database
  31002. 21:09:24having a similarity source okay
  31003. 21:09:26operation. So in this function we are
  31004. 21:09:28doing that. Sorry from rag where user is
  31005. 21:09:30giving the query as well as the trade
  31006. 21:09:32and the k parameter. So by default k
  31007. 21:09:34parameter is four that means four
  31008. 21:09:35relevant information it will extract
  31009. 21:09:37from the vector database we are doing
  31010. 21:09:39the similarity source operation that
  31011. 21:09:40means retrieve operation after that
  31012. 21:09:42whatever result we are getting we're
  31013. 21:09:44just loading inside result and we are
  31014. 21:09:46returning returning it as a string okay
  31015. 21:09:48so this is what we are doing inside
  31016. 21:09:50retive from rag and this function will
  31017. 21:09:52be using as a tool right now. So here
  31018. 21:09:54what I'm going to do I'm going to open
  31019. 21:09:56up my agent sorry tool and here I will
  31020. 21:09:58try to import that function. So let's
  31021. 21:10:00import
  31022. 21:10:03um the function name is retrieve from
  31023. 21:10:06rack. So let's import it here. So from
  31024. 21:10:09rag
  31025. 21:10:12import
  31026. 21:10:14retrieve
  31027. 21:10:18what's the name?
  31028. 21:10:21Retrieve from
  31029. 21:10:25Okay, we will be importing here and now
  31030. 21:10:28we'll just try to create a tool.
  31031. 21:10:33So here maybe I can create the tool. So
  31032. 21:10:36this is the tool name uh search uploaded
  31033. 21:10:38documents user will give the query and
  31034. 21:10:40we'll be using retip from rag this
  31035. 21:10:42function we'll pass the query trade ID
  31036. 21:10:45and it will give me the relevant answer.
  31037. 21:10:48Okay, for that query we are using this
  31038. 21:10:50this code for that. So I think now you
  31039. 21:10:52have understood like how we have
  31040. 21:10:54arranged everything how we have prepared
  31041. 21:10:56all of the tool. Okay, we have created
  31042. 21:10:58the database tool, we have created the
  31043. 21:10:59rack tool, we have created the search
  31044. 21:11:01tool, we have created a calculator tool.
  31045. 21:11:03Each and every tools are ready. Okay,
  31046. 21:11:05now in the agents
  31047. 21:11:08uh we'll be importing the tools right
  31048. 21:11:10now.
  31049. 21:11:12Let's import the tools.
  31050. 21:11:17So here we'll just write
  31051. 21:11:21from tools
  31052. 21:11:27import
  31053. 21:11:28tools.
  31054. 21:11:37Um, okay. So, we have to create a tool
  31055. 21:11:39object. So, here at the last what I'm
  31056. 21:11:41going to do, I'm going to just prepare
  31057. 21:11:45the list of the tools.
  31058. 21:11:48So, yeah. So you can see this is a list
  31059. 21:11:50inside that first of all I'm passing the
  31060. 21:11:51calculator then search uploaded
  31061. 21:11:52documents remember this recall and web
  31062. 21:11:54search all the tools we have created we
  31063. 21:11:57are just passing one by one here okay
  31064. 21:11:59now if you want to add any other tools
  31065. 21:12:01in future you can add it here so I'm
  31066. 21:12:02going to give you a task guys you just
  31067. 21:12:04try to add the real time where the
  31068. 21:12:06weather search tool and uh stock price
  31069. 21:12:09tool okay this tool two tool you can add
  31070. 21:12:11at least here okay now this thing we are
  31071. 21:12:14importing here tools now we are using
  31072. 21:12:18this tool for the bind operation. Okay.
  31073. 21:12:20Now we are doing the bind operation and
  31074. 21:12:22our uh workflow is getting created.
  31075. 21:12:26Okay. So that means still here
  31076. 21:12:27everything is fine. Everything is good.
  31077. 21:12:30Okay. Now uh one thing I will do before
  31078. 21:12:32the testing see here we are uh building
  31079. 21:12:35the agent right. So it's not necessary
  31080. 21:12:37to build the agents every time whenever
  31081. 21:12:39you are initializing the chatbot. Okay.
  31082. 21:12:42because uh if you're building from uh
  31083. 21:12:45scratch so I mean it will take some time
  31084. 21:12:48right so instead of that maybe we can
  31085. 21:12:50create a cache agent cache that means we
  31086. 21:12:53can build one time and save in the cache
  31087. 21:12:56and every time whenever it will um
  31088. 21:12:59reinitialize the chatbot instead of
  31089. 21:13:01building from again we can uh take the
  31090. 21:13:03agent from the cache okay so for this
  31091. 21:13:06this code is required
  31092. 21:13:09so simply you can write this code so
  31093. 21:13:11here I created create a dictionary
  31094. 21:13:12called agent cache uh and we had created
  31095. 21:13:16a function called get agent. So you will
  31096. 21:13:18only pass the model okay a model name.
  31097. 21:13:22So what will happen? And this will go to
  31098. 21:13:24the normalize model name function and
  31099. 21:13:26you will get the correct model name and
  31100. 21:13:29you are checking if selected model in
  31101. 21:13:32agent cache okay not in agent cache then
  31102. 21:13:36you will try to build the agents okay
  31103. 21:13:38otherwise what you are doing you are
  31104. 21:13:40taking the existing agent only so you
  31105. 21:13:42are not building again the agent again
  31106. 21:13:44and again okay so this thing you can
  31107. 21:13:46write now we can test whether this uh
  31108. 21:13:49workflow is working or not so I can open
  31109. 21:13:51up my rag dot sorry app.py and here I
  31110. 21:13:54can test it. So I'll just try to import
  31111. 21:13:57import um from agent
  31112. 21:14:08agent
  31113. 21:14:10input get agent.
  31114. 21:14:16Now
  31115. 21:14:18agent is equal to get agent. Here you
  31116. 21:14:20have to pass the model name.
  31117. 21:14:23So let's say I'll give the same name.
  31118. 21:14:27This model name I'll keep.
  31119. 21:14:39So it will only take the model name I
  31120. 21:14:41think. Yeah model name. Okay. Now we can
  31121. 21:14:44do the invoke operation.
  31122. 21:14:48Yeah. So we have written this code for
  31123. 21:14:50testing. Okay. So here we are using the
  31124. 21:14:53streaming right. So that's why instead
  31125. 21:14:54of invoking I'm just doing agent stream
  31126. 21:14:57and we are giving the human message here
  31127. 21:15:00and stream will return a uh generator
  31128. 21:15:03object and for this we are using this
  31129. 21:15:04for loop and we're uh getting the answer
  31130. 21:15:06token by token and we're streaming that
  31131. 21:15:10and uh here is the code. So let's test
  31132. 21:15:14it whether it's working or not. I will
  31133. 21:15:15open up my terminal and uh I'll just
  31134. 21:15:18execute python.py.
  31135. 21:15:24Now see all the folders are getting
  31136. 21:15:26created.
  31137. 21:15:28Now here we are getting the response as
  31138. 21:15:29you can see streaming response. So this
  31139. 21:15:31is the blog about a machine learning we
  31140. 21:15:33got. See okay that means everything is
  31141. 21:15:36working fine. And here we are given um
  31142. 21:15:40like um testing trade just to test the
  31143. 21:15:44workflow because this workflow needs a
  31144. 21:15:45trade ID right we we have given a
  31145. 21:15:47testing trade here in this
  31146. 21:15:49configuration. Now you can see um all of
  31147. 21:15:53the folders got created and you can see
  31148. 21:15:55this is your state uh state actually
  31149. 21:15:59um state database it is serving inside
  31150. 21:16:01SQLite and uh this is the chromb um that
  31151. 21:16:05means the vector database will be
  31152. 21:16:08creating here and the upload folder as
  31153. 21:16:11well as of now we haven't uploaded
  31154. 21:16:12anything that's why it's coming like
  31155. 21:16:13that now we can ask anything uh that may
  31156. 21:16:16use any tool let's say I will ask
  31157. 21:16:21Tell me
  31158. 21:16:24today's
  31159. 21:16:30news
  31160. 21:16:34of AI. So definitely he will use uh the
  31161. 21:16:37tool that mean search tool. Let's see.
  31162. 21:16:51Now see it has uh done the internet
  31163. 21:16:52search operation with the help of tably
  31164. 21:16:56and uh it found the result. Okay,
  31165. 21:16:59regarding the today's uh news of AI and
  31166. 21:17:02you can see it has referred different
  31167. 21:17:03different website here. Okay, different
  31168. 21:17:05different website URL are present. Okay.
  31169. 21:17:07So from this URL it has extracted the
  31170. 21:17:09news and this is what we got in the
  31171. 21:17:12answer and one best part is that you can
  31172. 21:17:16also uh see this uh database that that
  31173. 21:17:19means whatever methods are available
  31174. 21:17:20inside that. So for this you have to
  31175. 21:17:23install one extension called SQLite
  31176. 21:17:27okay viewer.
  31177. 21:17:30So this extension you have to install.
  31178. 21:17:32So this is the like author you can
  31179. 21:17:35install this extension. I already
  31180. 21:17:36installed that. Now after installing
  31181. 21:17:38this, you'll be able to see your data uh
  31182. 21:17:41data uh sorry database. Now let's double
  31183. 21:17:44click and you will see that all of the
  31184. 21:17:47information it has saved here. All of
  31185. 21:17:48the like checkpoint you can see. Okay.
  31186. 21:17:51All of the checkpoint it has saved here
  31187. 21:17:54with a trade ID as well. And trade ID is
  31188. 21:17:56nothing but test ID as of now we have
  31189. 21:17:58given.
  31190. 21:18:00So now let's uh test the long-term
  31191. 21:18:02memory as well. That means uh it is able
  31192. 21:18:05to save my um save uh my long-term
  31193. 21:18:09memory in my uh conversation database or
  31194. 21:18:11not. I think you remember we used SQL
  31195. 21:18:14SQL alchemy database for that right. Um
  31196. 21:18:17so if you are um if you are let's say
  31197. 21:18:20doing any kinds of conversation with
  31198. 21:18:22your uh chatbot if you want to remember
  31199. 21:18:24something okay that means the long-term
  31200. 21:18:27conversation uh it will also remember
  31201. 21:18:28with the help of this database. So for
  31202. 21:18:30this we'll test that uh that's why I
  31203. 21:18:32have given a prompt my name is BP
  31204. 21:18:35remember that and uh I think you know
  31205. 21:18:37that in database
  31206. 21:18:39uh database.py we created a function
  31207. 21:18:41called save memory okay save memory and
  31208. 21:18:44this thing I created as a tool now
  31209. 21:18:47inside tools.py Pi you'll see that this
  31210. 21:18:50uh remember this uh tools will be using
  31211. 21:18:52this save memory save memory function
  31212. 21:18:54okay that means if user is giving any
  31213. 21:18:56kinds of conversation it will save
  31214. 21:18:58inside the memory the SQL alchemy memory
  31215. 21:19:00right and you it will automatically use
  31216. 21:19:03that tool if user wants to remember
  31217. 21:19:05something it will use this tool and it
  31218. 21:19:07will store that conversation uh in the
  31219. 21:19:10database itself okay we'll try to test
  31220. 21:19:11this part so for this we are giving this
  31221. 21:19:13prompt my name is Bumpy remember that
  31222. 21:19:16and uh if you want to execute first of
  31223. 21:19:17All you have to initialize the database.
  31224. 21:19:19Okay, because if you check the database
  31225. 21:19:20inside that we created a function called
  31226. 21:19:23uh init DB. Okay, we have to initialize
  31227. 21:19:25the database. First of all, database
  31228. 21:19:26would be created. All the table would be
  31229. 21:19:27created. Then we'll be able to store
  31230. 21:19:29that. So let's import it. So in the
  31231. 21:19:31app.py from database
  31232. 21:19:35import
  31233. 21:19:37db then we'll try to initialize the
  31234. 21:19:39database. Okay, now I think it will
  31235. 21:19:41work. Let's test it. I'll open up my
  31236. 21:19:44terminal.
  31237. 21:19:46Clear. I'll execute my app.py.
  31238. 21:19:51Now you can see that uh memory saved
  31239. 21:19:53successfully. Got it. By I remembered
  31240. 21:19:55your name. Now if I uh go back now
  31241. 21:19:58you'll see that this database uh
  31242. 21:20:00database is created. Chatbot memory.
  31243. 21:20:02This is my SQL alchemy database. Now if
  31244. 21:20:04I open this okay now you'll be able to
  31245. 21:20:06see the uh table. Okay. All the three
  31246. 21:20:08table has created chat message
  31247. 21:20:09conversations and long-term memory. And
  31248. 21:20:11it will save in the long-term memory I
  31249. 21:20:13think remember in the database. So I
  31250. 21:20:15think remember whenever it will save
  31251. 21:20:17something right save memory it will use
  31252. 21:20:20my long-term memory okay long-term table
  31253. 21:20:24long-term memory table so in the
  31254. 21:20:25long-term memory table you'll see that
  31255. 21:20:27it has saved my information my name is
  31256. 21:20:29puppy okay so that's how uh it will it
  31257. 21:20:32is working okay so right now if you are
  31258. 21:20:34asking let's say
  31259. 21:20:37what is my name now it will use that uh
  31260. 21:20:42sorry not here I have to ask it here
  31261. 21:20:49what is my name. Now it will use that um
  31262. 21:20:56tool that means this tool again
  31263. 21:21:00recall memory tool and it will search in
  31264. 21:21:02the memory that means in the database
  31265. 21:21:04and uh it will get this information and
  31266. 21:21:06it will reply that. Let me show you.
  31267. 21:21:18Okay. You can see your name is Baki. So
  31268. 21:21:22it is using
  31269. 21:21:24your conversation story. Okay. That
  31270. 21:21:27means your long-term long-term memory.
  31271. 21:21:29Yeah. So everything is working fine
  31272. 21:21:31guys. Uh uh we have already tested and
  31273. 21:21:33our workflow is working great. Now what
  31274. 21:21:35we have to do guys? we have to uh we
  31275. 21:21:38have to uh create the front end that
  31276. 21:21:41means the user interface we'll be taking
  31277. 21:21:44all of the message from the user and
  31278. 21:21:46we'll try to connect with the back end
  31279. 21:21:47that means we'll create a fast API
  31280. 21:21:48server and there we'll try to make the
  31281. 21:21:50communication okay so to for the front
  31282. 21:21:54end guys uh here we will be using this
  31283. 21:21:56HTML uh file index html file inside that
  31284. 21:21:59we'll be writing all of the HTML CSS
  31285. 21:22:01JavaScript code whatever you need for
  31286. 21:22:03this user interface okay the user
  31287. 21:22:04interface we created And again if you
  31288. 21:22:07are not familiar with these kinds of
  31289. 21:22:08HTML, CSS, okay, JavaScript, no need to
  31290. 21:22:12worry. Even I also took the help from
  31291. 21:22:14ChatgPT. I already uh generated this
  31292. 21:22:17template from Chad GPT and ChatgPT
  31293. 21:22:20written that HTML, CSS, JavaScript code
  31294. 21:22:22for me. Whatever required for this user
  31295. 21:22:25interface. Okay. But uh in your team
  31296. 21:22:28there would be some kinds of person they
  31297. 21:22:29will be working on this front- end
  31298. 21:22:30design part. You don't need to worry
  31299. 21:22:32about that. So let me show you. This is
  31300. 21:22:35the code I have generated from chartg
  31301. 21:22:37guys. Again you don't need to remember
  31302. 21:22:39this code. You can take from uh you can
  31303. 21:22:42generate this code from chartg or gemini
  31304. 21:22:44whatever you want. So here is the HTML
  31305. 21:22:47CSS everything I have written in the
  31306. 21:22:49single file itself. This is the design
  31307. 21:22:51of that front end. Each and everything
  31308. 21:22:53you can see color.
  31309. 21:22:56So this is a big file.
  31310. 21:23:00See okay all of the front end uh code I
  31311. 21:23:05have written here and the see this is
  31312. 21:23:07the JavaScript code okay so in the
  31313. 21:23:09JavaScript some um um that means uh
  31314. 21:23:13backend API is getting triggered as well
  31315. 21:23:15I'll show you these are the part see
  31316. 21:23:18this is the entire code we have
  31317. 21:23:20generated from chat GPT
  31318. 21:23:23okay chat GPT and one more thing I have
  31319. 21:23:26done uh I think you saw the voice mode
  31320. 21:23:28right here is the voice mode see this
  31321. 21:23:30This void mode you can add two way you
  31322. 21:23:33can use the Python voice API inside
  31323. 21:23:36Python I think you know there is a
  31324. 21:23:38library called speech uh speech
  31325. 21:23:40recognization library you can use that
  31326. 21:23:42for this voice voice mode either in
  31327. 21:23:46already this um uh JavaScript okay
  31328. 21:23:49JavaScript there is a library uh there
  31329. 21:23:51is a library called let me show you
  31330. 21:23:56this voice features
  31331. 21:24:14Yeah. So here is the code part. So in
  31332. 21:24:16JavaScript uh there is a already inbuilt
  31333. 21:24:18library called speech recognization. So
  31334. 21:24:20we're using this speech recognization
  31335. 21:24:22library here. Okay. You can see we're
  31336. 21:24:24using this speech recognization library
  31337. 21:24:26and automatically it will use your uh
  31338. 21:24:29Windows microphone. Okay. And uh it will
  31339. 21:24:32uh start uh listening you. Okay. And
  31340. 21:24:34whatever uh speech you will give and it
  31341. 21:24:37will try to listen it will try to
  31342. 21:24:40understand and it will try to convert
  31343. 21:24:41that speech to text. Okay. So this is
  31344. 21:24:43already available inside JavaScript. Uh
  31345. 21:24:45if you have already studied about
  31346. 21:24:46JavaScript I think you know that this
  31347. 21:24:48library is available. So you don't need
  31348. 21:24:50to separately write inside Python. Okay.
  31349. 21:24:52You can directly use the JavaScript
  31350. 21:24:54functionality here. So we have already
  31351. 21:24:55used the JavaScript functionality and we
  31352. 21:24:57are doing the speech recognization that
  31353. 21:24:58means this part. Okay. Now if you click
  31354. 21:25:00here it will start listening. Okay. And
  31355. 21:25:03uh you can uh like um tell something and
  31356. 21:25:05it will automatically recognize that. So
  31357. 21:25:07we're using this part here. Okay. So
  31358. 21:25:09yes, this is the entire HTML, CSS and
  31359. 21:25:11JavaScript code we have written inside
  31360. 21:25:13HTML and uh index.html. And this code
  31361. 21:25:15you can generate um from chatgi
  31362. 21:25:19anywhere. Even you can also copy this
  31363. 21:25:20code and you can give uh give it to the
  31364. 21:25:22chart GP and you can ask explain this
  31365. 21:25:24code in a simple manner. You'll see that
  31366. 21:25:26it will explain like what are the
  31367. 21:25:27functionality it it has already. Okay.
  31368. 21:25:30But don't worry this uh front end part
  31369. 21:25:33um you can implement
  31370. 21:25:35um uh with any kinds of front- end
  31371. 21:25:37developer. You can see it with them. You
  31372. 21:25:39can um just tell your expectation what
  31373. 21:25:41kinds of front end you need. They will
  31374. 21:25:43try to develop for that. But uh uh if
  31375. 21:25:45you're creating production grade uh like
  31376. 21:25:48uh application better to use any front-
  31377. 21:25:50end framework for that like nextjs is
  31378. 21:25:52there okay in market next JS is there
  31379. 21:25:58next JS is there react is there okay
  31380. 21:25:59these are the framework you can use for
  31381. 21:26:01this kinds of front-end development okay
  31382. 21:26:05but here uh we are creating this front
  31383. 21:26:08end with the help of HTML CSS and
  31384. 21:26:09JavaScript
  31385. 21:26:12now let me show you how this our design
  31386. 21:26:15uh will look like. For this uh we'll
  31387. 21:26:17just write our first API code that means
  31388. 21:26:19our first API server. So for this we can
  31389. 21:26:22write inside our app.py. Let's open it
  31390. 21:26:24up. And this part we can maybe keep
  31391. 21:26:27inside our test.py. Okay. Let's create
  31392. 21:26:29another file called test.py.
  31393. 21:26:35I'm not going to delete it. I'm just
  31394. 21:26:37keeping it just for your reference.
  31395. 21:26:38Okay. Now in the app.py, I'll just
  31396. 21:26:40remove everything.
  31397. 21:26:43Now let's uh import all the necessary
  31398. 21:26:44library.
  31399. 21:26:48Yeah. So again I will import this
  31400. 21:26:53ENB where certify and this is for the uh
  31401. 21:26:56path issue. Okay. We have to add then
  31402. 21:26:59we'll be importing the fast API
  31403. 21:27:02related functionality. So you can see
  31404. 21:27:04we're importing JSON UI ID. I need for
  31405. 21:27:08this trading. Okay. every time we need
  31406. 21:27:10to create a unique trade and for this UI
  31407. 21:27:11it is required then you click on fast
  31408. 21:27:14API okay fast API from fast API
  31409. 21:27:16importing these are the libraries okay
  31410. 21:27:18and here we'll be showing the streaming
  31411. 21:27:20response and inside fast API already
  31412. 21:27:22streaming response function is there you
  31413. 21:27:24can use that then JSON response then
  31414. 21:27:26ginger template so these are the things
  31415. 21:27:28we need and definitely you should have
  31416. 21:27:30little bit knowledge on fast API okay
  31417. 21:27:32how fast API works here then um from
  31418. 21:27:38lang chain we'll be importing these are
  31419. 21:27:40the functionality so we are importing
  31420. 21:27:42human message AI message AI message
  31421. 21:27:44chunk tool message okay so basically
  31422. 21:27:46we'll be uh doing the verification like
  31423. 21:27:48what kinds of response we are getting
  31424. 21:27:50from the workflow whether it is human
  31425. 21:27:53message AI message okay or AI message
  31426. 21:27:56some tool message based on that we'll
  31427. 21:27:57try to filter out the content
  31428. 21:28:01and uh apart from that I also need to
  31429. 21:28:04import my agent
  31430. 21:28:06okay agent
  31431. 21:28:08From agent we're importing our get agent
  31432. 21:28:10function. This will return me the agent.
  31433. 21:28:12Let me close these are the things.
  31434. 21:28:18Then after that we'll be importing some
  31435. 21:28:20other functionality from the database.
  31436. 21:28:27So from database we're importing init
  31437. 21:28:29database. Init uh DB save chat message.
  31438. 21:28:33Okay that means this function save chat
  31439. 21:28:35message. Then we are importing get chat
  31440. 21:28:38history. Okay, get chat history. Then
  31441. 21:28:41create or update conversation. This
  31442. 21:28:44function and list conversation. Okay,
  31443. 21:28:46these are the functionality I need.
  31444. 21:28:49Then from rag and tools I'll import.
  31445. 21:28:55So from rag I'll import this add
  31446. 21:28:57documents to rag. That means if user is
  31447. 21:29:00asking any uh uploading any document
  31448. 21:29:02we'll try to call this function. First
  31449. 21:29:03of all, it will add the document to the
  31450. 21:29:06rack. Okay, that means my vector is
  31451. 21:29:09stored. Then from tools, we are
  31452. 21:29:11importing send current trade ID because
  31453. 21:29:13every time I need to create a unique
  31454. 21:29:15trade ID if user is creating the trades.
  31455. 21:29:17Okay, so these are the functionality I
  31456. 21:29:19need to import. Now let's initialize the
  31457. 21:29:21first API.
  31458. 21:29:26So we'll initialize the first API.
  31459. 21:29:28That's how we can initialize the first
  31460. 21:29:30API. and we can redirect a folder that
  31461. 21:29:32means the templates inside templates
  31462. 21:29:34folder I have my HTML CSS and JavaScript
  31463. 21:29:36code that's why we are giving this
  31464. 21:29:37directory then we are again creating
  31465. 21:29:39these two folder if it is not available
  31466. 21:29:41uploads and data and we'll be
  31467. 21:29:44initializing the database
  31468. 21:29:46my SQL alchemy database okay database
  31469. 21:29:48should be initialized first of all then
  31470. 21:29:52let's create the default route so this
  31471. 21:29:54is our default route okay and here we're
  31472. 21:29:57using uh asynchronous asynchronous
  31473. 21:29:59programming is uh because uh instead of
  31474. 21:30:02running my
  31475. 21:30:04endpoint uh as a sequence I can run in
  31476. 21:30:06parallel and this concept I have already
  31477. 21:30:08told you uh I have already discussed in
  31478. 21:30:10my playlist you can see a synchronous
  31479. 21:30:12programming is available you can go
  31480. 21:30:14through that okay why asynchronous
  31481. 21:30:15programming is required for AI agents
  31482. 21:30:17okay uh especially it is already
  31483. 21:30:19integrated in fast API if you're using
  31484. 21:30:21fast API you can integrate this
  31485. 21:30:22asynchronous programming so please go
  31486. 21:30:24through this session you will understand
  31487. 21:30:25why asynchronous programming is required
  31488. 21:30:26I'm not going to explain this part okay
  31489. 21:30:28again so Yeah, that's why I'm using as
  31490. 21:30:30keyword and this is my home route. That
  31491. 21:30:33means my default route. If user is
  31492. 21:30:34visiting our uh let's say uh server, you
  31493. 21:30:37will be able to see that index.html
  31494. 21:30:39page. Okay, we are rendering that here.
  31495. 21:30:41Now, let me show you. Let's um
  31496. 21:30:45render it.
  31497. 21:30:52Yeah, we'll try to render. So here we'll
  31498. 21:30:55uh we'll mention two more things in my
  31499. 21:30:56environment variable which is the
  31500. 21:31:02app host and app port or you can also
  31501. 21:31:04directly write here
  31502. 21:31:08host should be
  31503. 21:31:130
  31504. 21:31:160.0.0 0 this is my local host at port
  31505. 21:31:20number I'll give
  31506. 21:31:238 0 8 0 okay now this two part I don't
  31507. 21:31:27need
  31508. 21:31:30here it should be app because my file
  31509. 21:31:32name is app and inside that I'm creating
  31510. 21:31:34a app app uh object okay now this is my
  31511. 21:31:38host this is my port and it will reload
  31512. 21:31:39every time whenever you will change
  31513. 21:31:41something and with the help of uon we're
  31514. 21:31:43running the first API server yeah so
  31515. 21:31:46everything is fine now let me execute
  31516. 21:31:47and show you. Uh so first of all I'll
  31517. 21:31:51close my previous application. Okay,
  31518. 21:31:53previous application is also running.
  31519. 21:31:58Now let's clear. [clears throat]
  31520. 21:32:00Now python app.py.
  31521. 21:32:10Now I'll give the permission.
  31522. 21:32:12It is running on post uh local host port
  31523. 21:32:15number 80080. Let's open it up.
  31524. 21:32:19Local host port number 80080.
  31525. 21:32:26So this is the interface guys. Okay. We
  31526. 21:32:28have created uh with the help of chat
  31527. 21:32:30GPT. Okay. So it has all the button this
  31528. 21:32:34uh chat input box, document uploader
  31529. 21:32:36option, this voyage option, then you can
  31530. 21:32:39select the models from the front end,
  31531. 21:32:41send the prompt. Okay. So each and
  31532. 21:32:42everything we have created here. Now we
  31533. 21:32:44have to make it as functional.
  31534. 21:32:46So first of all uh here what I'm going
  31535. 21:32:48to do I'm going to write more route
  31536. 21:32:51here. So
  31537. 21:32:54first of all here what I'm going to do
  31538. 21:32:55I'm going to write a route that route
  31539. 21:32:57will fetch all of my previous trades I
  31540. 21:33:00have done the chat operation. Okay that
  31541. 21:33:02means uh if you saw like uh previously
  31542. 21:33:05it is you can see all of the trades
  31543. 21:33:07previously whatever trades I did the
  31544. 21:33:08conversation right you can switch
  31545. 21:33:09between any of the trades you can see
  31546. 21:33:11that. So this thing I have to fetch for
  31547. 21:33:13this. What I can do? I can write a route
  31548. 21:33:15here. So this is the route
  31549. 21:33:22after this home route. I'll add this.
  31550. 21:33:24Okay. / conversation. Okay. And this /
  31551. 21:33:27conversation we are calling inside my
  31552. 21:33:30JavaScript. Let me show you here. This
  31553. 21:33:34is the function we have written. So this
  31554. 21:33:36will basically call this route. Okay.
  31555. 21:33:38and it will load all of the conversation
  31556. 21:33:40conversation trades and it will show in
  31557. 21:33:42the front end. Okay, now let me show you
  31558. 21:33:45if I refresh.
  31559. 21:33:48No chats is available.
  31560. 21:33:54Okay, now let me do the chat and let me
  31561. 21:33:57show you because right now we haven't
  31562. 21:33:59done any chat operation, right? That's
  31563. 21:34:00why it's not showing.
  31564. 21:34:04Okay, this is the first time we are
  31565. 21:34:06doing right. So first time you won't be
  31566. 21:34:08able to see the conversation but let
  31567. 21:34:10let's complete it then I will show you.
  31568. 21:34:11Okay. Yeah. Then uh the second thing we
  31569. 21:34:15have to add which is this uh this one
  31570. 21:34:19actually this features. So let's say now
  31571. 21:34:21if I switch to any any let's say um uh
  31572. 21:34:25trades. So let me run this previous app
  31573. 21:34:27then I think I can explain better.
  31574. 21:34:33Yeah now this is running. Now see if I
  31575. 21:34:35click on any of the trades right so
  31576. 21:34:38you'll see that the previous
  31577. 21:34:39conversation story today I'm able to see
  31578. 21:34:40that okay that means each of the trades
  31579. 21:34:42is having a conversation okay so this
  31580. 21:34:45conversation uh I have to also load for
  31581. 21:34:47this I'll be creating another route in
  31582. 21:34:50my first API server so this is the work
  31583. 21:34:52of fast API right you can create
  31584. 21:34:54different different route and you can uh
  31585. 21:34:56hit that a um route anytime okay from
  31586. 21:34:58your u javascript code or any other code
  31587. 21:35:02you can hit
  31588. 21:35:05So here this is the route I have created
  31589. 21:35:08called history and it will take the
  31590. 21:35:10trade ID as well. That means which trade
  31591. 21:35:12you want to uh see the conversation.
  31592. 21:35:14Okay. You have to give the trade ID. So
  31593. 21:35:16trade ID. So basically this will get the
  31594. 21:35:19story. Okay. How you'll get the history?
  31595. 21:35:21Because we are using this get history
  31596. 21:35:24function from the database. Okay. And
  31597. 21:35:25previously here you can see for
  31598. 21:35:27conversation we are using list
  31599. 21:35:29conversation function. Okay. It will
  31600. 21:35:30list all of the conversation. So this
  31601. 21:35:32two function we are using here. Okay.
  31602. 21:35:34And this slash story we are calling
  31603. 21:35:37inside my
  31604. 21:35:39uh JavaScript. Let me show you. See here
  31605. 21:35:42we are calling this / story. Okay. First
  31606. 21:35:44of all you're getting the um traits then
  31607. 21:35:46we are getting the story and all of the
  31608. 21:35:48message you are able to see that. Okay.
  31609. 21:35:50So this is the function you need here.
  31610. 21:35:52Done. Now the next functionality I have
  31611. 21:35:55to write for the upload operation. Let's
  31612. 21:35:56say if user is uploading any kinds of
  31613. 21:35:58documents. If they're uploading any
  31614. 21:36:00kinds of documents, what will happen?
  31615. 21:36:01Let's try to do that. So for this I have
  31616. 21:36:04written this function
  31617. 21:36:07written this route.
  31618. 21:36:14This is the route. Okay. / upload. So it
  31619. 21:36:19will uh take the uploaded documents. And
  31620. 21:36:21after that here we are calling that
  31621. 21:36:23function. Let me show you. So we are
  31622. 21:36:25taking the file name. We're taking the
  31623. 21:36:27file and we are generating the unique ID
  31624. 21:36:30of the file. Okay. Then here create and
  31625. 21:36:33upload the conversation. Okay.
  31626. 21:36:36Uh so here uh basically we are calling
  31627. 21:36:39this function just to uh just to save
  31628. 21:36:42the message that the user has uploaded
  31629. 21:36:43any documents here. It will also save in
  31630. 21:36:45the story that means the database story.
  31631. 21:36:48We are using this function and here we
  31632. 21:36:50are using this add rag uh documents to
  31633. 21:36:52the rag this function. So this function
  31634. 21:36:54basically will read that documents,
  31635. 21:36:56process it and it is stored in the
  31636. 21:36:57vector database. Okay. Then we are
  31637. 21:37:00returning the response. So I think you
  31638. 21:37:01are getting okay what we are doing here.
  31639. 21:37:03Very simple. Okay. So every time
  31640. 21:37:05whatever user is doing you have to save
  31641. 21:37:06in the database. Okay. All the activity
  31642. 21:37:09you have to save in the database then
  31643. 21:37:10you are doing the other stuff.
  31644. 21:37:13Now we'll do the general conversation
  31645. 21:37:20like um if user is asking anything this
  31646. 21:37:24will hit my
  31647. 21:37:26chat route that means I will be able to
  31648. 21:37:28see my streaming response. So this is
  31649. 21:37:31for this this is the function I have
  31650. 21:37:32written.
  31651. 21:37:34Okay again I'm using asynchronous
  31652. 21:37:36because I want to run in parallel. So I
  31653. 21:37:38named it as chat stream. So this is the
  31654. 21:37:40route / chat/stream
  31655. 21:37:44and uh this thing also you are calling
  31656. 21:37:46from this
  31657. 21:37:49JavaScript.
  31658. 21:37:53Okay, as you can see so JavaScript is
  31659. 21:37:56hitting that route and uh we are taking
  31660. 21:37:59the user message trade. Okay, trade we
  31661. 21:38:02are taking and every time uh whenever
  31662. 21:38:05let's say uh user is uh clicking on new.
  31663. 21:38:09Okay, new that means new button that
  31664. 21:38:11time what will happen a new trade would
  31665. 21:38:13be created and here we are setting the
  31666. 21:38:14trade ID that time. So trade we're
  31667. 21:38:16taking selected model we're taking. Then
  31668. 21:38:18we are preparing the user message. We
  31669. 21:38:21are initializing the agent. As you can
  31670. 21:38:22see we are calling the get agent
  31671. 21:38:24function and this will give me the
  31672. 21:38:25agent. Okay. After that we are updating
  31673. 21:38:29the conversation in the database. Then
  31674. 21:38:31we are saving the chat message as well.
  31675. 21:38:33That means every time it will save the
  31676. 21:38:34conversation. Okay. Whatever
  31677. 21:38:36conversation user is doing or it will
  31678. 21:38:38set in the chat message. That means in
  31679. 21:38:39the chat message table here in this
  31680. 21:38:41table. Okay. It will save all the
  31681. 21:38:43conversation. After that we are setting
  31682. 21:38:45the current trade id. We are preparing
  31683. 21:38:47the config that means the trade and we
  31684. 21:38:50are written we have written another
  31685. 21:38:52function called event generator. Okay.
  31686. 21:38:54So here it is using asynchronous.
  31687. 21:38:56Uh so here basically what we are doing
  31688. 21:38:58we preparing the human message. Then we
  31689. 21:39:00are running the stream stream code. You
  31690. 21:39:02can see we are doing this agent. We are
  31691. 21:39:05passing all of the input and
  31692. 21:39:06configuration and we are just showing
  31693. 21:39:08the answer token by token. And for this
  31694. 21:39:10we are using some kinds of utility
  31695. 21:39:12function like should stream chunk. then
  31696. 21:39:14SSE data. Okay, these are the things you
  31697. 21:39:16need. Uh because sometimes whenever you
  31698. 21:39:19are uh calling any kinds of tool, tool
  31699. 21:39:21will give you the raw response and this
  31700. 21:39:23raw response you don't want to show in
  31701. 21:39:25the front end, right? So for this you
  31702. 21:39:26have to do the some filter operation. So
  31703. 21:39:28this code I have written here. Let me
  31704. 21:39:30show you.
  31705. 21:39:41So this is the code. These are the
  31706. 21:39:42utility function unit.
  31707. 21:39:45Yeah. SEC data. Then should stream
  31708. 21:39:48chunk. So basically it will first of all
  31709. 21:39:49check whether it a tool to tool
  31710. 21:39:51response. Okay. Then it is a AI message
  31711. 21:39:54or not. Okay. These kinds of things
  31712. 21:39:55verification it will do. Then it will
  31713. 21:39:57extract the text from the chunk. That
  31714. 21:40:00means instead of uh getting the raw
  31715. 21:40:02message it will only take the content
  31716. 21:40:04and it will return you. Okay. So this is
  31717. 21:40:06what actually we're using in this
  31718. 21:40:07function. You can see we're using in
  31719. 21:40:08this function. should stream extract uh
  31720. 21:40:12from chunk as a token by token then we
  31721. 21:40:15are showing it in the console and every
  31722. 21:40:17time we're doing the yield operation
  31723. 21:40:19okay so if you're using uh asynchronous
  31724. 21:40:23I think you know what is yield right uh
  31725. 21:40:25you can go through that recording okay
  31726. 21:40:28then we are using u past api streaming
  31727. 21:40:30response function and we're giving this
  31728. 21:40:32event generator uh function inside that
  31729. 21:40:35okay so basically this will show my uh
  31730. 21:40:38response as a streaming one by one
  31731. 21:40:40token. Yeah. So, yes, uh this is the uh
  31732. 21:40:43code you just need to write in the first
  31733. 21:40:45API server, fast API uh endpoint now. I
  31734. 21:40:48think everything is ready.
  31735. 21:40:51Let me see.
  31736. 21:40:58So, everything is ready. Now, we can
  31737. 21:40:59test our app. I'll come here. Refresh.
  31738. 21:41:03Okay. Now, let's do chat operation. Hi,
  31739. 21:41:07I am Buppy.
  31740. 21:41:10Let's send it. Okay. If you send it, so
  31741. 21:41:12what will happen? It will hit that
  31742. 21:41:16this route. Okay. Chat stream route.
  31743. 21:41:22So you can see uh hi BP, it's nice to
  31744. 21:41:24meet you. How I can help you today? And
  31745. 21:41:26it has also taken the trade. Right now I
  31746. 21:41:28can create another trade. Again I'll do
  31747. 21:41:31some message. Let's say
  31748. 21:41:33my name is
  31749. 21:41:36Alex.
  31750. 21:41:41Okay. Okay. Alex, I have saved your
  31751. 21:41:43memory. Nice to meet you. Okay. This is
  31752. 21:41:46uh another trade. This is another
  31753. 21:41:47trades. Okay. And if I click here, you
  31754. 21:41:49can see the conversation here. Okay. You
  31755. 21:41:51can see the conversation here. Why it is
  31756. 21:41:54happening? Because of these two function
  31757. 21:41:55two um
  31758. 21:41:58two method. One is uh this last
  31759. 21:42:00conversation. it is uh it is actually um
  31760. 21:42:04filtering out all of the trades you have
  31761. 21:42:06in the database. Now if I show you my
  31762. 21:42:08database right the chat memory database
  31763. 21:42:10now see every time whatever conversation
  31764. 21:42:12you are doing chat message you are doing
  31765. 21:42:16yeah so I have refreshed now see this
  31766. 21:42:18conversation is available so whatever
  31767. 21:42:20conversation you are doing right hi my
  31768. 21:42:21name is Buffy okay blah blah blah all
  31769. 21:42:24the conversation you will see with the
  31770. 21:42:25trade ID here okay trade ID here and uh
  31771. 21:42:29here is the conversation
  31772. 21:42:32and here is the long-term memory okay so
  31773. 21:42:34that's how we are saving inside our
  31774. 21:42:36database every
  31775. 21:42:38Now let's uh test uh any other message
  31776. 21:42:41that say tell tell me
  31777. 21:42:46the latest
  31778. 21:42:51news
  31779. 21:42:53in AI. So basic uh it will uh use the
  31780. 21:42:56search tool that time. Let's see see it
  31781. 21:42:58is using web search tool.
  31782. 21:43:06and see you are getting the response.
  31783. 21:43:09Now let's ask another question.
  31784. 21:43:11Calculate
  31785. 21:43:13this.
  31786. 21:43:26You'll see that it will use calculator
  31787. 21:43:28to
  31788. 21:43:37this is the response. Now you can also
  31789. 21:43:39upload any documents. So if you are
  31790. 21:43:40uploading right now so it will hit this
  31791. 21:43:42route upload route / upload this one.
  31792. 21:43:45Okay. And it will create the vector
  31793. 21:43:47store. You can see that vector store
  31794. 21:43:49would be created and you can perform the
  31795. 21:43:51chat operation on top of that. Let's
  31796. 21:43:52upload. Let's have a upload
  31797. 21:43:55my resume.
  31798. 21:44:00Done. Now you can see the uploaded
  31799. 21:44:02documents as well. It is available in
  31800. 21:44:03the upload folder. See the document you
  31801. 21:44:05have uploaded. It is available. Now we
  31802. 21:44:07can perform the chart operation. Who is
  31803. 21:44:11Bier
  31804. 21:44:13Ahmed Baki
  31805. 21:44:17on PDF.
  31806. 21:44:22Now it will use document search that
  31807. 21:44:23means the rack tool. Okay. Now you can
  31808. 21:44:25see that the my vector store is created.
  31809. 21:44:27So this is my vector store. Okay. So
  31810. 21:44:30this is the beauty of this um chatbot.
  31811. 21:44:36Now see it is uh telling about me right?
  31812. 21:44:39Okay. Everything is working fine. Now
  31813. 21:44:41let's test the boys mode whether it's
  31814. 21:44:42working or not. Um
  31815. 21:44:47I'll give the permission.
  31816. 21:44:50How many years of experience Bktier
  31817. 21:44:52Ahmed Bi is having?
  31818. 21:44:57Okay, it is not able to recognize my
  31819. 21:44:59name.
  31820. 21:45:01Okay, let me do it again.
  31821. 21:45:06How many years of experience he is
  31822. 21:45:08having
  31823. 21:45:10now? Good. Now, let's send it.
  31824. 21:45:20Now see based on the uploaded documents
  31825. 21:45:21bkhmed bi has five plus years of
  31826. 21:45:23experience. Amazing. It's working fine.
  31827. 21:45:25Okay. Even you can do the wise mode as
  31828. 21:45:28well. Dictate mode as well. Okay. Now
  31829. 21:45:30you can select different different
  31830. 21:45:31model. Let's I'll select this model. Now
  31831. 21:45:33you can ask anything
  31832. 21:45:35uh tell me about
  31833. 21:45:38ML.
  31834. 21:45:43Now see it is telling you about ML. Now
  31835. 21:45:45you can generate code, you can uh do
  31836. 21:45:49realtime source operation, you can
  31837. 21:45:50upload your documents, you can use the
  31838. 21:45:52voice mode, you can create different
  31839. 21:45:54different trades. Okay. Anything you can
  31840. 21:45:56do like chat GPT. Okay. So our
  31841. 21:45:58application is prepared. Now we have
  31842. 21:46:00given some suggestion. You can also use
  31843. 21:46:02this suggestion to prepare a like
  31844. 21:46:04instance prompt. Okay. Instant prompt.
  31845. 21:46:06This is also possible. So yes guys uh
  31846. 21:46:09that's how we have created the entire
  31847. 21:46:11system and uh this is uh like a chat GPT
  31848. 21:46:14application we have created our own chat
  31849. 21:46:16GP we have created now we can deploy
  31850. 21:46:19this application over the cloud and we
  31851. 21:46:22can make it live so that other people
  31852. 21:46:23can use it and uh my request would be to
  31853. 21:46:26everyone just try to upgrade this uh
  31854. 21:46:28application as much as you can just try
  31855. 21:46:30to add integrate more features okay just
  31856. 21:46:32try to integrate more features more tool
  31857. 21:46:34see here I have used few tools right I
  31858. 21:46:37have used very few tools here.
  31859. 21:46:40Where's the tools?
  31860. 21:46:42Here is the tools. Okay, I have used
  31861. 21:46:43very tool few tools here. You can use as
  31862. 21:46:46much as tool you can. Okay, just try to
  31863. 21:46:48use as much as tool you can and make it
  31864. 21:46:50like more powerful. Okay, now you can
  31865. 21:46:55um also test the memory. My f colors is
  31866. 21:47:02red.
  31867. 21:47:13is red. Okay. Now you'll see that
  31868. 21:47:16it will save this information in the
  31869. 21:47:18memory.
  31870. 21:47:20Okay. Now you can ask what is
  31871. 21:47:25my favorite color.
  31872. 21:47:33Now it will use the long-term memory to
  31873. 21:47:36give you the response. Now see your
  31874. 21:47:37favorite colors is red. Okay. Now you
  31875. 21:47:39can also see in the long-term memory you
  31876. 21:47:42can open this memory. You can go to the
  31877. 21:47:44long-term memory. Refresh. So you'll see
  31878. 21:47:47that my favorite color is red. Okay.
  31879. 21:47:50Everything is available. Now in the lang
  31880. 21:47:53also you'll see that it's tracing your
  31881. 21:47:56execution. Now see GPT. Now all of the
  31882. 21:48:00trades you can see even the trades as
  31883. 21:48:02well in which trades how many
  31884. 21:48:04conversation you have done each and
  31885. 21:48:06everything you can see here okay all of
  31886. 21:48:08this thing you can monitor here
  31887. 21:48:10everything you can debug here okay see
  31888. 21:48:12everything is available
  31889. 21:48:14and this monitoring part also I told you
  31890. 21:48:16in my playlist
  31891. 21:48:18like how to monitor your AI agents and I
  31892. 21:48:22already explained about this lang okay
  31893. 21:48:24you can go through that so yes guys uh
  31894. 21:48:26everything is working fine uh we are
  31895. 21:48:29Uh now we'll try to deploy this project
  31896. 21:48:31over the AWS cloud as a CI/CD. We'll
  31897. 21:48:34just try to make it live because right
  31898. 21:48:36now it's running on local host. Now
  31899. 21:48:37we'll make it live. We'll try to do the
  31900. 21:48:39CI/CD deployment here.
  31901. 21:48:43So guys uh our app is ready. Now we'll
  31902. 21:48:46be deploying this uh application uh as a
  31903. 21:48:49CI/CD over the AWS cloud. But before
  31904. 21:48:52that let me push all the changes uh
  31905. 21:48:54because we have um updated all of the
  31906. 21:48:58component one by one. So simply here I'm
  31907. 21:49:01going to give
  31908. 21:49:03um updated all component
  31909. 21:49:14then I will push the changes
  31910. 21:49:19and apart from that I also added the
  31911. 21:49:21deployment step here as you can see uh
  31912. 21:49:23this is the deployment step we'll be
  31913. 21:49:25following
  31914. 21:49:26uh let me show
  31915. 21:49:31So now if I refresh in my GitHub
  31916. 21:49:37so see all the codes are updated. Okay.
  31917. 21:49:39And this is the deployment step guys
  31918. 21:49:41will be following. So here first of all
  31919. 21:49:43I will be logging with my AWS console.
  31920. 21:49:45Then there I will be creating IM user
  31921. 21:49:47that means identity access management.
  31922. 21:49:49After that u uh there we'll just try to
  31923. 21:49:53um give some of the permission. Okay.
  31924. 21:49:56like what are the services we'll be
  31925. 21:49:57using? So here we'll be using EC2
  31926. 21:49:59instance and ECR elastic container
  31927. 21:50:01registry. So in the elastic container
  31928. 21:50:03registry we'll try to store our docker
  31929. 21:50:05image. Okay, because we'll be using
  31930. 21:50:07docker service here to containerize
  31931. 21:50:09entire our application and uh we'll try
  31932. 21:50:11to store in the ECR service. CCR is a um
  31933. 21:50:15um I mean docker uh image storage
  31934. 21:50:16service. So there you can store any
  31935. 21:50:18kinds of docker image.
  31936. 21:50:20Uh so this is the uh description for the
  31937. 21:50:22deployment. First of all, we'll be
  31938. 21:50:23building the docker image of our source
  31939. 21:50:25code. Then we'll try to push this docker
  31940. 21:50:27image to the ECR elastic container
  31941. 21:50:29registry of AWS service. Then we'll
  31942. 21:50:31launch our EC2 machine. Uh it should is
  31943. 21:50:34a virtual machine. Then we'll try to
  31944. 21:50:36pull uh our image from ECR to EC2. Then
  31945. 21:50:40we'll try to run this u docker image as
  31946. 21:50:42a container. Then we'll do some port
  31947. 21:50:44mapping. After that uh we'll be able to
  31948. 21:50:47access the application. And these are
  31949. 21:50:49the policy we have to provide whenever
  31950. 21:50:50we'll be creating the im user. Okay. So
  31951. 21:50:52this is the entire step guys. I have
  31952. 21:50:54written all of the command everything
  31953. 21:50:55whatever you required I just mentioned
  31954. 21:50:57it here. So you just try to follow this
  31955. 21:50:58readmi file and we'll try to perform the
  31956. 21:51:00deployment but uh beforeh doing the
  31957. 21:51:03deployment guys you need some of the
  31958. 21:51:04file here. Um let me show you what are
  31959. 21:51:07the files you need. Yeah. So the first
  31960. 21:51:09uh things you need which is the
  31961. 21:51:11cic.imml.
  31962. 21:51:13Uh but before that let's create a
  31963. 21:51:15dockard file first of all. So docker
  31964. 21:51:20file.
  31965. 21:51:21Okay. So we'll be writing this docker
  31966. 21:51:24file docker file and again uh if you are
  31967. 21:51:27not familiar with docker uh then if you
  31968. 21:51:29are not familiar with uh this kinds of
  31969. 21:51:32mlops concept
  31970. 21:51:34so on my YouTube channel I already have
  31971. 21:51:36a complete uh mlops course guys here I
  31972. 21:51:39have already covered all kinds of mlops
  31973. 21:51:42tools like docker okay I have also
  31974. 21:51:44covered linux mlflow dbch and everything
  31975. 21:51:47but you don't need to cover all of them
  31976. 21:51:49uh if you are completely new with the
  31977. 21:51:50docker and all you can go through this
  31978. 21:51:52recording. I think dockard starts here.
  31979. 21:51:55Even you will see this u um timing.
  31980. 21:51:58Okay. Uh this time stamp. So from here
  31981. 21:52:01you can uh uh see right where is the
  31982. 21:52:03docker. Simply you can uh click on the
  31983. 21:52:05time stamp. You'll be able to see the
  31984. 21:52:07docker. So just try to learn if you
  31985. 21:52:09don't know about docker and if you want
  31986. 21:52:11to understand the docker command just
  31987. 21:52:13try to go through that recording. So
  31988. 21:52:15here let's try to add all the docker
  31989. 21:52:17related command. So this is our docker
  31990. 21:52:21file. Okay. And these are the command
  31991. 21:52:22you have to mention in the docker file.
  31992. 21:52:24So first of all we're taking the base
  31993. 21:52:25image and python 3.11 we are using. Then
  31994. 21:52:28we're creating the working directory.
  31995. 21:52:31Then we are setting some environment
  31996. 21:52:33variable just to prevent some error.
  31997. 21:52:35Then we are running these are the
  31998. 21:52:37command and just to upgrade our uh um
  31999. 21:52:40like Ubuntu instance and u install some
  32000. 21:52:42tools. Then we're copying the
  32001. 21:52:44requirement.txt. We are installing the
  32002. 21:52:46requirement. TXT. After that we are
  32003. 21:52:48copying all of the source code in the
  32004. 21:52:49root directory. We are creating the
  32005. 21:52:51folders like uploads and data. These two
  32006. 21:52:52folders we're creating. Then after that
  32007. 21:52:54we're exposing the port. We are running
  32008. 21:52:56our application on port number 80080. So
  32009. 21:52:59I think you have seen that this is the
  32010. 21:53:01port. Okay. We are running our
  32011. 21:53:02application. Make sure you are giving
  32012. 21:53:04the same port. If you're changing the
  32013. 21:53:06port here you have to also change. Then
  32014. 21:53:08this is the command to run the our
  32015. 21:53:09app.py server. So you can um app uh so
  32016. 21:53:13we are um running the app.py. Inside
  32017. 21:53:15app.py we are having this app object.
  32018. 21:53:17Okay. We created this app object. So we
  32019. 21:53:19are running it here. Then we're uh
  32020. 21:53:21giving the host and as well as the put.
  32021. 21:53:23So this is the docker we have to write.
  32022. 21:53:25And if you're writing docker you need
  32023. 21:53:27another file here called dot
  32024. 21:53:31docker
  32025. 21:53:33ignore.
  32026. 21:53:35Inside that you will just write all of
  32027. 21:53:37these folders and file you don't need
  32028. 21:53:39whenever you are building the docker
  32029. 21:53:40image. Okay. So these are the things I
  32030. 21:53:42will avoid and that means any kinds of
  32031. 21:53:44virtual uh environment or these are the
  32032. 21:53:46file I'll just try to avoid whenever it
  32033. 21:53:48will build a docker image it's kind of
  32034. 21:53:50your g ignore. So whenever you are
  32035. 21:53:51pushing anything in the g github right
  32036. 21:53:53you are ignoring something in the get
  32037. 21:53:55ignore these are the files. So same
  32038. 21:53:56thing you have to write in the docker
  32039. 21:53:58ignore if you want to ignore anything
  32040. 21:54:00whenever you are creating the docker
  32041. 21:54:01image. Okay. Yeah. Then uh docker uh
  32042. 21:54:05file is done. Now we'll just try to
  32043. 21:54:07create a folder. I'm going to name it as
  32044. 21:54:09GitHub.
  32045. 21:54:11Inside that you have to create another
  32046. 21:54:13folder.
  32047. 21:54:15The folder name should be workflows.
  32048. 21:54:16Okay. Just make sure you are giving the
  32049. 21:54:18same name otherwise it will not work
  32050. 21:54:19because uh as a CI/CD tool guys here
  32051. 21:54:22we'll be using GitHub actions. Okay. Uh
  32052. 21:54:24I told you we'll be using CI/CD
  32053. 21:54:26approach. So if you are pushing your
  32054. 21:54:28code to the GitHub automatically it will
  32055. 21:54:30get deployed over the cloud. Okay. We'll
  32056. 21:54:31be creating that pipeline and as a CI/CD
  32057. 21:54:34tool we'll be using GitHub action and
  32058. 21:54:35GitHub action it is already available on
  32059. 21:54:37GitHub. Okay, it is already um um I mean
  32060. 21:54:40uh pre predefined setup. You don't need
  32061. 21:54:42to set up the GitHub um um sorry uh this
  32062. 21:54:45uh GitHub action server separately. It
  32063. 21:54:47is already running on GitHub. So that's
  32064. 21:54:49why you need this folder and workflows
  32065. 21:54:51and inside that you will be creating a
  32066. 21:54:52file called CICD
  32067. 21:54:56yiml yml. Okay. So this is the file. So
  32068. 21:54:59inside that you will you have to write
  32069. 21:55:01all the CI/CD related command and these
  32070. 21:55:04are the command you will be getting from
  32071. 21:55:06the internet only. If you just search uh
  32072. 21:55:09GitHub action CI/CD deployment um
  32073. 21:55:11command you will see this kinds of uh
  32074. 21:55:14code would be available over the
  32075. 21:55:16internet. Even you can also generate
  32076. 21:55:17from charge GPT. So this is the uh
  32077. 21:55:19command I have prepared guys. Here I
  32078. 21:55:20have mentioned all of these step and
  32079. 21:55:22command you need to perform whenever you
  32080. 21:55:24are doing the CI/CD. First of all we are
  32081. 21:55:26giving the name of this workflow. Then
  32082. 21:55:28whenever you are pushing your code on
  32083. 21:55:30the main branch that time what will
  32084. 21:55:32happen this will trigger. Okay. So in
  32085. 21:55:35continuous integration what we are doing
  32086. 21:55:37guys we are authenticating with the AWS
  32087. 21:55:39account uh with the help of this secret
  32088. 21:55:41key AWS access keys access uh secret
  32089. 21:55:44access key and region we are
  32090. 21:55:46authenticating then we are logging into
  32091. 21:55:47the Amazon ECR we are building the
  32092. 21:55:49docker image then we are pushing this
  32093. 21:55:51docker image to the Amazon ECR. Okay.
  32094. 21:55:53Then in continuous deployment what what
  32095. 21:55:55we are doing again we are authenticating
  32096. 21:55:56with the account our AWS account with
  32097. 21:55:59this credential then we are logging into
  32098. 21:56:00the ECR we are pulling that docker image
  32099. 21:56:03and we are running inside our EC2
  32100. 21:56:04machine. Okay so these are the commands
  32101. 21:56:06I have written guys and you know that to
  32102. 21:56:08run this application you need some
  32103. 21:56:10environment variable. So these are the
  32104. 21:56:12environment variable you need and all
  32105. 21:56:13the environment variable I have
  32106. 21:56:15mentioned here. Okay you can see I need
  32107. 21:56:16Google API key, Google model, table API,
  32108. 21:56:19lang. So whatever key you are using make
  32109. 21:56:21sure you are adding in as environment
  32110. 21:56:23variable. Okay. And we'll be write
  32111. 21:56:24reading it from the GitHub um GitHub
  32112. 21:56:26secrets. We'll try to add all of this
  32113. 21:56:28credential in the GitHub secrets because
  32114. 21:56:30directly I haven't mentioned inside my
  32115. 21:56:32code. So that's why always secret file
  32116. 21:56:34should be um written in secrets. Okay,
  32117. 21:56:36GitHub secrets. So yes uh this is the
  32118. 21:56:39entire cicd.iml and we'll be using this
  32119. 21:56:42file for the deployment and uh I'll
  32120. 21:56:44share all of these resources in the
  32121. 21:56:45description. From there you can check it
  32122. 21:56:47out. And if you want to learn more about
  32123. 21:56:49this CI/CD. ML and again just try to
  32124. 21:56:51check that uh MLOPS course there I
  32125. 21:56:54already discussed about the CI/CD. Okay.
  32126. 21:56:55So inside CI/CD I already explained that
  32127. 21:56:57concept you can go through that. So yeah
  32128. 21:57:00now uh let's try to follow the pipeline.
  32129. 21:57:05So if I go to my GitHub. So this is the
  32130. 21:57:08pipeline. First of all let's login with
  32131. 21:57:09the AWS console. Make sure you have the
  32132. 21:57:12AWS account guys. I already have the
  32133. 21:57:14account. I'll just try to login.
  32134. 21:57:17I'll just sign in with my management
  32135. 21:57:19console.
  32136. 21:57:34So here you just need to uh give your uh
  32137. 21:57:39authentication
  32138. 21:57:43authentication credential that means
  32139. 21:57:44your email and password. So let's give
  32140. 21:57:47my email and password and let me login
  32141. 21:57:48with my AWS console guys.
  32142. 21:57:52So this is my AWS uh console guys. Uh uh
  32143. 21:57:56just try to login and you will be able
  32144. 21:57:57to see this kinds of interface. So here
  32145. 21:57:59the first thing uh what we have to do we
  32146. 21:58:02have to create a IM user. Okay, let's
  32147. 21:58:04create the IM user. So here just search
  32148. 21:58:06for IM identity access management
  32149. 21:58:14and uh here I'll just click on IM user
  32150. 21:58:17create a new user I'll give the name
  32151. 21:58:19let's say BPI GPT
  32152. 21:58:23you can give any name you can attach the
  32153. 21:58:26policies now here you need these are the
  32154. 21:58:28policies Amazon EC2 full access and ECR
  32155. 21:58:32sorry ECR and EC2 elastic container
  32156. 21:58:35study and EC2 machine. So this is the
  32157. 21:58:37service here. I'll just try to search
  32158. 21:58:38and select
  32159. 21:58:40uh then I'll just try to add another
  32160. 21:58:42one. This one and
  32161. 21:58:46um this one Amazon EC2 full access.
  32162. 21:58:54Once we have done I'll just click on
  32163. 21:58:56next. Now see both uh permission I have
  32164. 21:58:58given. And why this permission is
  32165. 21:59:00required? because I want uh I don't want
  32166. 21:59:02to give the full access to my um to my
  32167. 21:59:06uh let's say project whenever it will do
  32168. 21:59:07the deployment uh otherwise um if any
  32169. 21:59:11mistakes is there it will be using any
  32170. 21:59:13other services as well okay there is a
  32171. 21:59:14possibility so to prevent that we're
  32172. 21:59:16only giving the permission the services
  32173. 21:59:19we're using from AWS okay now I'll just
  32174. 21:59:21create the user so user creation is done
  32175. 21:59:24now I'll click on the user
  32176. 21:59:26I'll go to the security credential
  32177. 21:59:29and here you'll see one option call
  32178. 21:59:31create access key. I'll select the first
  32179. 21:59:33option command line interface and
  32180. 21:59:35confirm do the confirmation. Click on
  32181. 21:59:37next. Now let's create the access key.
  32182. 21:59:39So this is our access key and secret
  32183. 21:59:41access key you need to authenticate your
  32184. 21:59:42AWS uh account from your Python client.
  32185. 21:59:45Okay. Now I'll just try to download as a
  32186. 21:59:47CSV file. Done. And make sure you just
  32187. 21:59:50keep this file. Uh I need it later on
  32188. 21:59:52whenever uh we just uh create the GitHub
  32189. 21:59:56secret. Okay. I'll just try to open in a
  32190. 21:59:58Notepad++. So this is the credential.
  32191. 22:00:00This is your access key ID. This is your
  32192. 22:00:02secret access key ID. Okay. Yeah.
  32193. 22:00:04Perfect. Now let's click on done. Now
  32194. 22:00:07the next step we have to follow. Uh we
  32195. 22:00:10have to create the ECR repo to store the
  32196. 22:00:11docker image. Now let's create the ECR
  32197. 22:00:13repo. I'll go to the home and I'll
  32198. 22:00:15search for ECR elastic container
  32199. 22:00:18registry. Okay. So this is a fully
  32200. 22:00:20managed docker container registry and
  32201. 22:00:23this is the alter alternative of docker
  32202. 22:00:24hub. Okay. The docker hub you used
  32203. 22:00:26right. In docker hub also you can store
  32204. 22:00:28the docker image here. Uh this service
  32205. 22:00:30actually has created. Okay, this is this
  32206. 22:00:32is the AWS container story. Now I'll
  32207. 22:00:35just create a new reg. Give the name.
  32208. 22:00:38I'll give
  32209. 22:00:41GPT. You can give any name everything
  32210. 22:00:44just keep it as it is. Now create this
  32211. 22:00:46repository. Okay, this is the repository
  32212. 22:00:48and copy this URI and keep it somewhere.
  32213. 22:00:50Okay, I need it later on. So maybe in
  32214. 22:00:52readmi file I'll just try to store here.
  32215. 22:00:54Okay.
  32216. 22:00:57Perfect.
  32217. 22:01:00Now uh it is also done. Now I'll again
  32218. 22:01:01click on home and see the next step.
  32219. 22:01:04Next step is you have to create a EC2
  32220. 22:01:06machine Ubuntu instance. Now let's
  32221. 22:01:08search for EC2 EC2 instance virtual
  32222. 22:01:12service in cloud.
  32223. 22:01:16And here I'll just try to launch an
  32224. 22:01:18instance.
  32225. 22:01:19Uh click on launch without walk through.
  32226. 22:01:23Now give the name. I'll give bi GPT
  32227. 22:01:28machine
  32228. 22:01:30again you can give uh any kinds of name
  32229. 22:01:32here then you have to select this Ubuntu
  32230. 22:01:34instance okay most of the production
  32231. 22:01:36server would be Ubuntu and there are
  32232. 22:01:38some other operating system as well but
  32233. 22:01:39select the Ubuntu one now here you can
  32234. 22:01:41uh you can select the instance type okay
  32235. 22:01:46like uh how much memory how much CPU you
  32236. 22:01:49need you can select from here so at
  32237. 22:01:51least here I'll just try to select this
  32238. 22:01:53four um sorry not this one huh uh 8 GB
  32239. 22:01:59memory okay this 8 GB memory at least
  32240. 22:02:01I'll be taking for this project and two
  32241. 22:02:04CPU cores but if you have a very let's
  32242. 22:02:07say uh I mean heavy project that time
  32243. 22:02:09you can use some heavy instance here
  32244. 22:02:11okay and all the instance how how much
  32245. 22:02:13it will charge per hour it has already
  32246. 22:02:15given you estimated cost so I'll select
  32247. 22:02:17this one
  32248. 22:02:18once it is done now you can create the
  32249. 22:02:20key value pair
  32250. 22:02:22this is optional uh optional means you
  32251. 22:02:24have to create it if you want to access
  32252. 22:02:26your EC2 instance from any third party
  32253. 22:02:28tools like mobile extreme and putty that
  32254. 22:02:29time it's required so I'll give
  32255. 22:02:33GPT
  32256. 22:02:34now let's create the key value here now
  32257. 22:02:37see one p file would be downloaded this
  32258. 22:02:39p credential you need whenever you want
  32259. 22:02:41to use any third party tool but I don't
  32260. 22:02:43want to use any third partyy tool I'll
  32261. 22:02:44be using uh this um instance in the same
  32262. 22:02:48AWS console only I'll tell you how to do
  32263. 22:02:50that now just try to select these two
  32264. 22:02:53options allow HTTPS and allow HTTP
  32265. 22:02:55traffic and uh you can also select your
  32266. 22:02:58storage like how much storage you need.
  32267. 22:03:00So I'll take uh 8 GB storage as of now
  32268. 22:03:02you can increase it okay as per your
  32269. 22:03:04requirement. Let's say you can take 32
  32270. 22:03:07GB or 16 GB as per your requirement.
  32271. 22:03:10So here I'll just try to launch the
  32272. 22:03:12instance
  32273. 22:03:21now. Click on view instance.
  32274. 22:03:29Now let's refresh. And you can see our
  32275. 22:03:32instance is running. Okay. Now I'll
  32276. 22:03:34click on this instance.
  32277. 22:03:36And here you will see one option called
  32278. 22:03:37connect button. Okay. Just click on
  32279. 22:03:39connect. And if you are using any third
  32280. 22:03:41party tools like mobile extreme and puty
  32281. 22:03:44that time you can use SSS client to
  32282. 22:03:45connect that. Okay. These are the
  32283. 22:03:46command you have to execute.
  32284. 22:03:48I'll just launch this uh terminal in the
  32285. 22:03:50same AWS uh console only. Now let's
  32286. 22:03:54connect that. Now see it will open a new
  32287. 22:03:57window and there you will see a Ubuntu
  32288. 22:03:59terminal and there you have to set up
  32289. 22:04:01everything.
  32290. 22:04:13So this is the Ubuntu terminal. Now
  32291. 22:04:15let's clear. Okay. And if you don't know
  32292. 22:04:18about Ubuntu again you can refer my
  32293. 22:04:20course. So there I already discussed
  32294. 22:04:22about the Linux operating system. Okay.
  32295. 22:04:24How to run the Linux command each and
  32296. 22:04:26everything. So first of all here uh I
  32297. 22:04:28have already given all of the command.
  32298. 22:04:30First of all you have to upgrade the
  32299. 22:04:32machine. So these are the command you
  32300. 22:04:33have to execute. Just try to copy and
  32301. 22:04:35right click and paste and run.
  32302. 22:04:39So this is a new launched machine and
  32303. 22:04:41here I have to upgrade and set up all of
  32304. 22:04:44the requirement tools I need here.
  32305. 22:04:48Then I'll copy the second command
  32306. 22:04:52and I'll execute.
  32307. 22:04:56So I'll give yes permission.
  32308. 22:04:59Yeah. So it will upgrade all of the
  32309. 22:05:00tools. Now here I have to install the
  32310. 22:05:03docker because initially there is no
  32311. 22:05:05docker in this instance. So this these
  32312. 22:05:07are the command you have to execute to
  32313. 22:05:08install the docker.
  32314. 22:05:24Okay, let's clear.
  32315. 22:05:27Paste.
  32316. 22:05:29Now I'll copy the next one.
  32317. 22:05:43Then I'll copy the next one.
  32318. 22:05:57Paste and run.
  32319. 22:05:58Then the last command this one.
  32320. 22:06:04Okay. So docker is installed
  32321. 22:06:06successfully. Now you can check it. So
  32322. 22:06:07docker
  32323. 22:06:09version. You can see this is the version
  32324. 22:06:12is running. Okay. Now the next thing
  32325. 22:06:15guys uh we have to configure our EC2 as
  32326. 22:06:17a self-hosted runner. That means we have
  32327. 22:06:18to connect. Okay. We have to connect our
  32328. 22:06:20GitHub repo with our AWS uh account.
  32329. 22:06:23Okay. So that if you are uh committing
  32330. 22:06:25any changes okay if you're pushing your
  32331. 22:06:27code it will automatically deployed over
  32332. 22:06:29the as cloud. So for this this is the
  32333. 22:06:31connection we have to build. So for this
  32334. 22:06:33make sure you are using your GitHub repo
  32335. 22:06:35guys the same repo you are updating your
  32336. 22:06:36project not my repo. So let's create
  32337. 22:06:38another um tab here because I want to
  32338. 22:06:42refer this command okay from this one.
  32339. 22:06:44So now here you have an option called
  32340. 22:06:46settings. Click on settings and there
  32341. 22:06:49you will see an option called action and
  32342. 22:06:50go to the runners. Okay. Now create a
  32343. 22:06:53new self-hosted runner.
  32344. 22:06:56Select this Linux
  32345. 22:06:59and you have to execute these are the
  32346. 22:07:00command one by one. Copy and execute in
  32347. 22:07:02the terminal.
  32348. 22:07:05So that's how we'll be connecting.
  32349. 22:07:08Now next command and execute.
  32350. 22:07:16Then again third command and execute.
  32351. 22:07:24Done. Now we have this command
  32352. 22:07:34done. Now I think uh we have executed
  32353. 22:07:38all of this command. Now we have to run
  32354. 22:07:39this configure command. Let's copy this
  32355. 22:07:41and execute.
  32356. 22:07:45Now see GitHub action initialized and it
  32357. 22:07:47has connected to my GitHub. Now it is
  32358. 22:07:49asking enter the name of the runner
  32359. 22:07:51group. I'll press enter simply. Now it
  32360. 22:07:53is asking enter the name of the runner.
  32361. 22:07:55Okay. Now name of the runner is
  32362. 22:07:58self-hosted.
  32363. 22:08:00Self-hosted. Okay. Make sure you're
  32364. 22:08:02giving the same name. I'll copy.
  32365. 22:08:05And here I'll just try to paste it.
  32366. 22:08:08Self-hosted. Then it is telling uh this
  32367. 22:08:11runner will have any following labels.
  32368. 22:08:13No. I'll press enter. Then it is telling
  32369. 22:08:15name of the work folder. I'll again
  32370. 22:08:17press enter. Okay. Done. Now the last
  32371. 22:08:19command you have to execute this one. So
  32372. 22:08:22if you execute your GitHub would be
  32373. 22:08:24connected to the AWS. Now see connected
  32374. 22:08:27to the GitHub and listening for the
  32375. 22:08:28jobs. Now if I come to my repo now if I
  32376. 22:08:32go to the runners again. Now you can see
  32377. 22:08:35that uh this status is idle. That means
  32378. 22:08:38my uh AWS is connected with my GitHub.
  32379. 22:08:40Now if I push anything in my GitHub, it
  32380. 22:08:43will automatically get triggered that
  32381. 22:08:46CI/CD pipeline and all of the uh code
  32382. 22:08:48would be deployed over my as cloud. But
  32383. 22:08:50before that we have to set this
  32384. 22:08:53credential. Okay, these are the secret
  32385. 22:08:55credential in my GitHub uh GitHub
  32386. 22:08:56secrets. So let's do that. So for this
  32387. 22:08:59again uh here you will see one option
  32388. 22:09:01called secret and variable. Click here
  32389. 22:09:03and click on this action. Now here
  32390. 22:09:06you'll see this repository secret. Just
  32391. 22:09:08click on new repository secret and here
  32392. 22:09:10you have to add all the secret one by
  32393. 22:09:11one. Now first of all you have to add
  32394. 22:09:12this Google API key or whatever API key
  32395. 22:09:14you are using you can add here one by
  32396. 22:09:16one. So this is my Google API key. Let's
  32397. 22:09:22copy that.
  32398. 22:09:26Yeah.
  32399. 22:09:29A copy and paste it here.
  32400. 22:09:36Done. Now next I will add my Google
  32401. 22:09:38model.
  32402. 22:09:47This the model
  32403. 22:09:54that's how you have to add all of the
  32404. 22:09:55secret one by one. Now API key.
  32405. 22:10:11Now next you have this langid tracing
  32406. 22:10:20should be true.
  32407. 22:10:27Now lang speed end point.
  32408. 22:10:38This is the end point.
  32409. 22:10:50Now lang spit API key.
  32410. 22:11:05Now next you have this lang project
  32411. 22:11:12project name. So this is the project
  32412. 22:11:14name bpg.
  32413. 22:11:19Done. Now we have to add the AWS related
  32414. 22:11:22credential. AWS access key.
  32415. 22:11:27So why do you have the access key in the
  32416. 22:11:29CSV file? I think you remember we have
  32417. 22:11:30already downloaded. Let's copy this
  32418. 22:11:32access key before the comma till here.
  32419. 22:11:35I'll copy and paste it.
  32420. 22:11:38Then next I have AWS secret access key.
  32421. 22:11:46And in this file only you have the
  32422. 22:11:48secret access key after this comma.
  32423. 22:11:50Okay, whatever values you have just try
  32424. 22:11:52to add in the secret
  32425. 22:11:55H. Now next you have this head of this
  32426. 22:11:58region.
  32427. 22:12:05So right now I'm inside this region
  32428. 22:12:07called North Virginia US East one. Okay.
  32429. 22:12:10If you're in other region you can give
  32430. 22:12:11the name. I'll give US East one.
  32431. 22:12:17Make sure you are writing in same way.
  32432. 22:12:23US East one.
  32433. 22:12:25US East one. Okay. H the secret. Now
  32434. 22:12:30last I have to add my ECR weapon name.
  32435. 22:12:37So where do you have the web name? I
  32436. 22:12:39think remember we copied one URI right
  32437. 22:12:44here. So here is the name. Just try to
  32438. 22:12:46copy after this slash and add it here.
  32439. 22:12:51Done. Okay. All of these secrets we have
  32440. 22:12:53added one by one. Now let's try uh it's
  32441. 22:12:55time to commit our changes. I'll go to
  32442. 22:12:57my repo.
  32443. 22:12:59Now let's commit the changes here.
  32444. 22:13:04CICD
  32445. 22:13:08add it.
  32446. 22:13:10Now push the changes.
  32447. 22:13:15Done. Now if I refresh
  32448. 22:13:18now see my action is running. We
  32449. 22:13:20workflow is running. Now I'll click on
  32450. 22:13:21action. Uh I'll open the CI/CD
  32451. 22:13:25workflow. Now see continuous integration
  32452. 22:13:27is running. So it is building the docker
  32453. 22:13:29image and pushing it to the ECR. All of
  32454. 22:13:30the execution you'll be able to see. So
  32455. 22:13:32let's wait. This process may take some
  32456. 22:13:34time.
  32457. 22:14:13building is done. Now it is
  32458. 22:14:16uh pushing the image to the uh ECR
  32459. 22:14:20elastic container registry.
  32460. 22:14:30You can even check in this year. So
  32461. 22:14:34let's create a new tab and I'll go to
  32462. 22:14:37the elastic container registry.
  32463. 22:14:39So this is my registry. I'll click here.
  32464. 22:14:41So see the image has been pushed.
  32465. 22:14:44Okay. Now it is running continuous
  32466. 22:14:45deployment. Now it will pull that ACR
  32467. 22:14:49image and it will run on my EC2.
  32468. 22:14:52Now see pulling is completed.
  32469. 22:15:02Now see it will run the docker image as
  32470. 22:15:04a container. Done. See all of the
  32471. 22:15:06execution are green that means
  32472. 22:15:08everything is fine. Now I'll come to my
  32473. 22:15:10instance and there is a option um URL
  32474. 22:15:13you will get public DNS. Just copy this
  32475. 22:15:15URL and paste it here and execute. See
  32476. 22:15:19initially this uh application will not
  32477. 22:15:21open because right now this is running
  32478. 22:15:22on port number 8080 but we haven't done
  32479. 22:15:24the port mapping. So if you want to do
  32480. 22:15:26the port mapping just come here and
  32481. 22:15:28there is a option called security. Click
  32482. 22:15:29on security. Go to the security groups
  32483. 22:15:33and you have one option called edit
  32484. 22:15:35inbound rules then add the rules and
  32485. 22:15:38here just try to add port number 8080
  32486. 22:15:41okay and just try to okay one more thing
  32487. 22:15:44you have to add this 0000 that means you
  32488. 22:15:46can access from anywhere then save the
  32489. 22:15:47rules then I will go to my instance
  32490. 22:15:52copy this
  32491. 22:15:54URL again and at the last I will give
  32492. 22:15:57port number 80080 okay now if I execute
  32493. 22:16:00Now see my uh application is running.
  32494. 22:16:03Okay. See our uh BGP is running and this
  32495. 22:16:06is completely live right now. You can
  32496. 22:16:08share this URL with anyone and they will
  32497. 22:16:11be able to access. Okay. Now you can
  32498. 22:16:12purchase any kinds of domain name. You
  32499. 22:16:14can also change the domain here. Now
  32500. 22:16:15let's test whether it's working or not.
  32501. 22:16:18Okay. Now here I have given hi. It is
  32502. 22:16:20giving hello how I can assist you uh how
  32503. 22:16:22I can help you today. And it has also
  32504. 22:16:24loaded my previous trades. Uh why?
  32505. 22:16:26because in my GitHub I already um
  32506. 22:16:29updated my database right so from
  32507. 22:16:32database it is loading in the old
  32508. 22:16:33conversation okay that's why you're able
  32509. 22:16:35to see that see that now let's uh do the
  32510. 22:16:37chat operation I'll tell my name is BP
  32511. 22:16:46see now you can even create a new
  32512. 22:16:48threads and you can do the conversation
  32513. 22:16:50but let's continue here now here you can
  32514. 22:16:54upload your documents
  32515. 22:16:56your any kinds of documents that I will
  32516. 22:16:59upload my
  32517. 22:17:01resume.
  32518. 22:17:06Okay. Now I'll ask who is book based
  32519. 22:17:13on
  32520. 22:17:14PDF.
  32521. 22:17:17Now it is using my doc search tool and
  32522. 22:17:19it is giving you the response. Okay. Now
  32523. 22:17:21you can open search any latest
  32524. 22:17:23information,
  32525. 22:17:25latest
  32526. 22:17:28news in
  32527. 22:17:31um
  32528. 22:17:33Bollywood.
  32529. 22:17:41Now see realtime s operation it is doing
  32530. 22:17:46and this is the latest news I got. So
  32531. 22:17:49yes guys, everything is working fine.
  32532. 22:17:51Okay. Now this is completely live and
  32533. 22:17:53now if I let's say close my uh this uh
  32534. 22:17:56this window that means this terminal
  32535. 22:17:58still my application will be working.
  32536. 22:18:00See. Okay. Now the best part is that uh
  32537. 22:18:04if you push anything right if you push
  32538. 22:18:06anything push any new ch
  32539. 22:18:08uh automatically this pipeline will
  32540. 22:18:11trigger and all of the new features
  32541. 22:18:14would be added in in your um deployment
  32542. 22:18:17server uh without uh let's say stopping
  32543. 22:18:19your application. This is the main
  32544. 22:18:21benefit. Okay. So this is the one time
  32545. 22:18:24setup and rest of the life you can
  32546. 22:18:26enjoy. Now here everything is done. Now
  32547. 22:18:29uh we have seen the deployment. Now
  32548. 22:18:31let's try to stop all the instance we
  32549. 22:18:33have created uh because our landing is
  32550. 22:18:35over. I don't want to keep it running
  32551. 22:18:37otherwise it will charge me. And one
  32552. 22:18:39more thing I want to show you this uh
  32553. 22:18:40langismith monitoring. So if I go to my
  32554. 22:18:43lang in bpgpt see the last execution.
  32555. 22:18:47Okay it has done. Okay perfect. Now
  32556. 22:18:49let's try to um terminate everything.
  32557. 22:18:54So first of all I'll terminate my EC2
  32558. 22:18:57instance.
  32559. 22:18:59So select it and click here instant
  32560. 22:19:02state and terminate and delete. Okay, if
  32561. 22:19:04you stop it, it will stop but it will uh
  32562. 22:19:06it will not delete. Okay, but I will
  32563. 22:19:08delete it everything.
  32564. 22:19:10Terminate and delete. Now see after some
  32565. 22:19:13times it will delete it and shut down.
  32566. 22:19:16Once it is done I will search for ECR
  32567. 22:19:20ECR
  32568. 22:19:22elastic container history and uh
  32569. 22:19:25whatever history I created I'll select
  32570. 22:19:26and delete it. I'll give delete message
  32571. 22:19:35and confirm. Then I will delete my IM
  32572. 22:19:38user as well.
  32573. 22:19:45Now delete
  32574. 22:19:47deactive
  32575. 22:19:49right confirm and delete.
  32576. 22:19:57Okay. So everything is deleted. Now this
  32577. 22:19:59server is down.
  32578. 22:20:19So see now this uh URL is down because
  32579. 22:20:21we have deleted everything. So fine guys
  32580. 22:20:24uh we have done. Um now I'll share this
  32581. 22:20:27code and everything in the description.
  32582. 22:20:29Uh from there you can check it out. I
  32583. 22:20:32will add a beautiful readme here. Readme
  32584. 22:20:35let's say uh information uh so that uh
  32585. 22:20:38you can see all of the commands all of
  32586. 22:20:40the steps in the readme itself. Okay.
  32587. 22:20:42Now this was uh the as deployment. Now
  32588. 22:20:45if you don't have the AWS account guys
  32589. 22:20:47still you want to deploy this
  32590. 22:20:48application and you want to test uh for
  32591. 22:20:50this uh you can use render. Okay there
  32592. 22:20:53is another one called render.com. you
  32593. 22:20:55can use this uh platform and here you
  32594. 22:20:57can do the deployment. Okay. So for
  32595. 22:20:58render I already created a video in my
  32596. 22:21:01playlist as you can see uh deploy aentk
  32597. 22:21:03chatbot on render for free with docker.
  32598. 22:21:06You can simply uh check this video and
  32599. 22:21:08you will be able to deploy this uh
  32600. 22:21:10project over the render cloud as well.
  32601. 22:21:12Okay. So yes uh this is all about guys.
  32602. 22:21:14I hope you like this uh uh
  32603. 22:21:16implementation. If you found this uh
  32604. 22:21:18this implementation useful guys please
  32605. 22:21:20try to subscribe to my channel. So this
  32606. 22:21:22is my channel guys. Please try to
  32607. 22:21:24subscribe. Uh let's hit uh 100k
  32608. 22:21:27subscriber as soon as possible and uh I
  32609. 22:21:30have lots of plan for this channel. I'll
  32610. 22:21:33bring lots of content related agent MCP
  32611. 22:21:36okay uh data science. So each and
  32612. 22:21:39everything would be available in one
  32613. 22:21:40place and uh if you want to connect me
  32614. 22:21:42guys this is my LinkedIn profile. So
  32615. 22:21:44here you can also connect me. You can
  32616. 22:21:46also follow follow me here. So
  32617. 22:21:47definitely um we'll try to keep in touch
  32618. 22:21:50and if you have any kinds of question
  32619. 22:21:52you can feel free to reach out here. So
  32620. 22:21:54guys in this video I'll be developing
  32621. 22:21:56one end to end multi- aent application
  32622. 22:21:58with the help of Langraph.
  32623. 22:22:01So in this video the application I'm
  32624. 22:22:03going to develop the application name
  32625. 22:22:05would be Tripate AI. So Tripmetate AI is
  32626. 22:22:08a multi- aent uh application. Uh here uh
  32627. 22:22:11you only just need to mention your trip
  32628. 22:22:13location and this will uh give you the
  32629. 22:22:16entire uh plan uh with respect to the
  32630. 22:22:18location uh you are planning for the
  32631. 22:22:20trip and this will also give you some
  32632. 22:22:23amazing informations like uh your
  32633. 22:22:26flights, your hotels. Okay. Then it will
  32634. 22:22:28give you the travel itinerary even it
  32635. 22:22:31will give you the day-to-day plan you
  32636. 22:22:33will be making whenever you are on a
  32637. 22:22:34trip. So this is a very much a cool
  32638. 22:22:37application we'll be developing. Why?
  32639. 22:22:39because uh we know that all of the uh
  32640. 22:22:42people out there they are very much
  32641. 22:22:45interested uh especially in trip
  32642. 22:22:47especially about the travel. So let's
  32643. 22:22:50say whenever we are planning for any
  32644. 22:22:51travel let's say uh country A to B. So
  32645. 22:22:55before going to that particular country
  32646. 22:22:57we just need to make some plans right
  32647. 22:22:59let's say um if I want to visit that
  32648. 22:23:02country so which flight I have to take
  32649. 22:23:05okay after let's say taking the flight
  32650. 22:23:07um uh in which hotel I have to stay
  32651. 22:23:10right then uh where I need to visit what
  32652. 22:23:13are the me uh memorable locations there
  32653. 22:23:15right even uh what would be my day one
  32654. 22:23:18plan day two plan let's say I have that
  32655. 22:23:20much amount of budget so how much money
  32656. 22:23:22I should spend in day one day two like
  32657. 22:23:25that. Okay. So this is the major problem
  32658. 22:23:27um whenever we are planning for any
  32659. 22:23:29kinds of trips. Okay. So why not we can
  32660. 22:23:31create a multi- aent system so that
  32661. 22:23:33agent will prepare the entire plan for
  32662. 22:23:36us. Okay. Only just need to give the
  32663. 22:23:38location. Let's say I want to visit uh
  32664. 22:23:40let's say uh country A to B. Okay. I
  32665. 22:23:43only just provide that much informations
  32666. 22:23:45to my agent and my agent will prepare
  32667. 22:23:47everything for me. Okay. Even I can
  32668. 22:23:50download that particular plan as a PDF
  32669. 22:23:52file and I can take it on my smartphone
  32670. 22:23:54anytime and I can visit anywhere. Okay.
  32671. 22:23:56So this is the system guys we'll be
  32672. 22:23:58developing throughout the entire video
  32673. 22:24:00and for this we'll be using some amazing
  32674. 22:24:02tools and technologies. Okay. So guys uh
  32675. 22:24:04first of all I want to show you the
  32676. 22:24:06application demo how this application
  32677. 22:24:07looks like and how this application will
  32678. 22:24:09be uh working. Then after that we'll
  32679. 22:24:12start the development. Okay. So to
  32680. 22:24:14implement this uh entire system guys I
  32681. 22:24:16have used some amazing technology. I
  32682. 22:24:18have used a fast API. So it is running
  32683. 22:24:21on fast API back end. Even I have used
  32684. 22:24:23HTML, CSS and little bit of JavaScript
  32685. 22:24:26to design the entire front end. Okay. As
  32686. 22:24:28you can see this is a beautiful front
  32687. 22:24:30end I have created. Then uh for this
  32688. 22:24:32agent workflow multi- aent workflow I
  32689. 22:24:34used langraph. Okay. And uh the large
  32690. 22:24:37language model wise actually I'm using
  32691. 22:24:39gro
  32692. 22:24:41actually playground that means gro
  32693. 22:24:43platform. So from the gro platform guys
  32694. 22:24:46I'm using llama model. Okay. metal lama
  32695. 22:24:48model then uh for the memory persistence
  32696. 22:24:50memory I'm utilizing postgrace SQL
  32697. 22:24:54database so if you know postgrace is
  32698. 22:24:56amazing uh database okay whenever you
  32699. 22:24:58are implementing this kinds of agentic
  32700. 22:25:00application so postgrace you can utilize
  32701. 22:25:03okay uh here uh this postgrace uh
  32702. 22:25:06supports so many functionality whenever
  32703. 22:25:09you are implementing this kinds of
  32704. 22:25:10agents so for our uh persistence memory
  32705. 22:25:13guys we'll be using postgrace database
  32706. 22:25:15inside this development and Postgrace
  32707. 22:25:17I'm not going to use the local Postgress
  32708. 22:25:19server instead of that I have set up uh
  32709. 22:25:22this uh Postgress on the render cloud
  32710. 22:25:24okay my Postgress is running on my
  32711. 22:25:26render cloud let me show you so this is
  32712. 22:25:29my Postgress server it is running on
  32713. 22:25:30render cloud so from here we just
  32714. 22:25:33connected our application okay so right
  32715. 22:25:35now this is not local anymore so if you
  32716. 22:25:38close your local system as well still
  32717. 22:25:40this uh this application will be running
  32718. 22:25:43then for the realtime search operation
  32719. 22:25:45guys uh for finding hotels or for
  32720. 22:25:47finding uh different different uh
  32721. 22:25:50itinary for a specific location we'll be
  32722. 22:25:53using tably okay tably search tool so
  32723. 22:25:55with the help of that we'll be doing the
  32724. 22:25:57internet search realtime internet search
  32725. 22:25:58and we'll try to figure out all of the
  32726. 22:26:00latest informations about that country
  32727. 22:26:02okay then uh for the flight information
  32728. 22:26:05guys we'll be using uh aviation stack uh
  32729. 22:26:07platform basically they provides a API
  32730. 22:26:10key with the help of this API key you
  32731. 22:26:11can get the entire flight informations
  32732. 22:26:14okay for any kinds of country. So yes,
  32733. 22:26:16these are my tool to tools and
  32734. 22:26:18technologies we'll be using for this
  32735. 22:26:20development and after this development
  32736. 22:26:22I'm also going to show you how we can
  32737. 22:26:23deploy this project over the render
  32738. 22:26:25cloud. Okay. So here we are not only
  32739. 22:26:28going to develop this project uh even
  32740. 22:26:30after completing the development I will
  32741. 22:26:32show you the deployment part as well. So
  32742. 22:26:34make sure you watch this video till the
  32743. 22:26:36end and if you found this content useful
  32744. 22:26:38please try to subscribe to my channel
  32745. 22:26:40and please try to share this with your
  32746. 22:26:42friends and family and please guys hit
  32747. 22:26:43the like and uh I need your support if
  32748. 22:26:46you are supporting me guys definitely I
  32749. 22:26:48can bring this kinds of content more and
  32750. 22:26:50uh yeah it would be amazing okay
  32751. 22:26:52altogether so please try to subscribe to
  32752. 22:26:54my channel this should be my request to
  32753. 22:26:56all of you so yes uh this is how my
  32754. 22:26:58application interface looks like uh you
  32755. 22:27:00can see this is a tripmate AI platform a
  32756. 22:27:02multi- aent Travel planner with
  32757. 22:27:04Langraph. So here basically you can plan
  32758. 22:27:06your perfect trip with AI. You can
  32759. 22:27:08search flight, discover hotels, generate
  32760. 22:27:10a complete travel itinerary using multi-
  32761. 22:27:13aent langraph system. Okay. Now for an
  32762. 22:27:16example here what you have to give. So
  32763. 22:27:18here you have a input box. So basically
  32764. 22:27:21you can mention uh where to where you
  32765. 22:27:23want to let's say go for the trip. You
  32766. 22:27:25just only need to mention let's say here
  32767. 22:27:27I have given some example. to plan a
  32768. 22:27:28complete 7 days trip uh 7 days Japan
  32769. 22:27:31trip from Bangladesh under one uh two
  32770. 22:27:33two lakhs. Okay, let's say you have two
  32771. 22:27:35lakhs budget. You can provide this
  32772. 22:27:36information. So what I can do? I can
  32773. 22:27:38copy this information. I can paste it
  32774. 22:27:40here. Let's say maybe I can tell uh plan
  32775. 22:27:42a complete 7 days. Let's say here I will
  32776. 22:27:45give
  32777. 22:27:48I'll get Nepal tool. Okay, Nepal trip
  32778. 22:27:51from Bangladesh under two lakhs. Okay,
  32779. 22:27:53so let's say this is my uh this is my uh
  32780. 22:27:55let's say plan for the trip. Now simply
  32781. 22:27:57you just need to click on generate
  32782. 22:27:59plans.
  32783. 22:28:00Now see um after some times you will see
  32784. 22:28:04the entire plan would be ready. Even you
  32785. 22:28:06can download this uh down download that
  32786. 22:28:08plan as a PDF file. Let me show you. So
  32787. 22:28:11guys uh as you can see uh it has
  32788. 22:28:13successfully generated the 7 days Nepal
  32789. 22:28:15trip from Bangladesh under u two lakhs
  32790. 22:28:18taka. So as you can see this is the trip
  32791. 22:28:21summary. Uh we have planned a 7-day uh
  32792. 22:28:24Nepal trip from Bangladesh that includes
  32793. 22:28:26a visit to Kathmandu then Pok uh Pokara
  32794. 22:28:31then uh Chitwan and others exciting uh
  32795. 22:28:33destinations and blah blah blah you can
  32796. 22:28:36see. So first of all it has given the
  32797. 22:28:37flight informations. Let's say if I want
  32798. 22:28:39to visit Nepal. First of all, I have to
  32799. 22:28:42uh I have to go to the Dhaka and Dhaka
  32800. 22:28:45to Kathmandu. There is a flight and this
  32801. 22:28:47is the flight information it is giving
  32802. 22:28:49and the times as well when this flight
  32803. 22:28:51is available. Okay. Then some hotel
  32804. 22:28:54suggestion it is giving. So after you
  32805. 22:28:55reach to Kathmandu so in which hotel you
  32806. 22:28:58just need to stay and what would be the
  32807. 22:29:00cost per night even it is also telling
  32808. 22:29:02you. Apart from that it is giving you
  32809. 22:29:04the dayby-day uh itinary. Here is the
  32810. 22:29:06dayby-day itinary. Day one Dhaka to
  32811. 22:29:08Kathmandu you will be visiting. Okay. Uh
  32812. 22:29:11so it is giving you the entire step.
  32813. 22:29:13Okay. See then when you reach the
  32814. 22:29:16Kathmandu so in day two what should be
  32815. 22:29:20your visit location? It is giving you
  32816. 22:29:22the entire visit location. Okay. And
  32817. 22:29:24what is the entry fee each and
  32818. 22:29:25everything it is giving you. Then Kmandu
  32819. 22:29:28to Pokara again it is uh giving you the
  32820. 22:29:30plan. You have to take a bus or private
  32821. 22:29:33card. Okay. And this is the estimated
  32822. 22:29:34cost for that. Okay. So that's how it is
  32823. 22:29:36giving you the entire summary. So then
  32824. 22:29:38day four, day five, okay, day six, day
  32825. 22:29:42seven and the entire estimated budget is
  32826. 22:29:44also giving you like how much money uh
  32827. 22:29:47uh I mean it will spend um in 7 days.
  32828. 22:29:50Okay, if you're visiting Nepal. So it is
  32829. 22:29:52giving you the estimated cost about
  32830. 22:29:54flights, accommodations, transportation,
  32831. 22:29:56food and activities, total budget. Okay.
  32832. 22:29:59Then the final recommendation it is
  32833. 22:30:01giving you uh you can see some final
  32834. 22:30:03recommendation we are also getting. So
  32835. 22:30:05yes uh if I get these kinds of things
  32836. 22:30:07guys okay in just one place it would be
  32837. 22:30:10amazing for us because otherwise what I
  32838. 22:30:12have to do I have to individually search
  32839. 22:30:14Google let's say what is the best hotel
  32840. 22:30:16in Kathmandu okay and how much let's say
  32841. 22:30:19price they are taking so I have to
  32842. 22:30:21search individually I have to search the
  32843. 22:30:23flight uh flight information
  32844. 22:30:25individually I have to search hotel
  32845. 22:30:27information individually okay I have to
  32846. 22:30:29search this dayby-day itinary
  32847. 22:30:31individually okay so yeah this take uh
  32848. 22:30:33takes time And it needs lots of
  32849. 22:30:35exploration, right? I I have to search
  32850. 22:30:37on Google, go to different different
  32851. 22:30:38website, just try to see their review.
  32852. 22:30:40Then after that, I'll try to select this
  32853. 22:30:42one. Then again, I have to note it,
  32854. 22:30:44right? I have to take a note. Let's say
  32855. 22:30:45I will visit uh A to B, B to C, okay?
  32856. 22:30:48And it will take that much of money.
  32857. 22:30:50This is the estimated time. I have to
  32858. 22:30:51note everything. So that much time I
  32859. 22:30:53don't have. So why not we can bring
  32860. 22:30:55everything inside of one platform. Okay?
  32861. 22:30:58One uh one let's say uh one system
  32862. 22:31:01there. I only just need to give my uh
  32863. 22:31:03trip plan and it will generate uh the
  32864. 22:31:06entire plan for me. This is what we have
  32865. 22:31:08developed guys. Okay. So this is very
  32866. 22:31:10interesting and realtime application
  32867. 22:31:12guys because right now these kinds of
  32868. 22:31:14application you'll be uh seeing okay uh
  32869. 22:31:16people are using there are some platform
  32870. 22:31:18they are providing this kinds of let's
  32871. 22:31:20let's say functionality only you just
  32872. 22:31:22need to give the location and it will
  32873. 22:31:23give you the entire trip plan for that.
  32874. 22:31:25Okay. Now if I go to the cut uh Nepal
  32875. 22:31:27right so I don't have any kinds of issue
  32876. 22:31:29because I know what is the estimated
  32877. 22:31:30cost there what is the best hotels there
  32878. 22:31:33right what is the best flights there
  32879. 22:31:35right uh in day 1 day 2 day three where
  32880. 22:31:38I need to visit which which is the best
  32881. 22:31:40location to visit there in 7 days all
  32882. 22:31:42the information I have okay so I don't
  32883. 22:31:46need anyone to guide me there is what
  32884. 22:31:48guys will be doing now you can see there
  32885. 22:31:50is a download PDF option if I click on
  32886. 22:31:52download PDF so you can see this PDF
  32887. 22:31:54file would be available Now you can take
  32888. 22:31:56this PDF file on your smartphone okay or
  32889. 22:31:58on your laptop anywhere you can take and
  32890. 22:32:01you can just open it up and you can see
  32891. 22:32:02okay what you have to do amazing right
  32892. 22:32:05so yes guys this is the things we'll be
  32893. 22:32:07developing even you can also copy this
  32894. 22:32:09information and you can also paste it
  32895. 22:32:11anywhere even you can also send it uh to
  32896. 22:32:13your friends and family this is also
  32897. 22:32:15possible okay so that's how not only uh
  32898. 22:32:19not only Nepal you can give Japan Dubai
  32899. 22:32:21Thailand okay global anywhere while You
  32900. 22:32:24just need to visit just try to mention
  32901. 22:32:26here you can generate the plan. Okay.
  32902. 22:32:28With respect to that and uh I already
  32903. 22:32:31told you this u uh this is also
  32904. 22:32:33utilizing the postgrace database. All
  32905. 22:32:35the information it is saving in the
  32906. 22:32:36postgrace. This is uh already uh um
  32907. 22:32:40postgress servers we have created on the
  32908. 22:32:41render render server. Okay. Render is a
  32909. 22:32:44cloud platform and let me show you I
  32910. 22:32:47have my PG admin. So in PG admin I
  32911. 22:32:50connected my remote server that means my
  32912. 22:32:52render postgress server and here you can
  32913. 22:32:54see the persistence memory checkpoint.
  32914. 22:33:09So see these are my persistence memory
  32915. 22:33:11checkpoint and you can see this is
  32916. 22:33:13connected with render cloud. See this
  32917. 22:33:15connected with render cloud. Okay. and
  32918. 22:33:17all of me all of my persistence memory
  32919. 22:33:20checkpoint all of my conversation are
  32920. 22:33:22saved here okay even I'm also using
  32921. 22:33:25langismith here
  32922. 22:33:29to monitor my entire application
  32923. 22:33:37so as you can see I'm using lang lang
  32924. 22:33:40smmith guys to monitor my entire
  32925. 22:33:41application it is using this travel
  32926. 22:33:43agent uh project and it is monitoring
  32927. 22:33:45the entire
  32928. 22:33:47entire application. Okay. So yes guys uh
  32929. 22:33:50that that's how we'll be developing this
  32930. 22:33:52entire application end to end completely
  32931. 22:33:54end to end we'll try to develop. So yes
  32932. 22:33:56guys this is the entire uh application
  32933. 22:33:59uh this is the entire application demo.
  32934. 22:34:01Now let's start the development. So guys
  32935. 22:34:03before starting the development first of
  32936. 22:34:06all let's try to understand the
  32937. 22:34:07application uh overview and the
  32938. 22:34:10application architectures. So as you can
  32939. 22:34:12see tripate AI this is a langraph
  32940. 22:34:14multi-agent tribal planet system. So you
  32941. 22:34:16can see this is a multi- aent travel
  32942. 22:34:18planner that turns a natural language
  32943. 22:34:21trip request into a practical travel
  32944. 22:34:23plan with flight suggestions, hotel
  32945. 22:34:25ideas and day-to-day uh itinerary. Uh uh
  32946. 22:34:29the projects uh uses a multi- aent
  32947. 22:34:31workflow built with langraph and why
  32948. 22:34:34this project uh as you can see planning
  32949. 22:34:36a trip usually means jumping between
  32950. 22:34:39multiple websites, tools and
  32951. 22:34:41spreadsheets. Okay, as I already told
  32952. 22:34:42you, let's say if you're planning for a
  32953. 22:34:44trip, right? Uh you have to visit
  32954. 22:34:46multiple websites to uh look for the
  32955. 22:34:48flights information, hotel informations,
  32956. 22:34:51right? Then uh which location you just
  32957. 22:34:54need to visit there, right? These are
  32958. 22:34:56the things you have to uh explore and
  32959. 22:34:57you have to take a notes on the
  32960. 22:34:59spreadsheet or anywhere then um uh you
  32961. 22:35:02will be making the entire plan. So this
  32962. 22:35:03takes uh lots of time, right? And uh it
  32963. 22:35:06needs lots of exploration even sometimes
  32964. 22:35:08you you may miss out anything, right?
  32965. 22:35:11Uh so this project brings that flow into
  32966. 22:35:13one experience by combining a flight s
  32967. 22:35:15agent, a hotel research agent and uh
  32968. 22:35:19itinerary plan planning agent and a
  32969. 22:35:22final response agents. Okay. Uh all
  32970. 22:35:24coordinated through a langraph workflow
  32971. 22:35:27that means in a single place we'll be
  32972. 22:35:29combining all of them and each of the
  32973. 22:35:31task would be mentioned to each of the
  32974. 22:35:34agent. That means for the flight search
  32975. 22:35:36operation we will be creating an an
  32976. 22:35:38agent. For uh hotel uh hotel information
  32977. 22:35:41we'll be defining another agent. For uh
  32978. 22:35:44itinerary planning we'll be defining
  32979. 22:35:46another agents. Okay. For final report
  32980. 22:35:48generation we'll be defining another
  32981. 22:35:49agents. That's how we'll be creating
  32982. 22:35:51multiple agents together and those
  32983. 22:35:53agents will be uh those those agents
  32984. 22:35:56will be responsible for generating the
  32985. 22:35:58entire trip summary for me. Okay. Trip
  32986. 22:36:01plan for me. So that's why we call it as
  32987. 22:36:02a multi- aent system. So here we are not
  32988. 22:36:05utilizing one agent. We are using
  32989. 22:36:06multiple agents and each of the agents
  32990. 22:36:08will have some kinds of tools to
  32991. 22:36:10complete that particular task. Okay. So
  32992. 22:36:13here is the entire uh like architecture
  32993. 22:36:15guys. As you can see for this project so
  32994. 22:36:17first of all I already told you here
  32995. 22:36:18we'll be utilizing uh multiple agent.
  32996. 22:36:22As you can see here we'll be utilizing
  32997. 22:36:24multiple agent. The first agents will be
  32998. 22:36:25creating the flight agents. Okay. So
  32999. 22:36:27basically this will search the flight
  33000. 22:36:28and finds the best option for visiting
  33001. 22:36:31location A to B. Okay. And for get uh
  33002. 22:36:34and to get these kinds of flight
  33003. 22:36:35informations, it needs some tools,
  33004. 22:36:37right? And here we'll be using aviation
  33005. 22:36:39stack API. So this aviation stack API uh
  33006. 22:36:42what it it can do it can search realtime
  33007. 22:36:44flight informations, right? And it will
  33008. 22:36:47give you that particular flight
  33009. 22:36:48informations to the flight agent and
  33010. 22:36:49flight agent will try to utilize that.
  33011. 22:36:51Okay. So optionally you can also use
  33012. 22:36:53tably search here but I feel like uh
  33013. 22:36:55aviation stack is having all kinds of
  33014. 22:36:57flight integration in one place. So
  33015. 22:36:58that's why we'll be using a aviation
  33016. 22:37:00stack API key here. Then second agents
  33017. 22:37:03will be developing this hotel agents. So
  33018. 22:37:06what this hotel agent will it will
  33019. 22:37:07search hotels and compares options. That
  33020. 22:37:10means it will only look uh it is not
  33021. 22:37:12only going to look for the agents. It
  33022. 22:37:14will all it will look for the best
  33023. 22:37:16hotels for you. Okay. Best hotels uh
  33024. 22:37:18with respect to your budget, right? So
  33025. 22:37:20this hotel information it will try to
  33026. 22:37:22find and for this we will be using some
  33027. 22:37:24kinds of tools. Right? And here we'll be
  33028. 22:37:26using tably search. Okay. So tably
  33029. 22:37:28search with the help of tably search
  33030. 22:37:30we'll try to figure out the best hotels
  33031. 22:37:32uh from that particular location and
  33032. 22:37:34we'll try to give the suggestion
  33033. 22:37:36optionally you can use Google place API
  33034. 22:37:38this is optional but uh I'll be using
  33035. 22:37:39tably tab search okay because this is
  33036. 22:37:41completely free to use then the next one
  33037. 22:37:44uh itinary agent so this basically
  33038. 22:37:46creates the day wise itinary uh that
  33039. 22:37:49means where you have to visit okay what
  33040. 22:37:50are the activities you have to do there
  33041. 22:37:52what are the best places okay each and
  33042. 22:37:54everything this particular agents will
  33043. 22:37:55try to uh get it for for you And again
  33044. 22:37:58to get these are the information u the
  33045. 22:38:00best in best visit location activities
  33046. 22:38:03we'll be using tably API key again.
  33047. 22:38:05Okay. So with the help of tab will
  33048. 22:38:06perform the internet search operation
  33049. 22:38:08and um real time will get the
  33050. 22:38:11information and it will try to um use
  33051. 22:38:13this information in my itinary agents.
  33052. 22:38:16Then uh fourth I'll be using this final
  33053. 22:38:18response agents that means it will be
  33054. 22:38:19using all the information and will try
  33055. 22:38:22to prepare the entire plan for you
  33056. 22:38:24entire trip plan for you. Okay, that
  33057. 22:38:26means it it combines all the information
  33058. 22:38:27and generate a final response. And again
  33059. 22:38:30for this we'll be using a large language
  33060. 22:38:32model and the large language model wise
  33061. 22:38:33we'll be using llama 3. Okay, and we'll
  33062. 22:38:35be using gro provider. Uh I think you
  33063. 22:38:38know grock provides some free uh free
  33064. 22:38:40limits. Okay, you can generate uh API
  33065. 22:38:43keys and you can access some model.
  33066. 22:38:44Okay, completely free. You don't need to
  33067. 22:38:45pay for that. But there is a limitation
  33068. 22:38:47but it's fine. Okay, for this particular
  33069. 22:38:49task I will be using this free API key.
  33070. 22:38:51But if you want you can also take the
  33071. 22:38:53subscription. You can uh use some
  33072. 22:38:54premium model. It's completely up to
  33073. 22:38:56you. Okay. So, yeah, we'll be using this
  33074. 22:38:58uh hog rock provider here.
  33075. 22:39:01Uh yeah, then uh you can see uh each of
  33076. 22:39:04the agents will be connected to a shared
  33077. 22:39:06state that mean shared memory h and we
  33078. 22:39:08call it as a state. If you are already
  33079. 22:39:10working in langraph, I think know there
  33080. 22:39:12is a concept of state, right? We have to
  33081. 22:39:14create the state and these are the state
  33082. 22:39:15I need guys. Okay, I need user query.
  33083. 22:39:18That means whatever user will pass, I'll
  33084. 22:39:20save inside the user query. Whatever
  33085. 22:39:22flight results I'll be getting, I'll try
  33086. 22:39:24to save in the flight results. Whatever
  33087. 22:39:25hotel results I'll be getting, I'll try
  33088. 22:39:27to save in the hotel results. Whatever
  33089. 22:39:29itinary response I'll be getting, I'll
  33090. 22:39:31try to say save inside itary results.
  33091. 22:39:33Whatever final response I'll be getting,
  33092. 22:39:34I'll save inside final response. Okay?
  33093. 22:39:36And whatever my agents will try to
  33094. 22:39:38reply, okay? Uh that entire plan, I'll
  33095. 22:39:41try to save inside my masses state. And
  33096. 22:39:44this uh shared state will be uh storing
  33097. 22:39:46inside one amazing database guys. We
  33098. 22:39:48call it as a Postgress SQL. Okay. So
  33099. 22:39:50this uh database we'll be using for my
  33100. 22:39:53memory. Okay, memory memory purpose
  33101. 22:39:54we'll be using that means we'll try to
  33102. 22:39:56store all of the checkpoints all of the
  33103. 22:39:57conversation here. Okay. So it will
  33104. 22:39:59basically have the conversation story
  33105. 22:40:01user preferences agents output and state
  33106. 22:40:03updates. Okay. So this is the entire
  33107. 22:40:06architecture guys we'll try to follow
  33108. 22:40:07and we'll be implementing this entire
  33109. 22:40:10agents. Okay. I hope you get it. So guys
  33110. 22:40:13as you can see to develop this entire
  33111. 22:40:15application I need the four agents here.
  33112. 22:40:17uh the flight agent, hotel agent, then
  33113. 22:40:20uh itinary agents and the fin final
  33114. 22:40:22response agents. Okay. So we'll be
  33115. 22:40:25developing four agents and we'll try to
  33116. 22:40:27uh combine them all together and this
  33117. 22:40:29will become a multi- aent system. Okay.
  33118. 22:40:31Yeah.
  33119. 22:40:34So first of all uh to implement uh this
  33120. 22:40:36entire system guys what I need I need to
  33121. 22:40:38create my GitHub repository. So uh there
  33122. 22:40:41I'll try to create a repo and u I'll
  33123. 22:40:44start uh writing the code.
  33124. 22:40:51So for this let's open up my GitHub
  33125. 22:40:53guys. I'll open up my GitHub.
  33126. 22:40:57I'll go to my repository
  33127. 22:41:00and let's create a new repo here. I'm
  33128. 22:41:03going to give the name of this repo. So
  33129. 22:41:06what I can do maybe I can copy this name
  33130. 22:41:11and I can give it here. Okay, let's say
  33131. 22:41:13this is my name
  33132. 22:41:15and uh simply I'll just try to make it
  33133. 22:41:18as public. Uh I'll add the readmi file.
  33134. 22:41:21Get ignore wise I'll be taking python
  33135. 22:41:25and license. Let's take this um MIT
  33136. 22:41:28license. Okay, you can take any license.
  33137. 22:41:30It's up to you. Uh okay, everything is
  33138. 22:41:32fine. Now simply what I'll do, I'll just
  33139. 22:41:35try to create this repository.
  33140. 22:41:44Okay, so my repo is created guys. Okay,
  33141. 22:41:46next thing I'll just try to clone this
  33142. 22:41:48repo. I'll just uh click on this code
  33143. 22:41:51and copy this HTTP URL and I will open
  33144. 22:41:54up my local folder.
  33145. 22:41:58So here I'll open up my terminal
  33146. 22:42:01and let's clone it. So get clone
  33147. 22:42:07paste that URL.
  33148. 22:42:11So it has already cloned my repo. So now
  33149. 22:42:13I'll go inside that. So cd the name of
  33150. 22:42:15the repo is trip AI. Okay. So now I'm
  33151. 22:42:18inside this folder. I'm inside this
  33152. 22:42:21folder. Okay. Now here I'm going to open
  33153. 22:42:22up my visual code studio.
  33154. 22:42:32Okay. Perfect.
  33155. 22:42:35So here I already moved my um
  33156. 22:42:38architecture file which is
  33157. 22:42:40demo.excaliraw.
  33158. 22:42:41So here I'm using excali file format. So
  33159. 22:42:44for this you have to install one
  33160. 22:42:45extension called excali draw. Okay xcali
  33161. 22:42:49draw. So this is the extension you have
  33162. 22:42:51to install. So if you install you will
  33163. 22:42:52be able to open this file guys. Okay.
  33164. 22:42:54And here you will be getting this
  33165. 22:42:55architecture diagram. So fine. Um yeah.
  33166. 22:42:59Now next guys what I have to do? I have
  33167. 22:43:02to first of all uh create the
  33168. 22:43:03environment and we have to create the
  33169. 22:43:05folder structure. So to create the
  33170. 22:43:07environment guys um here uh what I can
  33171. 22:43:10do I can write this step
  33172. 22:43:19how to run
  33173. 22:43:23first um create the environment
  33174. 22:43:31virtual
  33175. 22:43:34environment ment.
  33176. 22:43:40So to get the virtual environment uh you
  33177. 22:43:42have to use this command
  33178. 22:43:51p
  33179. 22:43:55rate
  33180. 22:43:56hyphen n
  33181. 22:43:59uh then you have to give the name of the
  33182. 22:44:01environment. I will give let's say
  33183. 22:44:06travel
  33184. 22:44:08then I'll give the python version. So
  33185. 22:44:11python is equal to 3.11. Okay I'll be
  33186. 22:44:14using 3.11 and hyphen y that means I
  33187. 22:44:17want to give the permission. So this is
  33188. 22:44:18the command you have to use to create
  33189. 22:44:19the environment. Then second you have to
  33190. 22:44:22uh activate the environment.
  33191. 22:44:30activate the environment.
  33192. 22:44:37So to activate the environment you have
  33193. 22:44:39to use this command
  33194. 22:44:41panda activate
  33195. 22:44:46travel.
  33196. 22:44:51Then next you have to install the
  33197. 22:44:53requirement file.
  33198. 22:45:02Install the requirements.
  33199. 22:45:07So we'll be using this command. So pip
  33200. 22:45:09installer
  33201. 22:45:13requirements
  33202. 22:45:19txt.
  33203. 22:45:21Okay. So yeah uh these are the step we
  33204. 22:45:23have to follow. So first of all let's
  33205. 22:45:25create the environment. I'll copy this
  33206. 22:45:27command and I'll open up my terminal.
  33207. 22:45:32Let's clear.
  33208. 22:45:34Let's create the environment first of
  33209. 22:45:35all.
  33210. 22:45:38Okay. Uh there is a space I have given
  33211. 22:45:40but uh the space should not be there. It
  33212. 22:45:43should be hypen only. Okay. Now copy
  33213. 22:45:45this again and execute it here.
  33214. 22:46:13Okay, done. Now I have to activate the
  33215. 22:46:15environment.
  33216. 22:46:20So this is the command.
  33217. 22:46:28See I have activated. Now I'll be
  33218. 22:46:30installing the requirements. But for
  33219. 22:46:32this I need to create the requirements
  33220. 22:46:33file
  33221. 22:46:35requirements.txt.
  33222. 22:46:37Okay. So here I need to mention all of
  33223. 22:46:40the requirements I need for this uh
  33224. 22:46:43agent. So I already uh noted all the
  33225. 22:46:46requirements I'll be using. So these are
  33226. 22:46:48the requirements guys I need. I need
  33227. 22:46:50langraph definitely to create the agent
  33228. 22:46:52workflow. Langchen you need um because
  33229. 22:46:55if you want to use langraph so langen is
  33230. 22:46:58the dependency and uh uh whenever I want
  33231. 22:47:01to load any large language model and all
  33232. 22:47:02right I have to use the langen there
  33233. 22:47:05then we'll be using grock provider uh
  33234. 22:47:07that means lm provider that's why we'll
  33235. 22:47:09be installing langen grog then langen
  33236. 22:47:11community is also required then we'll be
  33237. 22:47:12using tably search tool we'll be using
  33238. 22:47:14langen tab and I told you I'll be using
  33239. 22:47:17postgraql database for this I need this
  33240. 22:47:19uh ps
  33241. 22:47:22I cop g binary then uh uh this pull uh
  33242. 22:47:26the uh these two things I need okay for
  33243. 22:47:28this u uh database okay uh database and
  33244. 22:47:32another thing I need this langchen
  33245. 22:47:34checkpoint postgress okay these are the
  33246. 22:47:35dependency for the database okay then
  33247. 22:47:38python env to manage the environment
  33248. 22:47:40credential so let's create this env file
  33249. 22:47:44okay here we'll try to mention all of
  33250. 22:47:46these uh credential secret credential
  33251. 22:47:48then tavly python unit request library
  33252. 22:47:50unit I already told you about the
  33253. 22:47:52postgrace right uh I will save my
  33254. 22:47:55checkpoints in the postgra database
  33255. 22:47:57that's why this lang lang graph
  33256. 22:47:59checkpoint postgrace is required then uh
  33257. 22:48:02I'll also get the um um um I mean flight
  33258. 22:48:06information right for this um I'll be
  33259. 22:48:08using one um package called airports
  33260. 22:48:11data so inside airports data some
  33261. 22:48:13informations are available we'll try to
  33262. 22:48:15utilize that then uh I'll be considering
  33263. 22:48:17all of the country right whenever I'll
  33264. 22:48:19try to search for the flights so that's
  33265. 22:48:21There is another package called PI
  33266. 22:48:22country. So inside that all of the
  33267. 22:48:24country informations are available.
  33268. 22:48:25We'll try to also use that. Then fast
  33269. 22:48:27API for my entire u uh back end and
  33270. 22:48:31front end development. Then uh first API
  33271. 22:48:34dependencies u with help of uicon we'll
  33272. 22:48:36try to launch the fast API server. Then
  33273. 22:48:38the ginger ginger two templates. Okay.
  33274. 22:48:40So these are the requirements guys I
  33275. 22:48:41need and I already mentioned all of the
  33276. 22:48:43version. Okay. And you should also
  33277. 22:48:44mention the version. Uh otherwise what
  33278. 22:48:46will happen? Let's say uh if you if you
  33279. 22:48:49not mention the version. So if you're
  33280. 22:48:51running this project after 2 month there
  33281. 22:48:53is a possibility uh one of the package
  33282. 22:48:55will get update and that functionality
  33283. 22:48:57will be deprecated. Okay that time you
  33284. 22:48:58will get the error. So that's why it's
  33285. 22:49:00uh necessary to add the version. Okay
  33286. 22:49:02this is super important. Now let's
  33287. 22:49:04install the dependency. So I'll copy
  33288. 22:49:05this command
  33289. 22:49:07and I'll try to install the dependency
  33290. 22:49:09here.
  33291. 22:49:25Okay, let's wait uh once it is installed
  33292. 22:49:28then we'll try to
  33293. 22:49:31uh see the next step.
  33294. 22:49:42So apart from this uh dependency, I also
  33295. 22:49:44need to install some other tools as
  33296. 22:49:46well. Let me show you.
  33297. 22:50:00So installation is complete and there is
  33298. 22:50:02no error. Okay, it's completely fine.
  33299. 22:50:05Now guys, uh what I need I need some
  33300. 22:50:07more tools. Okay, uh I told you we'll be
  33301. 22:50:09using this uh PG admin to see my tables,
  33302. 22:50:13right? My uh conversation checkpoints
  33303. 22:50:15even you can also see the different
  33304. 22:50:17different uh conversation it has saved
  33305. 22:50:18right in in the memory. So you can able
  33306. 22:50:21to see that because uh I'll be creating
  33307. 22:50:23this uh postgrace server on my render
  33308. 22:50:25cloud and to see that I need this uh PG
  33309. 22:50:28admin. Okay, PG admin um this uh
  33310. 22:50:31graphical user interface we have to
  33311. 22:50:33install that. So let me close my PG
  33312. 22:50:36admin and let me show you how to install
  33313. 22:50:37this this PG admin. So if you want to
  33314. 22:50:39install the PG admin guys uh only in
  33315. 22:50:41just Google just try to search PG admin.
  33316. 22:50:47Okay, PG admin download
  33317. 22:50:50for Windows. So this is the website just
  33318. 22:50:54try to visit
  33319. 22:51:01uh or you can directly search like
  33320. 22:51:02postgress download okay post
  33321. 22:51:08postgra sql download so this is the
  33322. 22:51:11website
  33323. 22:51:13h here just try to choose your operating
  33324. 22:51:16system let's say I'm using windows you
  33325. 22:51:19can uh also select other operating
  33326. 22:51:20system as
  33327. 22:51:23And there is a option called uh download
  33328. 22:51:25the installer.
  33329. 22:51:27Okay. Now you have to [snorts] choose
  33330. 22:51:28which one you will be downloading. So
  33331. 22:51:30make sure you are installing the latest
  33332. 22:51:31one. Okay. 18.4. So here is the download
  33333. 22:51:34option. Just try to click here. It will
  33334. 22:51:36start downloading that. Okay. So this is
  33335. 22:51:39the uh file guys you have to download.
  33336. 22:51:41Okay. This is around uh 400 MB you can
  33337. 22:51:44download. So for me I already
  33338. 22:51:45downloaded. I'll just try to cancel it.
  33339. 22:51:47So once you have downloaded guys in the
  33340. 22:51:48download folder you will see this uh
  33341. 22:51:50file this uh uh postsql okay installer
  33342. 22:51:54now you just need to double click and
  33343. 22:51:55install this uh software okay inside
  33344. 22:51:57your system. So I think you know how to
  33345. 22:51:59install any software. Okay. The way you
  33346. 22:52:01install any software just try to double
  33347. 22:52:02click and do next next. Okay. Um it will
  33348. 22:52:05ask for uh like u um password. Okay. You
  33349. 22:52:08just need to set the password and you
  33350. 22:52:11can complete the installation process.
  33351. 22:52:13Okay. So once you have done the
  33352. 22:52:14installation now simply you just need to
  33353. 22:52:16search for PG admin. PG
  33354. 22:52:20admin on your search bar. Now you'll be
  33355. 22:52:21able to see this kinds of uh this kinds
  33356. 22:52:23of application. Now let's open it up.
  33357. 22:52:26Okay. So this kinds of interface you'll
  33358. 22:52:27be able to see
  33359. 22:52:36see this is my PG admin. So for me I
  33360. 22:52:38already connected with the server that's
  33361. 22:52:39why it's coming like that but for you it
  33362. 22:52:42would be completely different. Okay. So
  33363. 22:52:43maybe I can close this H. See for this
  33364. 22:52:46you will be getting this [clears throat]
  33365. 22:52:47kinds of window screen or welcome
  33366. 22:52:48screen. Okay. So now uh what I have to
  33367. 22:52:51do guys I have to set up this uh I have
  33368. 22:52:55to set up this u u u postgress server on
  33369. 22:52:58my render cloud. Okay, because I told
  33370. 22:53:00you for this uh persistence memory we'll
  33371. 22:53:03be using post P postgress, right? So how
  33372. 22:53:05to install this Postgress server on the
  33373. 22:53:07render cloud. Let me show you. So here
  33374. 22:53:09I'll just visit the render.
  33375. 22:53:12Okay, make sure you have a account on
  33376. 22:53:14render. If you don't have account,
  33377. 22:53:15please try to create one account for me.
  33378. 22:53:17I already have the account. I'll just
  33379. 22:53:18try to go to my dashboard.
  33380. 22:53:20Let me close these other tab.
  33381. 22:53:26So here uh to launch a postgra server
  33382. 22:53:29guys you just need to click on new and
  33383. 22:53:32there you will see one option called
  33384. 22:53:34post grace postgrace okay postgrace
  33385. 22:53:36database just try to click here so give
  33386. 22:53:39the name of that uh postgrace
  33387. 22:53:43I'll give let's say trip
  33388. 22:53:50agent
  33389. 22:53:54repagent uh let's say this is the name I
  33390. 22:53:56have given now you can give the database
  33391. 22:53:59name so I'll give let's say
  33392. 22:54:03um
  33393. 22:54:05I'll give trip memory
  33394. 22:54:15or let's say agent memory
  33395. 22:54:21Okay. Now you have to give the user. So
  33396. 22:54:24I can give my user ID. You can give your
  33397. 22:54:27any unique user ID. Here I have given
  33398. 22:54:29ENT buff. Then um everything just keep
  33399. 22:54:32it default. No need to change anything.
  33400. 22:54:35Just here in the plan option you just
  33401. 22:54:37select the free instance. Okay. So uh
  33402. 22:54:40render provides actually free instance.
  33403. 22:54:42You can use the free instance to launch
  33404. 22:54:44this server. Okay. And if you want to
  33405. 22:54:45take this subscription you can also do
  33406. 22:54:46do that. But in free instance there is a
  33407. 22:54:48limitation. I think after
  33408. 22:54:517 or 14 days I think this instance would
  33409. 22:54:54be deleted automatically. And here you
  33410. 22:54:55are getting 200
  33411. 22:54:5856 MB RAM 0.1 CPU and 1 GB storage.
  33412. 22:55:02Okay. I think this is enough for our
  33413. 22:55:04learning. But whenever you are creating
  33414. 22:55:05any real world application production
  33415. 22:55:07grade application whichever you will be
  33416. 22:55:09using right uh that time you can take
  33417. 22:55:11their subscription plan. Okay. No need
  33418. 22:55:13to take the free instance that time.
  33419. 22:55:16So yeah, everything just keep it default
  33420. 22:55:17and simply just create the database.
  33421. 22:55:25Okay. Uh it's uh giving one error
  33422. 22:55:27because uh previously I also created one
  33423. 22:55:29uh postgress server, right? So first of
  33424. 22:55:32all I had to delete that one. So maybe I
  33425. 22:55:35can delete that one.
  33426. 22:55:39So this is the database I created,
  33427. 22:55:41right? I'll just try to delete that.
  33428. 22:55:45So if you're doing for the first time
  33429. 22:55:46right uh you don't need to do that it
  33430. 22:55:48will create but uh for me I created
  33431. 22:55:51previously that's why it's coming like
  33432. 22:55:52that. So I'll just try to delete it.
  33433. 22:55:57Done. Now maybe I will be able to create
  33434. 22:55:59that.
  33435. 22:56:02All the informations are fine. Let's
  33436. 22:56:04create the database.
  33437. 22:56:06Okay. Now it is getting created. Okay.
  33438. 22:56:08Now let's wait. This starter should be
  33439. 22:56:10active. Once it is active then we can
  33440. 22:56:12use this database.
  33441. 22:56:37Okay guys, now you can see status is
  33442. 22:56:39available. That means my um Postgress
  33443. 22:56:42server is running successfully. Okay,
  33444. 22:56:43you can check there. You can go to the
  33445. 22:56:46dashboard and you can see it is
  33446. 22:56:47available and this is running. Okay, now
  33447. 22:56:49I have to connect this uh Postgress
  33448. 22:56:51server with my PG admin so that I can
  33449. 22:56:54see all of the uh table inside that all
  33450. 22:56:56of the database inside that. Okay,
  33451. 22:56:58whatever I'm going to create later on.
  33452. 22:57:00So for this uh what I can do I can go
  33453. 22:57:03below
  33454. 22:57:05and there is a URL you have to copy.
  33455. 22:57:08This is called external database URL.
  33456. 22:57:10Okay. So render uh tells you if you are
  33457. 22:57:13connecting this uh server in an external
  33458. 22:57:16service that that means right now I'm
  33459. 22:57:18using PG admin. This is the external
  33460. 22:57:20service. Okay. This is running on on my
  33461. 22:57:21local machine. So for this I have to use
  33462. 22:57:24external database URL. Okay. But there
  33463. 22:57:26is another one called internal database
  33464. 22:57:28URL. As you can see this is the internal
  33465. 22:57:29database URL. This is only required
  33466. 22:57:31whenever you are deploying this project.
  33467. 22:57:34That means let's say I am deploying the
  33468. 22:57:36same project in the render cloud. Okay.
  33469. 22:57:38And I'm using render postgress server
  33470. 22:57:41that time I will be using internal
  33471. 22:57:42database. Okay. So if you're only
  33472. 22:57:45running your application in the same
  33473. 22:57:47render cloud that time internal database
  33474. 22:57:49should be used. Okay. Database URL
  33475. 22:57:51should be used. But if you're running
  33476. 22:57:52from the external one you have to use uh
  33477. 22:57:55you have to copy this external database
  33478. 22:57:56URL. Okay. Now let's try to copy that
  33479. 22:57:58and make sure you don't share this URL
  33480. 22:58:00with anyone otherwise they will be able
  33481. 22:58:02to access your database. Okay. I'm going
  33482. 22:58:04to remove I'm going to delete the
  33483. 22:58:05instance after this recording. That's
  33484. 22:58:07why I'm showing you. So I'll copy this
  33485. 22:58:10and uh what I can do. Maybe I can save
  33486. 22:58:13it somewhere.
  33487. 22:58:16Let's I will save save this inside my
  33488. 22:58:18readmi file.
  33489. 22:58:24Okay. So this is the information I have.
  33490. 22:58:27So this information I need to connect
  33491. 22:58:30with my PG admin. So now let's open the
  33492. 22:58:32PG admin. So there is a option called
  33493. 22:58:34server. Just try to right click and
  33494. 22:58:36there is a option called register. Okay
  33495. 22:58:38just click on register and there is a
  33496. 22:58:41option called server. Now here you just
  33497. 22:58:43need to uh give the name of the server.
  33498. 22:58:46So I'll give
  33499. 22:58:48um
  33500. 22:58:50tab agent
  33501. 22:58:54or let's say tripmate
  33502. 22:58:58server. I'll give my application name
  33503. 22:59:01trip.
  33504. 22:59:04So this is the name
  33505. 22:59:08trip.
  33506. 22:59:16Okay, I'll give tripmmet and uh just
  33507. 22:59:19keep it as it is. Okay, then uh there is
  33508. 22:59:22a option called connection. Just click
  33509. 22:59:24on the connection and here you have to
  33510. 22:59:25give the name. Okay, host name and where
  33511. 22:59:28get get this host name? Host name should
  33512. 22:59:30be uh this one.
  33513. 22:59:33This should be the host name. See after
  33514. 22:59:35add the rate, right? Whatever you have
  33515. 22:59:37just try to copy till.com render.com.
  33516. 22:59:39This is your host name. Just try to copy
  33517. 22:59:42and provide it here.
  33518. 22:59:46So this is the host name. Okay. Now by
  33519. 22:59:49default uh this postgress run runs on
  33520. 22:59:52port number five uh 5432. No need to
  33521. 22:59:55change change this. Now you have to give
  33522. 22:59:57the database name. Okay. So what is the
  33523. 22:59:59database name? So here is the database
  33524. 23:00:02name agent memory.
  33525. 23:00:10So just try to copy this.
  33526. 23:00:13This is the name. You can also verify
  33527. 23:00:16simply go to the
  33528. 23:00:19server
  33529. 23:00:21and here is the database. Okay. So this
  33530. 23:00:23is the name actually it has taken for
  33531. 23:00:24the database. So I have given agent
  33532. 23:00:27memory but it has added this uh 68 K5
  33533. 23:00:32because it should be unique name. Okay,
  33534. 23:00:33that's why this information has added.
  33535. 23:00:35Okay, just try to copy this and add it
  33536. 23:00:37here.
  33537. 23:00:39Okay, now it has u it is asking for the
  33538. 23:00:42username. So what is the username? I
  33539. 23:00:45think you remember I given the username
  33540. 23:00:47entpo
  33541. 23:00:49verify in the postgress
  33542. 23:00:51server.
  33543. 23:00:53here. So, username is yenduppy. Let's
  33544. 23:00:55copy and paste it here. Now, I have to
  33545. 23:01:00give the password. Okay. Where to get
  33546. 23:01:01the password?
  33547. 23:01:03Here is the password.
  33548. 23:01:05This is the password. Okay. Let's copy.
  33549. 23:01:08Even it is also available on my URL. So,
  33550. 23:01:10this is the URL. Okay. This is the
  33551. 23:01:12password. Just try to copy and paste it
  33552. 23:01:15here. Okay. Then just try to activate
  33553. 23:01:18this one. Save password on. And uh yeah,
  33554. 23:01:22everything is fine. Now simply
  33555. 23:01:26let me check everything is required or
  33556. 23:01:28not. No, I think everything is fine. Now
  33557. 23:01:29I'll just try to save this information.
  33558. 23:01:36See once you will do that it will be
  33559. 23:01:39connected to the uh render postgress
  33560. 23:01:42server. Okay. Now you can expand it. Now
  33561. 23:01:45you can click on database. Now see this
  33562. 23:01:47agent memory uh 68 uh 68 K5 agent memory
  33563. 23:01:5468 K5 okay this database I can see
  33564. 23:01:57because this is already connected now
  33565. 23:01:59whatever tables you will be creating
  33566. 23:02:00inside that it would it would be
  33567. 23:02:02available inside PG admin okay I can see
  33568. 23:02:04all the tables so this this table now I
  33569. 23:02:07can refresh and simply
  33570. 23:02:09uh see right now there is no table uh we
  33571. 23:02:11haven't created but once I will try to
  33572. 23:02:13create the table you'll be able to see
  33573. 23:02:14all the tables okay all of the
  33574. 23:02:16conversations be available. So see so
  33575. 23:02:18far we have connected our uh Postgress
  33576. 23:02:20server with my PG admin. Now right now
  33577. 23:02:22you have the graphical user interface
  33578. 23:02:24and from there you can see all of the
  33579. 23:02:27tables you will be creating going
  33580. 23:02:28forward. Okay so that means my Postgress
  33581. 23:02:31installation is completely done.
  33582. 23:02:32Postgress setup is completely done and
  33583. 23:02:34this is running on my render cloud.
  33584. 23:02:37Okay. I hope you get it.
  33585. 23:02:39So guys, we have successfully uh set up
  33586. 23:02:41our postgrad server on the render and we
  33587. 23:02:44have connected with our PG admin and
  33588. 23:02:46this is running completely fine. Now I
  33589. 23:02:49need to set up some additional uh
  33590. 23:02:51additional let's say keys which is
  33591. 23:02:53required for this development. So first
  33592. 23:02:55thing I need the um I need the aviation
  33593. 23:02:59stack API key. Okay.
  33594. 23:03:03Um aviation stack API key.
  33595. 23:03:06Then I need
  33596. 23:03:09Gro API key. Okay, first of all, let's
  33597. 23:03:12collect the Gro API key. Okay, our LLM
  33598. 23:03:15provider API key because here I told you
  33599. 23:03:17I'll be using a metal lama model. Okay,
  33600. 23:03:19llama 3 model from the Gro Gro provider.
  33601. 23:03:23Then um I need
  33602. 23:03:27table API key.
  33603. 23:03:33Then I need uh my database URL.
  33604. 23:03:37Okay, that means my postgress database
  33605. 23:03:39URL. And we already copied the URL. I
  33606. 23:03:41think you remember that external URL.
  33607. 23:03:43I'll just try to copy this as it is.
  33608. 23:03:45Let's cut it. Okay. And I'll try to save
  33609. 23:03:48inside this variable.
  33610. 23:03:52So this is the URL. Okay. So with this
  33611. 23:03:54URL, my Python client will be able to
  33612. 23:03:57connect with my Postgress server. It
  33613. 23:03:59will store all of the conversation
  33614. 23:04:00there. Okay. So make sure you copied
  33615. 23:04:03this external URL, the URL we just
  33616. 23:04:05copied. Okay, external URL this one and
  33617. 23:04:08try to save here. Okay, then I need um
  33618. 23:04:12some other things like my lang uh API
  33619. 23:04:17key and tracing. These are the things I
  33620. 23:04:19need. Let me show you
  33621. 23:04:24because uh to monitor to trace the
  33622. 23:04:27entire application we'll be using lang.
  33623. 23:04:29So this is the lang. Okay, lang speed
  33624. 23:04:31tracing it should be true. Lang speed
  33625. 23:04:33endpoint. So this is the URL you have to
  33626. 23:04:35provide and lang API key we have to
  33627. 23:04:37collect. Okay. So let's delete this API
  33628. 23:04:39and I'll collect my own API and lang
  33629. 23:04:42project name. So let's say I'll give uh
  33630. 23:04:45travel agent. Okay. Or let's say I'll
  33631. 23:04:47give uh my project name which is
  33632. 23:04:51tripmmeti.
  33633. 23:04:59Let's say this is my project name. Okay.
  33634. 23:05:02Now let's collect all of the API key one
  33635. 23:05:03by one. Okay. One more thing I have to
  33636. 23:05:05add which is the default origin data.
  33637. 23:05:09H default origin data [clears throat]
  33638. 23:05:10means let's say here the things you have
  33639. 23:05:13to do. You have to give the location A
  33640. 23:05:16to B. Let's say you want to visit India
  33641. 23:05:18to Thailand, right? So India is your
  33642. 23:05:21origin, right? And Thailand you want to
  33643. 23:05:24visit. So by default if user is not
  33644. 23:05:26providing origin let's say user is
  33645. 23:05:28giving the prompt like that uh I want to
  33646. 23:05:32visit Nepal. Okay. So you are not giving
  33647. 23:05:35the origin here. So by default uh you
  33648. 23:05:38can set the origin here. Okay. Let's say
  33649. 23:05:40which your origin. So let's say I'm from
  33650. 23:05:42Dhaka right now. So I'll give D A C.
  33651. 23:05:45Okay. That means Dhaka. So from Dhaka it
  33652. 23:05:47will plan to the different country.
  33653. 23:05:50Okay. That means Dhaka is the origin
  33654. 23:05:51right now for me. Okay. I I hope you get
  33655. 23:05:54it guys. Okay. So that's how we can add
  33656. 23:05:57a default origin. If user is missing
  33657. 23:05:59their origin, you it will automatically
  33658. 23:06:01take the default origin. Okay, you can
  33659. 23:06:02change this origin as per your
  33660. 23:06:03requirement. If you're in let's say
  33661. 23:06:05Thailand, you can give Thailand. If
  33662. 23:06:06you're in let's say USA, you can give
  33663. 23:06:08USA. Okay, it's up to you you. So yes,
  33664. 23:06:11uh this is how we have to add all of the
  33665. 23:06:14API key. Now let's collect the Gro API
  33666. 23:06:15key first of all. So what I will do,
  33667. 23:06:17I'll just uh go to the Gro platform. So
  33668. 23:06:21you can search for Gro
  33669. 23:06:24Gro API key. Okay, simply search for
  33670. 23:06:26Grock API key and um go to the first
  33671. 23:06:29website
  33672. 23:06:36and uh you can create a API key here.
  33673. 23:06:38Okay, so let's create a API key.
  33674. 23:06:43So what I can do, I can maybe remove my
  33675. 23:06:46previous API key.
  33676. 23:06:52Now I'll create a new one. I'll give the
  33677. 23:06:55name. Let's say I'll give um
  33678. 23:06:58my trip agent
  33679. 23:07:08tripment no expiration just try to keep
  33680. 23:07:11it here. If you want expiration you can
  33681. 23:07:12also select. Now let's submit.
  33682. 23:07:21Now this is your API key. Just try to
  33683. 23:07:23copy and make sure you are adding inside
  33684. 23:07:25your environment variable. Okay. Yeah.
  33685. 23:07:29Now you can ask me I have given double
  33686. 23:07:30quotation here but in the database URL I
  33687. 23:07:33haven't given any document uh double
  33688. 23:07:34quotation. See whenever you are adding
  33689. 23:07:36the database URL no need to give any
  33690. 23:07:37double quotation. Okay. Uh because
  33691. 23:07:40database uh URL is a sensitive
  33692. 23:07:42information. If you are give quotation
  33693. 23:07:44sometimes it will also consider as a
  33694. 23:07:45quotation uh as this u as this URL.
  33695. 23:07:49Okay. So that's why I'm not giving any
  33696. 23:07:50kinds of quotation. Perfect. So we have
  33697. 23:07:52successfully copied the gro grapi key
  33698. 23:07:55and uh inside gro you will be able to
  33699. 23:07:57see different different models are
  33700. 23:07:58available. Let me show you if I go to
  33701. 23:08:01the dashboard
  33702. 23:08:04I think playground and here you have
  33703. 23:08:06different different model. So here I'll
  33704. 23:08:08be using meta llama model. Okay. You can
  33705. 23:08:11also use any other model. It's
  33706. 23:08:12completely up to you. Then the next
  33707. 23:08:14thing guys I need my aviation stack API
  33708. 23:08:18key. Okay. So let's search for aviation
  33709. 23:08:20stack API key. You can simply search on
  33710. 23:08:23Google aviation stack API key. So this
  33711. 23:08:26is the first website. Just go to the
  33712. 23:08:28website.
  33713. 23:08:30Okay. So this is the website guys. Now
  33714. 23:08:33here you will see one option get free
  33715. 23:08:35API key. But for this you have to sign
  33716. 23:08:36up. Okay. Sign up in their account. So I
  33717. 23:08:39already have the account. I'll try to
  33718. 23:08:40login.
  33719. 23:08:42Let's give my email and password
  33720. 23:08:45and login.
  33721. 23:08:50Okay. So I've lo I've logged in. Now
  33722. 23:08:52here you have the API key. Okay. Just
  33723. 23:08:53try to copy this API key. Uh this is the
  33724. 23:08:56API key as you can see. Just try to copy
  33725. 23:08:59and you paste it here.
  33726. 23:09:03Okay. This is my aation stack API key.
  33727. 23:09:05So we need this aation stack API key to
  33728. 23:09:07get the realtime flight information.
  33729. 23:09:09Okay. Uh so as you can see this is the
  33730. 23:09:13interface
  33731. 23:09:18so free realtime flight status and
  33732. 23:09:20global aviation data API. Okay. This
  33733. 23:09:22provides flight tracker airport
  33734. 23:09:25uh timetable data web service trusted by
  33735. 23:09:28uh 5,000 plus of smart test company.
  33736. 23:09:31Okay fine. Now the next thing I need
  33737. 23:09:34which is uh table API key. Okay. For
  33738. 23:09:37realtime source operation I think you
  33739. 23:09:38saw the diagram right? So I have already
  33740. 23:09:41collected my aviation stack API key and
  33741. 23:09:43gro API key. Okay, for the large
  33742. 23:09:45language model provider. Now for
  33743. 23:09:46realtime source operation I need tably
  33744. 23:09:48API key. Now let's collect this tably
  33745. 23:09:50API key. So for this on Google just try
  33746. 23:09:52to search for tably API key. Go to the
  33747. 23:09:55tabi
  33748. 23:10:00and make sure you login with your
  33749. 23:10:02account.
  33750. 23:10:04Okay. Now here you have the API key.
  33751. 23:10:06Okay. So previously I already have some
  33752. 23:10:08API key. Maybe I can collect or maybe I
  33753. 23:10:11can create a new one. So let me delete
  33754. 23:10:13some of the API key.
  33755. 23:10:19I'll create a new one. I'm going to name
  33756. 23:10:21it name it as let's say
  33757. 23:10:24my project name.
  33758. 23:10:29Now simply create the API key.
  33759. 23:10:33Okay. Now copy this one and add inside
  33760. 23:10:37your environment variable
  33761. 23:10:41H. Now [clears throat] last thing I need
  33762. 23:10:43my Langismith API key for the tracing.
  33763. 23:10:46So we'll be using Langismith platform.
  33764. 23:10:47So you can search for
  33765. 23:10:48smith.langchen.com.
  33766. 23:10:50So this is the langismith platform. So
  33767. 23:10:52if you don't have account guys please
  33768. 23:10:54try to create one account. Uh so I
  33769. 23:10:56already logged in with my account. Okay.
  33770. 23:10:59But for you it will look like that.
  33771. 23:11:01Okay. So once you have done that uh you
  33772. 23:11:04have to collect the API key. So left
  33773. 23:11:07hand side you will see one option called
  33774. 23:11:08settings. Now here is the API key
  33775. 23:11:11section. Okay. Just create one API key.
  33776. 23:11:14So I'll create one API key here.
  33777. 23:11:20You can give the name.
  33778. 23:11:30Okay. Just keep it as it is.
  33779. 23:11:33Now expiration date you can give it as
  33780. 23:11:36never and create the API key. Now copy
  33781. 23:11:39this API key and mention it here.
  33782. 23:11:44Okay. And give the name of the
  33783. 23:11:47langismith project. I have given uh trip
  33784. 23:11:49AI. So it will create this project
  33785. 23:11:51inside that you will perform all the
  33786. 23:11:52tracing. Okay. So yes uh that's how we
  33787. 23:11:54have collected all of the API key
  33788. 23:11:56whichever we needed here. Now uh we what
  33789. 23:11:59we'll do guys, we'll just try to define
  33790. 23:12:01the folder structure. Then we'll try to
  33791. 23:12:03um implement the component one by one.
  33792. 23:12:08So guys, now let's try to define our
  33793. 23:12:10folder structure.
  33794. 23:12:12So first of all here uh what I'm going
  33795. 23:12:14to do, I'm going to create a folder. I'm
  33796. 23:12:17going to name it as tools. So inside
  33797. 23:12:18that I'm going to create all of my tools
  33798. 23:12:21I need uh for this development. So I
  33799. 23:12:23think you know I need some tools like uh
  33800. 23:12:25these aviation stack tools. So this
  33801. 23:12:28function I'll be writing separately. So
  33802. 23:12:29it will get the realtime flight
  33803. 23:12:31informations. Then for hotel agents I
  33804. 23:12:33need tabby right. So tab will do the
  33805. 23:12:35realtime source operation. It will get
  33806. 23:12:37the uh different different uh
  33807. 23:12:39information let information. For this I
  33808. 23:12:41will be creating another function. Okay.
  33809. 23:12:43So that's how I need separate separate
  33810. 23:12:44tools and this thing I'll try to define
  33811. 23:12:46inside my tools. So let's uh create some
  33812. 23:12:48file inside that. So first of all I'm
  33813. 23:12:50going to
  33814. 23:12:53define a constructor
  33815. 23:12:57init_.py.
  33816. 23:12:59Now inside that let's create a file. I'm
  33817. 23:13:02going to name it as flight 2.py
  33818. 23:13:12and I'm going to create another file.
  33819. 23:13:13I'm going to name it as tabulator.py.
  33820. 23:13:27Okay. Yeah. Now, uh I need another
  33821. 23:13:34um
  33822. 23:13:37another files here.
  33823. 23:13:42I'm going to name it as back end
  33824. 23:13:51dotpy.
  33825. 23:13:53Then I'm going to create another file
  33826. 23:13:55called app.py.
  33827. 23:13:57So this is going to be my endpoint.
  33828. 23:13:59Okay. And uh I'm going to create another
  33829. 23:14:02folder called templates. So inside that
  33830. 23:14:05I'll write try to write my front end
  33831. 23:14:07codes that means HTML codes. write
  33832. 23:14:10templates inside that I'm going to
  33833. 23:14:12create a file called index
  33834. 23:14:14dot HTML. So here we'll try to write all
  33835. 23:14:17of the HTML code because I told you
  33836. 23:14:19we'll be using HTML CSS JavaScript with
  33837. 23:14:22the first API and first API needs this
  33838. 23:14:24template folder and this uh HTML file
  33839. 23:14:27and whatever CSS and um uh JavaScript
  33840. 23:14:30file uh I'll be writing it should be
  33841. 23:14:32available inside static folder
  33842. 23:14:35okay static folder inside that I'm going
  33843. 23:14:37to create two more file one is style
  33844. 23:14:43dot CSS other this uh script.js.
  33845. 23:14:56Okay. And if you don't know about HTML,
  33846. 23:14:58CSS, JavaScript, no need to worry. Uh
  33847. 23:15:00simply you can take the help from chart
  33848. 23:15:02GPT and you can create this at the user
  33849. 23:15:04interface for you. Okay. So yes, these
  33850. 23:15:06are my folders and file I need for this
  33851. 23:15:09development. Now let me close this at
  33852. 23:15:11the one by one.
  33853. 23:15:17Now let me commit the changes on my
  33854. 23:15:19GitHub. So simply I'll tell folder
  33855. 23:15:24structure
  33856. 23:15:26addit.
  33857. 23:15:38Now if I go to my GitHub refresh
  33858. 23:15:41see all of the folder structures are
  33859. 23:15:43available. Okay. So later on I also need
  33860. 23:15:46dockard file. Uh I will use that
  33861. 23:15:47whenever I'll do the deployment. Okay.
  33862. 23:15:49As of now it's completely fine. Now
  33863. 23:15:51first of all uh what I can do guys?
  33864. 23:15:53First of all let's say um here
  33865. 23:15:57I'm going to define the tool. Okay.
  33866. 23:15:59First of all let's write this tably
  33867. 23:16:01tool.
  33868. 23:16:07H so I already installed the uh
  33869. 23:16:10environment and the environment name is
  33870. 23:16:15travel right I think I created travel
  33871. 23:16:17I'll select this environment okay now
  33872. 23:16:18let's import some necessary package so
  33873. 23:16:20I'll import tavly
  33874. 23:16:23import
  33875. 23:16:25tavi client okay then I need operating
  33876. 23:16:28system
  33877. 23:16:30then I need so from
  33878. 23:16:34env import
  33879. 23:16:36load 4 DNB done. Now I'll try to load my
  33880. 23:16:39environment variable
  33881. 23:16:42H then let's create a table client first
  33882. 23:16:44of all. So client
  33883. 23:16:47is equal to table client.
  33884. 23:16:52So first of all inside that you have to
  33885. 23:16:54pass the API key. So why do you have the
  33886. 23:16:56API key? API key is available inside my
  33887. 23:16:58environment. I'll just write west dot
  33888. 23:17:00get env. Okay. get
  33889. 23:17:04uh
  33890. 23:17:06env.
  33891. 23:17:08And what is the name of my key?
  33892. 23:17:12The key name is
  33893. 23:17:15Table API key. I'll copy this and paste
  33894. 23:17:18it here.
  33895. 23:17:24So this is going to be uh this is going
  33896. 23:17:26going to give me the client. Okay. So
  33897. 23:17:28after that here we'll just try to write
  33898. 23:17:30a function. So div tab search
  33899. 23:17:39inside that uh it will take a query that
  33900. 23:17:41means the search query.
  33901. 23:17:45Okay. And uh it will search over the
  33902. 23:17:49internet. So for this I'll just try to
  33903. 23:17:51write response
  33904. 23:17:53is equal to client
  33905. 23:17:56dot search. Okay. And inside search I
  33906. 23:17:59will give my query
  33907. 23:18:02query is equal to my query and there is
  33908. 23:18:05another parameter you have to give
  33909. 23:18:07called max result. Okay that means how
  33910. 23:18:08many maximum search result you want. So
  33911. 23:18:11I need five results. Okay five search
  33912. 23:18:13results I need.
  33913. 23:18:15Then then whatever results I'll try to
  33914. 23:18:17get guys I'll try to uh I'll just try to
  33915. 23:18:20do some refinement operation that means
  33916. 23:18:22it will also give me some uh some kinds
  33917. 23:18:24of metadata but I don't need the
  33918. 23:18:26metadata. I only need the content,
  33919. 23:18:28right? And to filter out, I have written
  33920. 23:18:30this code.
  33921. 23:18:36Let me show you.
  33922. 23:18:39First of all, let's define the result.
  33923. 23:18:46So it it is going to be empty list.
  33924. 23:18:48Okay.
  33925. 23:18:49So this is the filter code I have
  33926. 23:18:51written. So it will run a for loop.
  33927. 23:18:53Okay. So um it will run the for loop on
  33928. 23:18:56the response result and it will get the
  33929. 23:18:58title URL snippet. Snippet means the
  33930. 23:19:01content and uh it will length the
  33931. 23:19:03snippet if the snippet it is more than
  33932. 23:19:06300 words. So what I'm going to do I'm
  33933. 23:19:08going to split it and I'm going to
  33934. 23:19:11append in my result uh result list.
  33935. 23:19:13Okay, that means I'm only taking the
  33936. 23:19:16content uh from my source result instead
  33937. 23:19:18of some metadata. Okay. So yeah, I think
  33938. 23:19:22um
  33939. 23:19:24[clears throat] it's done. Uh even you
  33940. 23:19:26can also uh I mean remove this if you
  33941. 23:19:28don't want. So this thing I have added
  33942. 23:19:30just to keep only the first 300
  33943. 23:19:32character to avoid wall of text. Okay.
  33944. 23:19:35So that's why but if you want you can uh
  33945. 23:19:37take the entire snippet if you want.
  33946. 23:19:39Okay. Uh it's up to you. Uh because we
  33947. 23:19:42are using a free large language model
  33948. 23:19:44and definitely some input output
  33949. 23:19:46limitations are there. Tken limitation
  33950. 23:19:47are there. So that's why I've taken like
  33951. 23:19:50some um some like important first
  33952. 23:19:53character instead of um I mean the last
  33953. 23:19:56one but you can uh you can ignore this
  33954. 23:19:59line. Okay, maybe you can directly take
  33955. 23:20:01the snippet and you can add inside the
  33956. 23:20:02results. Okay, this is completely up to
  33957. 23:20:04you. So this is my uh tably search
  33958. 23:20:06function. Okay, now let's test whether
  33959. 23:20:08it's working or not. So what I can do
  33960. 23:20:10maybe I can create another file here.
  33961. 23:20:12I'm going to name it as test.py.
  33962. 23:20:15Let's import this
  33963. 23:20:18from tools
  33964. 23:20:22dot tably.
  33965. 23:20:25import taby source.
  33966. 23:20:30Now
  33967. 23:20:31let's define an object. I'm going to
  33968. 23:20:34call the table s. Inside that I'm going
  33969. 23:20:36to give a query. So let's say I'll give
  33970. 23:20:39um best hotels
  33971. 23:20:46in
  33972. 23:20:48India
  33973. 23:20:50and I'm going to print the response.
  33974. 23:20:56Now let's execute.
  33975. 23:20:58So python test.py.
  33976. 23:21:04So you can see this is the information
  33977. 23:21:05we are getting. Best hotels in India. So
  33978. 23:21:08it is uh uh see it is referring
  33979. 23:21:11different different website realtime
  33980. 23:21:13website. Okay. Uh that means
  33981. 23:21:15tripadvisor.com [snorts]
  33982. 23:21:18and it is finding some best website uh
  33983. 23:21:21hotels. Okay. Then some other YouTube
  33984. 23:21:23resources also it has u referred some
  33985. 23:21:26review it has uh seen right and it is
  33986. 23:21:29giving you some best hotels in India.
  33987. 23:21:30Okay. So that's how we are getting best
  33988. 23:21:33out of all of the uh all of the let's
  33989. 23:21:36say resources out there with the help of
  33990. 23:21:38this tablely instead of manually
  33991. 23:21:40exploring. I have the table. I can
  33992. 23:21:42search like I need best things. It will
  33993. 23:21:44automatically search over different
  33994. 23:21:46different website, hotels. Okay. And it
  33995. 23:21:48will give me those information. Okay.
  33996. 23:21:50For my agents, this is the idea. See?
  33997. 23:21:52Okay. It is referring that URL. That
  33998. 23:21:56means this function is working
  33999. 23:21:57completely fine. There is no issue with
  34000. 23:21:58this function. Now, simply I'll just try
  34001. 23:22:01to
  34002. 23:22:03open up my code again. Yeah. Now, next
  34003. 23:22:06guys, I'll be writing my flight tools.
  34004. 23:22:08Okay. This uh tools I have to write. Now
  34005. 23:22:10this will give you that realtime flight
  34006. 23:22:11informations. Okay. So for this let's
  34007. 23:22:14import some necessary library. So I need
  34008. 23:22:16hovering system.
  34009. 23:22:19I need regular expression.
  34010. 23:22:22I need certify.
  34011. 23:22:29I need
  34012. 23:22:34air
  34013. 23:22:37airports data. I need pi country
  34014. 23:22:48then I need. So from env
  34015. 23:22:52import load env.
  34016. 23:22:57Okay then I'll load the environment
  34017. 23:23:00variable.
  34018. 23:23:02After that um see if you're using
  34019. 23:23:04Windows operating system uh you might
  34020. 23:23:06get a path issue. So to prevent that we
  34021. 23:23:08add this two line SSL uh uh sert files
  34022. 23:23:13and request key bundles. Okay you have
  34023. 23:23:15to give certified dot wire. So if you're
  34024. 23:23:18uh getting the path issue that time you
  34025. 23:23:20can give. Okay. So I have given uh for
  34026. 23:23:22this sest purpose. Then first of all I
  34027. 23:23:24have to get my aviation API key. So I'll
  34028. 23:23:27just write API key is equal to
  34029. 23:23:35OS dot get env. Okay. And what is the
  34030. 23:23:40name of that? And the name of that is
  34031. 23:23:43aviation API key. Aviation stack API
  34032. 23:23:45key. I'll just try to get this API key.
  34033. 23:23:49So once you get the API key, you also
  34034. 23:23:51need to take the origin.
  34035. 23:23:56See I'm taking the origin as well.
  34036. 23:23:58Default origin we mentioned Dhaka here
  34037. 23:24:01but if you want you can also change it
  34038. 23:24:03as per your requirement. Okay. So here
  34039. 23:24:05my default origin is dhaka. If user is
  34040. 23:24:06not giving any default origin it will
  34041. 23:24:08take the dhaka otherwise uh it will take
  34042. 23:24:10the default uh uh it will take the
  34043. 23:24:12origin. Okay. From the user query then
  34044. 23:24:15uh what is the base URL for aviation
  34045. 23:24:17flights. So this is the base URL. You
  34046. 23:24:20can visit the base URL. So here you have
  34047. 23:24:23to give a API key. If you give the API
  34048. 23:24:24key, this will give you the this will
  34049. 23:24:26return you the aviation. Sorry, this
  34050. 23:24:28will return you the flight information.
  34051. 23:24:29Okay. So, we are hitting this website
  34052. 23:24:31API. Okay. Now, uh first of all, I will
  34053. 23:24:35load the airport's data. So, to load the
  34054. 23:24:38airports data, you have to use airports
  34055. 23:24:40data.load. Then you have to give I uh I
  34056. 23:24:43a
  34057. 23:24:46give you all the airports. Then I will
  34058. 23:24:48also mention my country allias
  34059. 23:24:54because sometimes uh user may pass the
  34060. 23:24:57allies information right let's say user
  34061. 23:24:59will give us US means USA okay that's
  34062. 23:25:01how it it has all the allies name for
  34063. 23:25:04all the country let's say Korea K R
  34064. 23:25:06Dhaka uh D AK right I already told you
  34065. 23:25:09so this is called allies so we are
  34066. 23:25:11defining the allies then country many
  34067. 23:25:15airport.
  34068. 23:25:16So all the country main airport I'll
  34069. 23:25:18just try to mention here. So these are
  34070. 23:25:21the airport name. Okay. So B, DA, India,
  34071. 23:25:25Dell like that. Then city main airport
  34072. 23:25:32these are my city many airports. Okay we
  34073. 23:25:35are defining.
  34074. 23:25:38Then we'll just write a function for
  34075. 23:25:40cleaning the text. So clean text. So it
  34076. 23:25:43this will take the text and it will
  34077. 23:25:44perform the cleaning operation. It will
  34078. 23:25:45remove some stop words and all. Okay?
  34079. 23:25:47And it will return return you that.
  34080. 23:25:51Then I'll write another function. This
  34081. 23:25:53will return you country name to code.
  34082. 23:25:56Okay? If you give any text that means
  34083. 23:25:57the country name, it will return you the
  34084. 23:25:59country code.
  34085. 23:26:01Then airports
  34086. 23:26:03country matches.
  34087. 23:26:05So if you're um giving give if you're
  34088. 23:26:09giving any airports and country code it
  34089. 23:26:11will give you the uh airports. Okay.
  34090. 23:26:16Then get best airports for the country.
  34091. 23:26:19For this I have written another
  34092. 23:26:20function.
  34093. 23:26:23Okay. So get best airport for the
  34094. 23:26:25country. So you just need to give the
  34095. 23:26:27country code. It will give you the best
  34096. 23:26:28airport for that.
  34097. 23:26:30Then uh some other things I have also
  34098. 23:26:32added here. So this is like more robust
  34099. 23:26:35code I have written. Um
  34100. 23:26:39if you see over the uh internet right
  34101. 23:26:43and if you see this uh aviation stack uh
  34102. 23:26:46API key code uh you will see different
  34103. 23:26:47different codes are available over the
  34104. 23:26:49internet people are using to get the
  34105. 23:26:51realtime information realtime uh flight
  34106. 23:26:54information with respect to all the
  34107. 23:26:55country. Okay. So I utilize the internet
  34108. 23:26:57resources and I prepared the entire uh
  34109. 23:27:00function for you. Okay. So this is
  34110. 23:27:02giving you the location.
  34111. 23:27:05Okay. Then let me show you some other
  34112. 23:27:08things I have added.
  34113. 23:27:20So this is the entire code guys. Okay.
  34114. 23:27:31So one thing I have to import which is
  34115. 23:27:34request.
  34116. 23:27:39Now see this is the entire code I have
  34117. 23:27:41written to get the flight informations.
  34118. 23:27:43Okay. So see these are some dependency
  34119. 23:27:45utility function I need to get the
  34120. 23:27:47airport informations flight
  34121. 23:27:49informations. See
  34122. 23:27:54and some of the functionality I
  34123. 23:27:55generated from chart GPT just to make it
  34124. 23:27:57more robust. See here my main intention
  34125. 23:27:59is to handle all of the country user is
  34126. 23:28:01giving right. So that's why these are
  34127. 23:28:03the things are required. So see it will
  34128. 23:28:05return uh these are the thing airlines
  34129. 23:28:07flight status departure. Okay terminal
  34130. 23:28:10gate schedule. So these are the
  34131. 23:28:12information it will return from the
  34132. 23:28:14aviation stack API. So search flight
  34133. 23:28:18see we are getting these are the
  34134. 23:28:20informations. Okay now let's uh test
  34135. 23:28:23this whether it is working or not. So
  34136. 23:28:24what I can do? So this is the function
  34137. 23:28:26search
  34138. 23:28:28flight. This is my final function. This
  34139. 23:28:29takes the query and the limit. So by
  34140. 23:28:31default limit I have given 10. Okay 10
  34141. 23:28:34information it will give you okay 10
  34142. 23:28:36flight information it will return you.
  34143. 23:28:38So let let's test it. So what I can do
  34144. 23:28:41maybe I can copy this code.
  34145. 23:28:48I'll go to the test. I'll comment this.
  34146. 23:28:51Let's import that. So from
  34147. 23:28:54uh tools
  34148. 23:28:56dot flight
  34149. 23:29:01tools import
  34150. 23:29:07search flights. Okay. Now let's mention
  34151. 23:29:10the search plate and I'll get the result
  34152. 23:29:17and I'll print that.
  34153. 23:29:24Let's say I'll give Nepal trip from
  34154. 23:29:27Bangladesh.
  34155. 23:29:29Now if I execute
  34156. 23:29:39Now see this is giving you all the
  34157. 23:29:41flight information from Bangladesh to
  34158. 23:29:44Nepal. See all the flight information it
  34159. 23:29:46is returning you. Okay. And why this is
  34160. 23:29:49happening? Because I have written this
  34161. 23:29:51code. This code okay this is like more
  34162. 23:29:54robust code and it can handle almost all
  34163. 23:29:56kinds of entry. Okay. All kinds of
  34164. 23:29:58flight informations. Okay. So I took the
  34165. 23:30:01help from JPT. I prepared this entire
  34166. 23:30:04functionality for you. Even we can also
  34167. 23:30:06write a small function but a small
  34168. 23:30:08function has some limitation only if you
  34169. 23:30:10hit the aviation stack API key that time
  34170. 23:30:12uh sometimes uh if you are uh giving the
  34171. 23:30:15wrong let's say location name that times
  34172. 23:30:18it will uh return you none. Okay. So to
  34173. 23:30:21handle this kinds of scenario because
  34174. 23:30:23user can give any anything right in the
  34175. 23:30:25chat interface they can sometimes uh
  34176. 23:30:28let's say give the wrong input okay uh
  34177. 23:30:31of the country that time it can also
  34178. 23:30:33handle this kinds of scenario okay
  34179. 23:30:34that's why I have written this code now
  34180. 23:30:37you can ask me why I'm not using tools
  34181. 23:30:39decorator here whenever I'm writing the
  34182. 23:30:41tools um see here I'm not going to use
  34183. 23:30:45it as a um as a like custom tool instead
  34184. 23:30:49of Right? I'll be using it inside my
  34185. 23:30:52agent. Okay, I'll tell you this part how
  34186. 23:30:54to do that. That's why I'm not using any
  34187. 23:30:55kinds of tool functionality from langen.
  34188. 23:30:57Okay, I'll tell you. So yes, uh my table
  34189. 23:31:01and flight tools functionality are added
  34190. 23:31:03and this is completely working fine. We
  34191. 23:31:05have already tested. Now we'll start the
  34192. 23:31:08uh agent workflow. Okay, but before that
  34193. 23:31:10let me commit the changes. So here I'll
  34194. 23:31:12just write flight
  34195. 23:31:18and
  34196. 23:31:20davi
  34197. 23:31:23tools
  34198. 23:31:25edit.
  34199. 23:31:34Now go to uh GitHub refresh.
  34200. 23:31:38This is available. Okay.
  34201. 23:31:41All right. Now let's work on the um
  34202. 23:31:44agentic workflow part. That means right
  34203. 23:31:47now my tools are ready. Okay. Uh all the
  34204. 23:31:49tools whatever we'll be using aviation
  34205. 23:31:51stack and tab these are ready. Okay.
  34206. 23:31:54Then I now I'll be working on the agent
  34207. 23:31:56part. Okay. We'll try to define all the
  34208. 23:31:57agents one by one and we'll be creating
  34209. 23:31:59the langraph workflow. Once all of the
  34210. 23:32:02agent uh implementation is complete then
  34211. 23:32:05we'll um also uh define the uh state.
  34212. 23:32:10Okay. And this state will try to save
  34213. 23:32:12inside my post SQL database. Okay. So
  34214. 23:32:16yeah, this is the entire plan. Now let's
  34215. 23:32:18try to work on the um agent workflow.
  34216. 23:32:21For this, I'm going to open up my
  34217. 23:32:22backend.py.
  34218. 23:32:25And here I'll just try to write all of
  34219. 23:32:27my code.
  34220. 23:32:30H. So first of all here, let's import
  34221. 23:32:32all the necessary library.
  34222. 23:32:36I need operating system
  34223. 23:32:39again. I need certify just to prevent
  34224. 23:32:42that path issue. And I need as well
  34225. 23:32:53load env. Okay. So I'll load my
  34226. 23:32:56environment variable
  34227. 23:32:58and uh this is the code I need to
  34228. 23:33:02prevent that path issue. Okay. Then I
  34229. 23:33:05need some other libraries as well. Let
  34230. 23:33:08me show you. Um these are the libraries
  34231. 23:33:11I need.
  34232. 23:33:14So I need uh this typing type dict and
  34233. 23:33:17why I need I think you know to define
  34234. 23:33:19the state okay of the graph. then
  34235. 23:33:21operator I need because here we'll be
  34236. 23:33:24using the reducer concept because all of
  34237. 23:33:26the conversation uh we are doing right
  34238. 23:33:28let's say I'm giving an input my my uh
  34239. 23:33:32agent is giving a output right and this
  34240. 23:33:34output I don't want to replace with the
  34241. 23:33:36previous one I have to add uh add it
  34242. 23:33:39like a list okay and for this I I can
  34243. 23:33:42use reducer concept okay I think you
  34244. 23:33:43know we have already studied about this
  34245. 23:33:45thing inside our course right inside my
  34246. 23:33:48aenti course I already told you about
  34247. 23:33:50that if you haven't checked that please
  34248. 23:33:51try to check then UI ID I need just to
  34249. 23:33:54define a shon trade I think you know uh
  34250. 23:33:58in persistence memory we have to give a
  34251. 23:34:00trade right trade id so every times uh
  34252. 23:34:02we can generate a new trades okay for
  34253. 23:34:04the user then uh this is for the
  34254. 23:34:06postgress okay database uh then uh we
  34255. 23:34:09are also importing this uh row uh dict
  34256. 23:34:11row okay for the postgress database then
  34257. 23:34:14uh from lang graph we are importing
  34258. 23:34:15state graph start and end and this is
  34259. 23:34:17the checkp pointer so from lang graph
  34260. 23:34:19checkpoint post case we're importing
  34261. 23:34:21postgress s ser s ser s ser s ser s ser
  34262. 23:34:22s ser s ser s ser s ser s server okay so
  34263. 23:34:23we'll try to save my checkpoint in my
  34264. 23:34:24postgress server apart from that I also
  34265. 23:34:27need to import these are the libraries
  34266. 23:34:30like from langen uh messages I need any
  34267. 23:34:33message human message AI message system
  34268. 23:34:35message then from grock
  34269. 23:34:39lang gro I need chat gro because we are
  34270. 23:34:41using grock API provider to access the
  34271. 23:34:43large language model and the tools we
  34272. 23:34:46have created so from tools
  34273. 23:34:50dot tab
  34274. 23:34:53I'll import my
  34275. 23:34:56table search and from tools
  34276. 23:35:01dot flight tools I'll import the search
  34277. 23:35:05flight
  34278. 23:35:06okay these two things I'll try to import
  34279. 23:35:08okay so yeah these are my imports uh I
  34280. 23:35:11need as of now first of all here what
  34281. 23:35:13I'm going to do I'm going to um I'm
  34282. 23:35:17going going to
  34283. 23:35:19define a function. Okay. So this
  34284. 23:35:20function what it returns it returns the
  34285. 23:35:22database URL. That means I think you
  34286. 23:35:25remember let me show you. So let me
  34287. 23:35:27close these are the files.
  34288. 23:35:30So I think you remember in the viewb we
  34289. 23:35:33have mentioned the database URL. Okay.
  34290. 23:35:34So this is the database URL. So this
  34291. 23:35:36database URL I have to return. Okay just
  34292. 23:35:39to connect with my Postgress SQL
  34293. 23:35:41database server. Okay. So for this I'll
  34294. 23:35:43define a function. So see this is the
  34295. 23:35:45function only you just need to do a
  34296. 23:35:47slight modification here which is that
  34297. 23:35:50at the last okay at the last of this URL
  34298. 23:35:52you will be adding this SSL mode is
  34299. 23:35:55equal to required that means if you if
  34300. 23:35:57this is your database right so here we
  34301. 23:35:59are adding this line we are adding this
  34302. 23:36:02line we are adding
  34303. 23:36:04this
  34304. 23:36:06this thing okay at the last
  34305. 23:36:12this thing at the last we'll be adding
  34306. 23:36:14Okay, this is required. Why this is
  34307. 23:36:16required? Because here we will be um
  34308. 23:36:19we'll be connecting with my remote
  34309. 23:36:21Postgress server, right? And uh for
  34310. 23:36:24remote postgress server, this is
  34311. 23:36:25required. So that's why we are checking.
  34312. 23:36:27First of all, we are getting the
  34313. 23:36:28database URL. Then we are checking if
  34314. 23:36:30not database URL, I'll raise the
  34315. 23:36:32exception database URL is missing.
  34316. 23:36:34Otherwise, I'll try to check if SSL mode
  34317. 23:36:36not in database URL, I'll just try to
  34318. 23:36:38add it and return the database URL.
  34319. 23:36:40Okay. Now how this uh this will uh look
  34320. 23:36:43like? So let me show you. So maybe I can
  34321. 23:36:46call this function. So URL is equal to
  34322. 23:36:50database URL. So I'll print the URL
  34323. 23:36:54right now.
  34324. 23:37:03So I'll
  34325. 23:37:05come here Python
  34326. 23:37:08app.py Py
  34327. 23:37:12okay sorry it's back end.py Pi sorry my
  34328. 23:37:15mistake so python
  34329. 23:37:18backend.py apply
  34330. 23:37:22now see this is what we are getting this
  34331. 23:37:23is the entire URL add the last see it is
  34332. 23:37:26adding this this thing okay it is it
  34333. 23:37:28will give you this uh question mark then
  34334. 23:37:30this SSL mode is equal to required okay
  34335. 23:37:33this thing it should add then I will be
  34336. 23:37:35able to connect with my postgress remote
  34337. 23:37:38server okay which is running on red okay
  34338. 23:37:40I hope you get it that's why we are
  34339. 23:37:41giving this function
  34340. 23:37:44yeah so now let's delete this code it's
  34341. 23:37:47not required Okay. Now guys, uh we'll
  34342. 23:37:50try to get some other things like my
  34343. 23:37:59let me show you
  34344. 23:38:05like my Gro
  34345. 23:38:08Gro API key.
  34346. 23:38:12So we are loading the GRO API key. Okay.
  34347. 23:38:14From the environment variable. Then here
  34348. 23:38:16we'll just try to write a condition
  34349. 23:38:19if not grock API key found it will raise
  34350. 23:38:21exception. Okay. Now we'll try to define
  34351. 23:38:23the large language model.
  34352. 23:38:28So here we are defining the large
  34353. 23:38:29language model. As you can see we are
  34354. 23:38:30using chat gro and model is equal to I'm
  34355. 23:38:33using llama 3.37 billion versatile
  34356. 23:38:36model. Okay, this is available on the
  34357. 23:38:39um rock.
  34358. 23:38:46See this one. Okay, this model we are
  34359. 23:38:48using. Okay, now you can use any model
  34360. 23:38:51only. You just need to give the model
  34361. 23:38:52ID. Okay, just try to check here. It has
  34362. 23:38:55the model ID. Just copy this model ID
  34363. 23:38:57and paste it here. It will use that
  34364. 23:38:59model and we are giving the um API key.
  34365. 23:39:03Then we have to define the state. Okay,
  34366. 23:39:05my
  34367. 23:39:07graph state.
  34368. 23:39:09So this is the state I have prepared
  34369. 23:39:11guys and I think you know what is a
  34370. 23:39:13state and how to define the state each
  34371. 23:39:14and everything I have completed in my
  34372. 23:39:16course. Please try to check guys. Okay.
  34373. 23:39:17So I named it as table state and
  34374. 23:39:19inherited with the type dict first of
  34375. 23:39:21all the message that means you can match
  34376. 23:39:23with here message okay whatever message
  34377. 23:39:25uh user is giving I'll try to store here
  34378. 23:39:27but this should be reducer object. Okay
  34379. 23:39:30that means we are doing operation dot
  34380. 23:39:32add that means every time it will add
  34381. 23:39:33add that message. Okay, instead of
  34382. 23:39:34replacing then user query whatever query
  34383. 23:39:37user is passing I'll write save in the
  34384. 23:39:39user query then flight result hotel
  34385. 23:39:41result uh then itinary uh result and one
  34386. 23:39:44additional things I have provided here
  34387. 23:39:46which is llm calls that means I want to
  34388. 23:39:48see how many times llm calls we are
  34389. 23:39:50doing here that means we'll do the lm
  34390. 23:39:52count as well this thing I also stored
  34391. 23:39:54inside my state memory okay that is my
  34392. 23:39:57shared memory now first of all I'll
  34393. 23:39:59define my flight agent okay the first
  34394. 23:40:01agent let's define the first agent So
  34395. 23:40:04this is my first agent. Flight agent.
  34396. 23:40:09Okay. So I named it as a flight agent.
  34397. 23:40:10It will take this state. Okay. As a
  34398. 23:40:12shared memory. Then uh first of all I'm
  34399. 23:40:15taking the user query from this state.
  34400. 23:40:16And we are doing the flight search
  34401. 23:40:18operation with the help of this search
  34402. 23:40:20flight function we have written inside
  34403. 23:40:21my flight tools. Okay. That is why I'm
  34404. 23:40:23not using this function as a tool custom
  34405. 23:40:26tool. Instead of that I'm using inside
  34406. 23:40:28my agent. Okay. I think you remember uh
  34407. 23:40:30I think you get it right. Why I'm not
  34408. 23:40:32using custom function? Yeah. So I'm
  34409. 23:40:35using directly inside my agent. So it is
  34410. 23:40:37doing the search operation. Uh it will
  34411. 23:40:39get the flight information and I'm
  34412. 23:40:41returning the flight information as a
  34413. 23:40:42result and AI message. Okay. The flight
  34414. 23:40:45result fetched. Then I'm also doing the
  34415. 23:40:47LM count. That means uh initially my LLM
  34416. 23:40:50call should be zero. Okay. So I'm just
  34417. 23:40:53uh getting that particular data and I'm
  34418. 23:40:55doing the plus one add operation. That
  34419. 23:40:58means if initially it was zero it will
  34420. 23:41:00add the plus one that means one LM call
  34421. 23:41:02I have done that's how many time LLM
  34422. 23:41:05call I will try to do I'll just try to
  34423. 23:41:06update this LM calls okay done so this
  34424. 23:41:09is my first agent we have prepared now
  34425. 23:41:11let me define the second agent which is
  34426. 23:41:12nothing but hotel agent okay now let's
  34427. 23:41:14define the hotel agent now what hotel
  34428. 23:41:16agent do it will use the tabularly
  34429. 23:41:18search and it will get the hotel
  34430. 23:41:20informations see this is my next agent
  34431. 23:41:22which is hotel agent so again it will
  34432. 23:41:24take the state and this is the query
  34433. 23:41:26best hotels for user query that means if
  34434. 23:41:29user is giving let's say I want to visit
  34435. 23:41:32uh Japan from Bangladesh so Japan best
  34436. 23:41:35hotel it will try to find right and for
  34437. 23:41:37this we're using tably search
  34438. 23:41:38functionality so this is the tab search
  34439. 23:41:40functionality it will found best hotels
  34440. 23:41:42okay from the internet and it will
  34441. 23:41:45return it here then I'm returning this
  34442. 23:41:46hotel result as well as the AI message
  34443. 23:41:48hotel information fetched and again we
  34444. 23:41:50are updating the lm calls with plus one
  34445. 23:41:53okay I think you get it so this is my
  34446. 23:41:55second agent now I'll try to define in
  34447. 23:41:57my third agent which is itinonary agent.
  34448. 23:42:00Okay. So basically this will uh do the
  34449. 23:42:02uh plan it will basically
  34450. 23:42:05uh create the places to visit activities
  34451. 23:42:07all of this thing right. So here what
  34452. 23:42:09I'm going to do I'm going to utilize the
  34453. 23:42:11large language model here because
  34454. 23:42:12without large language model I can't
  34455. 23:42:14generate the plan right so that's why I
  34456. 23:42:16have to use the large language model. So
  34457. 23:42:17this is my
  34458. 23:42:21uh next agent.
  34459. 23:42:23Okay inside back end.py I have to write
  34460. 23:42:26this is my uh itinary agent. Okay, as
  34461. 23:42:29you can see itinary agents this is
  34462. 23:42:31taking the state and this is the prompt
  34463. 23:42:33I'm defining. So create a complete
  34464. 23:42:34travel itinary uh user query. This is
  34465. 23:42:37the user query. This is the flight
  34466. 23:42:38result. This is the hotel information.
  34467. 23:42:40Okay. Make the itinary a practical
  34468. 23:42:42budget hour and easy to follow. Okay.
  34469. 23:42:45Now here we are ining the LLM. The LM we
  34470. 23:42:48have defined. I think remember this is
  34471. 23:42:49the LM we invoking the LM with this
  34472. 23:42:52prompt.
  34473. 23:42:54We are giving the system message you are
  34474. 23:42:56expert table planner and this is the
  34475. 23:42:57human message we are giving as a prompt.
  34476. 23:43:00Okay. Then after that we are returning
  34477. 23:43:01the itinary response message as well as
  34478. 23:43:04the LLM call we are also updating. Okay.
  34479. 23:43:07I hope you get it. So that's how we are
  34480. 23:43:08completing the third agent which is
  34481. 23:43:10itinonary agents. Now we'll be creating
  34482. 23:43:12the final agents which is final response
  34483. 23:43:14agents. That means it will take all of
  34484. 23:43:15the results and it will combine
  34485. 23:43:17everything. It will generate a final
  34486. 23:43:19response for me. Okay. So let's try
  34487. 23:43:20write it here. Uh so this is the result
  34488. 23:43:26for final response.
  34489. 23:43:36So this is our final agent. It will take
  34490. 23:43:38this state again and this is the final
  34491. 23:43:40prompt. Generate the final trial
  34492. 23:43:42response for the user. This is the user
  34493. 23:43:43query, flight information, hotel
  34494. 23:43:45information and this is the uh itinary
  34495. 23:43:48plan. Format the final answer
  34496. 23:43:50beautifully using these sections. That
  34497. 23:43:52means it will have the trip summary,
  34498. 23:43:54flight information, hotel suggestion,
  34499. 23:43:55daybyday, itinary, estimated budget,
  34500. 23:43:57final recommendation and some important
  34501. 23:43:59note as well. Okay. So yeah, this is my
  34502. 23:44:02entire prompt and we are again booking
  34503. 23:44:04the LLM. We are giving the system
  34504. 23:44:06message. You're a professional AI travel
  34505. 23:44:07booking assistant and this is the human
  34506. 23:44:09prompt you're giving and whatever
  34507. 23:44:10response I'm getting, I'm returning as a
  34508. 23:44:12response and I'm updating my LM call.
  34509. 23:44:14Okay, that's how we have completed four
  34510. 23:44:17agents implementation. Okay, now we'll
  34511. 23:44:19try to build the graph. So in like graph
  34512. 23:44:21we have to define the graph. Let's try
  34513. 23:44:23to define the graph right now. So we'll
  34514. 23:44:26build the graph. So to build the graph
  34515. 23:44:28first of all I have defined my state
  34516. 23:44:30graph. I passed my state and this is
  34517. 23:44:32going to be my graph. Now we'll try to
  34518. 23:44:34add all of the nodes one by one. First
  34519. 23:44:36of all I will add my flight agent then
  34520. 23:44:39hotel agent then itinerary agent then
  34521. 23:44:41final respond agents. All the agents
  34522. 23:44:43I'll try to add one by one.
  34523. 23:44:47So these are my agents. Okay, I'm adding
  34524. 23:44:49the nodes. Flight agent, flight agent,
  34525. 23:44:51hotel agent, hotel agent, itinary
  34526. 23:44:53agents, itinary agents, flight agents,
  34527. 23:44:55flight agents, sorry, final agent, final
  34528. 23:44:57agents. I have added all of the agent
  34529. 23:44:59node. Now I have to do the age
  34530. 23:45:01connection. Okay, that means flight
  34531. 23:45:03agents would be connected to the hotel
  34532. 23:45:04agent, hotel agent would be connected to
  34533. 23:45:06the itinary agents, final agents would
  34534. 23:45:08be connected to the final response
  34535. 23:45:09agents. Okay, that is the connection we
  34536. 23:45:11have to build right now. So, let me show
  34537. 23:45:13you the connection.
  34538. 23:45:15So, this is the connection. So, you can
  34539. 23:45:17see start uh start to flight agents.
  34540. 23:45:20Okay. Then uh flight agents to hotel
  34541. 23:45:23agents. Flight agent to hotel agents.
  34542. 23:45:26Then hotel agents to itinary agents.
  34543. 23:45:28Hotel agents to itinary agents. Okay.
  34544. 23:45:29Then itary agents to final response
  34545. 23:45:31agent to final response agents and final
  34546. 23:45:33respon agents to end. Okay. So this is
  34547. 23:45:35the connection we had we have done. Now
  34548. 23:45:38we have to define the postgrace
  34549. 23:45:41checkpointer. So I think remember we
  34550. 23:45:43already written a function called
  34551. 23:45:45database URL. So basically this returns
  34552. 23:45:47the database URL. Okay. And we are um
  34553. 23:45:50storing the URL inside a variable called
  34554. 23:45:53database URL. Now I'll try to do the
  34555. 23:45:56connection.
  34556. 23:45:58So we are using uh psyg.
  34557. 23:46:03We are giving the database URL. Then
  34558. 23:46:05auto commit is equal to true and row
  34559. 23:46:07factory is equal to dro. Okay, these are
  34560. 23:46:08the parameter I have to pass and it will
  34561. 23:46:10give you the connection and this
  34562. 23:46:12connection I have to pass inside my
  34563. 23:46:14checkpointer.
  34564. 23:46:16So postgress saver I think remember we
  34565. 23:46:18imported from checkpo pointer here from
  34566. 23:46:21lang gap checkpointter postgate
  34567. 23:46:22postgress saver inside that we have to
  34568. 23:46:24pass this connection and this will
  34569. 23:46:26return the checkpoint and we have to do
  34570. 23:46:28the checkpointter uh checkpointer dot
  34571. 23:46:30setup once it is done then I'll try to
  34572. 23:46:32pass this checkp pointer inside my graph
  34573. 23:46:35okay we'll try to compile so travel
  34574. 23:46:37graph is equal to graph graph dot
  34575. 23:46:40compile and we are giving the checkpoint
  34576. 23:46:42now all of this state would be saved
  34577. 23:46:43inside my memory Okay.
  34578. 23:46:47Then uh once everything is done, now let
  34579. 23:46:48me write the function
  34580. 23:46:52for my first API.
  34581. 23:46:56So this is the function final function.
  34582. 23:47:00So run travel agent. So this takes the
  34583. 23:47:02run user input and the trade ID. Okay.
  34584. 23:47:05So first of all, if user is uh not given
  34585. 23:47:07trade ID, so what I'm doing, I'm just uh
  34586. 23:47:10generating a unique trade ID and uh we
  34587. 23:47:13are preparing the configuration. Okay,
  34588. 23:47:14configurable inside trade ID. I'm
  34589. 23:47:16passing my trade ID. Then I'm invoking
  34590. 23:47:18my travel graph. Okay, so here we're
  34591. 23:47:20doing the invoking. So we are giving the
  34592. 23:47:22human message user input and initially
  34593. 23:47:25my flight result, hotel result, itinary
  34594. 23:47:27lm cost would be empty. That's why I'm
  34595. 23:47:30passing as a empty. Then I'm passing the
  34596. 23:47:31configuration. Whatever result I'm
  34597. 23:47:33getting, I'm just checking the content
  34598. 23:47:35and I'm returning the response. That
  34599. 23:47:36means my trade ID, answer, flight
  34600. 23:47:38result, hotel result, it lm cost, each
  34601. 23:47:40and everything I'm just returning on my
  34602. 23:47:43front end. Okay. And in from here I'll
  34603. 23:47:46try to get the informations and uh what
  34604. 23:47:49I can do I'll just try to show in my
  34605. 23:47:51front end. Okay. The front end will try
  34606. 23:47:53to create. Now let me test whether it's
  34607. 23:47:54working or not. So what I can do I can
  34608. 23:47:56maybe run this travel agent test. I'll
  34609. 23:48:00copy this and open my test.py.
  34610. 23:48:03Let me import here. So from back end
  34611. 23:48:08uh import
  34612. 23:48:11run agent. Okay. And then again I'll try
  34613. 23:48:14to comment out.
  34614. 23:48:18So
  34615. 23:48:20response is equal [clears throat] to
  34616. 23:48:24run table agent
  34617. 23:48:31and I'll print the response
  34618. 23:48:38even maybe what I can do I can instead
  34619. 23:48:40of writing like that I can write a full
  34620. 23:48:42loop. Okay let me show you
  34621. 23:48:45I can write a for loop like that.
  34622. 23:48:54So here I'm taking a user input uh from
  34623. 23:48:56the user and um
  34624. 23:49:01um okay instead of for loop maybe I can
  34625. 23:49:02directly run okay then I'm running the
  34626. 23:49:04travel agent this uh function and I'm
  34627. 23:49:07passing the user input and trade ID uh
  34628. 23:49:11just for testing purpose I've given test
  34629. 23:49:12user and whatever response I'm getting
  34630. 23:49:14I'm just u printing the response. Okay,
  34631. 23:49:16now let me test. So I'll just try to
  34632. 23:49:19execute.
  34633. 23:49:35So I'll just run python backend.py.
  34634. 23:49:39Not backend.py, sorry. It should be
  34635. 23:49:43um it should be test.py. Pi. Okay, let's
  34636. 23:49:47execute. Huh? So, Python test.py.
  34637. 23:49:54Now, it is asking the user input. So,
  34638. 23:49:56let's give a input.
  34639. 23:50:12So, this is my user input. uh plan a
  34640. 23:50:15complete 7 days India trip from
  34641. 23:50:17Bangladesh including flights, hotel, uh
  34642. 23:50:20sightseeing under two lakhs. Now let's
  34643. 23:50:22see
  34644. 23:50:33now see this is the entire plan I'm
  34645. 23:50:35getting. So final response, the summary,
  34646. 23:50:38flight information, hotel suggestions,
  34647. 23:50:41dayby-day itinerary, then uh estimated
  34648. 23:50:44budget, final recommendation. Amazing.
  34649. 23:50:47Okay, it's working fine. Now we have to
  34650. 23:50:50add uh add this inside my user
  34651. 23:50:52interface. Okay, right now my back end
  34652. 23:50:54is ready. Okay, we are able to test it
  34653. 23:50:56perfectly. Now we'll be creating the
  34654. 23:50:59uh front end user interface with the
  34655. 23:51:01help of fast API and we'll be writing
  34656. 23:51:03the uh fast API uh fast API route. Okay.
  34657. 23:51:07Uh backend route and so that my front
  34658. 23:51:09end can communicate with my um like back
  34659. 23:51:12end. Okay. So for this we'll be using
  34660. 23:51:14fast API service and fast API is a
  34661. 23:51:16production grade um uh web framework.
  34662. 23:51:19Okay. Especially API creation framework
  34663. 23:51:20you can use. Okay. So let's try to
  34664. 23:51:24implement my first API code guys right
  34665. 23:51:26now.
  34666. 23:51:29And one more thing I want to show you. I
  34667. 23:51:31already executed my uh workflow and it
  34668. 23:51:34has executed successfully. I think we
  34669. 23:51:36have seen that. Now let me see whether
  34670. 23:51:38it is able to store the checkpoint in my
  34671. 23:51:40database or not. Now I'll open up my PG
  34672. 23:51:42admin. And now if I refresh on my table
  34673. 23:51:45right now if I go inside the table
  34674. 23:51:48you'll see that all of the checkpoint
  34675. 23:51:50has created. Okay. Now here is a
  34676. 23:51:51checkpoint uh checkpointter table is
  34677. 23:51:53there. Now just try to right click and
  34678. 23:51:56there's a option called view edit data.
  34679. 23:51:58Now just click on all rows. Okay. If you
  34680. 23:52:00do that you'll be able to see that all
  34681. 23:52:02of the checkpoint it has saved here.
  34682. 23:52:08See all of the checkpoint it has saved.
  34683. 23:52:10Okay. This is the state memory and it
  34684. 23:52:13has also traced on my langid platform.
  34685. 23:52:16Let me open my lang.
  34686. 23:52:20done. If I go to my langu so trip AI if
  34687. 23:52:25I go inside that now see this is the
  34688. 23:52:27langismith execution even you can see
  34689. 23:52:29the trade wise okay the test user uh
  34690. 23:52:32trade we have given initially and this
  34691. 23:52:34is the execution
  34692. 23:52:36okay this is the execution it has done
  34693. 23:52:38okay see amazing right now let's try to
  34694. 23:52:41add my first API code so for this uh
  34695. 23:52:44I'll open up my app.py I
  34696. 23:52:48and here let's define all of the code
  34697. 23:52:51and I'm expecting guys you are already
  34698. 23:52:52familiar with fast API here uh first API
  34699. 23:52:55knowledge is required.
  34700. 23:52:59So here what I'm going to do I'm going
  34701. 23:53:01to import some necessary libraries.
  34702. 23:53:05Yeah. So I'm importing path from path
  34703. 23:53:07lip pack uvicon from fast API. I'm
  34704. 23:53:10importing fast API request first API.
  34705. 23:53:12I'm importing HTML response, JSON
  34706. 23:53:14response, static file, ginger templates
  34707. 23:53:16and base model from pientic. So here I
  34708. 23:53:19need piic just to define my um data
  34709. 23:53:22structure. I think I already completed
  34710. 23:53:24pientic videos as well on my um on my uh
  34711. 23:53:28agenti course and why pyic is required.
  34712. 23:53:30I already told you please guys to go
  34713. 23:53:32through that session. Then I need
  34714. 23:53:34another functionality which is my uh
  34715. 23:53:37this function run travel agent from my
  34716. 23:53:39back end. Let me import it as well.
  34717. 23:53:44So from back end
  34718. 23:53:48import
  34719. 23:53:52run agent. Okay. First of all let's
  34720. 23:53:54create a base directory.
  34721. 23:53:58Then I'll define my first API app.
  34722. 23:54:02That's how we can define the first API
  34723. 23:54:03app. So I have named it as AI travel
  34724. 23:54:05planning system. Or maybe I can give
  34725. 23:54:07this name trip AI.
  34726. 23:54:17Okay, tripate AI.
  34727. 23:54:20So this is a lang multi- aent travel
  34728. 23:54:23planner with fast API front end. And
  34729. 23:54:25this is the version we have given. Okay.
  34730. 23:54:27Now first of all you have to mount your
  34731. 23:54:29static folder as well as the template
  34732. 23:54:32folder. So let's mount
  34733. 23:54:34because inside static you have
  34734. 23:54:36JavaScript and CSS and template you have
  34735. 23:54:38the HTML. So we are doing the app
  34736. 23:54:39domount static and this is my static
  34737. 23:54:42fold file uh file directories okay we
  34738. 23:54:44are giving it and similar wise we have
  34739. 23:54:46[snorts] to give the templates as well.
  34740. 23:54:48So you can see ginger templates I am
  34741. 23:54:50passing my directory which is templates
  34742. 23:54:52inside that I have my HTML content. Now
  34743. 23:54:54what I have done guys I have already uh
  34744. 23:54:57generated HTML CSS code from chart GPT
  34745. 23:54:59for this uh project. See if you don't
  34746. 23:55:01know about HTML CSS design it's
  34747. 23:55:03completely fine that is there would be a
  34748. 23:55:05separate front-end developer for that.
  34749. 23:55:07uh they will be using some other front-
  34750. 23:55:09end framework like NexJS, react okay
  34751. 23:55:11with the help of that they will be
  34752. 23:55:12creating the front end server for you
  34753. 23:55:14and then they will be connecting with
  34754. 23:55:15your first API back end right so if you
  34755. 23:55:18don't know about HTML CSS completely
  34756. 23:55:20fine just try to go through chat GPT and
  34757. 23:55:22just tell I need this kinds of interface
  34758. 23:55:24okay just give me the HTML CSS and
  34759. 23:55:26JavaScript code charge GPT will give you
  34760. 23:55:28and you just need to copy paste here and
  34761. 23:55:30you you need to modify with respect to
  34762. 23:55:31your requirement so I've done the same
  34763. 23:55:33thing so this is my HTML code I
  34764. 23:55:35generated from chart GPT
  34765. 23:55:37uh for my user interface and then I
  34766. 23:55:40modify it okay as per my requirement. So
  34767. 23:55:43here title wise I can give my name trip
  34768. 23:55:46materi.
  34769. 23:55:56So that's how you can uh modify the data
  34770. 23:55:59data property with respect to your
  34771. 23:56:01requirement. Okay. Whatever data you
  34772. 23:56:02have inside HTML content just try to
  34773. 23:56:04change. So this is a simple code I have
  34774. 23:56:06generated from charge JPT and it needs a
  34775. 23:56:08CSS okay just to load the design. So CSS
  34776. 23:56:11style. So I'll again try to
  34777. 23:56:15give this CSS design here in my CSS file
  34778. 23:56:19static CSS style CSS file.
  34779. 23:56:22So this is the CSS codes design. Okay. I
  34780. 23:56:25have added
  34781. 23:56:27okay again I generated from chat GPT.
  34782. 23:56:30Then just to communicate with my front
  34783. 23:56:32end uh the just to communicate with my
  34784. 23:56:34first API route I need this scriptjs. So
  34785. 23:56:38again I prepared with the help of charg.
  34786. 23:56:42So this is my javascript code and hit it
  34787. 23:56:45hits my first API route. Okay I'll tell
  34788. 23:56:48you what are the route it will hit just
  34789. 23:56:50to get the data. So first of all it will
  34790. 23:56:52hit my API travel. Okay, API travel
  34791. 23:56:55means it will uh hit that API travel
  34792. 23:56:57route and it will get the uh it will get
  34793. 23:57:00the entire plan. Okay, that means
  34794. 23:57:01whatever execution I showed you right
  34795. 23:57:03now, these are the information it will
  34796. 23:57:04try to get and it will try to show in my
  34797. 23:57:06front end. Okay, this is what it is
  34798. 23:57:08doing. Now, let me show you. First of
  34799. 23:57:09all, let me define all the routes one by
  34800. 23:57:12one. So, first of all, I'll try to
  34801. 23:57:14define my
  34802. 23:57:16pantic schema travel request. I'm
  34803. 23:57:19inheriting with the base model and this
  34804. 23:57:20has the message and trade ID. Okay. And
  34805. 23:57:23this is my default route.
  34806. 23:57:26This is my default route. If you visit
  34807. 23:57:27my app, first of all, it will launch my
  34808. 23:57:29HTML page. And this is the final
  34809. 23:57:33API route.
  34810. 23:57:38This is my final API route as you can
  34811. 23:57:40see API/travel.
  34812. 23:57:42If you hit that and again I'm using
  34813. 23:57:43asynchronous, okay, asynchronous
  34814. 23:57:45functionality. Why asynchronous? Because
  34815. 23:57:47it will run my agent is a asynchronous
  34816. 23:57:50way. Okay, that means parallel execution
  34817. 23:57:52it will do. I think I already covered
  34818. 23:57:54this asynchronous as well in my
  34819. 23:57:55playlist. Just try to go through that.
  34820. 23:57:57So asynchronous uh I'm running you can
  34821. 23:57:59see travel planner it will take the uh
  34822. 23:58:02information from the user that means the
  34823. 23:58:04user input whatever user input will pass
  34824. 23:58:05from the input box. First of all I'm
  34825. 23:58:07checking if user is not available. I'm
  34826. 23:58:09returning message can cannot be empty.
  34827. 23:58:13Then if available I'm running my run
  34828. 23:58:15travel agent that means this function.
  34829. 23:58:16Okay, this function I have imported from
  34830. 23:58:18back end. So this function will return
  34831. 23:58:20what result okay and from the result
  34832. 23:58:22we're extracting these are the content
  34833. 23:58:24and we're returning okay in my front end
  34834. 23:58:28and if some exception is occurring I'm
  34835. 23:58:30handling the exception okay and uh some
  34836. 23:58:33other route I need uh sometimes uh it
  34837. 23:58:36will check the health condition of my
  34838. 23:58:38first API server so for this it will hit
  34839. 23:58:40this route / health and it will if
  34840. 23:58:43everything is uh working fine it will
  34841. 23:58:44give uh status is okay and this is
  34842. 23:58:47running and some icon to load some icon
  34843. 23:58:50actually you need this one okay now uh
  34844. 23:58:54finally I'm going to execute my server
  34845. 23:58:56with the help of uon run so app clone
  34846. 23:58:59app because this is app file and my
  34847. 23:59:01object is app my objective app okay then
  34848. 23:59:05uh host and port number and reload is
  34849. 23:59:07equal to true so these are the things
  34850. 23:59:08you have to provide okay now in this uh
  34851. 23:59:12javascript I'm calling this route if I
  34852. 23:59:14show you if I do just ctrl f and paste
  34853. 23:59:18see This is what actually I'm executing.
  34854. 23:59:19So whenever user is generating the
  34855. 23:59:21response, it is hitting here. Okay. And
  34856. 23:59:23it is getting the information. Let me
  34857. 23:59:25show you. So I'll execute my app right
  34858. 23:59:27now. So python app.py.
  34859. 23:59:34See this is running on local host port
  34860. 23:59:36number 8,000.
  34861. 23:59:38So I'll come here. Search for local host
  34862. 23:59:41port number 8,000. See this is your
  34863. 23:59:44application. Okay. Uh you can see this
  34864. 23:59:46is your application. Now here you have
  34865. 23:59:49to give the input. So let's say I'll
  34866. 23:59:50give this input Dubai trip. Plan a 5
  34867. 23:59:53days Dubai trip from Dhaka with flights,
  34868. 23:59:55hotels and sites uh site syncs. Now if I
  34869. 23:59:59see click on generate plan that time it
  34870. 24:00:01will hit this route. Okay, hit this
  34871. 24:00:03route and it will get all of these uh
  34872. 24:00:05information. It will generate all of the
  34873. 24:00:06information then it will get and show in
  34874. 24:00:08the front end. Let me show you. See
  34875. 24:00:12uh okay uh just terminating. Okay.
  34876. 24:00:14Because my previous application is
  34877. 24:00:16running. Okay. I already executed my uh
  34878. 24:00:18this app previously just to show you. So
  34879. 24:00:20let me first of all stop this execution.
  34880. 24:00:23Okay, now it will run.
  34881. 24:00:26It's running. Now refresh again. Now let
  34882. 24:00:30me give this prompt and generate the
  34883. 24:00:32plan.
  34884. 24:00:41Now see this is the entire plan we are
  34885. 24:00:44getting. Okay. in a beautiful format.
  34886. 24:00:47Okay. And there is a download PDF button
  34887. 24:00:50and how this is coming because of the
  34888. 24:00:51front- end design we have done. Okay. So
  34889. 24:00:54this work uh this work is completely uh
  34890. 24:00:56responsible for front- end designer. So
  34891. 24:00:59uh you just tell them okay what you
  34892. 24:01:00need. So if you need this kinds of
  34893. 24:01:02download PDF or if you need let's say uh
  34894. 24:01:05any u download any markdown file you
  34895. 24:01:08just tell them okay they will try to
  34896. 24:01:09prepare for you and you can um you can
  34897. 24:01:13just use that as it is. Okay. And this
  34898. 24:01:15is the trade it has created. Okay. Uh
  34899. 24:01:18because we haven't passed any trades.
  34900. 24:01:19That's why it has created a um randomly
  34901. 24:01:23generated trades. Okay. So that's how we
  34902. 24:01:25can give any kinds of prompt. Right now
  34903. 24:01:28let's say instead of Dubai I'll give
  34904. 24:01:31maybe Thailand.
  34905. 24:01:42See this is the plan for the Thailand.
  34906. 24:01:44So this is the summary. This is the
  34907. 24:01:46flight information. This is the hotel
  34908. 24:01:48suggestions. This is the dayby-day
  34909. 24:01:50itinary. Uh first day, second day, third
  34910. 24:01:53day, fourth day, fifth day, sixth day, 7
  34911. 24:01:55days. Okay. And estimated budget unit.
  34912. 24:01:59Then final recommendation. Okay.
  34913. 24:02:01Amazing. Right? Now I can easily
  34914. 24:02:03download this file and I can uh I can
  34915. 24:02:06store in my mobile phone. Okay. And I
  34916. 24:02:08can use it anytime. So yes guys that's
  34917. 24:02:11how we can implement this entire system
  34918. 24:02:13and if I show you my checkpoint right
  34919. 24:02:16now if I again do let's say refresh see
  34920. 24:02:19all of the checkpoint would be available
  34921. 24:02:22all of the conversation me would be
  34922. 24:02:23available inside my postgress see okay
  34923. 24:02:26now see initially I executed test user
  34924. 24:02:28now this is the current user the current
  34925. 24:02:31trade okay current execution and these
  34926. 24:02:32are my messages now you can also see the
  34927. 24:02:38um
  34928. 24:02:40lang. So if I go to the lang smmith uh
  34929. 24:02:43if I again refresh
  34930. 24:02:46now another trade should be created. See
  34931. 24:02:48this is the trade and two conversation I
  34932. 24:02:50have done. Now this is the two
  34933. 24:02:51conversation. Now you can see all of the
  34934. 24:02:53informations. Okay. Which tools it is
  34935. 24:02:55using each and everything is visible
  34936. 24:02:56here. Input and output each and
  34937. 24:02:58everything. Okay. So amazing guys. We
  34938. 24:03:00have successfully completed our uh
  34939. 24:03:02implementation and it is working fine.
  34940. 24:03:05Now what I want to do guys, I want to
  34941. 24:03:07deploy it over the render cloud. Okay.
  34942. 24:03:10So I'll deploy this uh project on my
  34943. 24:03:13render cloud. But before that let me
  34944. 24:03:15commit the changes. So here I'll just
  34945. 24:03:18try to
  34946. 24:03:21app add it commit and see the changes.
  34947. 24:03:29Okay. Now if I go to my GitHub refresh
  34948. 24:03:34now see it's updated. Okay. Now it's
  34949. 24:03:36ready for the deployment. Now let's do
  34950. 24:03:38the deployment of this application.
  34951. 24:03:44Okay. So guys for the deployment uh
  34952. 24:03:46we'll be using docker. Um so let's
  34953. 24:03:49create a file here. I'm going to name it
  34954. 24:03:51as docker file. And inside that you have
  34955. 24:03:55to mention all of the docker related
  34956. 24:03:56command. And uh if you don't know about
  34957. 24:03:58Docker guys u docker is a
  34958. 24:04:01containerization service and this
  34959. 24:04:03tutorials uh this tutorial is already
  34960. 24:04:05available on my YouTube channel. Let me
  34961. 24:04:07show you. So if I go to my YouTube right
  34962. 24:04:10deals with BP.
  34963. 24:04:12So if you go to the video section I
  34964. 24:04:15already have a full MLOps course. Okay
  34965. 24:04:18here if you see here uh this is the
  34966. 24:04:21MLOps course. You can open it up. And
  34967. 24:04:24this course already covered the docker.
  34968. 24:04:27Okay.
  34969. 24:04:30Yeah. So see docker for mlops. You can
  34970. 24:04:32um at least go through this docker part.
  34971. 24:04:34Okay. And try to master the docker. And
  34972. 24:04:37if you're interested learning entire
  34973. 24:04:38mlops, this is already available. This
  34974. 24:04:40is around 12 hours of recording. You can
  34975. 24:04:41go through that. Okay. And if you like
  34976. 24:04:43the content, please try to subscribe to
  34977. 24:04:44my channel. So docker is required. I'm
  34978. 24:04:47expecting you already familiar with
  34979. 24:04:48docker. So simply I'll try to add all of
  34980. 24:04:50the docker related command here. So this
  34981. 24:04:53is these are my docker related command
  34982. 24:04:54guys. As you can see first of all I'm
  34983. 24:04:56taking a beige image 3.11 creating
  34984. 24:04:58working directory uh adding some
  34985. 24:05:00environment variable then uh running
  34986. 24:05:02some commands copying the requirement.xt
  34987. 24:05:05file then installing the requirement.xt
  34988. 24:05:07file copying all of my source code then
  34989. 24:05:10uh this thing I don't need. I'll just
  34990. 24:05:12try to remove
  34991. 24:05:14this thing I not did. Then I have to
  34992. 24:05:17expose the port. Okay, port should be uh
  34993. 24:05:20port number
  34994. 24:05:228,000 I think. Right, we are using port
  34995. 24:05:24number 8,000. So I'll try to add port
  34996. 24:05:26number 8,000 here.
  34997. 24:05:29And uh we running the command hicon app
  34998. 24:05:32file uh local host and port number
  34999. 24:05:358,000.
  35000. 24:05:37H So this is my docker file. Okay, I
  35001. 24:05:39need and for this I need to create
  35002. 24:05:41another file which is dot
  35003. 24:05:44docker
  35004. 24:05:46ignore
  35005. 24:05:48and here you have to mention all of the
  35006. 24:05:50uh files and folder you you want to
  35007. 24:05:53ignore during docker dockerization. So
  35008. 24:05:55these are the thing I'll try to ignore.
  35009. 24:05:57Okay, during dockerization. So now let
  35010. 24:06:00me push the changes again and what I'm
  35011. 24:06:02going to do I'm going to also update the
  35012. 24:06:04readmi file. Okay, I already created the
  35013. 24:06:06uh Redmi file update.
  35014. 24:06:11So I have added a beautiful Redmi
  35015. 24:06:13content. Let me show you. So this is the
  35016. 24:06:15Redmi guys I have added. So I have given
  35017. 24:06:18the entire um project summary features
  35018. 24:06:21ST project structure prerequisite
  35019. 24:06:24environment installation running the
  35020. 24:06:27endpoint. Okay. So each and everything I
  35021. 24:06:29have added. So your project should have
  35022. 24:06:30one beautiful readmi file guys. Okay.
  35023. 24:06:32This is super important. So read me just
  35024. 24:06:34try to add uh one more thing I want to
  35025. 24:06:37add which is uh I will give my project
  35026. 24:06:40name as it is
  35027. 24:06:48now it looks good I think now it look
  35028. 24:06:51[clears throat] it looks good so yeah uh
  35029. 24:06:54I think we are done now let me commit
  35030. 24:06:55the changes
  35031. 24:06:58docker
  35032. 24:07:01addit
  35033. 24:07:09Now if I go to my GitHub refresh
  35034. 24:07:12now see beautifully I have added the
  35035. 24:07:14readme and each and everything. Okay now
  35036. 24:07:16it is ready for the deployment. Now what
  35037. 24:07:18I'm going to do guys I'm going to open
  35038. 24:07:19up my render cloud.
  35039. 24:07:31Go to the dashboard.
  35040. 24:07:35Now I'll create a new web service. Okay.
  35041. 24:07:40Select this public git repo and copy
  35042. 24:07:43this GitHub rep. Okay.
  35043. 24:07:46Copy this URL and paste it here and
  35044. 24:07:49let's connect.
  35045. 24:07:52Okay. See automatically it has taken and
  35046. 24:07:54it is using the docker services. Okay.
  35047. 24:07:57For the deployment. So everything just
  35048. 24:07:59keep it as it is. No need to change
  35049. 24:08:00anything. Simply just create uh select
  35050. 24:08:02this free instance. Okay. So I'll select
  35051. 24:08:04the free instance. But if you're doing
  35052. 24:08:05like actual deployment, just try to take
  35053. 24:08:07the subscription. Okay. Because free
  35054. 24:08:08instance has having like very low
  35055. 24:08:11configuration machine and there is some
  35056. 24:08:12limitation as well. Okay. Now once
  35057. 24:08:14everything is fine, you have to add the
  35058. 24:08:15environment variable. Okay. So what I
  35059. 24:08:17can do maybe I can add it from myv file.
  35060. 24:08:21So simply I can copy
  35061. 24:08:23myv as it is.
  35062. 24:08:30Okay. And add the variables.
  35063. 24:08:33Now it has added my GO API key.
  35064. 24:08:39I can delete this one. Grow API key.
  35065. 24:08:42This is my GO API key. This is my
  35066. 24:08:44aviation. This is my default origin.
  35067. 24:08:47This is my table. This is my database
  35068. 24:08:49URL. Now this database URL, you have to
  35069. 24:08:51give the internal database URL. Okay. So
  35070. 24:08:53again I will go to my render. go to my
  35071. 24:08:56postgress server
  35072. 24:08:59and go below and copy this internal URL.
  35073. 24:09:02Okay, this one. Copy this.
  35074. 24:09:05Okay, I'll copy this and uh add it here.
  35075. 24:09:14So I've given my internal one. Okay.
  35076. 24:09:17Then languid tracing endpoint, languid
  35077. 24:09:20API key and Langmith project name. Okay.
  35078. 24:09:23So everything is fine. Now simply uh
  35079. 24:09:26deploy the web service.
  35080. 24:09:33Now it should take some time. First of
  35081. 24:09:35all, it will build the docker image.
  35082. 24:09:42So we'll wait guys. Okay. Once this uh
  35083. 24:09:44this is complete, this is live, then
  35084. 24:09:45we'll be able to access that
  35085. 24:09:58as it is installing the requirements.
  35086. 24:10:22See um installation done. Now it is
  35087. 24:10:25exporting my Docker image as a layer.
  35088. 24:10:52And if you want to see the AWS
  35089. 24:10:54deployment guys, this is already
  35090. 24:10:55available on my YouTube uh on this
  35091. 24:10:58playlist you can see AWS CI/CD
  35092. 24:10:59deployment. Okay, you can go through the
  35093. 24:11:00CI/CD deployment. You can learn how to
  35094. 24:11:02deploy as a CI/CD. Even this project
  35095. 24:11:04also I have deployed as a CI/CD on AWS.
  35096. 24:11:06Okay, you can refer it.
  35097. 24:11:12And this is also CI/CD. If you push your
  35098. 24:11:14changes, uh it can upgrade your uh
  35099. 24:11:18features, okay, automatically.
  35100. 24:11:21Again, I created another tutorial like
  35101. 24:11:23this one. Uh render deployment. You can
  35102. 24:11:25go through that.
  35103. 24:11:43so guys as you can see our application
  35104. 24:11:45is live now. Let's copy this URL and
  35105. 24:11:47paste it here and if I hit enter so it
  35106. 24:11:50should open your application. Now see
  35107. 24:11:52our TripMate AI is live right now. Now
  35108. 24:11:54let's uh test it. So I'll give this
  35109. 24:11:58prompt. Okay. uh 7 days India trip from
  35110. 24:12:01Bangladesh. Now let's generate the plan.
  35111. 24:12:05Now it's generating. Let's wait.
  35112. 24:12:10Now see this is the entire plan we are
  35113. 24:12:12getting. Amazing. Right now it is live.
  35114. 24:12:15Now you can share this with your friends
  35115. 24:12:17and family. They can also access that
  35116. 24:12:19and you can tell them just use my multi-
  35117. 24:12:22aent right now just to prepare your
  35118. 24:12:24trip. So yes guys this is all about from
  35119. 24:12:26this implementation. I hope you liked
  35120. 24:12:28it. Okay guys, we have successfully
  35121. 24:12:30completed our uh agent AI course with
  35122. 24:12:33the help of Langraph. We have learned
  35123. 24:12:35each and everything whatever uh are
  35124. 24:12:38required to implement this kinds of
  35125. 24:12:39agentic system. Now u I have uh another
  35126. 24:12:43plan guys uh actually I have designed
  35127. 24:12:46some more phases okay for the future and
  35128. 24:12:50this is available on my channel on DS
  35129. 24:12:52with Buppy YouTube channel. So this is
  35130. 24:12:54my channel guys DS with BPY. So here I
  35131. 24:12:57only completed the langraph right lang
  35132. 24:12:59graph agentic uh AI orchestration
  35133. 24:13:01framework and uh we have implemented all
  35134. 24:13:04of the AI agents with the help of
  35135. 24:13:06langraph but what about the others
  35136. 24:13:08framework okay there are some other
  35137. 24:13:09frameworks are also available on the
  35138. 24:13:11market uh like krui is there right and
  35139. 24:13:14then Microsoft autogen is there N8 is
  35140. 24:13:16there right so if you want to learn
  35141. 24:13:18these are the framework also so you can
  35142. 24:13:21subscribe to my channel because in my
  35143. 24:13:23channel I'll try to publish all of the
  35144. 24:13:25video related these are the framework
  35145. 24:13:28like crewi we'll try to master the
  35146. 24:13:30entire crewi in depth we'll also
  35147. 24:13:32implement some end to end agentic AI
  35148. 24:13:34application with the help of crewi we'll
  35149. 24:13:36be also learning about the Microsoft
  35150. 24:13:37autogen already I have Microsoft autogen
  35151. 24:13:39playlist okay uh I will upload all of
  35152. 24:13:42the recording related autogen okay we'll
  35153. 24:13:44be also implementing some projects end
  35154. 24:13:46to end projects then I'll be covering
  35155. 24:13:48the no code platform as well like n okay
  35156. 24:13:51this would be also available on my
  35157. 24:13:52YouTube channel then uh one very
  35158. 24:13:55interesting ing and important concept
  35159. 24:13:56which is MCP. So this MCP I didn't cover
  35160. 24:14:00in this course right uh in this my uh
  35161. 24:14:02agenti with langraph course because this
  35162. 24:14:05is already like a very long course we
  35163. 24:14:08have recorded so far it is around uh 25
  35164. 24:14:11hours of recording okay so that's why uh
  35165. 24:14:13all of these uh concept like MCP autogen
  35166. 24:14:17crew AI okay these are the recording
  35167. 24:14:19would be available on my YouTube channel
  35168. 24:14:20okay these are the video would be
  35169. 24:14:21available on my YouTube channel so
  35170. 24:14:23please try to refer my YouTube channel
  35171. 24:14:24you can subscribe to my YouTube channel
  35172. 24:14:26so I think you'll be enjoying a lot the
  35173. 24:14:29future phases as well. Okay. So, we'll
  35174. 24:14:31try to master the entire model context
  35175. 24:14:33protocol in my YouTube channel. Then
  35176. 24:14:36phase uh 10, we'll try to cover the AI
  35177. 24:14:39safety and evaluation. Nowadays, if you
  35178. 24:14:41are creating any kinds of agent
  35179. 24:14:43application, this is super important uh
  35180. 24:14:45to know like how we can add the AI
  35181. 24:14:47safety evaluation pipeline inside your
  35182. 24:14:49agents. Uh definitely we have to master
  35183. 24:14:51the guardrails and safety. We'll try to
  35184. 24:14:53see prompt injection, security tools,
  35185. 24:14:55restriction, AI safety patterns. Okay,
  35186. 24:14:57these are the concept we have to cover
  35187. 24:14:59and everything would be available on my
  35188. 24:15:00YouTube channel. Okay, that means these
  35189. 24:15:02are the future phases would be available
  35190. 24:15:04on my channel DS with Buppy. And if you
  35191. 24:15:06want to understand, if you want to learn
  35192. 24:15:08these are the concept, you just need to
  35193. 24:15:10subscribe to my channel and all of the
  35194. 24:15:11content would be available on my YouTube
  35195. 24:15:13channel. Okay. So yes, uh if you found
  35196. 24:15:15my content useful guys, please try to
  35197. 24:15:17subscribe to my channel and support me.
  35198. 24:15:19If you're supporting me, definitely I
  35199. 24:15:21can bring this kinds of content more in
  35200. 24:15:22future and uh yeah, I think uh you'll be
  35201. 24:15:25learning a lot. And if you want to
  35202. 24:15:27connect me, so this is my LinkedIn
  35203. 24:15:29profile bulk bi. Simply you can follow
  35204. 24:15:31me here. You can connect me here. And if
  35205. 24:15:34you have any kinds of query, you can ask
  35206. 24:15:35me. If you need any kinds of guidance,
  35207. 24:15:37you just uh ping me on my l uh LinkedIn.
  35208. 24:15:40Definitely I'll try to help you with
  35209. 24:15:42that. So yes guys, this is all about
  35210. 24:15:44from this course. I hope you enjoyed a
  35211. 24:15:46lot. So thank you so much for watching
  35212. 24:15:48and I will see you next time.

About this transcript

This page contains the full transcript of Agentic AI – Complete Course for Beginners by freeCodeCamp.org, generated from the public captions YouTube serves with the video. The transcript has 242,791 words across 35,212 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.