Skip to content

Commit dd061af

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 28f3221 commit dd061af

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

@@ -107,6 +108,18 @@ def add_auth_token_getter(
107108
"""
108109
return self.add_auth_token_getters({auth_source: get_id_token})
109110

111+
@deprecated("Please use `add_auth_token_getters` instead.")
112+
def add_auth_tokens(
113+
self, auth_tokens: dict[str, Callable[[], str]], strict: bool = True
114+
) -> "AsyncToolboxTool":
115+
return self.add_auth_token_getters(auth_tokens)
116+
117+
@deprecated("Please use `add_auth_token_getter` instead.")
118+
def add_auth_token(
119+
self, auth_source: str, get_id_token: Callable[[], str], strict: bool = True
120+
) -> "AsyncToolboxTool":
121+
return self.add_auth_token_getter(auth_source, get_id_token)
122+
110123
def bind_params(
111124
self,
112125
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)