Awesome
<h1 align="center">PromptDX</h1> <p align="center"> <a href="https://github.com/puzzlet-ai"> <img src="https://www.puzzlet.ai/images/logo.svg" alt="PromptDX Logo" width="200"/> </a> </p> <p align="center"> <strong>A declarative, extensible, and composable approach for developing LLM prompts using Markdown and JSX.</strong> </p> <p align="center"> <a href="https://discord.gg/P2NeMDtXar">Discord</a> | <a href="https://puzzlet-ai.github.io/promptdx/">Docs</a> | <a href="https://github.com/puzzlet-ai/templatedx">TemplateDX</a> | <a href="https://puzzlet.ai">Puzzlet</a> </p>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
- Components
- Custom models
- Custom filters
- Custom JSX tags
- Loops and Conditionals
- Type Safety
Read our docs to learn more.
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 MyPrompt from './example.prompt.mdx';
const props = { name: "Emily" };
const result = await runInference(MyPrompt, props);
3. Node.js
Run PromptDX directly in your Node.js environment. Below is a sample implementation:
import { runInference, parse, registerDefaultPlugins } from "@puzzlet/promptdx";
import fs from 'fs';
const getMdxFile = (path) => {
const input = fs.readFileSync(path, 'utf-8');
return input;
}
const run = async () => {
const mdx = await getMdxFile(file);
// Set the base path for imports
const basePathForImports = './';
const bundled = await parse(mdx, basePathForImports, getMdxFile);
const props = { name: "Emily" };
const result = await runInference(bundled, props);
console.log(result);
}
// Registers the default model plugins (i.e. OpenAI, etc.) provided by PromptDX
registerDefaultPlugins().then(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.