_parse_model() — langchain Function Reference
Architecture documentation for the _parse_model() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD a54ee238_3c0b_0e79_2daa_6c5ad2b043cf["_parse_model()"] 0dc60931_4ce3_cfa4_06b1_e0f8b1869e73["base.py"] a54ee238_3c0b_0e79_2daa_6c5ad2b043cf -->|defined in| 0dc60931_4ce3_cfa4_06b1_e0f8b1869e73 7029a671_2a91_97a5_f6ff_7708a55ef68a["_init_chat_model_helper()"] 7029a671_2a91_97a5_f6ff_7708a55ef68a -->|calls| a54ee238_3c0b_0e79_2daa_6c5ad2b043cf 108cc2b1_073c_1dbb_45d1_1dcb1074e00a["_attempt_infer_model_provider()"] a54ee238_3c0b_0e79_2daa_6c5ad2b043cf -->|calls| 108cc2b1_073c_1dbb_45d1_1dcb1074e00a style a54ee238_3c0b_0e79_2daa_6c5ad2b043cf fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/langchain/chat_models/base.py lines 558–586
def _parse_model(model: str, model_provider: str | None) -> tuple[str, str]:
"""Parse model name and provider, inferring provider if necessary."""
# Handle provider:model format
if (
not model_provider
and ":" in model
and model.split(":", maxsplit=1)[0] in _BUILTIN_PROVIDERS
):
model_provider = model.split(":", maxsplit=1)[0]
model = ":".join(model.split(":")[1:])
# Attempt to infer provider if not specified
model_provider = model_provider or _attempt_infer_model_provider(model)
if not model_provider:
# Enhanced error message with suggestions
supported_list = ", ".join(sorted(_BUILTIN_PROVIDERS))
msg = (
f"Unable to infer model provider for {model=}. "
f"Please specify 'model_provider' directly.\n\n"
f"Supported providers: {supported_list}\n\n"
f"For help with specific providers, see: "
f"https://docs.langchain.com/oss/python/integrations/providers"
)
raise ValueError(msg)
# Normalize provider name
model_provider = model_provider.replace("-", "_").lower()
return model, model_provider
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does _parse_model() do?
_parse_model() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/chat_models/base.py.
Where is _parse_model() defined?
_parse_model() is defined in libs/langchain_v1/langchain/chat_models/base.py at line 558.
What does _parse_model() call?
_parse_model() calls 1 function(s): _attempt_infer_model_provider.
What calls _parse_model()?
_parse_model() is called by 1 function(s): _init_chat_model_helper.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free