Skip to content

Commit fcdfdae

Browse files
authored
chore: Restore add_auth_token(s) as deprecated for backward compatibility (#236)
* fix(toolbox-langchain)!: Base toolbox-langchain over toolbox-core * fix: add toolbox-core as package dependency * fix: Base sync client * fix: Fix running background asyncio in current loop issue * fix: Base toolbox sync & async tools to toolbox core counterparts * fix: Fix getting pydantic model from ToolboxSyncTool * fix: Fix issue causing async core tools for creating sync tools * fix: Fix reading name from correct param * fix: Fix issue of unknown parameter due to pydantic initialization * fix: Fix nit error + add comment * fix: Fix sync tool name assertion * chore: Temporarily remove unittests * chore: Remove unused strict flag + fix default values + fix docstring * fix: Update package to be from git repo * fix: Fix toolbox-core package local path * fix: Fix local package path * fix: Update git path * fix: Fix tests * fix: Fix using correct object for fetching loop * fix: Return invoke result * fix: Integration test errors * chore: Delint * fix: Fix integration test * fix: Fix integration tests * chore: Add unit tests previously deleted * chore: Delint * fix: Fix using correct protected member variables * chore: Delint * chore: Fix types * fix: Ensure bg loop/thread not null * fix: Check bg loop/thread value * fix: Revert warnings to prefer auth_tokens over auth_headers * chore: Update unittests * docs: Improve docstrings * chore: Add TODO note * chore: Improve TODO note * fix: Fix integration test * chore: Delint * chore: Rename internal member variable names to be more concise * chore: Delint * chore: Add toolbox actual package version in toml and local path in requirements.txt * fix: Fix editable toolbox-core package path in requirements.txt * fix: Fix lowest supported version until released * fix: Fix issue causing relative path in requirements.txt to cause issues * docs: Fix issue README * fix: Use correct core client interfaces in langchain client * fix: Use correct core tool interfaces in langchain tool * fix: Use correct interface from core tool * fix: Use correct interfaces of toolbox-core * chore: Update async client unit tests * chore: Fix client unit tests * chore: Delint * chore: Fix tools unit tests * 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 03d1b16 commit fcdfdae

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 to_thread
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)