pub struct FallbackTextAgent { /* private fields */ }Expand description
Tries each child agent in sequence. Returns the first successful result. If all fail, returns the last error.
Implementations§
Source§impl FallbackTextAgent
impl FallbackTextAgent
Sourcepub fn new(name: impl Into<String>, candidates: Vec<Arc<dyn TextAgent>>) -> Self
pub fn new(name: impl Into<String>, candidates: Vec<Arc<dyn TextAgent>>) -> Self
Create a new fallback agent that tries candidates in order.
Sourcepub fn with_middleware_chain(self, chain: MiddlewareChain) -> Self
pub fn with_middleware_chain(self, chain: MiddlewareChain) -> Self
Attach a middleware chain. AgentEvent::FallbackActivated is emitted
through it when a fallback branch (any candidate after the first) is
tried, so on_event observers (M::on_fallback) fire.
Trait Implementations§
Source§impl TextAgent for FallbackTextAgent
impl TextAgent for FallbackTextAgent
Source§fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
state: &'life1 State,
) -> Pin<Box<dyn Future<Output = Result<String, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
state: &'life1 State,
) -> Pin<Box<dyn Future<Output = Result<String, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute this agent. Reads/writes
state. Returns the final text output. Read moreSource§fn run_with<'life0, 'life1, 'async_trait>(
&'life0 self,
request: RunRequest,
state: &'life1 State,
) -> Pin<Box<dyn Future<Output = Result<RunResult, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn run_with<'life0, 'life1, 'async_trait>(
&'life0 self,
request: RunRequest,
state: &'life1 State,
) -> Pin<Box<dyn Future<Output = Result<RunResult, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Run one request and report everything it produced: the reply, the
turns to append to a conversation, token usage and tool calls. Read more
Source§fn run_stream<'a>(
&'a self,
request: RunRequest,
state: State,
) -> BoxStream<'a, Result<RunEvent, AgentError>>
fn run_stream<'a>( &'a self, request: RunRequest, state: State, ) -> BoxStream<'a, Result<RunEvent, AgentError>>
Run one request as a stream of
RunEvents: text as the model writes
it, each tool call and result, then RunEvent::Finished. Read moreSource§fn stream(
&self,
prompt: impl Into<String>,
) -> BoxStream<'_, Result<RunEvent, AgentError>>where
Self: Sized,
fn stream(
&self,
prompt: impl Into<String>,
) -> BoxStream<'_, Result<RunEvent, AgentError>>where
Self: Sized,
Stream the reply to one question, with no history and fresh state. Read more
Source§fn ask<'life0, 'async_trait>(
&'life0 self,
prompt: impl 'async_trait + Into<String> + Send,
) -> Pin<Box<dyn Future<Output = Result<String, AgentError>> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
'life0: 'async_trait,
fn ask<'life0, 'async_trait>(
&'life0 self,
prompt: impl 'async_trait + Into<String> + Send,
) -> Pin<Box<dyn Future<Output = Result<String, AgentError>> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
'life0: 'async_trait,
Ask one question, with no history and fresh state, and get the reply.
Source§fn ask_as<'life0, 'async_trait, T>(
&'life0 self,
prompt: impl 'async_trait + Into<String> + Send,
) -> Pin<Box<dyn Future<Output = Result<T, AgentError>> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
T: DeserializeOwned + JsonSchema + Send + 'async_trait,
'life0: 'async_trait,
fn ask_as<'life0, 'async_trait, T>(
&'life0 self,
prompt: impl 'async_trait + Into<String> + Send,
) -> Pin<Box<dyn Future<Output = Result<T, AgentError>> + Send + 'async_trait>>where
Self: Sized + 'async_trait,
T: DeserializeOwned + JsonSchema + Send + 'async_trait,
'life0: 'async_trait,
Ask one question and get the reply as a
T. Read moreAuto Trait Implementations§
impl Freeze for FallbackTextAgent
impl !RefUnwindSafe for FallbackTextAgent
impl Send for FallbackTextAgent
impl Sync for FallbackTextAgent
impl Unpin for FallbackTextAgent
impl !UnwindSafe for FallbackTextAgent
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<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>
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
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>,
Applies the layer to a service and wraps it in [
Layered].