Expand description
§prompeta 🎺
Declarative prompt engineering with semantic roles and pluggable rendering strategies.
Instead of building prompts as strings, you declare content with semantic roles
(instruction, context, focus, constraint, example, schema) and a PromptStrategy
renders the final text using best-practice prompt engineering.
§Quick start
use prompeta::{Prompt, ContentRole};
let prompt = Prompt::new()
.instruction("You are a helpful assistant.")
.context("User profile", "Name: Alice, Role: Engineer")
.focus("Current task", "Debug the authentication module")
.constraint("Do not modify production database")
.schema(serde_json::json!({
"diagnosis": "string",
"fix": "string",
"confidence": "float 0-1"
}));
// Renders using the default ClaudeStrategy
let text = prompt.to_string();§Key concepts
- Content roles — Each block of content has a semantic role that tells the renderer how to format and order it.
- Pluggable strategies — The
PromptStrategytrait lets you swap rendering logic per model family. AClaudeStrategyis provided by default. - Budget trimming —
Prompt::trim_to_budgetremoves lowest-priority blocks until the output fits within a character budget. - Tag-based manipulation — Block-level tags let you surgically remove or replace content without position-dependent code.
Structs§
- Block
- A content block with semantic metadata.
- Claude
Strategy - Default strategy optimized for Claude models.
- Prompt
- A declarative prompt: a collection of semantically-typed blocks.
Enums§
- Content
Role - Semantic role of a content block within a prompt.
Traits§
- Prompt
Strategy - Pluggable rendering algorithm for converting a
Promptto text.