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, where you and your collaborators can browse and reuse it.
StringPrompt
StringPrompt logs single-string prompts that you might use for system messages, user queries, or any standalone text input to an LLM. Use StringPrompt to manage individual prompt strings that don’t require the complexity of multi-message conversations.
- Python
- TypeScript
MessagesPrompt
MessagesPrompt lets you 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. Use MessagesPrompt for chat-based LLMs where you need to maintain context across multiple messages, define specific conversation patterns, or create reusable conversation templates.
- Python
- TypeScript
Parameterize prompts
Once you can create static prompts, the next step is to make them reusable across different inputs. BothStringPrompt and MessagesPrompt support dynamic content through parameterization. This lets you create reusable prompt templates with placeholders (using {variable} syntax) that you fill with different values at runtime. Parameterization is useful when your prompts must 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 when you need placeholders inside a multi-turn conversation.
- Python
- TypeScript