Home / Function/ from_llm() — langchain Function Reference

from_llm() — langchain Function Reference

Architecture documentation for the from_llm() function in retry.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  65b8d887_3dd4_9103_c7b2_1b8549b050cd["from_llm()"]
  760525b3_dbb5_ba3a_41f5_a11b5f2770f7["RetryWithErrorOutputParser"]
  65b8d887_3dd4_9103_c7b2_1b8549b050cd -->|defined in| 760525b3_dbb5_ba3a_41f5_a11b5f2770f7
  8084f39f_2d1c_341b_f9d7_505c3cd15722["from_llm()"]
  8084f39f_2d1c_341b_f9d7_505c3cd15722 -->|calls| 65b8d887_3dd4_9103_c7b2_1b8549b050cd
  8084f39f_2d1c_341b_f9d7_505c3cd15722["from_llm()"]
  65b8d887_3dd4_9103_c7b2_1b8549b050cd -->|calls| 8084f39f_2d1c_341b_f9d7_505c3cd15722
  style 65b8d887_3dd4_9103_c7b2_1b8549b050cd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/output_parsers/retry.py lines 212–231

    def from_llm(
        cls,
        llm: BaseLanguageModel,
        parser: BaseOutputParser[T],
        prompt: BasePromptTemplate = NAIVE_RETRY_WITH_ERROR_PROMPT,
        max_retries: int = 1,
    ) -> RetryWithErrorOutputParser[T]:
        """Create a RetryWithErrorOutputParser from an LLM.

        Args:
            llm: The LLM to use to retry the completion.
            parser: The parser to use to parse the output.
            prompt: The prompt to use to retry the completion.
            max_retries: The maximum number of times to retry the completion.

        Returns:
            A RetryWithErrorOutputParser.
        """
        chain = prompt | llm | StrOutputParser()
        return cls(parser=parser, retry_chain=chain, max_retries=max_retries)

Domain

Subdomains

Calls

Called By

Frequently Asked Questions

What does from_llm() do?
from_llm() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/output_parsers/retry.py.
Where is from_llm() defined?
from_llm() is defined in libs/langchain/langchain_classic/output_parsers/retry.py at line 212.
What does from_llm() call?
from_llm() calls 1 function(s): from_llm.
What calls from_llm()?
from_llm() is called by 1 function(s): from_llm.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free