diff --git a/packages/toolbox-langchain/README.md b/packages/toolbox-langchain/README.md index 478bd087..42146d7c 100644 --- a/packages/toolbox-langchain/README.md +++ b/packages/toolbox-langchain/README.md @@ -231,27 +231,16 @@ that fresh credentials or header values can be used. ### Configuration -You can configure these dynamic headers in two ways: +You can configure these dynamic headers as follows: -1. **During Client Initialization** - - ```python - from toolbox_langchain import ToolboxClient - - client = ToolboxClient( - "toolbox-url", - client_headers={"header1": header1_getter, "header2": header2_getter, ...} - ) - ``` - -1. **After Client Initialization** - - ```python - from toolbox_langchain import ToolboxClient +```python +from toolbox_langchain import ToolboxClient - client = ToolboxClient("toolbox-url") - client.add_headers({"header1": header1_getter, "header2": header2_getter, ...}) - ``` +client = ToolboxClient( + "toolbox-url", + client_headers={"header1": header1_getter, "header2": header2_getter, ...} +) +``` ### Authenticating with Google Cloud Servers diff --git a/packages/toolbox-langchain/src/toolbox_langchain/async_client.py b/packages/toolbox-langchain/src/toolbox_langchain/async_client.py index a29bfb85..4757188d 100644 --- a/packages/toolbox-langchain/src/toolbox_langchain/async_client.py +++ b/packages/toolbox-langchain/src/toolbox_langchain/async_client.py @@ -190,18 +190,3 @@ def load_toolset( strict: bool = False, ) -> list[AsyncToolboxTool]: raise NotImplementedError("Synchronous methods not supported by async client.") - - def add_headers( - self, - headers: Mapping[str, Union[Callable[[], str], Callable[[], Awaitable[str]]]], - ) -> None: - """ - Add headers to be included in each request sent through this client. - - Args: - headers: Headers to include in each request sent through this client. - - Raises: - ValueError: If any of the headers are already registered in the client. - """ - self.__core_client.add_headers(headers) diff --git a/packages/toolbox-langchain/src/toolbox_langchain/client.py b/packages/toolbox-langchain/src/toolbox_langchain/client.py index 19cb60d0..00dc9c4d 100644 --- a/packages/toolbox-langchain/src/toolbox_langchain/client.py +++ b/packages/toolbox-langchain/src/toolbox_langchain/client.py @@ -291,18 +291,3 @@ def load_toolset( for core_sync_tool in core_sync_tools: tools.append(ToolboxTool(core_tool=core_sync_tool)) return tools - - def add_headers( - self, - headers: Mapping[str, Union[Callable[[], str], Callable[[], Awaitable[str]]]], - ) -> None: - """ - Add headers to be included in each request sent through this client. - - Args: - headers: Headers to include in each request sent through this client. - - Raises: - ValueError: If any of the headers are already registered in the client. - """ - self.__core_client.add_headers(headers) diff --git a/packages/toolbox-langchain/tests/test_async_client.py b/packages/toolbox-langchain/tests/test_async_client.py index 2e1c3f56..a0c9def5 100644 --- a/packages/toolbox-langchain/tests/test_async_client.py +++ b/packages/toolbox-langchain/tests/test_async_client.py @@ -350,11 +350,3 @@ async def test_init_with_client_headers( mock_core_client_constructor.assert_called_once_with( url=URL, session=mock_session, client_headers=headers ) - - async def test_add_headers(self, mock_client): - """Tests that add_headers calls the core client's add_headers.""" - headers = {"X-Another-Header": lambda: "dynamic_value"} - mock_client.add_headers(headers) - mock_client._AsyncToolboxClient__core_client.add_headers.assert_called_once_with( - headers - ) diff --git a/packages/toolbox-langchain/tests/test_client.py b/packages/toolbox-langchain/tests/test_client.py index bf42c870..73ecdb5d 100644 --- a/packages/toolbox-langchain/tests/test_client.py +++ b/packages/toolbox-langchain/tests/test_client.py @@ -429,12 +429,3 @@ def test_init_with_client_headers(self, mock_core_client_constructor): mock_core_client_constructor.assert_called_once_with( url=URL, client_headers=headers ) - - @patch("toolbox_langchain.client.ToolboxCoreSyncClient") - def test_add_headers(self, mock_core_client_constructor): - """Tests that add_headers calls the core client's add_headers.""" - mock_core_instance = mock_core_client_constructor.return_value - client = ToolboxClient(URL) - headers = {"X-Another-Header": "dynamic_value"} - client.add_headers(headers) - mock_core_instance.add_headers.assert_called_once_with(headers)