Skip to content

Commit 0b1be65

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 a9ddd37 commit 0b1be65

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
import asyncio
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

@@ -104,6 +105,18 @@ def add_auth_token_getter(
104105
"""
105106
return self.add_auth_token_getters({auth_source: get_id_token})
106107

108+
@deprecated("Please use `add_auth_token_getters` instead.")
109+
def add_auth_tokens(
110+
self, auth_tokens: dict[str, Callable[[], str]], strict: bool = True
111+
) -> "ToolboxTool":
112+
return self.add_auth_token_getters(auth_tokens)
113+
114+
@deprecated("Please use `add_auth_token_getter` instead.")
115+
def add_auth_token(
116+
self, auth_source: str, get_id_token: Callable[[], str], strict: bool = True
117+
) -> "ToolboxTool":
118+
return self.add_auth_token_getter(auth_source, get_id_token)
119+
107120
def bind_params(
108121
self,
109122
bound_params: dict[str, Union[Any, Callable[[], Any]]],

0 commit comments

Comments
 (0)