Home / Function/ from_llm() — langchain Function Reference

from_llm() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  90960e44_6e6f_df41_ac91_99daad26500f["from_llm()"]
  439c6891_48c2_0c9f_d11e_ed92b4354fa0["StructuredChatOutputParserWithRetries"]
  90960e44_6e6f_df41_ac91_99daad26500f -->|defined in| 439c6891_48c2_0c9f_d11e_ed92b4354fa0
  style 90960e44_6e6f_df41_ac91_99daad26500f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/agents/structured_chat/output_parser.py lines 85–108

    def from_llm(
        cls,
        llm: BaseLanguageModel | None = None,
        base_parser: StructuredChatOutputParser | None = None,
    ) -> StructuredChatOutputParserWithRetries:
        """Create a StructuredChatOutputParserWithRetries from a language model.

        Args:
            llm: The language model to use.
            base_parser: An optional StructuredChatOutputParser to use.

        Returns:
            An instance of StructuredChatOutputParserWithRetries.
        """
        if llm is not None:
            base_parser = base_parser or StructuredChatOutputParser()
            output_fixing_parser: OutputFixingParser = OutputFixingParser.from_llm(
                llm=llm,
                parser=base_parser,
            )
            return cls(output_fixing_parser=output_fixing_parser)
        if base_parser is not None:
            return cls(base_parser=base_parser)
        return cls()

Subdomains

Frequently Asked Questions

What does from_llm() do?
from_llm() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/structured_chat/output_parser.py.
Where is from_llm() defined?
from_llm() is defined in libs/langchain/langchain_classic/agents/structured_chat/output_parser.py at line 85.

Analyze Your Own Codebase

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

Try Supermodel Free