ワンクリックで
chains
All Chain types — LLMChain, ConversationalChain, SequentialChain, StuffDocuments, ConversationalRetrievalQA, SqlDatabaseChain.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
All Chain types — LLMChain, ConversationalChain, SequentialChain, StuffDocuments, ConversationalRetrievalQA, SqlDatabaseChain.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
AgentExecutor, ChatAgent (ReAct), OpenAIToolsAgent, and the Agent trait.
JOB-251 — Why Arc<dyn LLM> over LLMClone, migration pattern, and correct LLM ownership model.
Trait conformance tests, property-based tests (proptest), fuzz targets, and boundary contracts for langchainx traits.
Core langchainx patterns — LLMChain, builder pattern, Chain trait, prompt macros, and basic invocation.
Constructing LLM backends (OpenAI, Claude, DeepSeek, Qwen, Ollama) and configuring CallOptions.
JOB-256 — blanket From impl, removing redundant Into impls, RwLock vs Mutex for memory.
| name | chains |
| description | All Chain types — LLMChain, ConversationalChain, SequentialChain, StuffDocuments, ConversationalRetrievalQA, SqlDatabaseChain. |
| Chain | Builder | Requires |
|---|---|---|
LLMChain | LLMChainBuilder | prompt, llm |
ConversationalChain | ConversationalChainBuilder | llm (memory optional, defaults to SimpleMemory) |
SequentialChain | SequentialChainBuilder | chains vec, input/output key mapping |
StuffDocumentsChain | StuffDocumentBuilder | llm (or a prompt) |
ConversationalRetrieverChain | ConversationalRetrieverChainBuilder | llm, retriever |
SqlDatabaseChain | SqlDatabaseChainBuilder | llm, datasource |
use langchainx::{
chain::{Chain, ConversationalChainBuilder},
llm::openai::OpenAI,
memory::SimpleMemory,
prompt_args,
};
let chain = ConversationalChainBuilder::new()
.llm(OpenAI::default())
.memory(SimpleMemory::new().into()) // Arc<Mutex<dyn BaseMemory>>
.build()?;
// Turn 1
chain.invoke(prompt_args! { "input" => "My name is Alice" }).await?;
// Turn 2 — chain remembers history
let reply = chain.invoke(prompt_args! { "input" => "What is my name?" }).await?;
The default input key is "input". History is stored under "history" in the prompt.
use langchainx::chain::{SequentialChainBuilder, Chain};
let chain = SequentialChainBuilder::new()
.add_chain(chain1) // Box<dyn Chain>
.add_chain(chain2)
.build()?;
// Output of chain1 is automatically piped as input to chain2
// using the output_key of chain1 as an input key for chain2
## StuffDocumentsChain
Stuffs retrieved documents into the prompt context.
use langchainx::chain::StuffDocumentBuilder;
let chain = StuffDocumentBuilder::new()
.llm(OpenAI::default())
.build()?;
Used internally by ConversationalRetrieverChain and question_answering::load_qa_with_sources_chain.
use langchainx::{
chain::{Chain, ConversationalRetrieverChainBuilder},
llm::openai::OpenAI,
memory::SimpleMemory,
vectorstore::Retriever,
prompt_args,
};
let retriever = Retriever::new(vector_store, 5);
let chain = ConversationalRetrieverChainBuilder::new()
.llm(OpenAI::default())
.retriever(retriever)
.memory(SimpleMemory::new().into())
.build()?;
let answer = chain.invoke(prompt_args! {
"input" => "What does the document say about X?"
}).await?;
## Streaming
use futures::StreamExt;
let mut stream = chain.stream(prompt_args! { "input" => "Tell me a story" }).await?;
while let Some(chunk) = stream.next().await {
match chunk {
Ok(data) => print!("{}", data.content),
Err(e) => eprintln!("stream error: {e}"),
}
}
Note: chains with memory do NOT automatically save memory when using stream() — only
call() and invoke() save to memory.