_utils.py — langchain Source File
Architecture documentation for _utils.py, a python file in the langchain codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 30343711_5521_a7f5_4f30_8070ee088ac6["_utils.py"] feec1ec4_6917_867b_d228_b134d0ff8099["typing"] 30343711_5521_a7f5_4f30_8070ee088ac6 --> feec1ec4_6917_867b_d228_b134d0ff8099 17a62cb3_fefd_6320_b757_b53bb4a1c661["langchain_core.callbacks"] 30343711_5521_a7f5_4f30_8070ee088ac6 --> 17a62cb3_fefd_6320_b757_b53bb4a1c661 dd5e7909_a646_84f1_497b_cae69735550e["pydantic"] 30343711_5521_a7f5_4f30_8070ee088ac6 --> dd5e7909_a646_84f1_497b_cae69735550e style 30343711_5521_a7f5_4f30_8070ee088ac6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""A fake callback handler for testing purposes."""
from __future__ import annotations
from typing import Any
from langchain_core.callbacks import BaseCallbackHandler
from pydantic import BaseModel
class BaseFakeCallbackHandler(BaseModel):
"""Base fake callback handler for testing."""
starts: int = 0
ends: int = 0
errors: int = 0
text: int = 0
ignore_llm_: bool = False
ignore_chain_: bool = False
ignore_agent_: bool = False
ignore_retriever_: bool = False
ignore_chat_model_: bool = False
# to allow for similar callback handlers that are not technically equal
fake_id: str | None = None
# add finer-grained counters for easier debugging of failing tests
chain_starts: int = 0
chain_ends: int = 0
llm_starts: int = 0
llm_ends: int = 0
llm_streams: int = 0
tool_starts: int = 0
tool_ends: int = 0
agent_actions: int = 0
agent_ends: int = 0
chat_model_starts: int = 0
retriever_starts: int = 0
retriever_ends: int = 0
retriever_errors: int = 0
retries: int = 0
class BaseFakeCallbackHandlerMixin(BaseFakeCallbackHandler):
"""Base fake callback handler mixin for testing."""
def on_llm_start_common(self) -> None:
self.llm_starts += 1
self.starts += 1
def on_llm_end_common(self) -> None:
self.llm_ends += 1
self.ends += 1
def on_llm_error_common(self) -> None:
self.errors += 1
def on_llm_new_token_common(self) -> None:
self.llm_streams += 1
// ... (199 more lines)
Domain
Subdomains
Dependencies
- langchain_core.callbacks
- pydantic
- typing
Source
Frequently Asked Questions
What does _utils.py do?
_utils.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, ApiManagement subdomain.
What does _utils.py depend on?
_utils.py imports 3 module(s): langchain_core.callbacks, pydantic, typing.
Where is _utils.py in the architecture?
_utils.py is located at libs/partners/anthropic/tests/unit_tests/_utils.py (domain: LangChainCore, subdomain: ApiManagement, directory: libs/partners/anthropic/tests/unit_tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free