Home / Function/ pull() — langchain Function Reference

pull() — langchain Function Reference

Architecture documentation for the pull() function in hub.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  a0c261bf_3425_07b8_dcc2_70e5a530c721["pull()"]
  ccf0b3ef_cfe3_66ba_e6be_6cff0b1467eb["hub.py"]
  a0c261bf_3425_07b8_dcc2_70e5a530c721 -->|defined in| ccf0b3ef_cfe3_66ba_e6be_6cff0b1467eb
  6075ed9d_f9d4_8afc_d040_b5028a8611ad["_get_client()"]
  a0c261bf_3425_07b8_dcc2_70e5a530c721 -->|calls| 6075ed9d_f9d4_8afc_d040_b5028a8611ad
  style a0c261bf_3425_07b8_dcc2_70e5a530c721 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/hub.py lines 111–154

def pull(
    owner_repo_commit: str,
    *,
    include_model: bool | None = None,
    api_url: str | None = None,
    api_key: str | None = None,
) -> Any:
    """Pull an object from the hub and returns it as a LangChain object.

    Args:
        owner_repo_commit: The full name of the prompt to pull from in the format of
            `owner/prompt_name:commit_hash` or `owner/prompt_name`
            or just `prompt_name` if it's your own prompt.
        include_model: Whether to include the model configuration in the pulled prompt.
        api_url: The URL of the LangChain Hub API. Defaults to the hosted API service
            if you have an API key set, or a localhost instance if not.
        api_key: The API key to use to authenticate with the LangChain Hub API.

    Returns:
        The pulled LangChain object.
    """
    client = _get_client(api_key=api_key, api_url=api_url)

    # Then it's langsmith
    if hasattr(client, "pull_prompt"):
        return client.pull_prompt(owner_repo_commit, include_model=include_model)

    # Then it's langchainhub
    if hasattr(client, "pull_repo"):
        # >= 0.1.15
        res_dict = client.pull_repo(owner_repo_commit)
        allowed_objects: Literal["all", "core"] = "all" if include_model else "core"
        obj = loads(json.dumps(res_dict["manifest"]), allowed_objects=allowed_objects)
        if isinstance(obj, BasePromptTemplate):
            if obj.metadata is None:
                obj.metadata = {}
            obj.metadata["lc_hub_owner"] = res_dict["owner"]
            obj.metadata["lc_hub_repo"] = res_dict["repo"]
            obj.metadata["lc_hub_commit_hash"] = res_dict["commit_hash"]
        return obj

    # Then it's < 0.1.15 langchainhub
    resp: str = client.pull(owner_repo_commit)
    return loads(resp)

Domain

Subdomains

Frequently Asked Questions

What does pull() do?
pull() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/hub.py.
Where is pull() defined?
pull() is defined in libs/langchain/langchain_classic/hub.py at line 111.
What does pull() call?
pull() calls 1 function(s): _get_client.

Analyze Your Own Codebase

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

Try Supermodel Free