Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Workflow:Wandb Weave Prompt Management

From Leeroopedia
Revision as of 11:00, 16 February 2026 by Admin (talk | contribs) (Auto-imported from workflows/Wandb_Weave_Prompt_Management.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains LLM_Ops, Prompt_Engineering, Version_Control
Last Updated 2026-02-14 11:00 GMT

Overview

End-to-end process for creating, versioning, and using managed prompts in Weave for reproducible LLM application development.

Description

This workflow covers the prompt management system in Weave, which provides structured classes for defining, templating, versioning, and retrieving prompts. The system supports three prompt types: StringPrompt for simple template strings, MessagesPrompt for chat-format message lists with roles, and EasyPrompt for a builder-pattern shorthand. All prompts support variable interpolation, versioning through Weave's object publishing system, and can be referenced by URI for reproducibility across environments.

Usage

Execute this workflow when you need to manage prompt templates across your LLM application lifecycle, including: iterating on prompt designs with version tracking, sharing prompts across team members, switching between prompt versions in evaluations, or maintaining a library of reusable prompt templates.

Execution Steps

Step 1: Define a Prompt

Create a prompt using one of the available prompt classes. StringPrompt accepts a template string with named placeholders. MessagesPrompt accepts a list of message dictionaries with role and content fields, supporting multi-turn chat formats. EasyPrompt provides a builder API for constructing prompts with system and user messages.

Key considerations:

  • StringPrompt uses Python string formatting syntax with named placeholders
  • MessagesPrompt supports nested content structures for multi-modal messages (text, images)
  • EasyPrompt provides convenience methods for common patterns and supports parameter defaults
  • All prompt types inherit from the base Prompt class which is a Weave Object

Step 2: Publish the Prompt

Publish the prompt to Weave to create a versioned, immutable snapshot. Each publish operation creates a new version with a unique reference URI. This enables tracking prompt evolution over time and switching between versions without code changes.

Key considerations:

  • Each publish creates a new version; previous versions remain accessible
  • Prompts are published under a name that serves as the version lineage identifier
  • Published prompts can be referenced across projects and environments
  • The versioning system tracks the full prompt content, not just diffs

Step 3: Retrieve and Use the Prompt

Load a published prompt by its reference URI and call its format method with the required variables to produce the final prompt text or message list. The formatted output can then be passed directly to an LLM API call.

Key considerations:

  • Use weave.ref() to create a reference to a specific prompt version
  • The format() method substitutes variables into template placeholders
  • Missing variables raise clear errors to prevent incomplete prompts
  • The prompt object itself is a traced Weave object, so usage is captured in call trees

Step 4: Iterate and Version

Modify the prompt content and publish again to create a new version. Compare prompt versions through the Weave UI to understand how changes affect model behavior. Use evaluations to systematically test prompt variations against a dataset.

Key considerations:

  • Version comparison is available in the Weave UI for published objects
  • Prompts can be used as parameters in Model subclasses for evaluation tracking
  • The EasyPrompt builder pattern simplifies rapid iteration on complex prompts
  • Prompt versions can be pinned in production while development uses latest

Execution Diagram

GitHub URL

Workflow Repository