Skip to content

Commit 0c74ce6

Browse files
committed
chore: Restore add_auth_token(s) as deprecated for backward compatibility
This PR addresses a breaking change introduced by the removal of `add_auth_token(s)` methods in #182. To ensure backward compatibility and facilitate a smoother upgrade path, these methods are now reintroduced but explicitly marked as **deprecated**. Users are encouraged to migrate to the new `add_auth_token_getter(s)` methods instead. > [!NOTE] > The `strict` flag in the deprecated methods are not used anymore since the functionality of the `strict` flag has been changed (see #205 for more details).
1 parent 0b7b3f9 commit 0c74ce6

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

packages/toolbox-langchain/src/toolbox_langchain/async_tools.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from typing import Any, Callable, Union
1616

17+
from deprecated import deprecated
1718
from langchain_core.tools import BaseTool
1819
from toolbox_core.tool import ToolboxTool as ToolboxCoreTool
1920
from toolbox_core.utils import params_to_pydantic_model
@@ -108,6 +109,18 @@ def add_auth_token_getter(
108109
"""
109110
return self.add_auth_token_getters({auth_source: get_id_token})
110111

112+
@deprecated("Please use `add_auth_token_getters` instead.")
113+
def add_auth_tokens(
114+
self, auth_tokens: dict[str, Callable[[], str]], strict: bool = True
115+
) -> "AsyncToolboxTool":
116+
return self.add_auth_token_getters(auth_tokens)
117+
118+
@deprecated("Please use `add_auth_token_getter` instead.")
119+
def add_auth_token(
120+
self, auth_source: str, get_id_token: Callable[[], str], strict: bool = True
121+
) -> "AsyncToolboxTool":
122+
return self.add_auth_token_getter(auth_source, get_id_token)
123+
111124
def bind_params(
112125
self,
113126
bound_params: dict[str, Union[Any, Callable[[], Any]]],

packages/toolbox-langchain/src/toolbox_langchain/tools.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from asyncio import wrap_future
1616
from typing import Any, Callable, Union
1717

18+
from deprecated import deprecated
1819
from langchain_core.tools import BaseTool
1920
from toolbox_core.sync_tool import ToolboxSyncTool as ToolboxCoreSyncTool
2021
from toolbox_core.utils import params_to_pydantic_model
@@ -94,6 +95,18 @@ def add_auth_token_getter(
9495
"""
9596
return self.add_auth_token_getters({auth_source: get_id_token})
9697

98+
@deprecated("Please use `add_auth_token_getters` instead.")
99+
def add_auth_tokens(
100+
self, auth_tokens: dict[str, Callable[[], str]], strict: bool = True
101+
) -> "ToolboxTool":
102+
return self.add_auth_token_getters(auth_tokens)
103+
104+
@deprecated("Please use `add_auth_token_getter` instead.")
105+
def add_auth_token(
106+
self, auth_source: str, get_id_token: Callable[[], str], strict: bool = True
107+
) -> "ToolboxTool":
108+
return self.add_auth_token_getter(auth_source, get_id_token)
109+
97110
def bind_params(
98111
self,
99112
bound_params: dict[str, Union[Any, Callable[[], Any]]],

0 commit comments

Comments
 (0)