Microsoft has released TypeChat, an open-source library designed to facilitate the development of natural language interfaces for large language models (LLMs), like GPT-4, PaLM 2, or LLaMa. The library, which is available on GitHub, leverages TypeScript and generative AI to bridge natural language, application schema, and APIs.
Bridging Natural Language and APIs
The recent surge of interest in LLMs has raised many questions for developers. While chat assistants such as ChatGPT, Bing Chat or Google Bard have been the most direct application, there have been challenges regarding how to integrate these models into existing app interfaces, such as how to augment traditional UIs with natural language interfaces and how to use AI to convert a user request into a form that apps can operate on.
TypeChat uses type definitions in your application to retrieve structured, type-safe AI responses. The library was introduced on July 20 by a team led by Anders Hejlsberg, a Microsoft technical fellow and lead developer for C# and TypeScript. The team aims to address the challenges of developing natural language interfaces, which often rely on complex decision trees to determine intent and collect required inputs for action.
TypeChat is open-source and model-neutral. It is designed to work with any chat completion-style API, although it works best with models trained on prose and code. The library is available on npm, and the team welcomes feedback and contributions on GitHub.
Replacing Prompt Engineering with Schema Engineering
The creators of TypeChat have replaced prompt engineering with schema engineering. Developers can define types representing intents supported in a natural language application. These could range from simple interfaces for categorizing sentiment to more complex types for applications like shopping carts or music apps.
Once the developer defines the types, TypeChat constructs a prompt to the LLM using those types and validates that the LLM response conforms to the schema. If validation fails, further language model interaction is used to repair the non-conforming output. TypeChat also summarizes the instance and confirms that it aligns with user intent.
Installation and Use
Developers can install TypeChat through Node Package Manager using the command
npm install typechat. The library can also be built from source using
npm run build.