Home / Function/ _infer_model_and_provider() — langchain Function Reference

_infer_model_and_provider() — langchain Function Reference

Architecture documentation for the _infer_model_and_provider() function in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  e9cf050d_cf9c_221c_0569_7b52c7831196["_infer_model_and_provider()"]
  76380b72_77fe_25f0_4fc9_0d116ee2433c["base.py"]
  e9cf050d_cf9c_221c_0569_7b52c7831196 -->|defined in| 76380b72_77fe_25f0_4fc9_0d116ee2433c
  2954192c_8016_8ddf_9323_43285db4aa1b["init_embeddings()"]
  2954192c_8016_8ddf_9323_43285db4aa1b -->|calls| e9cf050d_cf9c_221c_0569_7b52c7831196
  6736cae9_5ddc_f2a5_4634_a756a7d2c58c["_parse_model_string()"]
  e9cf050d_cf9c_221c_0569_7b52c7831196 -->|calls| 6736cae9_5ddc_f2a5_4634_a756a7d2c58c
  80a66df6_2383_888c_83e7_83324720ae54["_get_provider_list()"]
  e9cf050d_cf9c_221c_0569_7b52c7831196 -->|calls| 80a66df6_2383_888c_83e7_83324720ae54
  style e9cf050d_cf9c_221c_0569_7b52c7831196 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/embeddings/base.py lines 83–114

def _infer_model_and_provider(
    model: str,
    *,
    provider: str | None = None,
) -> tuple[str, str]:
    if not model.strip():
        msg = "Model name cannot be empty"
        raise ValueError(msg)
    if provider is None and ":" in model:
        provider, model_name = _parse_model_string(model)
    else:
        model_name = model

    if not provider:
        providers = _SUPPORTED_PROVIDERS
        msg = (
            "Must specify either:\n"
            "1. A model string in format 'provider:model-name'\n"
            "   Example: 'openai:text-embedding-3-small'\n"
            "2. Or explicitly set provider from: "
            f"{providers}"
        )
        raise ValueError(msg)

    if provider not in _SUPPORTED_PROVIDERS:
        msg = (
            f"Provider '{provider}' is not supported.\n"
            f"Supported providers and their required packages:\n"
            f"{_get_provider_list()}"
        )
        raise ValueError(msg)
    return provider, model_name

Domain

Subdomains

Called By

Frequently Asked Questions

What does _infer_model_and_provider() do?
_infer_model_and_provider() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/embeddings/base.py.
Where is _infer_model_and_provider() defined?
_infer_model_and_provider() is defined in libs/langchain/langchain_classic/embeddings/base.py at line 83.
What does _infer_model_and_provider() call?
_infer_model_and_provider() calls 2 function(s): _get_provider_list, _parse_model_string.
What calls _infer_model_and_provider()?
_infer_model_and_provider() is called by 1 function(s): init_embeddings.

Analyze Your Own Codebase

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

Try Supermodel Free