This feature is only accessible through the Python SDK. All code examples on this page are provided in Python.
Creating, evaluating, and refining prompts is a core activity for AI engineers.
Small changes to a prompt can have big impacts on your application’s behavior.
Weave lets you create prompts, save and retrieve them, and evolve them over time.
Weave is unopinionated about how a Prompt is constructed. If your needs are simple you can use our built-in weave.StringPrompt or weave.MessagesPrompt classes. If your needs are more complex you can subclass those or our base class weave.Prompt and override the
format method.
When you publish one of these objects with weave.publish, it will appear in your Weave project on the “Prompts” page.
StringPrompt
Perhaps this prompt does not yield the desired effect, so we modify the prompt to be more
clearly instructive.
When viewing this prompt object, I can see that it has two versions.
I can also select them for comparison to see exactly what changed.
MessagesPrompt
The MessagesPrompt can be used to replace an array of Message objects.
Parameterizing prompts
As the format method’s name suggests, you can pass arguments to
fill in template placeholders in the content string.
This also works with MessagesPrompt.