lc_core/runnables/mod.rs
1// src/core/runnables/mod.rs
2//! Runnable module - LangChain Expression Language (LCEL) core
3//!
4//! The Runnable trait is the foundation of LangChain's composability.
5//! Every component (LLM, Prompt, Tool, etc.) implements Runnable,
6//! enabling them to be chained together seamlessly.
7//!
8//! # LCEL Composition
9//!
10//! Use `pipe()` to chain runnables:
11//!
12//! ```rust,ignore
13//! let chain = prompt.pipe(llm).pipe(parser);
14//! let result = chain.invoke("What is Rust?".to_string(), None).await?;
15//! ```
16//!
17//! # Core Types
18//!
19//! - `Runnable<I, O>`: Base execution trait
20//! - `RunnableExt`: Extension providing `pipe()` composition
21//! - `RunnableSequence<I, O>`: Pipeline of chained runnables
22//! - `RunnableLambda<I, O>`: Closure wrapper
23//! - `RunnablePassthrough<I>`: Identity pass-through
24//! - `RunnableParallel<I>`: Fan-out/fan-in
25//! - `RunnableBranch<I, O>`: Conditional routing
26//! - `RunnableBinding<I, O>`: Config/kwargs binding
27//! - `LcelError`: Unified error type for pipelines
28
29mod any;
30mod assign;
31mod binding;
32mod branch;
33mod cancellation;
34mod config;
35mod error;
36mod ext;
37mod fallback;
38mod lambda;
39mod parallel;
40mod passthrough;
41mod runnable_trait;
42mod sequence;
43
44mod configurable;
45mod pick;
46mod retry;
47
48pub use any::{into_runnable_any, RunnableAny, RunnableAnyWrapper};
49pub use assign::RunnableAssign;
50pub use binding::RunnableBinding;
51pub use branch::RunnableBranch;
52pub use cancellation::CancellationToken;
53pub use config::{run_tree_from_config, RunnableConfig, RUN_META_PARENT_RUN_ID, RUN_META_TRACE_ID};
54pub use configurable::{RunnableConfigurable, RunnableConfigurableFields};
55pub use error::LcelError;
56pub use ext::RunnableExt;
57pub use fallback::RunnableWithFallbacks;
58pub use lambda::RunnableLambda;
59pub use parallel::RunnableParallel;
60pub use passthrough::RunnablePassthrough;
61pub use pick::RunnablePick;
62pub use retry::{RetryConfig, RetryOn, RunnableRetry};
63pub use runnable_trait::Runnable;
64pub use sequence::RunnableSequence;