_arun_llm_or_chain() — langchain Function Reference
Architecture documentation for the _arun_llm_or_chain() function in runner_utils.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD f3487723_0da7_fd94_b3c8_cdac21cf7e23["_arun_llm_or_chain()"] 8253c602_7d0c_9195_a7e1_3e9b19304131["runner_utils.py"] f3487723_0da7_fd94_b3c8_cdac21cf7e23 -->|defined in| 8253c602_7d0c_9195_a7e1_3e9b19304131 5dad9d8a_ecf9_b785_9a01_d927f6bea73e["_arun_llm()"] f3487723_0da7_fd94_b3c8_cdac21cf7e23 -->|calls| 5dad9d8a_ecf9_b785_9a01_d927f6bea73e 9b0e22db_68ee_87da_3140_8fa034a95ee3["_arun_chain()"] f3487723_0da7_fd94_b3c8_cdac21cf7e23 -->|calls| 9b0e22db_68ee_87da_3140_8fa034a95ee3 style f3487723_0da7_fd94_b3c8_cdac21cf7e23 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/smith/evaluation/runner_utils.py lines 803–855
async def _arun_llm_or_chain(
example: Example,
config: RunnableConfig,
*,
llm_or_chain_factory: MCF,
input_mapper: Callable[[dict], Any] | None = None,
) -> dict | str | LLMResult | ChatResult:
"""Asynchronously run the Chain or language model.
Args:
example: The example to run.
config: The configuration for the run.
llm_or_chain_factory: The Chain or language model constructor to run.
input_mapper: Optional function to map the input to the expected format.
Returns:
A list of outputs.
"""
chain_or_llm = (
"LLM" if isinstance(llm_or_chain_factory, BaseLanguageModel) else "Chain"
)
result = None
try:
if isinstance(llm_or_chain_factory, BaseLanguageModel):
output: Any = await _arun_llm(
llm_or_chain_factory,
example.inputs or {},
tags=config["tags"],
callbacks=config["callbacks"],
input_mapper=input_mapper,
metadata=config.get("metadata"),
)
else:
chain = llm_or_chain_factory()
output = await _arun_chain(
chain,
example.inputs or {},
tags=config["tags"],
callbacks=config["callbacks"],
input_mapper=input_mapper,
metadata=config.get("metadata"),
)
result = output
except Exception as e: # noqa: BLE001
logger.warning(
"%s failed for example %s with inputs %s\n%s",
chain_or_llm,
example.id,
example.inputs,
e,
)
result = EvalError(Error=e)
return result
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does _arun_llm_or_chain() do?
_arun_llm_or_chain() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/smith/evaluation/runner_utils.py.
Where is _arun_llm_or_chain() defined?
_arun_llm_or_chain() is defined in libs/langchain/langchain_classic/smith/evaluation/runner_utils.py at line 803.
What does _arun_llm_or_chain() call?
_arun_llm_or_chain() calls 2 function(s): _arun_chain, _arun_llm.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free