Getting Started
Follow the instructions below to install PromptDX in your app.
Install PromptDX
Install with npm:
npm install @puzzlet/promptdx
or yarn:
yarn add @puzzlet/promptdx
Create your first Prompt
index.prompt.mdx
---
name: basic-prompt
metadata:
model:
name: gpt-4o-mini
---
<User>Hello World</User>
Run your Prompt
VSCode
Run .prompt.mdx files directly within your VSCode editor.
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);
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);