pub struct WorkflowNode {
pub config: NodeConfig,
/* private fields */
}Expand description
工作流节点
Fields§
§config: NodeConfig节点配置
Implementations§
Source§impl WorkflowNode
impl WorkflowNode
Sourcepub fn start(id: &str) -> WorkflowNode
pub fn start(id: &str) -> WorkflowNode
创建开始节点
Sourcepub fn end(id: &str) -> WorkflowNode
pub fn end(id: &str) -> WorkflowNode
创建结束节点
Sourcepub fn task<F, Fut>(id: &str, name: &str, executor: F) -> WorkflowNodewhere
F: Fn(WorkflowContext, WorkflowValue) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<WorkflowValue, String>> + Send + 'static,
pub fn task<F, Fut>(id: &str, name: &str, executor: F) -> WorkflowNodewhere
F: Fn(WorkflowContext, WorkflowValue) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<WorkflowValue, String>> + Send + 'static,
创建任务节点
Sourcepub fn agent<F, Fut>(id: &str, name: &str, agent_executor: F) -> WorkflowNodewhere
F: Fn(WorkflowContext, WorkflowValue) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<WorkflowValue, String>> + Send + 'static,
pub fn agent<F, Fut>(id: &str, name: &str, agent_executor: F) -> WorkflowNodewhere
F: Fn(WorkflowContext, WorkflowValue) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<WorkflowValue, String>> + Send + 'static,
创建智能体节点
Sourcepub fn condition<F, Fut>(id: &str, name: &str, condition_fn: F) -> WorkflowNodewhere
F: Fn(WorkflowContext, WorkflowValue) -> Fut + Send + Sync + 'static,
Fut: Future<Output = bool> + Send + 'static,
pub fn condition<F, Fut>(id: &str, name: &str, condition_fn: F) -> WorkflowNodewhere
F: Fn(WorkflowContext, WorkflowValue) -> Fut + Send + Sync + 'static,
Fut: Future<Output = bool> + Send + 'static,
创建条件节点
Sourcepub fn join_with_transform<F, Fut>(
id: &str,
name: &str,
wait_for: Vec<&str>,
transform: F,
) -> WorkflowNodewhere
F: Fn(HashMap<String, WorkflowValue>) -> Fut + Send + Sync + 'static,
Fut: Future<Output = WorkflowValue> + Send + 'static,
pub fn join_with_transform<F, Fut>(
id: &str,
name: &str,
wait_for: Vec<&str>,
transform: F,
) -> WorkflowNodewhere
F: Fn(HashMap<String, WorkflowValue>) -> Fut + Send + Sync + 'static,
Fut: Future<Output = WorkflowValue> + Send + 'static,
创建聚合节点(带转换函数)
Sourcepub fn loop_node<F, Fut, C, CFut>(
id: &str,
name: &str,
body: F,
condition: C,
max_iterations: u32,
) -> WorkflowNodewhere
F: Fn(WorkflowContext, WorkflowValue) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<WorkflowValue, String>> + Send + 'static,
C: Fn(WorkflowContext, WorkflowValue) -> CFut + Send + Sync + 'static,
CFut: Future<Output = bool> + Send + 'static,
pub fn loop_node<F, Fut, C, CFut>(
id: &str,
name: &str,
body: F,
condition: C,
max_iterations: u32,
) -> WorkflowNodewhere
F: Fn(WorkflowContext, WorkflowValue) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<WorkflowValue, String>> + Send + 'static,
C: Fn(WorkflowContext, WorkflowValue) -> CFut + Send + Sync + 'static,
CFut: Future<Output = bool> + Send + 'static,
创建循环节点
Sourcepub fn sub_workflow(id: &str, name: &str, sub_workflow_id: &str) -> WorkflowNode
pub fn sub_workflow(id: &str, name: &str, sub_workflow_id: &str) -> WorkflowNode
创建子工作流节点
Sourcepub fn transform<F, Fut>(id: &str, name: &str, transform_fn: F) -> WorkflowNodewhere
F: Fn(HashMap<String, WorkflowValue>) -> Fut + Send + Sync + 'static,
Fut: Future<Output = WorkflowValue> + Send + 'static,
pub fn transform<F, Fut>(id: &str, name: &str, transform_fn: F) -> WorkflowNodewhere
F: Fn(HashMap<String, WorkflowValue>) -> Fut + Send + Sync + 'static,
Fut: Future<Output = WorkflowValue> + Send + 'static,
创建数据转换节点
Sourcepub fn llm_agent(id: &str, name: &str, agent: Arc<LLMAgent>) -> WorkflowNode
pub fn llm_agent(id: &str, name: &str, agent: Arc<LLMAgent>) -> WorkflowNode
创建 LLM 智能体节点(使用 LLMAgentBuilder)
这个方法接受 LLMAgentBuilder,构建 LLMAgent 并创建节点。 Agent 将被包装在闭包中以便在工作流中执行。
Sourcepub fn llm_agent_with_template(
id: &str,
name: &str,
agent: Arc<LLMAgent>,
prompt_template: String,
) -> WorkflowNode
pub fn llm_agent_with_template( id: &str, name: &str, agent: Arc<LLMAgent>, prompt_template: String, ) -> WorkflowNode
创建 LLM 智能体节点(使用自定义 prompt 模板)
允许使用 Jinja-style 模板格式化输入,例如:
Process this data: {{ input }}Sourcepub fn with_description(self, desc: &str) -> WorkflowNode
pub fn with_description(self, desc: &str) -> WorkflowNode
设置描述
Sourcepub fn with_retry(self, policy: RetryPolicy) -> WorkflowNode
pub fn with_retry(self, policy: RetryPolicy) -> WorkflowNode
设置重试策略
Sourcepub fn with_timeout(self, timeout_ms: u64) -> WorkflowNode
pub fn with_timeout(self, timeout_ms: u64) -> WorkflowNode
设置超时
Sourcepub fn with_branch(
self,
condition_name: &str,
target_node_id: &str,
) -> WorkflowNode
pub fn with_branch( self, condition_name: &str, target_node_id: &str, ) -> WorkflowNode
添加条件分支
Sourcepub fn parallel_branches(&self) -> &[String]
pub fn parallel_branches(&self) -> &[String]
获取并行分支
Sourcepub fn join_nodes(&self) -> &[String]
pub fn join_nodes(&self) -> &[String]
获取聚合等待节点
Sourcepub fn condition_branches(&self) -> &HashMap<String, String>
pub fn condition_branches(&self) -> &HashMap<String, String>
获取条件分支
Sourcepub fn sub_workflow_id(&self) -> Option<&str>
pub fn sub_workflow_id(&self) -> Option<&str>
获取子工作流 ID
Sourcepub fn wait_event_type(&self) -> Option<&str>
pub fn wait_event_type(&self) -> Option<&str>
获取等待事件类型
Sourcepub async fn execute(
&self,
ctx: &WorkflowContext,
input: WorkflowValue,
) -> NodeResult
pub async fn execute( &self, ctx: &WorkflowContext, input: WorkflowValue, ) -> NodeResult
执行节点
Auto Trait Implementations§
impl Freeze for WorkflowNode
impl !RefUnwindSafe for WorkflowNode
impl Send for WorkflowNode
impl Sync for WorkflowNode
impl Unpin for WorkflowNode
impl UnsafeUnpin for WorkflowNode
impl !UnwindSafe for WorkflowNode
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