Skip to main content

Create and Edit Prompts

This guide walks you through the process of creating new prompts and managing their versions within the MLflow Prompt Registry.

Creating a New Prompt​

You can initiate a new prompt in the MLflow Prompt Registry in two primary ways: through the MLflow UI or programmatically using the Python SDK.

  1. Navigate to the Prompt Registry section in your MLflow instance.
  2. Click on the "Create Prompt" (or similar) button.
  3. Fill in the prompt details such as name, prompt template text, and commit message (optional)

Registered Prompt in UI

Editing an Existing Prompt (Creating New Versions)​

Once a prompt version is created, its template and initial metadata are immutable. Editing an existing prompt means creating a new version of that prompt with your changes. This Git-like behavior ensures a complete history and allows you to revert to previous versions if needed.

  1. Navigate to the specific prompt you wish to edit in the Prompt Registry.
  2. Select the version you want to base your new version on (often the latest).
  3. Look for an "Edit Prompt" or "Create New Version" button.
  4. Modify the template, update metadata, or change tags as needed.
  5. Provide a new Commit Message describing the changes you made for this new version.

Update Prompt UI

Understanding Immutability​

It's crucial to remember that prompt versions in the MLflow Prompt Registry are immutable. Once mlflow.genai.register_prompt() is called and a version is created (or a new version of an existing prompt is made), the template, initial commit message, and initial metadata for that specific version cannot be altered. This design choice provides strong guarantees for reproducibility and lineage tracking.

If you need to change a prompt, you always create a new version.

Comparing Prompt Versions​

The MLflow UI provides tools to compare different versions of a prompt. This typically includes a side-by-side diff view, allowing you to easily see what changed in the template text, metadata, or tags between versions.

Compare Prompt Versions