Skip to main content

Runnable

Trait Runnable 

Source
pub trait Runnable<I, O>: Send + Sync
where I: Send + 'static, O: Send + 'static,
{ // Required method fn invoke<'life0, 'async_trait>( &'life0 self, input: I, config: RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<O, CognisError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: 'async_trait; // Provided methods fn batch<'life0, 'async_trait>( &'life0 self, inputs: Vec<I>, config: RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<Vec<O>, CognisError>> + Send + 'async_trait>> where 'life0: 'async_trait, I: 'static, O: 'static, Self: Sized + Sync + 'async_trait { ... } fn stream<'life0, 'async_trait>( &'life0 self, input: I, config: RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<RunnableStream<O>, CognisError>> + Send + 'async_trait>> where 'life0: 'async_trait, Self: Sized + Sync + 'async_trait { ... } fn stream_events<'life0, 'async_trait>( &'life0 self, input: I, config: RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<EventStream, CognisError>> + Send + 'async_trait>> where 'life0: 'async_trait, I: Serialize, O: Serialize, Self: Sized + Sync + 'async_trait { ... } fn name(&self) -> &str { ... } fn input_schema(&self) -> Option<Value> { ... } fn output_schema(&self) -> Option<Value> { ... } }
Expand description

The unified contract every cognis primitive implements.

Generic over I (input) and O (output). One required method (invoke); batch, stream, and stream_events have sensible defaults that implementations override only when they can do better.

Required Methods§

Source

fn invoke<'life0, 'async_trait>( &'life0 self, input: I, config: RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<O, CognisError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

One-shot invocation. The hot path.

Provided Methods§

Source

fn batch<'life0, 'async_trait>( &'life0 self, inputs: Vec<I>, config: RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<Vec<O>, CognisError>> + Send + 'async_trait>>
where 'life0: 'async_trait, I: 'static, O: 'static, Self: Sized + Sync + 'async_trait,

Run multiple inputs in parallel. Defaults to buffer_unordered honouring config.max_concurrency.

Source

fn stream<'life0, 'async_trait>( &'life0 self, input: I, config: RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<RunnableStream<O>, CognisError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: Sized + Sync + 'async_trait,

Stream the final output (chunks of O). Default emits one item via invoke — non-streaming runnables are correct without override.

Source

fn stream_events<'life0, 'async_trait>( &'life0 self, input: I, config: RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<EventStream, CognisError>> + Send + 'async_trait>>
where 'life0: 'async_trait, I: Serialize, O: Serialize, Self: Sized + Sync + 'async_trait,

Stream structured events. Default emits OnStart + OnEnd around an invoke call. Graph engines override to surface per-node events.

Source

fn name(&self) -> &str

Friendly name for telemetry / introspection.

Source

fn input_schema(&self) -> Option<Value>

JSON Schema for the input type, if known.

Source

fn output_schema(&self) -> Option<Value>

JSON Schema for the output type, if known.

Implementations on Foreign Types§

Source§

impl Runnable<String, Vec<Document>> for BM25Retriever

Source§

fn invoke<'life0, 'async_trait>( &'life0 self, query: String, __arg2: RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, CognisError>> + Send + 'async_trait>>
where 'life0: 'async_trait, BM25Retriever: 'async_trait,

Source§

fn name(&self) -> &str

Source§

impl Runnable<String, Vec<Document>> for EnsembleRetriever

Source§

fn invoke<'life0, 'async_trait>( &'life0 self, query: String, config: RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, CognisError>> + Send + 'async_trait>>
where 'life0: 'async_trait, EnsembleRetriever: 'async_trait,

Source§

fn name(&self) -> &str

Source§

impl Runnable<String, Vec<Document>> for VectorRetriever

Source§

fn invoke<'life0, 'async_trait>( &'life0 self, query: String, __arg2: RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, CognisError>> + Send + 'async_trait>>
where 'life0: 'async_trait, VectorRetriever: 'async_trait,

Source§

fn name(&self) -> &str

Source§

impl Runnable<Vec<Document>, Vec<Document>> for Dedup

Source§

fn invoke<'life0, 'async_trait>( &'life0 self, input: Vec<Document>, __arg2: RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, CognisError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Dedup: 'async_trait,

Source§

fn name(&self) -> &str

Source§

impl Runnable<Vec<Document>, Vec<Document>> for Enrichment

Source§

fn invoke<'life0, 'async_trait>( &'life0 self, input: Vec<Document>, __arg2: RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, CognisError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Enrichment: 'async_trait,

Source§

fn name(&self) -> &str

Source§

impl Runnable<Vec<Document>, Vec<Document>> for MetadataTransformer

Source§

fn invoke<'life0, 'async_trait>( &'life0 self, input: Vec<Document>, __arg2: RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<Vec<Document>, CognisError>> + Send + 'async_trait>>
where 'life0: 'async_trait, MetadataTransformer: 'async_trait,

Source§

fn name(&self) -> &str

Source§

impl<T> Runnable<Vec<Message>, T> for StructuredClient<T>
where T: JsonSchema + DeserializeOwned + Send + 'static,

Source§

fn invoke<'life0, 'async_trait>( &'life0 self, input: Vec<Message>, __arg2: RunnableConfig, ) -> Pin<Box<dyn Future<Output = Result<T, CognisError>> + Send + 'async_trait>>
where 'life0: 'async_trait, StructuredClient<T>: 'async_trait,

Source§

fn name(&self) -> &str

Implementors§

Source§

impl Runnable<FactExtractionInput, Vec<Fact>> for FactExtractor

Source§

impl Runnable<String, bool> for BooleanParser

Source§

impl Runnable<String, WorkflowState> for Workflow

Source§

impl Runnable<String, String> for StringParser

Source§

impl Runnable<String, Vec<String>> for CommaListParser

Source§

impl Runnable<String, Vec<String>> for NumberedListParser

Source§

impl Runnable<String, Vec<Document>> for ContextualCompressionRetriever

Source§

impl Runnable<String, Vec<Document>> for MultiQueryRetriever

Source§

impl Runnable<String, Vec<Document>> for RerankingRetriever

Source§

impl Runnable<String, Vec<Document>> for SelfQueryRetriever

Source§

impl Runnable<String, Vec<Document>> for TimeWeightedRetriever

Source§

impl Runnable<String, Vec<Document>> for CachingRetriever

Source§

impl Runnable<String, Vec<Document>> for CrossEncoderReranker

Source§

impl Runnable<String, Vec<Document>> for MultiVectorRetriever

Source§

impl Runnable<String, Vec<Document>> for ParentDocumentRetriever

Source§

impl Runnable<String, Vec<Document>> for QueryTranslatorRetriever

Source§

impl Runnable<String, HashMap<String, String>> for XmlParser

Source§

impl Runnable<Vec<Message>, Message> for Client

Source§

impl Runnable<Vec<Document>, Vec<Document>> for CompressorPipeline

Source§

impl Runnable<Vec<Document>, Vec<Document>> for LongContextReorder

Source§

impl<A, B, I, M, O> Runnable<I, O> for Pipe<A, B, I, M, O>
where A: Runnable<I, M>, B: Runnable<M, O>, I: Send + 'static, M: Send + 'static, O: Send + 'static,

Source§

impl<I> Runnable<I, String> for PromptTemplate<I>
where I: Serialize + Send + Sync + 'static,

Source§

impl<I> Runnable<I, Vec<Message>> for ChatPromptTemplate<I>
where I: Serialize + Send + Sync + 'static,

Source§

impl<I> Runnable<I, I> for Passthrough
where I: Send + 'static,

Source§

impl<I, E> Runnable<I, String> for FewShotTemplate<I, E>
where I: Serialize + Send + Sync + 'static, E: Serialize + Send + Sync + Clone + 'static,

Source§

impl<I, O> Runnable<I, HashMap<String, O>> for Parallel<I, O>
where I: Send + Sync + Clone + 'static, O: Send + 'static,

Source§

impl<I, O> Runnable<I, AssignOutput<I, O>> for Assign<I, O>
where I: Send + Sync + Clone + 'static, O: Send + 'static,

Source§

impl<I, O> Runnable<I, O> for Branch<I, O>
where I: Send + 'static, O: Send + 'static,

Source§

impl<I, O> Runnable<I, O> for Lambda<I, O>
where I: Send + 'static, O: Send + 'static,

Source§

impl<I, O> Runnable<I, O> for Configurable<I, O>
where I: Send + 'static, O: Send + 'static,

Source§

impl<O> Runnable<String, O> for LlmExtractor<O>
where O: DeserializeOwned + JsonSchema + Send + 'static,

Source§

impl<P, F, I, O> Runnable<I, O> for Fallback<P, F, I, O>
where P: Runnable<I, O>, F: Runnable<I, O>, I: Clone + Send + 'static, O: Send + 'static,

Source§

impl<R> Runnable<Vec<Message>, Message> for RunnableWithMessageHistory<R>

Source§

impl<R, I, O> Runnable<Vec<I>, Vec<O>> for Each<R, I, O>
where R: Runnable<I, O>, I: Send + 'static, O: Send + 'static,

Source§

impl<R, I, O> Runnable<I, O> for Bind<R, I, O>
where R: Runnable<I, O>, I: Send + 'static, O: Send + 'static,

Source§

impl<R, I, O> Runnable<I, O> for WithListeners<R, I, O>
where R: Runnable<I, O>, I: Clone + Send + Sync + 'static, O: Send + Sync + 'static,

Source§

impl<R, I, O> Runnable<I, O> for WithMiddleware<R, I, O>
where R: Runnable<I, O>, I: Send + 'static, O: Send + 'static,

Source§

impl<R, I, O> Runnable<I, O> for Retry<R, I, O>
where R: Runnable<I, O>, I: Clone + Send + 'static, O: Send + 'static,

Source§

impl<R, I, O> Runnable<I, O> for WithSchema<R, I, O>
where R: Runnable<I, O>, I: Send + 'static, O: Send + 'static,

Source§

impl<R, I, O> Runnable<I, O> for Timeout<R, I, O>
where R: Runnable<I, O>, I: Send + 'static, O: Send + 'static,

Source§

impl<R, I, O, K, B> Runnable<I, O> for Cache<R, I, O, K, B>
where R: Runnable<I, O>, I: Send + 'static, O: Clone + Send + Sync + 'static, K: Send + Sync + 'static, B: CacheBackend<K, O> + 'static,

Source§

impl<S> Runnable<S, S> for CompiledGraph<S>
where S: GraphState + Clone + Send + 'static, <S as GraphState>::Update: Clone,

Source§

impl<T> Runnable<String, T> for JsonParser<T>
where T: DeserializeOwned + Send + 'static,

Source§

impl<T> Runnable<String, T> for StructuredOutputParser<T>
where T: DeserializeOwned + JsonSchema + Send + 'static,

Source§

impl<T, P> Runnable<String, T> for OutputFixingParser<T, P>
where T: Send + 'static, P: OutputParser<T> + Send + Sync,

Source§

impl<T, P> Runnable<String, T> for RetryParser<T, P>
where T: Send + 'static, P: OutputParser<T> + Send + Sync,