_run_chain() — langchain Function Reference
Architecture documentation for the _run_chain() function in runner_utils.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 732636c1_f8cb_78e1_d81d_6611b0b6e364["_run_chain()"] 8253c602_7d0c_9195_a7e1_3e9b19304131["runner_utils.py"] 732636c1_f8cb_78e1_d81d_6611b0b6e364 -->|defined in| 8253c602_7d0c_9195_a7e1_3e9b19304131 385c1e91_d947_1192_8746_ee1dd66ceb54["_run_llm_or_chain()"] 385c1e91_d947_1192_8746_ee1dd66ceb54 -->|calls| 732636c1_f8cb_78e1_d81d_6611b0b6e364 style 732636c1_f8cb_78e1_d81d_6611b0b6e364 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/smith/evaluation/runner_utils.py lines 929–962
def _run_chain(
chain: Chain | Runnable,
inputs: dict[str, Any],
callbacks: Callbacks,
*,
tags: list[str] | None = None,
input_mapper: Callable[[dict], Any] | None = None,
metadata: dict[str, Any] | None = None,
) -> dict | str:
"""Run a chain on inputs."""
inputs_ = inputs if input_mapper is None else input_mapper(inputs)
if (
isinstance(chain, Chain)
and isinstance(inputs_, dict)
and len(inputs_) == 1
and chain.input_keys
):
val = next(iter(inputs_.values()))
output = chain.invoke(
val,
config=RunnableConfig(
callbacks=callbacks,
tags=tags or [],
metadata=metadata or {},
),
)
else:
runnable_config = RunnableConfig(
tags=tags or [],
callbacks=callbacks,
metadata=metadata or {},
)
output = chain.invoke(inputs_, config=runnable_config)
return output
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does _run_chain() do?
_run_chain() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/smith/evaluation/runner_utils.py.
Where is _run_chain() defined?
_run_chain() is defined in libs/langchain/langchain_classic/smith/evaluation/runner_utils.py at line 929.
What calls _run_chain()?
_run_chain() is called by 1 function(s): _run_llm_or_chain.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free