Skip to main content

PromptLayerSink

Trait PromptLayerSink 

Source
pub trait PromptLayerSink: Sized {
    // Required method
    fn prompt_layer_mut(&mut self) -> &mut PromptLayer;

    // Provided methods
    fn prompt_template(self, template: PromptTemplate) -> Self { ... }
    fn prompt_contribution(self, contribution: PromptContribution) -> Self { ... }
    fn replace_prompt_slot(
        self,
        slot: PromptSlot,
        contributions: impl IntoIterator<Item = PromptContribution>,
    ) -> Self { ... }
    fn clear_prompt_slot(self, slot: PromptSlot) -> Self { ... }
    fn prompt_layer(self, layer: PromptLayer) -> Self { ... }
}
Expand description

Builder-agnostic prompt-layer mutation surface.

Every builder that owns a PromptLayercrate::LashCoreBuilder (the runtime default prompt) and crate::SessionBuilder (the per-session prompt) — implements this trait by exposing its layer via prompt_layer_mut. The template/contribution/slot operations are then defined here exactly once, instead of being copy-pasted per builder.

(The per-turn TurnBuilder does not implement this trait: its prompt operations forward to the turn context, which owns that logic, so there is nothing to share.)

Required Methods§

Source

fn prompt_layer_mut(&mut self) -> &mut PromptLayer

Mutable access to the builder’s prompt layer, created on first use.

Provided Methods§

Source

fn prompt_template(self, template: PromptTemplate) -> Self

Set the base prompt template.

Source

fn prompt_contribution(self, contribution: PromptContribution) -> Self

Add a single prompt contribution to its slot.

Source

fn replace_prompt_slot( self, slot: PromptSlot, contributions: impl IntoIterator<Item = PromptContribution>, ) -> Self

Replace all contributions in a slot.

Source

fn clear_prompt_slot(self, slot: PromptSlot) -> Self

Clear all contributions from a slot.

Source

fn prompt_layer(self, layer: PromptLayer) -> Self

Replace the whole prompt layer.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§