mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-05 04:38:26 +00:00
langchain[patch]: make hub work with older langchainhub versions (#19076)
Make it work with older clients
This commit is contained in:
parent
0a784074d1
commit
0ddfe7fc9d
@ -80,6 +80,9 @@ def pull(
|
|||||||
:param api_key: The API key to use to authenticate with the LangChain Hub API.
|
:param api_key: The API key to use to authenticate with the LangChain Hub API.
|
||||||
"""
|
"""
|
||||||
client = _get_client(api_url=api_url, api_key=api_key)
|
client = _get_client(api_url=api_url, api_key=api_key)
|
||||||
|
|
||||||
|
if hasattr(client, "pull_repo"):
|
||||||
|
# >= 0.1.15
|
||||||
res_dict = client.pull_repo(owner_repo_commit)
|
res_dict = client.pull_repo(owner_repo_commit)
|
||||||
obj = loads(json.dumps(res_dict["manifest"]))
|
obj = loads(json.dumps(res_dict["manifest"]))
|
||||||
if isinstance(obj, BasePromptTemplate):
|
if isinstance(obj, BasePromptTemplate):
|
||||||
@ -89,3 +92,7 @@ def pull(
|
|||||||
obj.metadata["lc_hub_repo"] = res_dict["repo"]
|
obj.metadata["lc_hub_repo"] = res_dict["repo"]
|
||||||
obj.metadata["lc_hub_commit_hash"] = res_dict["commit_hash"]
|
obj.metadata["lc_hub_commit_hash"] = res_dict["commit_hash"]
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
# Then it's < 0.1.15
|
||||||
|
resp: str = client.pull(owner_repo_commit)
|
||||||
|
return loads(resp)
|
||||||
|
Loading…
Reference in New Issue
Block a user