apply() — langchain Function Reference
Architecture documentation for the apply() function in llm.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD be1cf4da_b223_486d_abea_864bf732bbc6["apply()"] ccf50fe1_4990_cf19_1e2d_25efe83f53c5["LLMChain"] be1cf4da_b223_486d_abea_864bf732bbc6 -->|defined in| ccf50fe1_4990_cf19_1e2d_25efe83f53c5 f8ca5dfd_cddf_f131_0f5b_583f692271a4["apply_and_parse()"] f8ca5dfd_cddf_f131_0f5b_583f692271a4 -->|calls| be1cf4da_b223_486d_abea_864bf732bbc6 377cb47d_aeea_738a_00c1_527af33d920e["generate()"] be1cf4da_b223_486d_abea_864bf732bbc6 -->|calls| 377cb47d_aeea_738a_00c1_527af33d920e 18717271_ee47_6d4a_ccbd_dc7577e19985["create_outputs()"] be1cf4da_b223_486d_abea_864bf732bbc6 -->|calls| 18717271_ee47_6d4a_ccbd_dc7577e19985 style be1cf4da_b223_486d_abea_864bf732bbc6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/chains/llm.py lines 224–247
def apply(
self,
input_list: list[dict[str, Any]],
callbacks: Callbacks = None,
) -> list[dict[str, str]]:
"""Utilize the LLM generate method for speed gains."""
callback_manager = CallbackManager.configure(
callbacks,
self.callbacks,
self.verbose,
)
run_manager = callback_manager.on_chain_start(
None,
{"input_list": input_list},
name=self.get_name(),
)
try:
response = self.generate(input_list, run_manager=run_manager)
except BaseException as e:
run_manager.on_chain_error(e)
raise
outputs = self.create_outputs(response)
run_manager.on_chain_end({"outputs": outputs})
return outputs
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does apply() do?
apply() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/llm.py.
Where is apply() defined?
apply() is defined in libs/langchain/langchain_classic/chains/llm.py at line 224.
What does apply() call?
apply() calls 2 function(s): create_outputs, generate.
What calls apply()?
apply() is called by 1 function(s): apply_and_parse.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free