ainvoke() — langchain Function Reference
Architecture documentation for the ainvoke() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 3d0312e3_a4c5_8ae3_1487_fac6e14b7ae4["ainvoke()"] f3cef70e_11b0_61c9_7ec0_7308f4b45056["Chain"] 3d0312e3_a4c5_8ae3_1487_fac6e14b7ae4 -->|defined in| f3cef70e_11b0_61c9_7ec0_7308f4b45056 db96fd56_b96b_a600_1f9e_fb81937f4570["acall()"] db96fd56_b96b_a600_1f9e_fb81937f4570 -->|calls| 3d0312e3_a4c5_8ae3_1487_fac6e14b7ae4 a668f6fe_95e7_c3c9_3e60_d9c0b67fe88c["aprep_inputs()"] 3d0312e3_a4c5_8ae3_1487_fac6e14b7ae4 -->|calls| a668f6fe_95e7_c3c9_3e60_d9c0b67fe88c 1fae3e72_380c_c210_1baa_d5fe1506cde1["_validate_inputs()"] 3d0312e3_a4c5_8ae3_1487_fac6e14b7ae4 -->|calls| 1fae3e72_380c_c210_1baa_d5fe1506cde1 2d831240_3b27_26e3_8258_1a3051c28410["_acall()"] 3d0312e3_a4c5_8ae3_1487_fac6e14b7ae4 -->|calls| 2d831240_3b27_26e3_8258_1a3051c28410 73fc6494_3cf5_d143_3c77_a2f6a40c55ed["aprep_outputs()"] 3d0312e3_a4c5_8ae3_1487_fac6e14b7ae4 -->|calls| 73fc6494_3cf5_d143_3c77_a2f6a40c55ed style 3d0312e3_a4c5_8ae3_1487_fac6e14b7ae4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/chains/base.py lines 187–238
async def ainvoke(
self,
input: dict[str, Any],
config: RunnableConfig | None = None,
**kwargs: Any,
) -> dict[str, Any]:
config = ensure_config(config)
callbacks = config.get("callbacks")
tags = config.get("tags")
metadata = config.get("metadata")
run_name = config.get("run_name") or self.get_name()
run_id = config.get("run_id")
include_run_info = kwargs.get("include_run_info", False)
return_only_outputs = kwargs.get("return_only_outputs", False)
inputs = await self.aprep_inputs(input)
callback_manager = AsyncCallbackManager.configure(
callbacks,
self.callbacks,
self.verbose,
tags,
self.tags,
metadata,
self.metadata,
)
new_arg_supported = inspect.signature(self._acall).parameters.get("run_manager")
run_manager = await callback_manager.on_chain_start(
None,
inputs,
run_id,
name=run_name,
)
try:
self._validate_inputs(inputs)
outputs = (
await self._acall(inputs, run_manager=run_manager)
if new_arg_supported
else await self._acall(inputs)
)
final_outputs: dict[str, Any] = await self.aprep_outputs(
inputs,
outputs,
return_only_outputs,
)
except BaseException as e:
await run_manager.on_chain_error(e)
raise
await run_manager.on_chain_end(outputs)
if include_run_info:
final_outputs[RUN_KEY] = RunInfo(run_id=run_manager.run_id)
return final_outputs
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does ainvoke() do?
ainvoke() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/base.py.
Where is ainvoke() defined?
ainvoke() is defined in libs/langchain/langchain_classic/chains/base.py at line 187.
What does ainvoke() call?
ainvoke() calls 4 function(s): _acall, _validate_inputs, aprep_inputs, aprep_outputs.
What calls ainvoke()?
ainvoke() is called by 1 function(s): acall.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free