_get_client() — langchain Function Reference
Architecture documentation for the _get_client() function in hub.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 6075ed9d_f9d4_8afc_d040_b5028a8611ad["_get_client()"] ccf0b3ef_cfe3_66ba_e6be_6cff0b1467eb["hub.py"] 6075ed9d_f9d4_8afc_d040_b5028a8611ad -->|defined in| ccf0b3ef_cfe3_66ba_e6be_6cff0b1467eb d38006a4_921c_fa6e_3114_2b4729224f76["push()"] d38006a4_921c_fa6e_3114_2b4729224f76 -->|calls| 6075ed9d_f9d4_8afc_d040_b5028a8611ad a0c261bf_3425_07b8_dcc2_70e5a530c721["pull()"] a0c261bf_3425_07b8_dcc2_70e5a530c721 -->|calls| 6075ed9d_f9d4_8afc_d040_b5028a8611ad style 6075ed9d_f9d4_8afc_d040_b5028a8611ad fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/hub.py lines 14–52
def _get_client(
api_key: str | None = None,
api_url: str | None = None,
) -> Any:
"""Get a client for interacting with the LangChain Hub.
Attempts to use LangSmith client if available, otherwise falls back to
the legacy `langchainhub` client.
Args:
api_key: API key to authenticate with the LangChain Hub API.
api_url: URL of the LangChain Hub API.
Returns:
Client instance for interacting with the hub.
Raises:
ImportError: If neither `langsmith` nor `langchainhub` can be imported.
"""
try:
from langsmith import Client as LangSmithClient
ls_client = LangSmithClient(api_url, api_key=api_key)
if hasattr(ls_client, "push_prompt") and hasattr(ls_client, "pull_prompt"):
return ls_client
from langchainhub import Client as LangChainHubClient
return LangChainHubClient(api_url, api_key=api_key)
except ImportError:
try:
from langchainhub import Client as LangChainHubClient
return LangChainHubClient(api_url, api_key=api_key)
except ImportError as e:
msg = (
"Could not import langsmith or langchainhub (deprecated),"
"please install with `pip install langsmith`."
)
raise ImportError(msg) from e
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does _get_client() do?
_get_client() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/hub.py.
Where is _get_client() defined?
_get_client() is defined in libs/langchain/langchain_classic/hub.py at line 14.
What calls _get_client()?
_get_client() is called by 2 function(s): pull, push.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free