Implementation:Wandb Weave Prompt Publish
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Prompt_Engineering, Versioning |
| Last Updated | 2026-02-14 00:00 GMT |
Overview
Concrete tool for publishing and versioning prompt templates provided by the Wandb Weave library.
Description
weave.publish() persists a Prompt object to the Weave backend. EasyPrompt also provides a convenience publish() method that delegates to the same underlying API. Each publish with the same name creates a new version if the content hash differs.
Usage
Call weave.publish(prompt, name) or prompt.publish(name) (for EasyPrompt) to save a prompt for versioned retrieval.
Code Reference
Source Location
- Repository: wandb/weave
- File: weave/trace/api.py
- Lines: L118-178 (publish)
- File: weave/prompt/prompt.py
- Lines: L417-420 (EasyPrompt.publish)
Signature
def publish(obj: Any, name: str | None = None) -> ObjectRef:
"""Save and version a Python object.
Args:
obj: The Prompt object to save.
name: The name to save under.
Returns:
A Weave Ref to the saved prompt.
"""
# EasyPrompt convenience method:
class EasyPrompt:
def publish(self, name: str | None = None) -> ObjectRef:
"""Publish this prompt to Weave."""
Import
import weave
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| obj | Prompt | Yes | The prompt object to publish |
| name | None | No | Name for the versioned prompt |
Outputs
| Name | Type | Description |
|---|---|---|
| return | ObjectRef | Immutable reference with entity, project, name, digest |
Usage Examples
Publish a StringPrompt
import weave
weave.init("my-team/my-project")
prompt = weave.StringPrompt(content="Translate '{text}' to {language}.")
ref = weave.publish(prompt, name="translation_prompt")
print(ref) # weave:///my-team/my-project/object/translation_prompt:<digest>
Publish an EasyPrompt
import weave
weave.init("my-team/my-project")
prompt = weave.EasyPrompt("You are a translator.", role="system")
prompt.append("{text}", role="user")
ref = prompt.publish("translation_prompt")
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment