pub enum Composable {
Agent(AgentBuilder),
Pipeline(Pipeline),
FanOut(FanOut),
Loop(Loop),
Fallback(Fallback),
MapOver(MapOver),
}Expand description
A composable workflow node — can be sequenced, fan-out, looped, etc.
Variants§
Agent(AgentBuilder)
A single agent node.
Pipeline(Pipeline)
A sequential pipeline of steps.
FanOut(FanOut)
A parallel fan-out of branches.
Loop(Loop)
A loop with optional termination predicate.
Fallback(Fallback)
A fallback chain (try each until one succeeds).
MapOver(MapOver)
One agent applied to every item of a state list
(patterns::map_over).
Implementations§
Source§impl Composable
impl Composable
Sourcepub fn compile(
self,
llm: Arc<dyn BaseLlm>,
) -> Result<Arc<dyn TextAgent>, ConfigError>
pub fn compile( self, llm: Arc<dyn BaseLlm>, ) -> Result<Arc<dyn TextAgent>, ConfigError>
Compile this composable tree into an executable TextAgent.
Recursively compiles the tree: pipelines become SequentialTextAgent,
fan-outs become ParallelTextAgent, loops become LoopTextAgent,
fallbacks become FallbackTextAgent, map-overs become
MapOverTextAgent, and agents compile via AgentBuilder::build() —
whose ConfigError (an MCP toolset on a text agent) is the only way
this fails.
let pipeline = AgentBuilder::new("writer").instruction("Write a draft")
>> AgentBuilder::new("reviewer").instruction("Review and improve");
let agent = pipeline.compile(llm)?;
let state = State::new();
let result = agent.run(&state).await?;Source§impl Composable
impl Composable
Sourcepub fn middleware(self, middleware: impl Into<MiddlewareComposite>) -> Self
pub fn middleware(self, middleware: impl Into<MiddlewareComposite>) -> Self
Attach middleware to a Loop or Fallback node — the place where
combinator-level observers (M::on_loop, M::on_fallback) live.
For other node kinds (single agent, pipeline, fan-out, map-over) this
is a no-op: attach M:: middleware to the agent itself via
AgentBuilder::middleware instead.
Source§impl Composable
impl Composable
Sourcepub fn first_step(&self) -> Option<&Composable>
pub fn first_step(&self) -> Option<&Composable>
The first step of a Pipeline, or None if this is not a pipeline
(or the pipeline is empty).
Sourcepub fn last_step(&self) -> Option<&Composable>
pub fn last_step(&self) -> Option<&Composable>
The last step of a Pipeline, or None if this is not a pipeline
(or the pipeline is empty).
Sourcepub fn nth_step(&self, n: usize) -> Option<&Composable>
pub fn nth_step(&self, n: usize) -> Option<&Composable>
The nth step of a Pipeline, or None if this is not a pipeline
or the index is out of bounds.
Sourcepub fn pipeline_steps(&self) -> Option<&[Composable]>
pub fn pipeline_steps(&self) -> Option<&[Composable]>
All steps of a Pipeline, or None if this is not a pipeline.
Sourcepub fn fan_out_branches(&self) -> Option<&[Composable]>
pub fn fan_out_branches(&self) -> Option<&[Composable]>
The branches of a FanOut, or None if this is not a fan-out.
Sourcepub fn loop_predicate(&self) -> Option<&LoopPredicate>
pub fn loop_predicate(&self) -> Option<&LoopPredicate>
The termination predicate of a Loop, or None if this is not a loop
(or the loop has no predicate).
Sourcepub fn loop_body(&self) -> Option<&Composable>
pub fn loop_body(&self) -> Option<&Composable>
The body of a Loop, or None if this is not a loop.
Sourcepub fn fallback_candidates(&self) -> Option<&[Composable]>
pub fn fallback_candidates(&self) -> Option<&[Composable]>
The candidates of a Fallback chain, or None if this is not a fallback.
Trait Implementations§
Source§impl BitOr<AgentBuilder> for Composable
Composable | AgentBuilder → FanOut (flattening)
impl BitOr<AgentBuilder> for Composable
Composable | AgentBuilder → FanOut (flattening)
Source§type Output = Composable
type Output = Composable
| operator.Source§impl BitOr for Composable
Composable | Composable → FanOut (flattening)
impl BitOr for Composable
Composable | Composable → FanOut (flattening)
Source§type Output = Composable
type Output = Composable
| operator.Source§impl Clone for Composable
impl Clone for Composable
Source§fn clone(&self) -> Composable
fn clone(&self) -> Composable
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Composable
impl Debug for Composable
Source§impl Div<AgentBuilder> for Composable
Composable / AgentBuilder → Fallback (flattening)
impl Div<AgentBuilder> for Composable
Composable / AgentBuilder → Fallback (flattening)
Source§type Output = Composable
type Output = Composable
/ operator.Source§impl Div for Composable
Composable / Composable → Fallback (flattening)
impl Div for Composable
Composable / Composable → Fallback (flattening)
Source§type Output = Composable
type Output = Composable
/ operator.Source§impl From<AgentBuilder> for Composable
impl From<AgentBuilder> for Composable
Source§fn from(b: AgentBuilder) -> Self
fn from(b: AgentBuilder) -> Self
Source§impl From<Fallback> for Composable
impl From<Fallback> for Composable
Source§impl From<FanOut> for Composable
impl From<FanOut> for Composable
Source§impl From<Loop> for Composable
impl From<Loop> for Composable
Source§impl From<MapOver> for Composable
impl From<MapOver> for Composable
Source§impl From<Pipeline> for Composable
impl From<Pipeline> for Composable
Source§impl Mul<LoopPredicate> for Composable
Composable * until(pred) → conditional Loop
impl Mul<LoopPredicate> for Composable
Composable * until(pred) → conditional Loop
Source§type Output = Composable
type Output = Composable
* operator.Source§impl Mul<u32> for Composable
Composable * 3 → Loop(max=3)
impl Mul<u32> for Composable
Composable * 3 → Loop(max=3)
Source§impl Shr<AgentBuilder> for Composable
Composable >> AgentBuilder → Pipeline (flattening)
impl Shr<AgentBuilder> for Composable
Composable >> AgentBuilder → Pipeline (flattening)
Source§type Output = Composable
type Output = Composable
>> operator.Source§impl Shr<Composable> for AgentBuilder
AgentBuilder >> Composable → Pipeline (flattening)
impl Shr<Composable> for AgentBuilder
AgentBuilder >> Composable → Pipeline (flattening)
Source§type Output = Composable
type Output = Composable
>> operator.Source§impl Shr for Composable
Composable >> Composable → Pipeline (flattening)
impl Shr for Composable
Composable >> Composable → Pipeline (flattening)
Source§type Output = Composable
type Output = Composable
>> operator.Auto Trait Implementations§
impl Freeze for Composable
impl !RefUnwindSafe for Composable
impl Send for Composable
impl Sync for Composable
impl Unpin for Composable
impl !UnwindSafe for Composable
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].