Skip to main content

Crate agent_context_builder

Crate agent_context_builder 

Source
Expand description

agent-context-builder: compose LLM system prompts from named sections.

Build a system prompt from independently managed named sections. Sections can be added, removed, reordered, and conditionally included. The final prompt is rendered in insertion or explicit priority order.

use agent_context_builder::ContextBuilder;

let prompt = ContextBuilder::new()
    .section("role", "You are a helpful assistant.")
    .section("rules", "Always cite sources.")
    .build();
assert!(prompt.contains("helpful assistant"));

Structsยง

ContextBuilder
Builds a system prompt from named, ordered sections.