weave.StringPrompt or weave.MessagesPrompt classes. If your needs are more complex, you can subclass those or the base class weave.Prompt and override the format method.
When you publish a prompt with weave.publish, it appears in your Weave project on the Prompts page.
StringPrompt
StringPrompt logs single-string prompts that you might use for system messages, user queries, or any standalone text input to an LLM. We recommend using StringPrompt to manage individual prompt strings that don’t require the complexity of multi-message conversations.
- Python
- TypeScript
MessagesPrompt
MessagesPrompt allows you to log multi-turn conversations and chat-based prompts. It stores an array of message objects (with roles like “system”, “user”, and “assistant”) that represent a complete conversation flow. We recommend using this for chat-based LLMs where you need to maintain context across multiple messages, define specific conversation patterns, or create reusable conversation templates.
- Python
- TypeScript
Parameterizing prompts
BothStringPrompt and MessagesPrompt support dynamic content through parameterization. This allows you to create flexible, reusable prompt templates with placeholders (using {variable} syntax) that can be filled with different values at runtime. This is useful for building scalable applications where prompts need to adapt to different inputs, user data, or contexts while maintaining a consistent structure. The format() method accepts key-value pairs to replace these placeholders with actual values.
- Python
- TypeScript
MessagesPrompt.
- Python
- TypeScript