RunnableSequence composes runnable components into an ordered pipeline: each component receives the previous component’s output, and the final result becomes the sequence output. This makes multi-step LangChain workflows readable, composable, and directly invokable. section 6.5.1
A sequence coordinates several moving parts:
- Preserve data flow order: every step must produce the inputs expected by the next step. section 6.2.3
- Combine transformations, prompt templates, language models, and output parsers in one runnable workflow. section 6.1.1
- Use RunnablePassthrough when one input, such as the original question, must continue through the pipeline unchanged. section 6.2.3
- Choose RunnableSequence.from([...]) or chained .pipe() calls; both express sequential composition, with the choice mainly reflecting coding style. section 6.1.1
Retrieval-augmented question answering
Create a retriever from a vector store, format retrieved documents as text, and pass the original question through a RunnableSequence. The sequence then supplies context and question to a prompt, sends the result to a language model, and parses the response as a string. Invoke it with { question: "What is artificial intelligence?" }. section 6.2.3
