@puzzlet/promptdx v1.2.6
Overview
PromptDX is a declarative, extensible, and composable approach for developing LLM prompts using Markdown and JSX.
PromptDX is designed to enhance the developer experience for applications built with large language models (LLMs). It allows you to open a PromptDX file and clearly see the exact input being sent to the LLM, while still providing the flexibility to abstract away necessary details.
PromptDX is built on top of the templating language, TemplateDX, and inspired by MDX.
Getting Started
Below is a basic example to help you get started with PromptDX:
example.prompt.mdx
---
name: basic-prompt
metadata:
model:
name: gpt-4o-mini
test_settings:
props:
num: 3
---
<System>You are a math expert</System>
<User>What's 2 + {props.num}?</User>Features
PromptDX supports:
- Markdown: 📝
- JSX components, props, & plugins: 🧩
- Unified API across models: 🔗
- Custom Models: 🛠️
- Streaming: 🌊
- Loops, Conditionals, and Filter Functions: ♻️
- Type Safety: 🛡️
Read our docs to learn more.
Models
By default, PromptDX doesn't support any model providers. Instead, support must be added through our plugins. Here's a list of currently supported plugins you can start using.
Built-In Model Plugins
| Provider | Model | Supported |
|---|---|---|
| OpenAI | gpt-4o | ✅ Supported |
| OpenAI | gpt-4o-mini | ✅ Supported |
| OpenAI | gpt-4-turbo | ✅ Supported |
| OpenAI | gpt-4 | ✅ Supported |
| OpenAI | o1-mini | ✅ Supported |
| OpenAI | o1-preview | ✅ Supported |
| OpenAI | gpt-3.5-turbo | ✅ Supported |
| Anthropic | claude-3-5-haiku-latest | ✅ Supported |
| Anthropic | claude-3-5-sonnet-latest | ✅ Supported |
| Anthropic | claude-3-opus-latest | ✅ Supported |
| Custom | any | ✅ Supported |
| ALL | ⚠️ Coming Soon | |
| Meta | ALL | ⚠️ Coming Soon |
| Groq | ALL | ⚠️ Coming Soon |
Want to add support for another model? Open an issue.
Custom Model Plugins
Refer to our docs to learn how to add custom model support.
Running PromptDX
You can run PromptDX using one of the following methods:
1. VSCode Extension
Run .prompt.mdx files directly within your VSCode editor.
2. Webpack Loader
Integrate PromptDX with your webpack workflow using our loader.
import { runInference, ModelPluginRegistry } from "@puzzlet/promptdx";
import AllModelPlugins from '@puzzlet/promptdx/models/all-latest';
import MyPrompt from './example.prompt.mdx';
// Note: Registering all latest models for demo/development purposes.
// In production, you'll likely want to selectively load these, and pin models.
ModelPluginRegistry.registerAll(AllModelPlugins);
const run = async () => {
const props = { name: "Emily" };
const result = await runInference(MyPrompt, props);
console.log(result)
}
run();3. Node.js
Run PromptDX directly in your Node.js environment. Below is a sample implementation:
import { runInference, ModelPluginRegistry, load } from "@puzzlet/promptdx";
import AllModelPlugins from '@puzzlet/promptdx/models/all-latest';
// Note: Registering all latest models for demo/development purposes.
// In production, you'll likely want to selectively load these, and pin models.
ModelPluginRegistry.registerAll(AllModelPlugins);
const run = async () => {
const props = { name: "Emily" };
const Prompt = await load('./example.prompt.mdx');
const result = await runInference(Prompt, props);
console.log(result);
}
run();Contributing
We welcome contributions! Please check out our contribution guidelines for more information.
Community
Join our community to collaborate, ask questions, and stay updated:
License
This project is licensed under the MIT License.