Principle:Wandb Weave Prompt Retrieval
| Knowledge Sources | |
|---|---|
| Domains | Prompt_Engineering, Object_Storage |
| Last Updated | 2026-02-14 00:00 GMT |
Overview
A reference-based retrieval mechanism that loads published prompts and applies template variable substitution.
Description
Prompt Retrieval loads a previously published prompt by name or version, deserializes it into the original Prompt object, and applies template variable substitution via format(). This enables production applications to use versioned prompts without hardcoding template text.
Usage
Use this principle in production code to load prompts by reference instead of defining them inline. This separates prompt content from application logic and enables prompt updates without code changes.
Theoretical Basis
Prompt retrieval follows a two-step process:
- Reference Resolution: weave.ref(location) creates an ObjectRef pointing to the prompt. The location can be a full URI, name:version, or just name (resolves to latest).
- Materialization: ref.get() deserializes the stored object back into a Prompt instance.
- Formatting: prompt.format(**kwargs) substitutes template variables.