Skip to main content

TaskNode

Trait TaskNode 

Source
pub trait TaskNode:
    Send
    + Sync
    + DynClone
    + Any {
    type Input: NodeArg;
    type Output: NodeArg;
    type Error: Error + Send + Sync + 'static;

    // Required method
    fn evaluate<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        node_id: &'life1 DynNodeId<Self>,
        input: &'life2 Self::Input,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

A typed step in a Task.

Implement this trait for your own domain-specific nodes when you want full control over how a task step runs. For lightweight closure nodes, use Task::register_node_fn, or Task::register_node_async_fn for async closures.

Required Associated Types§

Source

type Input: NodeArg

The input accepted by this node.

Source

type Output: NodeArg

The output produced by this node.

Source

type Error: Error + Send + Sync + 'static

The error returned when evaluation fails.

Required Methods§

Source

fn evaluate<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, node_id: &'life1 DynNodeId<Self>, input: &'life2 Self::Input, ) -> Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Evaluates the node with the current input.

Trait Implementations§

Source§

impl<Input: NodeArg, Output: NodeArg, Error: Error + Send + Sync + 'static> TaskNode for Box<dyn TaskNode<Input = Input, Output = Output, Error = Error>>

Source§

type Input = Input

The input accepted by this node.
Source§

type Output = Output

The output produced by this node.
Source§

type Error = Error

The error returned when evaluation fails.
Source§

fn evaluate<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, node_id: &'life1 NodeId<dyn TaskNode<Input = Self::Input, Output = Self::Output, Error = Self::Error>>, input: &'life2 Self::Input, ) -> Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Evaluates the node with the current input.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl TaskNode for Arc<dyn ChatCompletion>

Source§

type Input = ChatCompletionRequest<'static>

Source§

type Output = ChatCompletionResponse

Source§

type Error = LanguageModelError

Source§

fn evaluate<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _node_id: &'life1 NodeId<dyn TaskNode<Input = Self::Input, Output = Self::Output, Error = Self::Error>>, input: &'life2 Self::Input, ) -> Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source§

impl TaskNode for Arc<dyn SimplePrompt>

Source§

type Input = Prompt

Source§

type Output = String

Source§

type Error = LanguageModelError

Source§

fn evaluate<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _node_id: &'life1 NodeId<dyn TaskNode<Input = Self::Input, Output = Self::Output, Error = Self::Error>>, input: &'life2 Self::Input, ) -> Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source§

impl TaskNode for Arc<dyn ToolExecutor>

Source§

type Input = Command

Source§

type Output = CommandOutput

Source§

type Error = CommandError

Source§

fn evaluate<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _node_id: &'life1 NodeId<dyn TaskNode<Input = Self::Input, Output = Self::Output, Error = Self::Error>>, input: &'life2 Self::Input, ) -> Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source§

impl TaskNode for Box<dyn ChatCompletion>

Source§

type Input = ChatCompletionRequest<'static>

Source§

type Output = ChatCompletionResponse

Source§

type Error = LanguageModelError

Source§

fn evaluate<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _node_id: &'life1 NodeId<dyn TaskNode<Input = Self::Input, Output = Self::Output, Error = Self::Error>>, input: &'life2 Self::Input, ) -> Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source§

impl TaskNode for Box<dyn SimplePrompt>

Source§

type Input = Prompt

Source§

type Output = String

Source§

type Error = LanguageModelError

Source§

fn evaluate<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _node_id: &'life1 NodeId<dyn TaskNode<Input = Self::Input, Output = Self::Output, Error = Self::Error>>, input: &'life2 Self::Input, ) -> Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source§

impl TaskNode for Box<dyn ToolExecutor>

Source§

type Input = Command

Source§

type Output = CommandOutput

Source§

type Error = CommandError

Source§

fn evaluate<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _node_id: &'life1 NodeId<dyn TaskNode<Input = Self::Input, Output = Self::Output, Error = Self::Error>>, input: &'life2 Self::Input, ) -> Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source§

impl<Input: NodeArg, Output: NodeArg, Error: Error + Send + Sync + 'static> TaskNode for Box<dyn TaskNode<Input = Input, Output = Output, Error = Error>>

Source§

type Input = Input

Source§

type Output = Output

Source§

type Error = Error

Source§

fn evaluate<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, node_id: &'life1 NodeId<dyn TaskNode<Input = Self::Input, Output = Self::Output, Error = Self::Error>>, input: &'life2 Self::Input, ) -> Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Implementors§

Source§

impl<F, I, O, E> TaskNode for AsyncFn<F, I, O, E>
where F: for<'a> Fn(&'a I) -> Pin<Box<dyn Future<Output = Result<O, E>> + Send + 'a>> + Clone + Send + Sync + 'static, I: NodeArg + Clone, O: NodeArg + Clone, E: Error + Send + Sync + 'static,

Source§

type Input = I

Source§

type Output = O

Source§

type Error = E

Source§

impl<F, I, O, E> TaskNode for SyncFn<F, I, O, E>
where F: Fn(&I) -> Result<O, E> + Clone + Send + Sync + 'static, I: NodeArg + Clone, O: NodeArg + Clone, E: Error + Send + Sync + 'static,

Source§

type Input = I

Source§

type Output = O

Source§

type Error = E