back to index

When Should You Use LangChain?


Chapters

0:0 When to use LangChain
0:52 Do I need a framework?
4:3 LangChain for Learning
6:3 Moving on from LangChain
7:46 Should you use Langchain?

Whisper Transcript | Transcript Only Page

00:00:00.000 | Okay, so the first chapter of the course, we're going to focus on when should we actually use
00:00:06.260 | LangChain and when should we use something else. Now, through this chapter, we're not really going
00:00:11.440 | to focus too much on the code. Every other chapter is very code focused, but this one is
00:00:17.780 | a little more just theoretical. What is LangChain? Where does it fit in? When should I use it? When
00:00:22.600 | should I not? So I want to just start by framing this. LangChain is one of, if not the most popular
00:00:31.640 | open source framework within the Python ecosystem, at least for AI. It works pretty well for a lot of
00:00:38.180 | things and also works terribly for a lot of things as well, to be completely honest. There are massive
00:00:43.500 | pros, massive cons to using LangChain. Here, we're just going to discuss a few of those and see how
00:00:49.380 | LangChain maybe compares a little bit against other frameworks. So the very first question we
00:00:55.500 | should be asking ourselves is, do we even need a framework? Is a framework actually needed when
00:01:03.100 | we can just hit an API, you have the OpenAI API, other APIs, Mistral, so on, and we can get a response
00:01:10.140 | from an LLM in five lines of code on average for those. It is incredibly, incredibly simple. However,
00:01:17.440 | that can change very quickly when we start talking about agents or retrieval augmented generation,
00:01:24.280 | research assistance, all this sort of stuff, those use cases, those methods can suddenly get quite
00:01:33.760 | complicated when we're outside of frameworks. And that's not necessarily a bad thing, right? It can be
00:01:41.980 | incredibly useful to be able to just understand everything that is going on and build it yourself.
00:01:48.700 | But the problem is that to do that, you need time. Like you need to learn all the intricacies of
00:01:56.180 | building these things, the intricacies of these methods themselves, like what, you know, how do they
00:01:59.960 | even work? And that kind of runs in the opposite direction of what we see with AI at the moment,
00:02:05.780 | which is AI is being integrated into the world at an incredibly fast rate. And because of this,
00:02:13.280 | most engineers coming into the space are not from a machine learning or AI background. Most people
00:02:20.940 | don't necessarily have any experience with the system. A lot of engineers coming in that could be
00:02:27.040 | DevOps engineers, generic backend Python engineers, even frontend engineers coming in and building all
00:02:33.740 | these things, which is great, but they don't necessarily have the experience. And that, you know,
00:02:38.360 | that might be you as well. And that's not a bad thing because the idea is that obviously you're going to
00:02:43.100 | learn and you're going to pick up a lot of these things. And in this scenario, there's quite a good
00:02:48.720 | argument for using a framework because a framework means that you can get started faster and a
00:02:55.260 | framework like LangChain, it abstracts away a lot of stuff. And that's a big complaint that a lot of
00:03:02.300 | people will have with LangChain, but that abstracting away of many things is also what makes LangChain
00:03:09.420 | popular because it means that you can come in not really knowing, okay, what, you know, RAG is, for
00:03:13.840 | example, and you can implement a RAG pipeline, get the benefits of it without really needing to
00:03:19.000 | understand it. And yes, there's an argument against that as well, just implementing something without
00:03:24.160 | really understanding it. But as we'll see throughout the course, it is possible to work with LangChain
00:03:30.900 | in a way, as we will in this course, where you can implement these things in an abstract way and then
00:03:38.760 | break them apart and start understanding the intricacies at least a little bit. So that can
00:03:45.260 | actually be pretty good. However, again, circling back to what we said at the start, if the idea or
00:03:53.700 | your application is just a very simple, you know, you need to generate some text based on some basic
00:03:58.620 | input, maybe you should just use an API that's completely valid as well. Now, we just said, okay,
00:04:05.600 | a lot of people coming to LangChain might not be from an AI background.
00:04:09.440 | So another question for a lot of these engineers might be, okay, if I want to learn about, you know,
00:04:16.360 | RAG, agents, all of these things, should I skip LangChain and just try and build it from scratch
00:04:22.560 | myself? Well, LangChain can help a lot with that learning journey. So you can start very abstract.
00:04:29.720 | And as you gradually begin to understand the framework better, you can strip away more and
00:04:37.340 | more of those abstractions and get more into the details. And in my opinion, this gradual shift
00:04:43.400 | towards more explicit code with less abstraction is a really nice feature. And it's also what we focus
00:04:52.420 | on, right? Throughout this course, that's what we're going to be doing. Going to sign abstract,
00:04:56.600 | stripping away the abstractions and getting more explicit with what we're building. So for example,
00:05:01.720 | building an agent in LangChain, there's in this very simple and incredibly abstract create tools
00:05:09.680 | agent method that we can use. And like it creates a tool agent for you. It's, it doesn't tell you
00:05:17.180 | anything. So you can, you can use that, right? And we will use that initially in the course,
00:05:23.280 | but then you can actually go from that to defining your full agent execution logic,
00:05:31.440 | which is basically a tools call to open AI. You're going to be getting that tool information back,
00:05:36.640 | but then you've got to figure out, okay, how am I going to execute that? How am I going to store this
00:05:40.720 | information? And then how am I going to iterate through this? So we're going to be seeing that
00:05:46.480 | stripping away abstractions as we work through, as we build agents, as we do, as we build like our
00:05:52.240 | streaming use case, among the many other things, even chat memory, we'll see there as well. So
00:05:58.120 | LangChain can act as the on-ramp to your AI learning experience. Then what you might find,
00:06:05.620 | and I do think this is quite true for most people, is that if you, if you're really serious about AI
00:06:13.200 | engineering and that's what you want to do, like that's your focus, right? Which isn't for everyone,
00:06:17.900 | for certain. A lot of people just want to understand a bit of AI and they want to continue doing what
00:06:22.920 | they're doing and just integrate AI here and there. And maybe those, you know, if that's your focus,
00:06:27.520 | you might stick with LangChain. You know, there's not necessarily a reason to move on. But in the other
00:06:34.460 | scenario where you're thinking, okay, I want to get really good at this. I want to just learn as much
00:06:40.460 | as I can. And I'm going to dedicate basically my, you know, my short term future of my career
00:06:46.280 | on becoming AI engineer. Then LangChain might be the on-ramp. It might be your initial learning curve,
00:06:54.600 | but then after you've become competent with LangChain, you might actually find that you want
00:06:59.340 | to move on to other frameworks. And that doesn't necessarily mean that you're going to have wasted
00:07:04.040 | your time with LangChain. Because one, LangChain is a thing helping you learn. And two, one of the
00:07:09.660 | main frameworks that I recommend a lot of people to move on to is actually LangGraph, which is still
00:07:15.520 | within the LangChain ecosystem. And it still uses a lot of LangChain objects and methods, and of course,
00:07:22.940 | concepts as well. So even if you do move on from LangChain, you may move on to something like LangGraph,
00:07:29.460 | which you can't know LangChain for anyway. And let's say you do move on to another framework
00:07:34.520 | instead. In that scenario, the concepts that you learn from LangChain are still pretty important.
00:07:39.900 | So to just finish up this chapter, I just want to summarize on that question of should you be using
00:07:47.740 | LangChain? What's important to remember is that LangChain does abstract a lot. Now, this abstraction
00:07:53.380 | of LangChain is both a strength and a weakness. With more experience, those abstractions can feel
00:08:02.420 | like a limitation. And that is why we sort of go with the idea that LangChain is really good to get
00:08:11.620 | started with. But as the project grows in complexity or the engineers get more experience, they might move
00:08:16.840 | on something like LangGraph, which in any case, is going to be using LangChain to some degree. So in
00:08:23.040 | either one of those scenarios, LangChain is going to be a core tool in an AI engineered toolkit. So it's
00:08:32.900 | worth learning in our opinion. But of course, it comes with its, you know, it comes with its weaknesses.
00:08:38.480 | And it's just good to be aware of that it's not a perfect framework. But for the most part,
00:08:43.060 | you will learn a lot from it, and you will be able to build a lot with it. So with all of that,
00:08:49.360 | we'll move on to our first sort of hands-on chapter with LangChain, where we'll just introduce
00:08:56.260 | LangChain, some of the essential concepts. We're not going to dive too much into the syntax,
00:09:01.660 | but we'll see you understand a little bit of what we can do with it.
00:09:03.780 | LangChain, some of the most important concepts. We're not going to dive too much into the