Background of LangChain & Node.js
Background of LangChain & Node.js
History of The Framework
LangChain, or Language Chain, is a framework of Node.js used to develop applications using the Large Language Model (LLM). Launched in late 2022, it was initially created as a side project of JavaScript aside from Python packages. The JavaScript packages were unavailable until 2023, due to high demand from developers requesting support for JavaScript and Node.js. Harrison Chase, the founder of LangChain then saw the potential of this side project and pursued it until he could open a company of his own. The company started its business in January 2023.
LangChain started as an open-source project where users can view, copy, and modify the code. Per its name, the concept of LangChain is a "chain" of components needed to create an LLM application by performing an ordered series of tasks (IBM Technology, 2024). Such components are databases, APIs, and vector scores that are chained together using multi-step pipelines. They aim to provide a user-friendly and simple platform for users to develop LLM applications. In July 2024, they launched a new platform for debugging and testing the apps called LangGraph Studio.
Being actively participating in many Hackathons, Harrison has met various people with different views. He realized that most of them have the same needs for building LLM Apps, which gave him the idea of developing a tool that can facilitate developers in creating their desired apps. LangChain offers tools and abstractions to improve the customization, accuracy, and relevancy of the information the models generate (IBM Technology, 2024). The framework came to light after the popularity of many large language models such as OpenAI's GPT- and GPT-4. LangChain is designed to develop a wide range of applications powered by language models more seamlessly, including chatbots, question-answering, content generation, summarizers, and many more (Amazon Web Services, Inc., n.d.).
Node.js, a JavaScript runtime was developed in 2009 by Ryan Dahl, a software engineer unsatisfied with existing languages like Apache HTTP and Ruby on Rails. Node.js was built on top of Google's V8 JavaScript engine. It was first introduced at the European JSConf in November 2009. As Node.js can handle simultaneous connections with minimal overhead, it quickly gained attention from developers worldwide.
It was the first JavaScript runtime that offered back-end scripting, complementing the existing front-end scripting. This eases developers to develop both front-end and back-end scripting within the same language more seamlessly and simplifies workflows, making them full-stack developers. This greatly benefits developers as they do not have to use different languages to build their applications while minimizing the gap between the client-side and the server-side programming.
- Anis Syifaa'
Language Category & Programming Styles
🌐Node.js is NOT a programming language but a server-side runtime environment that enables users to run JavaScript code into machine code outside a web browser. It is built on the V8 JavaScript engine from Google Chrome (OpenJS Foundation, n.d.). While JavaScript was originally a client-side scripting language, Node.js extends its capabilities for server-side development by providing additional features like file system access, network communication, and asynchronous I/O operations. This makes Node.js ideal for developing server-side web applications, real-time applications, data-intensive applications, and microservices architectures (Fireship, 2020) (Code ON 코드온, 2022) (Sufiyan, 2024).
JavaScript is a versatile and multi-paradigm language supporting procedural, functional, and object-oriented programming. It is procedural when it is used to add interactivity to web pages where operations are performed sequentially. As it evolved, frameworks and libraries have allowed JavaScript to adopt functional programming by emphasizing pure functions and avoiding mutable states. In terms of object-oriented programming, it uses prototyping for inference which enables each object to inherit properties and methods from another object. (Ltaif, 2023)
🦜🔗 LangChain is an open-source framework designed to simplify the creation of applications using large language models (LLMs) (Mukherjee, 2024). It is built using Python but also supports components developed in JavaScript and TypeScript (Kumar, 2024) (LangChain, n.d.). The main properties of the LangChain framework include components which serve as modular building blocks for building applications, chains which combine multiple components to solve a specific task and agents which allow LLMs to interact with their environment. (GeeksforGeeks, 2024). LangChain can be used to build a wide range of LLM-powered applications, including chatbots, data analysis, content generation, machine translation and more. (Andres, 2024)
- Kueh Pang Teng
Usage in the Types of Applications
LangChain is well known for developing applications powered by large language models (LLMs), which are advanced artificial intelligence systems that are designed to understand, interpret, and generate human-like text. Innovations using LangChain in various industries can perform numerous tasks, including the ones that are mentioned below.
LangChain can be used to build chatbots that perform tasks in a natural language way, including answering questions from end users. (Deligence Technologies, 2024)
LangChain also provides functions for Speech-to-Text (STT) and Text-to-Speech (TTS) conversion.
LangChain offers an easy-to-use translation function that involves converting text from one language to another. (Surani, 2023)
- Sofia Batrisyia
Current Popularity
According to the W3Techs Trends Report, which is updated every month, on 7 December 2024, Node.js is ranking in the top 12 of historical trends in the usage of statistics of web servers. It holds 3.8% of usage and ranks 6th in trends in the usage statistics, as shown below (Q-Success, n.d.).
The popularity of Node.js can be attributed to its efficiency for building scalable network applications and real-time web applications. However, some of the more established web servers, such as Nginx and Apache, are more well known because they were developed more earlier than Node.js, which has a larger user base (Q-Success, n.d.).
- Sofia Batrisyia
Implementation Method
Node.js uses the V8 as its core engine to execute JavaScript code efficiently. When a Node.js application runs, the V8 engine parses and executes JavaScript code into machine code, which can be executed directly by the server's hardware. (GeeksforGeeks, 2024). Although JavaScript is traditionally considered an interpreted language, modern engines like V8 incorporate compiling the code. Specifically, V8 compiles them with just-in-time (JIT) compilation where the compilation is done before the execution of a program (Minhaz, 2023). This hybrid model combines the advantages of both compilation and interpreters which enables Node.js to achieve both flexibility and performance. The interpreter interprets the code line by line and the compiled code is dynamically optimised at runtime. LangChain's execution in Node.js depends on the runtime and, thus, inherits the hybrid model of the V8 engine, leveraging its optimised execution pathways for better performance (OpenJS Foundation, n.d.).
V8 Engine Workflow
source: https://shorturl.at/IeEwb
There are three steps involved in processing the code in the V8 engine:
Parsing
The JavaScript code are broken down into tokens. The tokens create the Abstract Syntax Tree (AST) which represents the structure of the code.
Compilation
The V8 engine uses the JIT compilation and transforms the code into machine code before execution.
Ignition interpreter converts the AST into bytecode. The engine starts running the code and collecting type feedback.
Turbofan compiler optimises the bytecode into highly-optimized machine code using feedback.
Execution
The byte code is executed by using the memory heap and the call stack of the V8 engine’s runtime environment.
Memory Heap stores all the variables and functions.
Call Stack tracks each function call.
The interpreter maps bytecode to corresponding handler functions, optimising memory usage with a compact map structure.
(freeCodeCamp, 2020) (GeeksforGeeks, 2021) (Minhaz, 2023)
- Kueh Pang Teng
The Programming Environments
Focus: Workflow Visualization and Debugging
LangChain can be integrated with LangGraph Studio, the first AI agent IDE (Integrated Development Environment) launched by LangChain. Agent IDE used LLM to decide the control flow of the system autonomously involving decision-making and complex workflows (Chase, 2024). It is a desktop app that depends on Docker Desktop or Orbstack to run and currently supports MacOS with the integration of LangSmith (Friis, 2024). It is open-source and available for Node.js, seamlessly visualizing and interacting with agent graphs while still focusing on debugging complex applications in AI or ML fields. The help of structured workflows will ease the developers' work for LLM (Large Language Models). Currently, it is only available for Apple Silicon when integrated with LangSmith. Thus, it also provides a real-time collaboration for debugging. Click here to know more.
Focus: Coding and Debugging
JetBrains developed WebStorm, the primary IDE for JavaScript, which has built-in Node.js support. It assists developers in working efficiently and saving time by providing coding assistance and fast navigation even in a complex project. The developers can run server-side, client-side, and Node.js applications all in the environment. It also supports database tools to manage databases and AI Assistant, which eases and fastens coding development. Click here to know more.
Focus: Coding and Debugging
AWS Cloud 9 is a cloud-based IDE, that allows the user to code and debug without the need for an application. It is a browser-based editor, so no file installation is needed and the project can be accessed from anywhere just with an Internet connection (Amazon Web Services, Inc., 2024). The developers can also use the default or custom configurations of environment functions by themselves. The teamwork collaborations also work perfectly here as the team can communicate using the built-in chat and see comments from others. Click here to know more.
- Nur Insyirah Iman
REFERENCES
History of the framework
Alejandro AO - Software & Ai. (2024, March 25). Harrison Chase: LangChain and the Future of LLM Applications | Alejandro AO [Video]. YouTube. https://www.youtube.com/watch?v=8E6uPB4U0E8
IBM Technology. (2024, March 15). What is LangChain? [Video]. YouTube. https://www.youtube.com/watch?v=1bUy-1hGZpI
Amazon Web Services, Inc. (n.d.). What is LangChain? https://aws.amazon.com/what-is/langchain/#:~:text=LangChain%20provides%20AI%20developers%20with,developers%20proficient%20in%20the%20framework.
Language Category and Programming Styles
OpenJS Foundation. (n.d.). Introduction to Node.js. https://nodejs.org/en/learn/getting-started/introduction-to-nodejs
Sufiyan, T. (2024, December 3). Node.js Overview: What is Node.js and Why It Matters. Simplilearn.com. https://www.simplilearn.com/tutorials/nodejs-tutorial/what-is-nodejs
Ltaif, B. (2023, October 29). JavaScript: procedural, functional, or Object-Oriented? DEV Community. https://dev.to/uncle_ben/javascript-procedural-functional-or-object-oriented-2km0
Fireship. (2020, May 21). Node.js Ultimate Beginner’s guide in 7 easy steps [Video]. YouTube. https://www.youtube.com/watch?v=ENrzD9HAZK4
Code ON 코드온. (2022, August 21). What is Node.js and how it works (explained in 2 minutes) [Video]. YouTube. https://www.youtube.com/watch?v=q-xS25lsN3I
GeeksforGeeks. (2024, June 3). Introduction to LangChain. GeeksforGeeks. https://www.geeksforgeeks.org/introduction-to-langchain/
Mukherjee, S. (2024, March 12). LangChain: A Beginner's Guide to Harness the Power of Language Models. Paperspace by DigitalOcean Blog. https://blog.paperspace.com/langchain/
Andres. (2024, August 15). Langchain Node JS Tutorial. https://www.restack.io/docs/langchain-knowledge-node-js-tutorial-cat-ai
Usage in Type of Application
LangChain, Inc. (2024). Introduction. https://js.langchain.com/v0.2/docs/introduction/
Surani, S. (2023, July 25). LangChain: Build AI Solutions with Node.js - A Comprehensive Guide | Widle. Medium. https://medium.com/widle-studio/building-ai-solutions-with-langchain-and-node-js-a-comprehensive-guide-widle-studio-4812753aedff
Svenson, G. (2024, November 16). How to Use JavaScript with Langchain: A Step-by-Step Guide. Medium. https://medium.com/@garysvenson09/how-to-use-javascript-with-langchain-a-step-by-step-guide-35c6de39f997
Deligence Technologies. (2024, February 2). Applications of Langchain. Medium. https://medium.com/@deligencetechnologiesinc/applications-of-langchain-4c8d3b2e18b7#:~:text=LangChain%20can%20be%20used%20to%20build%20applications%20that%20can%20translate,%2C%20websites%2C%20and%20software%20applications.
Current Popularity
Q-Success. (n.d.). Historical trends in the usage statistics of web servers. W3Techs. https://w3techs.com/technologies/history_overview/web_server
Verma, R. (2023, December 1). Node.js Statistics: Latest Usage Insights and Trends. IT Blog | Mobile App Development India | Offshore Web Development - Bacancytechnology.com. https://www.bacancytechnology.com/blog/nodejs-statistics#node.js-statistics-of-usage-based-on-various-parameters
Implementation Method
GeeksforGeeks. (2024, July 10). What is the Relationship between Node.js and V8? https://www.geeksforgeeks.org/what-is-the-relationship-between-node-js-and-v8/
GeeksforGeeks. (2021, October 31). Explain V8 engine in Node.js. GeeksforGeeks. https://www.geeksforgeeks.org/explain-v8-engine-in-node-js/
OpenJS Foundation. (n.d.). The V8 JavaScript Engine https://nodejs.org/en/learn/getting-started/the-v8-javascript-engine
Minhaz. (2023, July 4). Let’s Understand the JavaScript Just In Time Compiler (JIT) and How the V8 engine works. Medium. https://medium.com/@minhaz217/lets-understand-the-javascript-just-in-time-compiler-jit-and-how-the-v8-engine-works-ff6276d131a1
freeCodeCamp. (2020, August 26). How JavaScript works: under the hood of the V8 engine. freeCodeCamp.org. https://www.freecodecamp.org/news/javascript-under-the-hood-v8/
GeeksforGeeks. (2021, August 1). How V8 compiles JavaScript code ? GeeksforGeeks. https://www.geeksforgeeks.org/how-v8-compiles-javascript-code/
Programming Environment
Friis, E. (2024). GitHub - langchain-ai/langgraph-studio: Desktop app for prototyping and debugging LangGraph applications locally. GitHub. https://github.com/langchain-ai/langgraph-studio?tab=readme-ov-file
LangChain. (2024, August 1). LangGraph Studio: The first agent IDE. LangChain Blog. https://blog.langchain.dev/langgraph-studio-the-first-agent-ide/
Chase, H. (2024, June 28). What is an AI agent? LangChain Blog. https://blog.langchain.dev/what-is-an-agent/
JetBrains. (2021, June 1). WebStorm: the JavaScript and TypeScript IDE, by JetBrains. https://www.jetbrains.com/webstorm/ Amazon Web Services, Inc. (2024).
Amazon Web Services, Inc. (2024). AWS Cloud9 features. https://aws.amazon.com/cloud9/details/