pub struct ThinkingStep<'a, P: EventProducer<StateT>, StateT: AgentState = JsonValue> { /* private fields */ }Expand description
Helper for managing thinking block boundaries (chain-of-thought steps).
This struct wraps a thinking block with ThinkingStart and ThinkingEnd events.
Inside a thinking step, you can emit thinking content using ThinkingMessageStream.
§Example
ⓘ
// Start a thinking step with optional title
let step = ThinkingStep::start(&producer, Some("Analyzing user query")).await?;
// Emit thinking content inside the step
let thinking = ThinkingMessageStream::start(step.producer()).await?;
thinking.content("First, let me consider...").await?;
thinking.end().await?;
// End the thinking step
step.end().await?;Implementations§
Source§impl<'a, P: EventProducer<StateT>, StateT: AgentState> ThinkingStep<'a, P, StateT>
impl<'a, P: EventProducer<StateT>, StateT: AgentState> ThinkingStep<'a, P, StateT>
Sourcepub async fn start(
producer: &'a P,
title: Option<impl Into<String>>,
) -> Result<Self, ServerError>
pub async fn start( producer: &'a P, title: Option<impl Into<String>>, ) -> Result<Self, ServerError>
Start a new thinking step.
Emits a ThinkingStart event with an optional title.
Sourcepub async fn end(self) -> Result<(), ServerError>
pub async fn end(self) -> Result<(), ServerError>
End the thinking step.
Emits a ThinkingEnd event.
Consumes the step to prevent reuse.
Sourcepub fn producer(&self) -> &'a P
pub fn producer(&self) -> &'a P
Get a reference to the underlying producer.
Use this to create ThinkingMessageStream instances inside the step.
Auto Trait Implementations§
impl<'a, P, StateT> Freeze for ThinkingStep<'a, P, StateT>
impl<'a, P, StateT> RefUnwindSafe for ThinkingStep<'a, P, StateT>where
P: RefUnwindSafe,
StateT: RefUnwindSafe,
impl<'a, P, StateT> Send for ThinkingStep<'a, P, StateT>
impl<'a, P, StateT> Sync for ThinkingStep<'a, P, StateT>
impl<'a, P, StateT> Unpin for ThinkingStep<'a, P, StateT>where
StateT: Unpin,
impl<'a, P, StateT> UnsafeUnpin for ThinkingStep<'a, P, StateT>
impl<'a, P, StateT> UnwindSafe for ThinkingStep<'a, P, StateT>where
P: RefUnwindSafe,
StateT: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more