pub struct ScriptedCompleter { /* private fields */ }Expand description
A programmable completion provider.
Each call pops the next scripted reply; when the script is exhausted the
completer echoes the request (prompt or textual content becomes the output
content, with a one-request usage record), which is what a plain
echo-completer test double needs. Every received request is recorded and
can be inspected with ScriptedCompleter::requests.
Implementations§
Source§impl ScriptedCompleter
impl ScriptedCompleter
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Creates a completer with the given model name and an empty script.
Sourcepub fn push_output(self, output: AgentOutput) -> Self
pub fn push_output(self, output: AgentOutput) -> Self
Queues a fixed output as the next reply.
Sourcepub fn push_error(self, message: impl Into<String>) -> Self
pub fn push_error(self, message: impl Into<String>) -> Self
Queues an error as the next reply.
Sourcepub fn push_with<F>(self, reply: F) -> Self
pub fn push_with<F>(self, reply: F) -> Self
Queues a closure that builds the next reply from the request.
Sourcepub fn into_arc(self) -> Arc<Self> ⓘ
pub fn into_arc(self) -> Arc<Self> ⓘ
Wraps the completer for Model::with_completer.
Sourcepub fn requests(&self) -> Vec<CompletionRequest>
pub fn requests(&self) -> Vec<CompletionRequest>
Returns clones of every request received so far, in call order.
Trait Implementations§
Source§impl CompletionFeaturesDyn for ScriptedCompleter
impl CompletionFeaturesDyn for ScriptedCompleter
Source§fn model_name(&self) -> String
fn model_name(&self) -> String
Returns the provider model name used for diagnostics and usage reports.
Source§fn completion(
&self,
req: CompletionRequest,
) -> BoxPinFut<Result<AgentOutput, BoxError>>
fn completion( &self, req: CompletionRequest, ) -> BoxPinFut<Result<AgentOutput, BoxError>>
Performs a completion request and returns the agent-facing output. Read more
Auto Trait Implementations§
impl !Freeze for ScriptedCompleter
impl !RefUnwindSafe for ScriptedCompleter
impl !UnwindSafe for ScriptedCompleter
impl Send for ScriptedCompleter
impl Sync for ScriptedCompleter
impl Unpin for ScriptedCompleter
impl UnsafeUnpin for ScriptedCompleter
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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> ⓘ
Converts
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> ⓘ
Converts
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