microsoft/TypeChat

TypeChat is a library that makes it easy to build natural language interfaces using types.

What it solves

TypeChat solves the difficulty of building natural language interfaces. Traditionally, these apps relied on complex decision trees or fragile prompt engineering to ensure LLM responses are structured, safe, and valid. TypeChat replaces prompt engineering with "schema engineering," allowing developers to define the desired output format using types rather than long, complex prompts.

How it works

Instead of writing detailed prompts, developers define types (such as interfaces or discriminated unions) that represent the supported intents of the application. TypeChat then:

  1. Automatically constructs a prompt for the LLM based on these types.
  2. Validates that the LLM's response conforms to the schema.
  3. Repairs non-conforming output through further interaction with the language model if validation fails.
  4. Provides a succinct summary of the result to confirm alignment with user intent without using an LLM.

Who it’s for

Developers building natural language interfaces who want a more robust and predictable way to structure LLM outputs using TypeScript/JavaScript, Python, or C#/.NET.

Highlights

  • Schema-driven development: Replaces fragile prompt engineering with type definitions.
  • Automatic validation: Ensures LLM responses adhere to the defined schema.
  • Self-repairing output: Automatically fixes non-conforming responses via LLM interaction.
  • Multi-language support: Available for TypeScript/JavaScript, Python, and C#/.NET.

Related

  • Project
  • Project
  • Project
  • Project
  • Project