🎁 Checkout my Learn React by Making a Game course and get 1 month Free on Skillshare!

LangChain is the jQuery of integrating LLMs into Javascript apps

What is LangChain? In a simple answer, LangChain is a framework that was designed to simplify the making of applications that integrate Large Language Models - LLMs.

LangChain provides all the AI integration building blocks together in one framework. It does this in a modular, flexible and scalable architecture that is easy to maintain.

You can see LangChain as the glue layer for almost everything in the AI ecosystem.

By learning LangChain you will learn a lot about the structure, flows and practices of AI Engineering.

Just some of the use cases for LangChain:

  • LLMs are trained on human-written unstructured text. While this works well for human interactions try to send an unformatted text to an API, instead of JSON data. LangChain can help use to format the input and output on an LLM interaction.
  • LLMs are stateless. They don't remember how you are, or what you just said two seconds ago. LangChain provides support for both long and short-term memory.
  • LLMs can be slow. We can use LangChain to stream the responses while they are generated and provide fast feedback to the user.
  • LLMs have knowledge cutoff dates. For example, Chat GPT 3.5 does not have training data after 2021. With LangChain we can make and manage AI Agents that go online, search for info and use tools to parse that info.
  • We can chain multiple LLMs between them. For example, we can generate an article with Google's Gemini model and pass the text to Midjourney to generate images for that article.
  • LLMs lack access to internal organization documents. We can use RAG, Retrieval Augmented Generation, to serve extra context to a model. Then it can interact with users based on the the rules and knowledge of an organization. LangChain has a great toolset for doing RAG operations.

And what's nice is that LangChain standardizes operations like the ones above. We can easily swap components along the way. Want to use another LLM because it's better or cheaper? What to change the vector database to store the RAG embeddings? No problem, LangChain has you covered.

LangChain abstracts and standardizes the common patterns when working with LLMs. Do you remember the old days with all the browsers incompatibilist? And then jQuery appeared. Well, this is what LangChain tries to do in the LLM integration world.

It is possible to create any app without LangChain also, but LangChain simplifies it to a great extent andΒ hence way better than manual prompting.

If you want to delve deeper into the subject I would recommend listening to the episode with Harrison Chase, the founder of LangChain, from the excellent Latent Space podcast.

You can take a look here at how to use the StructuredOutputParser with Zod schema in in LangChain and see this full example for the first app with LangChain and JavaScript.

πŸ“– 50 Javascript, React and NextJs Projects

Learn by doing with this FREE ebook! Not sure what to build? Dive in with 50 projects with project briefs and wireframes! Choose from 8 project categories and get started right away.

πŸ“– 50 Javascript, React and NextJs Projects

Learn by doing with this FREE ebook! Not sure what to build? Dive in with 50 projects with project briefs and wireframes! Choose from 8 project categories and get started right away.


Leave a Reply

Your email address will not be published. Required fields are marked *