pub struct Conversation { /* private fields */ }Expand description
Fluent builder that produces a ConversationSpec; sugar over the spec.
(Not Debug: resolve_slot bindings hold async
closures. The serializable ConversationSpec is Debug via spec.)
Implementations§
Source§impl Conversation
impl Conversation
Sourcepub fn stage(self, id: impl Into<String>) -> Self
pub fn stage(self, id: impl Into<String>) -> Self
Begin authoring a new stage; subsequent setters apply to it. Routes to the
active overlay when between .overlay(..) and .end_overlay().
Sourcepub fn overlay(self, name: impl Into<String>) -> Self
pub fn overlay(self, name: impl Into<String>) -> Self
Begin authoring a digression/overlay; subsequent .stage(..) calls (until
.end_overlay()) populate it. Set its activation guard with .trigger(..)
(an overlay with no trigger never fires — fail-closed).
Sourcepub fn trigger(self, guard: Guard) -> Self
pub fn trigger(self, guard: Guard) -> Self
Set the activation guard of the overlay currently being authored.
Sourcepub fn resume(self, resume: Resume) -> Self
pub fn resume(self, resume: Resume) -> Self
Set the resume policy of the overlay currently being authored.
Sourcepub fn end_overlay(self) -> Self
pub fn end_overlay(self) -> Self
End overlay authoring; subsequent .stage(..) calls target the main
flow again. (Not a sub-builder exit — the Conversation is the same
value throughout — so it is named for what it does.)
Sourcepub fn add_overlay(self, overlay: OverlaySpec) -> Self
pub fn add_overlay(self, overlay: OverlaySpec) -> Self
Append a pre-built OverlaySpec (e.g. a Motif::faq_digression). Leaves
overlay-authoring mode (the overlay is already complete).
Sourcepub fn collect<I, S>(self, fields: I) -> Self
pub fn collect<I, S>(self, fields: I) -> Self
Collect the given slots in this stage (drives default completion).
Sourcepub fn collect_frame<F: Frame>(self) -> Self
pub fn collect_frame<F: Frame>(self) -> Self
Collect the slots of a typed gemini_adk_rs::frame::Frame in this
stage. The frame’s slot state-keys drive the captured completion; its
metadata (prompts/confirm/pii) is available via F::frame() for
confirmation and repair.
Sourcepub fn complete_when(self, guard: Guard) -> Self
pub fn complete_when(self, guard: Guard) -> Self
Set an explicit completion guard for this stage: the stage counts as
complete when guard holds (default: all collected slots captured).
Sourcepub fn commit(self, tool: impl Into<String>, when: Guard) -> Self
pub fn commit(self, tool: impl Into<String>, when: Guard) -> Self
Commit a confirm-before-act tool in this stage, gated by when.
Sourcepub fn next(self, to: impl Into<String>, when: Guard) -> Self
pub fn next(self, to: impl Into<String>, when: Guard) -> Self
Add a forward transition to to when when holds.
Sourcepub fn resolve_slot<I, S, F, Fut>(
self,
name: impl Into<String>,
args: I,
ttl: Option<Duration>,
fetch: F,
) -> Self
pub fn resolve_slot<I, S, F, Fut>( self, name: impl Into<String>, args: I, ttl: Option<Duration>, fetch: F, ) -> Self
Fill a slot in the current stage from an async resolver — a tool call,
HTTP fetch, MCP request, or agent. args names the State keys bound into
the JSON object passed to fetch; the returned value fills name. With a
ttl, results are memoized by (field, canonical args).
The slot is added to the stage’s collect, so its captured completion
waits for the resolution. The closure lives only in the builder; the
serializable spec is unaffected.
Sourcepub fn after(self, dep: impl Into<String>) -> Self
pub fn after(self, dep: impl Into<String>) -> Self
Add an explicit dependency on another stage.
Sourcepub fn repair(self, policy: RepairPolicy) -> Self
pub fn repair(self, policy: RepairPolicy) -> Self
Attach a RepairPolicy to the current stage.
Sourcepub fn require<I, S>(self, steps: I) -> Self
pub fn require<I, S>(self, steps: I) -> Self
Require these stages for completion (lowers to a Flow require). Targets
the active overlay when authoring one, else the main flow.
Sourcepub fn spec(&self) -> &ConversationSpec
pub fn spec(&self) -> &ConversationSpec
The spec built so far.
Sourcepub fn into_spec(self) -> ConversationSpec
pub fn into_spec(self) -> ConversationSpec
Consume into the underlying spec.
Sourcepub fn from_spec(
spec: ConversationSpec,
) -> Result<CompiledConversation, ConversationError>
pub fn from_spec( spec: ConversationSpec, ) -> Result<CompiledConversation, ConversationError>
Compile from a ConversationSpec (e.g. parsed from JSON/YAML).
If the spec declares any named-resolver slots (stage.resolve), this
errors — those slots would be collected but never filled. Use
Conversation::from_spec_with_resolvers to bind them.
Sourcepub fn from_spec_stubbing_resolvers(
spec: ConversationSpec,
) -> Result<CompiledConversation, ConversationError>
pub fn from_spec_stubbing_resolvers( spec: ConversationSpec, ) -> Result<CompiledConversation, ConversationError>
Compile a ConversationSpec with its declared resolvers stubbed
(each returns JSON null) — for structural validation, model-free
simulation, and CI, where resolver outputs are supplied by scenario
set steps rather than live fetches.
Use this (not from_spec) when compiling a spec from
untrusted JSON for testing/authoring; use
from_spec_with_resolvers at deploy
time to bind real implementations.
Sourcepub fn from_spec_with_resolvers(
spec: ConversationSpec,
registry: &ResolverRegistry,
) -> Result<CompiledConversation, ConversationError>
pub fn from_spec_with_resolvers( spec: ConversationSpec, registry: &ResolverRegistry, ) -> Result<CompiledConversation, ConversationError>
Compile a ConversationSpec and bind its declared named-resolver slots
from registry. This makes a JSON spec + a resolver registry a complete
deployable unit.
Errors if the spec references a resolver name absent from registry.
Sourcepub fn compile(self) -> Result<CompiledConversation, ConversationError>
pub fn compile(self) -> Result<CompiledConversation, ConversationError>
Lower and validate into a CompiledConversation.
Trait Implementations§
Source§impl Clone for Conversation
impl Clone for Conversation
Source§fn clone(&self) -> Conversation
fn clone(&self) -> Conversation
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for Conversation
impl Default for Conversation
Source§fn default() -> Conversation
fn default() -> Conversation
Auto Trait Implementations§
impl Freeze for Conversation
impl !RefUnwindSafe for Conversation
impl Send for Conversation
impl Sync for Conversation
impl Unpin for Conversation
impl !UnwindSafe for Conversation
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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].