Skip to main content

TypeChat

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

Building natural language interfaces has traditionally been difficult. These apps often relied on complex decision trees to determine intent and collect the required inputs to take action. Large language models (LLMs) have made this easier by enabling us to take natural language input from a user and match to intent. This has introduced its own challenges, including the need to constrain the model's reply for safety, structure responses from the model for further processing, and ensuring that the reply from the model is valid. Prompt engineering aims to solve these problems, but comes with a steep learning curve and increased fragility as the prompt increases in size.

TypeChat replaces prompt engineering with schema engineering.

Simply define types that represent the intents supported in your natural language application. That could be as simple as an interface for categorizing sentiment or more complex examples like types for a shopping cart or music application. For example, to add additional intents to a schema, a developer can add additional types into a discriminated union. To make schemas hierarchical, a developer can use a "meta-schema" to choose one or more sub-schemas based on user input.

After defining your types, TypeChat takes care of the rest by:

  1. Constructing a prompt to the LLM using types.
  2. Validating the LLM response conforms to the schema. If the validation fails, repair the non-conforming output through further language model interaction.
  3. Summarizing succinctly (without use of a LLM) the instance and confirm that it aligns with user intent.

Types are all you need!

Getting Started

Install TypeChat:

pip install typechat

You can also develop TypeChat from source, which needs Python >=3.11, hatch, and Node.js >=20:

git clone https://github.com/microsoft/TypeChat
cd TypeChat/python
hatch shell
npm ci

To see TypeChat in action, we recommend exploring the TypeChat example projects. You can try them on your local machine or in a GitHub Codespace.

To learn more about TypeChat, visit the documentation which includes more information on TypeChat and how to get started.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

typechat-0.0.5.tar.gz (56.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

typechat-0.0.5-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file typechat-0.0.5.tar.gz.

File metadata

  • Download URL: typechat-0.0.5.tar.gz
  • Upload date:
  • Size: 56.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.17.1 {"ci":null,"cpu":"AMD64","implementation":{"name":"CPython","version":"3.13.14"},"installer":{"name":"hatch","version":"1.17.1"},"openssl_version":"OpenSSL 3.0.21 9 Jun 2026","python":"3.13.14","system":{"name":"Windows","release":"11"}} HTTPX2/2.9.1

File hashes

Hashes for typechat-0.0.5.tar.gz
Algorithm Hash digest
SHA256 effa833c63b800410ffa6fda89748b529c2b8ff1df94d0e3e5cb8963507f8db2
MD5 ca32491ad500ffdc38d8758f0c0b5e88
BLAKE2b-256 d4c436e5a11e06f9d57e2e5185a2c1bee9c437ad3f099129b1fa07aee721dfef

See more details on using hashes here.

File details

Details for the file typechat-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: typechat-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.17.1 {"ci":null,"cpu":"AMD64","implementation":{"name":"CPython","version":"3.13.14"},"installer":{"name":"hatch","version":"1.17.1"},"openssl_version":"OpenSSL 3.0.21 9 Jun 2026","python":"3.13.14","system":{"name":"Windows","release":"11"}} HTTPX2/2.9.1

File hashes

Hashes for typechat-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8addc64fd8f008c618688fd9c0bb883dd27a19a81fde952e8ee118c5dd1183bb
MD5 8702de7be89a25d4d9c6cc463d698b7c
BLAKE2b-256 8dddeaac3128cbfa263afa9bbe966b16197a5b576760ccdcde919f59b3ff4f71

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page