@puzzlet/promptdx v0.1.2
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:
---
name: basic-prompt
metadata:
model:
name: gpt-4o-mini
test_settings:
props:
num: 3
---
import Instructions from './instructions.mdx';
<System>
You are a math expert
<Instructions outputType="latex" />
</System>
<User>
What's 2 + {props.num}?
</User>
Features
PromptDX supports:
- Markdown
- Components
- Custom models
- Custom filters
- Custom JSX tags
- Loops and Conditional
Read our docs to learn more.
Running PromptDX
You can run PromptDX using one of the following methods:
1. VSCode Extension
Install our VSCode extension to streamline your development process.
2. Webpack Loader
Integrate PromptDX with your webpack workflow using our loader.
3. Node.js
Run PromptDX directly in your Node.js environment. Below is a sample implementation:
import { bundle } from "@puzzlet/templatedx";
import { runInference } from "@puzzlet/promptdx";
const getMdxFile: ContentLoader = async (path: string) => {
const input = fs.readFileSync(path, 'utf-8');
return input;
}
const run = async (path: string) => {
const mdx = await getMdxFile(path);
const bundled = await bundle(mdx, `${basePathToMdxFile}`, getMdxFile);
const props = { name: "Emily" };
const result = await runInference(bundled, myProps);
}
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.