Home / Class/ ModelResponse Class — langchain Architecture

ModelResponse Class — langchain Architecture

Architecture documentation for the ModelResponse class in types.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  82f57f3c_8727_57bc_bed9_3ed0f8bdf6bd["ModelResponse"]
  fb1284e2_76fc_661f_c16d_e084e8c2b175["types.py"]
  82f57f3c_8727_57bc_bed9_3ed0f8bdf6bd -->|defined in| fb1284e2_76fc_661f_c16d_e084e8c2b175

Relationship Graph

Source Code

libs/langchain_v1/langchain/agents/middleware/types.py lines 272–286

class ModelResponse(Generic[ResponseT]):
    """Response from model execution including messages and optional structured output.

    The result will usually contain a single `AIMessage`, but may include an additional
    `ToolMessage` if the model used a tool for structured output.

    Type Parameters:
        ResponseT: The type of the structured response. Defaults to `Any` if not specified.
    """

    result: list[BaseMessage]
    """List of messages from model execution."""

    structured_response: ResponseT | None = None
    """Parsed structured output if `response_format` was specified, `None` otherwise."""

Frequently Asked Questions

What is the ModelResponse class?
ModelResponse is a class in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/types.py.
Where is ModelResponse defined?
ModelResponse is defined in libs/langchain_v1/langchain/agents/middleware/types.py at line 272.

Analyze Your Own Codebase

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

Try Supermodel Free