Home / Class/ MyCustomAsyncHandler Class — langchain Architecture

MyCustomAsyncHandler Class — langchain Architecture

Architecture documentation for the MyCustomAsyncHandler class in test_fake_chat_model.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  5f53f77b_adda_976c_2a8f_56c041df7972["MyCustomAsyncHandler"]
  64513429_d001_87b1_5f19_cc17a3f3577b["AsyncCallbackHandler"]
  5f53f77b_adda_976c_2a8f_56c041df7972 -->|extends| 64513429_d001_87b1_5f19_cc17a3f3577b
  80c98d4d_3f6a_0197_c2ea_3db4062a1246["test_fake_chat_model.py"]
  5f53f77b_adda_976c_2a8f_56c041df7972 -->|defined in| 80c98d4d_3f6a_0197_c2ea_3db4062a1246
  429352d1_0d71_7a11_96ae_cb09f01c9324["__init__()"]
  5f53f77b_adda_976c_2a8f_56c041df7972 -->|method| 429352d1_0d71_7a11_96ae_cb09f01c9324
  7a27e13a_f632_f712_1db5_4d6fd6f822f2["on_chat_model_start()"]
  5f53f77b_adda_976c_2a8f_56c041df7972 -->|method| 7a27e13a_f632_f712_1db5_4d6fd6f822f2
  bfc942da_74ef_84cf_c17e_3eb9a75e609b["on_llm_new_token()"]
  5f53f77b_adda_976c_2a8f_56c041df7972 -->|method| bfc942da_74ef_84cf_c17e_3eb9a75e609b

Relationship Graph

Source Code

libs/langchain/tests/unit_tests/llms/test_fake_chat_model.py lines 154–184

    class MyCustomAsyncHandler(AsyncCallbackHandler):
        def __init__(self, store: list[str]) -> None:
            self.store = store

        async def on_chat_model_start(
            self,
            serialized: dict[str, Any],
            messages: list[list[BaseMessage]],
            *,
            run_id: UUID,
            parent_run_id: UUID | None = None,
            tags: list[str] | None = None,
            metadata: dict[str, Any] | None = None,
            **kwargs: Any,
        ) -> Any:
            # Do nothing
            # Required to implement since this is an abstract method
            pass

        @override
        async def on_llm_new_token(
            self,
            token: str,
            *,
            chunk: GenerationChunk | ChatGenerationChunk | None = None,
            run_id: UUID,
            parent_run_id: UUID | None = None,
            tags: list[str] | None = None,
            **kwargs: Any,
        ) -> None:
            self.store.append(token)

Frequently Asked Questions

What is the MyCustomAsyncHandler class?
MyCustomAsyncHandler is a class in the langchain codebase, defined in libs/langchain/tests/unit_tests/llms/test_fake_chat_model.py.
Where is MyCustomAsyncHandler defined?
MyCustomAsyncHandler is defined in libs/langchain/tests/unit_tests/llms/test_fake_chat_model.py at line 154.
What does MyCustomAsyncHandler extend?
MyCustomAsyncHandler extends AsyncCallbackHandler.

Analyze Your Own Codebase

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

Try Supermodel Free