pub struct Sim { /* private fields */ }Expand description
A deterministic, model-free driver for a compiled conversation.
Implementations§
Source§impl Sim
impl Sim
Sourcepub fn new(convo: &CompiledConversation, mode: Enforcement) -> Self
pub fn new(convo: &CompiledConversation, mode: Enforcement) -> Self
Build a simulator over convo in the given enforcement mode.
Sourcepub fn set(&self, key: impl Into<String>, value: impl Serialize) -> &Self
pub fn set(&self, key: impl Into<String>, value: impl Serialize) -> &Self
Set a state value directly (information a recognizer can’t supply, or a scripted shortcut). Does not advance a turn.
Sourcepub async fn user(&mut self, utterance: &str) -> &mut Self
pub async fn user(&mut self, utterance: &str) -> &mut Self
The fake user speaks: run the conversation’s extractors over the utterance to fill slots (respecting validators), then advance a turn.
Sourcepub fn turn(&mut self) -> &mut Self
pub fn turn(&mut self) -> &mut Self
Advance a turn with no new user input (e.g. waiting on a tool/resolver).
Sourcepub fn tool_ok(&mut self, tool: &str) -> &mut Self
pub fn tool_ok(&mut self, tool: &str) -> &mut Self
A tool succeeds now; records it and advances a turn (processing any digression resume).
Sourcepub fn schedule_tool(
&mut self,
tool: impl Into<String>,
after: u32,
) -> &mut Self
pub fn schedule_tool( &mut self, tool: impl Into<String>, after: u32, ) -> &mut Self
Schedule a tool to succeed after turns — models tool latency.
Sourcepub fn active_overlay(&self) -> Option<&str>
pub fn active_overlay(&self) -> Option<&str>
The active digression, if one is suspending the main flow.
Sourcepub fn denied(&self) -> BTreeMap<String, String>
pub fn denied(&self) -> BTreeMap<String, String>
Currently-blocked tools, mapped to the reason.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Whether the conversation is complete.
Sourcepub fn slot<T: DeserializeOwned>(&self, key: &str) -> Option<T>
pub fn slot<T: DeserializeOwned>(&self, key: &str) -> Option<T>
Read a slot value.
Sourcepub fn explain(&self) -> FlowExplanation
pub fn explain(&self) -> FlowExplanation
The active layer’s control-plane explanation.
Auto Trait Implementations§
impl Freeze for Sim
impl !RefUnwindSafe for Sim
impl Send for Sim
impl Sync for Sim
impl Unpin for Sim
impl !UnwindSafe for Sim
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
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].