mirror of
https://github.com/hwchase17/langchain.git
synced 2026-05-03 01:46:42 +00:00
Deprecate classic hub entry points in favor of the LangSmith SDK.
Co-authored-by: Mason Daugherty <61371264+mdrxy@users.noreply.github.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import json
|
||||
from collections.abc import Sequence
|
||||
from typing import Any, Literal
|
||||
|
||||
from langchain_core._api import deprecated
|
||||
from langchain_core.load.dump import dumps
|
||||
from langchain_core.load.load import loads
|
||||
from langchain_core.prompts import BasePromptTemplate
|
||||
@@ -52,6 +53,12 @@ def _get_client(
|
||||
raise ImportError(msg) from e
|
||||
|
||||
|
||||
@deprecated(
|
||||
since="1.0.5",
|
||||
alternative="langsmith.Client.push_prompt",
|
||||
removal="2.0.0",
|
||||
package="langchain-classic",
|
||||
)
|
||||
def push(
|
||||
repo_full_name: str,
|
||||
object: Any, # noqa: A002
|
||||
@@ -108,6 +115,12 @@ def push(
|
||||
)
|
||||
|
||||
|
||||
@deprecated(
|
||||
since="1.0.5",
|
||||
alternative="langsmith.Client.pull_prompt",
|
||||
removal="2.0.0",
|
||||
package="langchain-classic",
|
||||
)
|
||||
def pull(
|
||||
owner_repo_commit: str,
|
||||
*,
|
||||
|
||||
34
libs/langchain/tests/unit_tests/test_hub.py
Normal file
34
libs/langchain/tests/unit_tests/test_hub.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
from langchain_core._api import LangChainDeprecationWarning
|
||||
|
||||
from langchain_classic import hub
|
||||
|
||||
|
||||
class FakeLangSmithClient:
|
||||
def pull_prompt(self, owner_repo_commit: str, **_: Any) -> str:
|
||||
return owner_repo_commit
|
||||
|
||||
def push_prompt(self, repo_full_name: str, **_: Any) -> str:
|
||||
return repo_full_name
|
||||
|
||||
|
||||
def test_pull_warns_about_sdk_replacement(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(hub, "_get_client", lambda **_: FakeLangSmithClient())
|
||||
|
||||
with pytest.warns(
|
||||
LangChainDeprecationWarning,
|
||||
match="langsmith.Client.pull_prompt",
|
||||
):
|
||||
assert hub.pull("owner/prompt") == "owner/prompt"
|
||||
|
||||
|
||||
def test_push_warns_about_sdk_replacement(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(hub, "_get_client", lambda **_: FakeLangSmithClient())
|
||||
|
||||
with pytest.warns(
|
||||
LangChainDeprecationWarning,
|
||||
match="langsmith.Client.push_prompt",
|
||||
):
|
||||
assert hub.push("owner/prompt", object={}) == "owner/prompt"
|
||||
Reference in New Issue
Block a user