1.2.6 • Published 11 months ago

@puzzlet/promptdx v1.2.6

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

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:

  1. Markdown: 📝
  2. JSX components, props, & plugins: 🧩
  3. Unified API across models: 🔗
  4. Custom Models: 🛠️
  5. Streaming: 🌊
  6. Loops, Conditionals, and Filter Functions: ♻️
  7. 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

ProviderModelSupported
OpenAIgpt-4o✅ Supported
OpenAIgpt-4o-mini✅ Supported
OpenAIgpt-4-turbo✅ Supported
OpenAIgpt-4✅ Supported
OpenAIo1-mini✅ Supported
OpenAIo1-preview✅ Supported
OpenAIgpt-3.5-turbo✅ Supported
Anthropicclaude-3-5-haiku-latest✅ Supported
Anthropicclaude-3-5-sonnet-latest✅ Supported
Anthropicclaude-3-opus-latest✅ Supported
Customany✅ Supported
GoogleALL⚠️ Coming Soon
MetaALL⚠️ Coming Soon
GroqALL⚠️ 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.

Download the VSCode Extension

2. Webpack Loader

Integrate PromptDX with your webpack workflow using our loader.

PromptDX Webpack 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.

1.2.0

12 months ago

1.1.0

12 months ago

1.0.0

12 months ago

1.2.6

11 months ago

1.2.5

11 months ago

1.2.4

11 months ago

1.2.3

12 months ago

1.2.2

12 months ago

1.2.1

12 months ago

0.2.0

12 months ago

0.1.4

12 months ago

0.1.3

12 months ago

0.1.5

12 months ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.4

1 year ago