← all repositories
microsoft/prompt-engine

Microsoft’s prompt templating for forgetful models

It automates the tedious string manipulation behind few-shot prompting, letting you assemble descriptions, examples, and dialog history into clean LLM inputs.

2.8k stars TypeScript LLMOps · EvalLanguage Models
prompt-engine
Not currently ranked — collecting fresh signals.
star history

What it does

prompt-engine is a TypeScript library that codifies common prompt-engineering patterns into a structured builder. You define a description, seed it with input-output examples, and append an ongoing dialog; the library formats the whole stack into a single string ready for any LLM. It also handles the housekeeping—when the dialog grows too long for the model’s token limit, it silently drops the oldest interactions to prevent overflow.

The interesting bit

The library treats the prompt less like a message and more like a state machine for a stateless brain. Because LLMs have no memory, the tool injects the entire conversation history into each new prompt, then prunes from the top when space runs out. It is essentially sophisticated glue code, but glue code that captures the exact few-shot and multi-turn patterns Microsoft documented for Codex and GPT-3.

Key highlights

  • Supports generic, code-generation (CodeEngine), and chat (ChatEngine) prompt patterns out of the box.
  • Language-agnostic code prompts: swap comment operators and config to target Python, JavaScript, or other languages.
  • Built-in token overflow management via maxTokens, which trims oldest dialog interactions first.
  • Prompts can be serialized to YAML for versioning, swapping, and external configuration.
  • Model-independent: outputs plain strings compatible with GPT-3, Codex, or other LLMs.

Verdict

Worth a look if you are building multi-turn LLM applications and want a disciplined, reusable way to manage few-shot context without hand-rolling string concatenation. Skip it if you already have a prompt-management layer or need logic beyond structured string assembly.

Frequently asked

What is microsoft/prompt-engine?
It automates the tedious string manipulation behind few-shot prompting, letting you assemble descriptions, examples, and dialog history into clean LLM inputs.
Is prompt-engine open source?
Yes — microsoft/prompt-engine is open source, released under the MIT license.
What language is prompt-engine written in?
microsoft/prompt-engine is primarily written in TypeScript.
How popular is prompt-engine?
microsoft/prompt-engine has 2.8k stars on GitHub.
Where can I find prompt-engine?
microsoft/prompt-engine is on GitHub at https://github.com/microsoft/prompt-engine.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.