Use the import statement to include components from other files:

example.prompt.mdx
---
name: math-tutor
metadata:
  model:
    name: gpt-4
---

import MathInstructions from './math-instructions.mdx';

<System>
  You are a math tutor.
  <MathInstructions />
</System>

<User>What's 2 + 2?</User>

Component Props

Components can accept props to make them more dynamic:

example.prompt.mdx
---
name: language-tutor
metadata:
  model:
    name: gpt-4
test_settings:
  props:
    language: "Spanish"
    difficulty: "beginner"
---

import LanguageInstructions from './language-instructions.mdx';

<System>
  <LanguageInstructions 
    language={props.language}
    level={props.difficulty}
  />
</System>

<User>How do I say "Hello"?</User>

Creating Components

Components are just regular .mdx files that can accept props:

math-instructions.mdx:

example.prompt.mdx
<If condition={props.level == "advanced"}>
  Provide detailed mathematical proofs and explanations.
</If>
<Else>
  Keep explanations simple and provide step-by-step solutions.
</Else>

Importing Plain Markdown

You can also import plain markdown files:

example.prompt.mdx
---
name: math-tutor
metadata:
  model:
    name: gpt-4
---

import MathInstructions from './math-instructions.md';

<System>
  You are a math tutor.
  <MathInstructions />
</System>

Best Practices

  1. Keep components focused and single-purpose
  2. Use meaningful component and prop names
  3. Consider breaking complex prompts into multiple components

Have Questions?

We’re here to help! Choose the best way to reach us: