Trait anchor_chain::node::Node

source ·
pub trait Node: Debug {
    type Input;
    type Output;

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

Represents a node that can process an input to produce an output.

The Node trait defines a generic processing operation with a specified input and output type. Implementors of this trait can be composed together to form a processing chain.

Required Associated Types§

source

type Input

The input type for the node.

source

type Output

The output type for the node.

Required Methods§

source

fn process<'life0, 'async_trait>( &'life0 self, input: Self::Input ) -> Pin<Box<dyn Future<Output = Result<Self::Output, AnchorChainError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Asynchronously processes the given input, returning the output. When chained together the output type of one node must match the input of the next node in the chain.

Implementors§

source§

impl Node for OpenAIEmbeddingModel

§

type Input = Vec<String>

§

type Output = Vec<Vec<f32>>

source§

impl<'a> Node for Prompt<'a>

Implements the Node trait for the Prompt struct.

§

type Input = HashMap<&'a str, &'a str>

§

type Output = String

source§

impl<C, N> Node for Link<C, N>
where C: Node + Send + Sync + Debug, C::Output: Send + 'static, C::Input: Send, N: Node<Input = C::Output> + Send + Sync + Debug, N::Output: Send,

§

type Input = <C as Node>::Input

§

type Output = <N as Node>::Output

source§

impl<I, O, C> Node for ParallelNode<I, O, C>
where I: Clone + Send + Sync + Debug, O: Send + Sync + Debug, C: Send + Sync + Debug,

§

type Input = I

§

type Output = C

source§

impl<I, O, L> Node for Chain<I, O, L>
where L: Node<Input = I, Output = O> + Send + Sync + Debug, I: Debug + Send + Sync, O: Debug + Send + Sync,

§

type Input = I

§

type Output = O

source§

impl<T> Node for OpenAIModel<T>
where T: Send + Sync + Debug + Into<Prompt> + Into<ChatCompletionRequestUserMessageContent>,

§

type Input = T

§

type Output = String

source§

impl<T> Node for OpenAIChatModel<T>
where T: Into<ChatCompletionRequestUserMessageContent> + Debug + Send + Sync,

§

type Input = T

§

type Output = String

source§

impl<T> Node for OpenAIInstructModel<T>
where T: Into<Prompt> + Debug + Send + Sync,

§

type Input = T

§

type Output = String

source§

impl<T> Node for Logger<T>
where T: Debug + Send + Sync,

§

type Input = T

§

type Output = T

source§

impl<T> Node for NoOpNode<T>
where T: Send + Sync + Debug,

§

type Input = T

§

type Output = T