There has been a bit of talk about Lanchain lately regarding the fact it is creating a walled garden around AI apps and results in lock-in. In this post, we’ll debate the differences between Langchain and just using an official SDK. I assume you’re working with OpenAI, but we also have Anthropic and Hugging Face (amongst others) to consider.
To understand the differences, Langchain is a framework for building AI apps. If you are a developer wanting to throw something together quickly, it is brilliant for quickly knocking out AI API wrapper apps, especially the OpenAI GPT API.
Where Langchain seems to fall apart is while you are developing any AI application that goes beyond simple prompting. When you want to customise aspects of Langchain, you realise its heavy-handed approach and how it makes you construct apps is restrictive and annoying.
The truth is Langchain is a convenience until it is not. It is an abstraction around things that developers could do themselves. If you’re building applications comprising a prompt, queries and storage, you can write a simple API call and some string manipulation to do the same thing much faster.
I am not jumping on the Langchain hate train because I have used it. But, my use cases did not require me to go outside the bounds of Langchain too much.
One of the biggest problems with Langchain is the documentation is terrible.
I know all too well how difficult it is to write documentation. I have been the leading documentation writer for Aurelia 2’s docs (https://docs.aurelia.io). And despite the fact I have been working on them on and off for maybe two years, they are still not perfect. I’m not being paid to write the docs. Aurelia is not a VC-backed project. It is truly open source.
The difference being Langchain is not an open-source project being run by volunteers. It has received $30 million in funding from Benchmark and Sequoia. It’s now a business, and businesses deserve scrutiny. Whenever I’ve tried to do something, I found the AI-powered search was terrible, the confusion between Langchain and LangchainJS leading to confusing results.
I will admit I got caught up in the Langchain hype. For simple uses, it gives the impression it’s adding value. However, in the case of OpenAI especially, they provide simple and performant SDKs you can install in your project, such as the Node.js SDK.
When I looked into the OpenAI Node.js SDK, I realised that I could have built the same apps without Langchain, and the time difference would not have been that great. Langchain gives you caching providers and adapters for working with vector databases, but these are not difficult things to implement yourself.
For more complex cases, you will be better off not having a dependency on Langchain and just writing your own light abstraction around whatever AI API you are working with.