pub struct AgentWorkflowBuilder { /* private fields */ }Expand description
Agent 工作流构建器
Implementations§
Source§impl AgentWorkflowBuilder
impl AgentWorkflowBuilder
Sourcepub fn new(id: impl Into<String>) -> AgentWorkflowBuilder
pub fn new(id: impl Into<String>) -> AgentWorkflowBuilder
创建新的构建器
Sourcepub fn with_name(self, name: impl Into<String>) -> AgentWorkflowBuilder
pub fn with_name(self, name: impl Into<String>) -> AgentWorkflowBuilder
设置名称
Sourcepub fn add_agent(
self,
id: impl Into<String>,
agent: Arc<LLMAgent>,
) -> AgentWorkflowBuilder
pub fn add_agent( self, id: impl Into<String>, agent: Arc<LLMAgent>, ) -> AgentWorkflowBuilder
添加 Agent 节点
Sourcepub fn add_agent_with_template(
self,
id: impl Into<String>,
agent: Arc<LLMAgent>,
template: impl Into<String>,
) -> AgentWorkflowBuilder
pub fn add_agent_with_template( self, id: impl Into<String>, agent: Arc<LLMAgent>, template: impl Into<String>, ) -> AgentWorkflowBuilder
添加带提示词模板的 Agent 节点
Sourcepub fn add_router<F, Fut>(
self,
id: impl Into<String>,
router_fn: F,
) -> AgentWorkflowBuilder
pub fn add_router<F, Fut>( self, id: impl Into<String>, router_fn: F, ) -> AgentWorkflowBuilder
添加路由节点
Sourcepub fn add_llm_router(
self,
id: impl Into<String>,
router_agent: Arc<LLMAgent>,
routes: Vec<String>,
) -> AgentWorkflowBuilder
pub fn add_llm_router( self, id: impl Into<String>, router_agent: Arc<LLMAgent>, routes: Vec<String>, ) -> AgentWorkflowBuilder
添加基于 LLM 的智能路由节点
Sourcepub fn add_transform<F, Fut>(
self,
id: impl Into<String>,
transform_fn: F,
) -> AgentWorkflowBuilderwhere
F: Fn(AgentValue) -> Fut + Send + Sync + 'static,
Fut: Future<Output = AgentValue> + Send + 'static,
pub fn add_transform<F, Fut>(
self,
id: impl Into<String>,
transform_fn: F,
) -> AgentWorkflowBuilderwhere
F: Fn(AgentValue) -> Fut + Send + Sync + 'static,
Fut: Future<Output = AgentValue> + Send + 'static,
添加转换节点
Sourcepub fn add_parallel(self, id: impl Into<String>) -> AgentWorkflowBuilder
pub fn add_parallel(self, id: impl Into<String>) -> AgentWorkflowBuilder
添加并行节点
Sourcepub fn add_join(
self,
id: impl Into<String>,
wait_for: Vec<&str>,
) -> AgentWorkflowBuilder
pub fn add_join( self, id: impl Into<String>, wait_for: Vec<&str>, ) -> AgentWorkflowBuilder
添加聚合节点
Sourcepub fn add_join_with<F, Fut>(
self,
id: impl Into<String>,
wait_for: Vec<&str>,
join_fn: F,
) -> AgentWorkflowBuilderwhere
F: Fn(HashMap<String, AgentValue>) -> Fut + Send + Sync + 'static,
Fut: Future<Output = AgentValue> + Send + 'static,
pub fn add_join_with<F, Fut>(
self,
id: impl Into<String>,
wait_for: Vec<&str>,
join_fn: F,
) -> AgentWorkflowBuilderwhere
F: Fn(HashMap<String, AgentValue>) -> Fut + Send + Sync + 'static,
Fut: Future<Output = AgentValue> + Send + 'static,
添加带自定义函数的聚合节点
Sourcepub fn connect(
self,
from: impl Into<String>,
to: impl Into<String>,
) -> AgentWorkflowBuilder
pub fn connect( self, from: impl Into<String>, to: impl Into<String>, ) -> AgentWorkflowBuilder
添加边
Sourcepub fn connect_on(
self,
from: impl Into<String>,
to: impl Into<String>,
condition: impl Into<String>,
) -> AgentWorkflowBuilder
pub fn connect_on( self, from: impl Into<String>, to: impl Into<String>, condition: impl Into<String>, ) -> AgentWorkflowBuilder
添加条件边
Sourcepub fn chain<S>(
self,
node_ids: impl IntoIterator<Item = S>,
) -> AgentWorkflowBuilder
pub fn chain<S>( self, node_ids: impl IntoIterator<Item = S>, ) -> AgentWorkflowBuilder
链式连接多个节点
自动将 start 连接到第一个节点,并将最后一个节点连接到 end
Sourcepub fn parallel_agents(
self,
parallel_id: impl Into<String>,
agent_ids: Vec<&str>,
join_id: impl Into<String>,
) -> AgentWorkflowBuilder
pub fn parallel_agents( self, parallel_id: impl Into<String>, agent_ids: Vec<&str>, join_id: impl Into<String>, ) -> AgentWorkflowBuilder
配置并行执行
从 parallel_node 分发到多个 Agent,然后在 join_node 聚合
Sourcepub fn build(self) -> AgentWorkflow
pub fn build(self) -> AgentWorkflow
构建工作流
Auto Trait Implementations§
impl Freeze for AgentWorkflowBuilder
impl !RefUnwindSafe for AgentWorkflowBuilder
impl Send for AgentWorkflowBuilder
impl Sync for AgentWorkflowBuilder
impl Unpin for AgentWorkflowBuilder
impl UnsafeUnpin for AgentWorkflowBuilder
impl !UnwindSafe for AgentWorkflowBuilder
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
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 moreSource§impl<T> Message for T
impl<T> Message for T
Source§fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
Convert a BoxedMessage to this concrete type
Source§fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
Convert this message to a BoxedMessage