LangChain
Using LangChain
LangChain is a set of open-source frameworks that provide a platform to build, test and deploy AI applications. You can use LangChain to build chatbots, RAGs, knowledge retrieval systems, and many more. LangChain provides simple, intuitive APIs that allow you to connect multiple AI components together to build a single AI application. This flexibility is what makes it powerful and loved by the AI developer community.
In the previous lesson, you used LangChain in the demo. This is what allowed you to easily swap LLMs. Without it, you’d have had to write lots of bespoke code for each LLM using their own SDK. With the hundreds of LLMs, retrievers, databases, tools and other AI components out there, you can imagine how difficult it could be to build an AI application.
There are many other frameworks and tools out there that help you build large AI applications. A few notable ones are AgentGPT, CrewAI, AutoGen, and n8n. LangChain has a host of other frameworks and tools designed for more specific scenarios. They work well together, but can also be used independently. An example is LangChain Agents.
LangChain Agents
An AI agent is an AI application that uses LLMs to reason and decide on tools to use to accomplish a given task. This is usually an iterative process that requires little to no human intervention. LangChain’s Agent framework is purpose-built for this.
Agents are one of the more advanced uses of AI. With LLMs only, they help us in reasoning and finding information. After you get this help, you’d usually go ahead and act on this information by creating a website with this information, create a PDF, or even broadcast emails to specific selected recipients. With agents, you can provide the services needed to accomplish these as tools, so the necessary actions can be taken after reasoning.
Understanding LangGraph
To quote from the official sources, “LangGraph is a low-level orchestration framework and runtime for building, managing, and deploying long-running, stateful agents”. LangGraph is a part of the LangChain suite of frameworks, and is particularly suitable for building advanced AI applications. LangGraph provides tools that allow you to run AI applications for long durations, view the state of various components at any point in time, manage memory, and deploy applications.
While it’s usually used together with LangChain, it can also be used independently. A key distinction between LangChain and LangGraph is that LangChain is designed to connect components in a linear fashion, whereas LangGraph connects them in a graph. This distinction alone opens up a world of possibilities for LangGraph, since you can now solve problems using concepts from graph systems.
This means it has state, nodes, and edges. By having nodes and edges, it also means you can revisit nodes multiple times. Key operations include a start, decision-making, and an end. Between the start and the end, you could take different routes, which may include looping until some condition is met. LangGraph, however, has a functional API that allows you to build using a more common functional programming paradigm.