TypeChat

Active
GitHub TypeScript MIT

Description

Microsoft's TypeScript library replacing prompt engineering with type definitions for structured LLM output, using TypeScript interfaces to define AI response contracts.

Key Features

  • Type-driven LLM output constraining: replaces prompt engineering with TypeScript interface definitions for structured responses
  • Automatic validation and repair: validates LLM output against schema and auto-repairs non-conforming responses via further conversation
  • Concise intent summarization: summarizes instances and confirms user intent without invoking an LLM
  • Multi-language support: bindings for TypeScript, Python, and C#/.NET
  • Hierarchical schema support: meta-schema mechanism selects sub-schemas based on user input
  • Discriminated union types: extend intent types through discriminated union definitions

Use Cases

💡 Building natural language shopping cart apps: parsing user conversations into structured orders via type definitions
💡 Creating chatbot intent classifiers: identifying user intent with interface definitions and routing to handlers
💡 Developing auto-fill form tools: extracting fields from natural language to populate structured forms
💡 Implementing secure LLM API gateways: ensuring all LLM output conforms to predefined schemas

Quick Start

1. Run: npm install typechat
2. Define TypeScript interfaces describing intents and data types
3. Create a TypeChat instance and specify the schema
4. Call instance methods to process user natural language input
5. Receive validated, structured output

Related Projects