mirror of
https://github.com/hwchase17/langchain.git
synced 2026-04-25 01:16:55 +00:00
docs(core): expanded get_lc_namespace docstring (#35229)
This commit is contained in:
@@ -134,9 +134,22 @@ class Serializable(BaseModel, ABC):
|
||||
def get_lc_namespace(cls) -> list[str]:
|
||||
"""Get the namespace of the LangChain object.
|
||||
|
||||
For example, if the class is
|
||||
[`langchain.llms.openai.OpenAI`][langchain_openai.OpenAI], then the namespace is
|
||||
`["langchain", "llms", "openai"]`
|
||||
The default implementation splits `cls.__module__` on `'.'`, e.g.
|
||||
`langchain_openai.chat_models` becomes
|
||||
`["langchain_openai", "chat_models"]`. This value is used by `lc_id` to
|
||||
build the serialization identifier.
|
||||
|
||||
New partner packages should **not** override this method. The default
|
||||
behavior is correct for any class whose module path already reflects
|
||||
its package name. Some older packages (e.g. `langchain-openai`,
|
||||
`langchain-anthropic`) override it to return a legacy-style namespace
|
||||
like `["langchain", "chat_models", "openai"]`, matching the module
|
||||
paths that existed before those integrations were split out of the
|
||||
main `langchain` package. Those overrides are kept for
|
||||
backwards-compatible deserialization; new packages should not copy them.
|
||||
|
||||
Deserialization mapping is handled separately by
|
||||
`SERIALIZABLE_MAPPING` in `langchain_core.load.mapping`.
|
||||
|
||||
Returns:
|
||||
The namespace.
|
||||
|
||||
Reference in New Issue
Block a user