__getattr__() — langchain Function Reference
Architecture documentation for the __getattr__() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 5e15bd7c_5823_c929_75aa_9a4d7576f2f0["__getattr__()"] 74f697e6_2555_becc_640e_6f41ea707eba["_ConfigurableModel"] 5e15bd7c_5823_c929_75aa_9a4d7576f2f0 -->|defined in| 74f697e6_2555_becc_640e_6f41ea707eba 4d79fd76_22aa_8160_64a3_c62bd0bfe875["_model()"] 5e15bd7c_5823_c929_75aa_9a4d7576f2f0 -->|calls| 4d79fd76_22aa_8160_64a3_c62bd0bfe875 style 5e15bd7c_5823_c929_75aa_9a4d7576f2f0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/langchain/chat_models/base.py lines 620–648
def __getattr__(self, name: str) -> Any:
if name in _DECLARATIVE_METHODS:
# Declarative operations that cannot be applied until after an actual model
# object is instantiated. So instead of returning the actual operation,
# we record the operation and its arguments in a queue. This queue is
# then applied in order whenever we actually instantiate the model (in
# self._model()).
def queue(*args: Any, **kwargs: Any) -> _ConfigurableModel:
queued_declarative_operations = list(
self._queued_declarative_operations,
)
queued_declarative_operations.append((name, args, kwargs))
return _ConfigurableModel(
default_config=dict(self._default_config),
configurable_fields=list(self._configurable_fields)
if isinstance(self._configurable_fields, list)
else self._configurable_fields,
config_prefix=self._config_prefix,
queued_declarative_operations=queued_declarative_operations,
)
return queue
if self._default_config and (model := self._model()) and hasattr(model, name):
return getattr(model, name)
msg = f"{name} is not a BaseChatModel attribute"
if self._default_config:
msg += " and is not implemented on the default model"
msg += "."
raise AttributeError(msg)
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does __getattr__() do?
__getattr__() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/chat_models/base.py.
Where is __getattr__() defined?
__getattr__() is defined in libs/langchain_v1/langchain/chat_models/base.py at line 620.
What does __getattr__() call?
__getattr__() calls 1 function(s): _model.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free