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 instruction(self, text: impl Into<String>) -> Self
pub fn instruction(self, text: impl Into<String>) -> Self
Set the stage’s instruction: guidance projected to the model while the stage is active. It steers what the model says; it is not verbatim speech and carries no guarantee of exact wording.
Sourcepub fn say(self, text: impl Into<String>) -> Self
pub fn say(self, text: impl Into<String>) -> Self
Alias of instruction. The name suggests exact
speech, which this never was; prefer instruction in new code.
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 allow<I, S>(self, tools: I) -> Self
pub fn allow<I, S>(self, tools: I) -> Self
Allow the given tools while this stage is active.
Calls to other governed tools are refused. Under
SteeringMode::ContextUpdate
the model is also offered only the admitted tools while the stage is
active.
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 verbatim(self, text: impl Into<String>) -> Self
pub fn verbatim(self, text: impl Into<String>) -> Self
Require the current stage to say text word for word (strict canned
mode): it completes only once the model’s output transcript matches.
The model holds the floor while it reads, unless the stage sets
timing. Needs output transcription on the session.
Sourcepub fn timing(self, timing: VoiceTiming) -> Self
pub fn timing(self, timing: VoiceTiming) -> Self
Set the current stage’s voice pacing; see VoiceTiming.
use std::time::Duration;
Conversation::new("disclosure")
.stage("read_terms")
.say("Read the terms word for word.")
.timing(VoiceTiming::new().uninterruptible())
.stage("confirm")
.collect(["agreed"])
.timing(VoiceTiming::new().reprompt_after(Duration::from_secs(6)));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 (const: unstable) · 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 !RefUnwindSafe for Conversation
impl !UnwindSafe for Conversation
impl Freeze for Conversation
impl Send for Conversation
impl Sync for Conversation
impl Unpin for Conversation
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> CloneAny for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§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> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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].§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.