Home / Function/ wrap_model_call() — langchain Function Reference

wrap_model_call() — langchain Function Reference

Architecture documentation for the wrap_model_call() function in test_middleware_typing.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  00fd3d3f_625e_3a68_8936_4823e0ec86b9["wrap_model_call()"]
  3c3b5386_19a6_3675_81a6_f2b04cf3c889["UserContextMiddleware"]
  00fd3d3f_625e_3a68_8936_4823e0ec86b9 -->|defined in| 3c3b5386_19a6_3675_81a6_f2b04cf3c889
  style 00fd3d3f_625e_3a68_8936_4823e0ec86b9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware_typing/test_middleware_typing.py lines 127–134

    def wrap_model_call(
        self,
        request: ModelRequest[UserContext],  # Correctly parameterized!
        handler: Callable[[ModelRequest[UserContext]], ModelResponse[Any]],
    ) -> ModelResponse[Any]:
        # request.runtime.context is UserContext - fully typed!
        _user_id: str = request.runtime.context["user_id"]
        return handler(request)

Domain

Subdomains

Frequently Asked Questions

What does wrap_model_call() do?
wrap_model_call() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware_typing/test_middleware_typing.py.
Where is wrap_model_call() defined?
wrap_model_call() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware_typing/test_middleware_typing.py at line 127.

Analyze Your Own Codebase

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

Try Supermodel Free