avatarLaxfed Paulacy

Summary

LangChain has introduced TypeScript support, providing developers with JavaScript preferences the same abstractions and capabilities as the Python package, including prompts, chains, agents, and memory management, while enabling seamless sharing of artifacts between languages.

Abstract

The LANGCHAIN — TypeScript Support article announces the release of TypeScript support for LangChain, a toolkit for working with language models. This development is a response to the growing interest from developers who prefer JavaScript, following the success of ChatGPT. The TypeScript package mirrors the Python package, offering identical abstractions such as Prompts, LLMs (Large Language Models), Text Splitters, Embeddings, Vectorstores, Chains, Agents, and Memory. The introduction of TypeScript support aims to facilitate web development and ensure that serialized formats for prompts, chains, and agents are compatible across Python and TypeScript, promoting community sharing and adoption. The article emphasizes the importance of this update in opening up new possibilities for developers and reflects the evolving priorities and use cases within the JavaScript and Python communities.

Opinions

  • The initial preference for Python among language model enthusiasts has shifted towards JavaScript due to the popularity of ChatGPT, indicating a broader trend in developer interests.
  • The necessity for a JavaScript native version of LangChain arose from the surge in interest from the developer community, highlighting the importance of language preferences in tool adoption.
  • The article suggests that the TypeScript package's close mirroring of the Python package is crucial for maintaining consistency and ease of transition between the two languages.
  • The ability to share artifacts between Python and TypeScript is seen as a significant feature, fostering community collaboration and the exchange of best practices.
  • The development of the TypeScript package is expected to continue, with a focus on incorporating features that cater specifically to web development needs, showcasing a commitment to serving the unique requirements of different developer groups.

LANGCHAIN — TypeScript Support

The computer was born to solve problems that did not exist before. — Bill Gates

TypeScript support for LangChain is finally here! This means that all your favorite prompts, chains, and agents are now recreatable in TypeScript natively. Both the Python version and TypeScript version utilize the same serializable format, allowing artifacts to seamlessly be shared between languages. Let’s dive into what TypeScript support entails and how to utilize it.

Why TypeScript?

Initially, the crowd playing with language models was more research-oriented and preferred Python. However, with the quick success of ChatGPT, there has been a surge of interest from developers who prefer using JavaScript. Hence, the development of a JavaScript native version of LangChain became necessary.

What’s in this package?

The TypeScript package includes all the same abstractions as the Python package:

Prompts

import { PromptTemplate } from 'langchain';

// Create a prompt
const prompt = new PromptTemplate();

LLMs (Large Language Models)

import { OpenAI } from 'langchain';

// Create an instance of an LLM
const openAIModel = new OpenAI();

Text Splitters

import { TextSplitter } from 'langchain';

// Utilize a text splitter
const textSplitter = new TextSplitter();

Embeddings

import { Embeddings } from 'langchain';

// Create embeddings
const embeddings = new Embeddings();

Vectorstores

import { Vectorstore } from 'langchain';

// Work with vectorstores
const vectorstore = new Vectorstore();

Chains

import { LLMChain } from 'langchain';

// Use a chain
const chain = new LLMChain();

Agents

import { Agents } from 'langchain';

// Interact with agents
const agent = new Agents();

Memory

import { BufferMemory } from 'langchain';

// Manage memory
const bufferMemory = new BufferMemory();

Relationship to the Python package

The TypeScript package aims to mirror the Python package closely. The serialized format introduced for prompts, chains, and agents in Python also works for the TypeScript version. This ensures that artifacts are shareable between languages, enabling community adoption and sharing of best prompts, chains, and agents.

Conclusion

TypeScript support for LangChain opens up new possibilities for developers who prefer using JavaScript. With the same abstractions available in both the Python and TypeScript packages, it becomes easier to transition between the two languages. As the TypeScript package continues to grow, more features aimed at facilitating web development will be included. This evolution reflects the different priorities and use cases within each community and allows for a wider range of applications.

Langchain
ChatGPT
Typescript
Recommended from ReadMedium