Skip to content

Deepractice/PromptML

Repository files navigation

DPML

Deepractice Prompt Markup Language

结构化 AI 提示工程的声明式标记语言

Define, validate, and transform AI prompts with XML-like syntax

使用类 XML 语法定义、验证和转换 AI 提示

Declarative · Type Safe · Extensible

声明式 · 类型安全 · 可扩展

Stars License npm CI

Quick StartDocumentationAPI Reference


Why DPML?

AI systems need structured ways to define behaviors: prompts, contexts, instructions, constraints, and more. DPML provides a unified markup language with schema validation and extensible transformers. Everything is declarative.

┌─────────────────────────────────────────────────────────────┐
│                      DPML Document                          │
│                                                             │
│  <prompt role="assistant">                                  │
│    <context>You are a travel planner</context>              │
│    <instruction>Help users plan trips</instruction>         │
│    <resource src="arp:text:file://./knowledge.md"/>         │
│  </prompt>                                                  │
├─────────────────────────────────────────────────────────────┤
│                     Processing Pipeline                     │
│                                                             │
│  Parse          →  DPML Text → DPMLDocument                 │
│  Validate       →  Schema → ValidationResult                │
│  Transform      →  Transformers → Target Format             │
├─────────────────────────────────────────────────────────────┤
│                      Core Concepts                          │
│                                                             │
│  Element        →  <tag>content</tag>                       │
│  Attribute      →  name="value"                             │
│  Schema         →  Structure & validation rules             │
│  Transformer    →  Convert to any format                    │
└─────────────────────────────────────────────────────────────┘

Quick Start

npm install dpml
import { createDPML, defineSchema, defineTransformer } from 'dpml';

// 1. Define schema
const schema = defineSchema({
  element: 'prompt',
  attributes: [{ name: 'role', required: true }],
  children: { elements: [{ element: 'context' }, { element: 'instruction' }] },
});

// 2. Define transformer
const transformer = defineTransformer({
  name: 'prompt-extractor',
  transform: (input) => ({
    role: input.document.rootNode.attributes.get('role'),
    context: input.document.rootNode.children[0]?.content,
    instruction: input.document.rootNode.children[1]?.content,
  }),
});

// 3. Compile
const dpml = createDPML({ schema, transformers: [transformer] });
const result = await dpml.compile(`
  <prompt role="assistant">
    <context>You are a helpful assistant</context>
    <instruction>Answer questions clearly</instruction>
  </prompt>
`);
// → { role: 'assistant', context: '...', instruction: '...' }

Packages

Package Description
dpml Main package - public API
@dpml/core Core library - parse, validate, transform

Ecosystem

Part of the Deepractice AI infrastructure:

  • AgentVM - AI Agent runtime
  • AgentX - AI Agent framework
  • ResourceX - Resource management protocol
  • DPML - Prompt markup language (this project)

Development

# Clone & setup
git clone https://github.com/Deepractice/dpml.git
cd dpml && bun install

# Build & test
bun run build
bun run test
bun run test:bdd

See Development Guide for BDD workflow.

Contributing

Contributions welcome! Please read our contributing guidelines before submitting PRs.

License

MIT © Deepractice


Built with care by Deepractice

About

Deepractice Prompt Markup Language | 标签语言驱动的 AI 工程开发新范式

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •