Skip to content

Commit 5ab16c7

Browse files
committed
remove files
1 parent a9c33c9 commit 5ab16c7

File tree

9 files changed

+120
-16
lines changed

9 files changed

+120
-16
lines changed

packages/toolbox-langchain/README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,16 +231,27 @@ that fresh credentials or header values can be used.
231231

232232
### Configuration
233233

234-
You can configure these dynamic headers as follows:
234+
You can configure these dynamic headers in two ways:
235235

236-
```python
237-
from toolbox_langchain import ToolboxClient
236+
1. **During Client Initialization**
238237

239-
client = ToolboxClient(
240-
"toolbox-url",
241-
client_headers={"header1": header1_getter, "header2": header2_getter, ...}
242-
)
243-
```
238+
```python
239+
from toolbox_langchain import ToolboxClient
240+
241+
client = ToolboxClient(
242+
"toolbox-url",
243+
client_headers={"header1": header1_getter, "header2": header2_getter, ...}
244+
)
245+
```
246+
247+
1. **After Client Initialization**
248+
249+
```python
250+
from toolbox_langchain import ToolboxClient
251+
252+
client = ToolboxClient("toolbox-url")
253+
client.add_headers({"header1": header1_getter, "header2": header2_getter, ...})
254+
```
244255

245256
### Authenticating with Google Cloud Servers
246257

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,18 @@ def load_toolset(
190190
strict: bool = False,
191191
) -> list[AsyncToolboxTool]:
192192
raise NotImplementedError("Synchronous methods not supported by async client.")
193+
194+
def add_headers(
195+
self,
196+
headers: Mapping[str, Union[Callable[[], str], Callable[[], Awaitable[str]]]],
197+
) -> None:
198+
"""
199+
Add headers to be included in each request sent through this client.
200+
201+
Args:
202+
headers: Headers to include in each request sent through this client.
203+
204+
Raises:
205+
ValueError: If any of the headers are already registered in the client.
206+
"""
207+
self.__core_client.add_headers(headers)

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,3 +291,18 @@ def load_toolset(
291291
for core_sync_tool in core_sync_tools:
292292
tools.append(ToolboxTool(core_tool=core_sync_tool))
293293
return tools
294+
295+
def add_headers(
296+
self,
297+
headers: Mapping[str, Union[Callable[[], str], Callable[[], Awaitable[str]]]],
298+
) -> None:
299+
"""
300+
Add headers to be included in each request sent through this client.
301+
302+
Args:
303+
headers: Headers to include in each request sent through this client.
304+
305+
Raises:
306+
ValueError: If any of the headers are already registered in the client.
307+
"""
308+
self.__core_client.add_headers(headers)

packages/toolbox-langchain/tests/test_client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,3 +429,12 @@ def test_init_with_client_headers(self, mock_core_client_constructor):
429429
mock_core_client_constructor.assert_called_once_with(
430430
url=URL, client_headers=headers
431431
)
432+
433+
@patch("toolbox_langchain.client.ToolboxCoreSyncClient")
434+
def test_add_headers(self, mock_core_client_constructor):
435+
"""Tests that add_headers calls the core client's add_headers."""
436+
mock_core_instance = mock_core_client_constructor.return_value
437+
client = ToolboxClient(URL)
438+
headers = {"X-Another-Header": "dynamic_value"}
439+
client.add_headers(headers)
440+
mock_core_instance.add_headers.assert_called_once_with(headers)

packages/toolbox-llamaindex/README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,27 @@ that fresh credentials or header values can be used.
204204

205205
### Configuration
206206

207-
You can configure these dynamic headers as follows:
207+
You can configure these dynamic headers in two ways:
208208

209-
```python
210-
from toolbox_llamaindex import ToolboxClient
209+
1. **During Client Initialization**
211210

212-
client = ToolboxClient(
213-
"toolbox-url",
214-
client_headers={"header1": header1_getter, "header2": header2_getter, ...}
215-
)
216-
```
211+
```python
212+
from toolbox_llamaindex import ToolboxClient
213+
214+
client = ToolboxClient(
215+
"toolbox-url",
216+
client_headers={"header1": header1_getter, "header2": header2_getter, ...}
217+
)
218+
```
219+
220+
1. **After Client Initialization**
221+
222+
```python
223+
from toolbox_llamaindex import ToolboxClient
224+
225+
client = ToolboxClient("toolbox-url")
226+
client.add_headers({"header1": header1_getter, "header2": header2_getter, ...})
227+
```
217228

218229
### Authenticating with Google Cloud Servers
219230

packages/toolbox-llamaindex/src/toolbox_llamaindex/async_client.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,16 @@ def load_toolset(
190190
strict: bool = False,
191191
) -> list[AsyncToolboxTool]:
192192
raise NotImplementedError("Synchronous methods not supported by async client.")
193+
194+
def add_headers(
195+
self,
196+
headers: Mapping[str, Union[Callable[[], str], Callable[[], Awaitable[str]]]],
197+
) -> None:
198+
"""
199+
Add headers to be included in each request sent through this client.
200+
Args:
201+
headers: Headers to include in each request sent through this client.
202+
Raises:
203+
ValueError: If any of the headers are already registered in the client.
204+
"""
205+
self.__core_client.add_headers(headers)

packages/toolbox-llamaindex/src/toolbox_llamaindex/client.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,3 +292,16 @@ def load_toolset(
292292
for core_sync_tool in core_sync_tools:
293293
tools.append(ToolboxTool(core_tool=core_sync_tool))
294294
return tools
295+
296+
def add_headers(
297+
self,
298+
headers: Mapping[str, Union[Callable[[], str], Callable[[], Awaitable[str]]]],
299+
) -> None:
300+
"""
301+
Add headers to be included in each request sent through this client.
302+
Args:
303+
headers: Headers to include in each request sent through this client.
304+
Raises:
305+
ValueError: If any of the headers are already registered in the client.
306+
"""
307+
self.__core_client.add_headers(headers)

packages/toolbox-llamaindex/tests/test_async_client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,11 @@ async def test_init_with_client_headers(
350350
mock_core_client_constructor.assert_called_once_with(
351351
url=URL, session=mock_session, client_headers=headers
352352
)
353+
354+
async def test_add_headers(self, mock_client):
355+
"""Tests that add_headers calls the core client's add_headers."""
356+
headers = {"X-Another-Header": lambda: "dynamic_value"}
357+
mock_client.add_headers(headers)
358+
mock_client._AsyncToolboxClient__core_client.add_headers.assert_called_once_with(
359+
headers
360+
)

packages/toolbox-llamaindex/tests/test_client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,3 +431,12 @@ def test_init_with_client_headers(self, mock_core_client_constructor):
431431
mock_core_client_constructor.assert_called_once_with(
432432
url=URL, client_headers=headers
433433
)
434+
435+
@patch("toolbox_llamaindex.client.ToolboxCoreSyncClient")
436+
def test_add_headers(self, mock_core_client_constructor):
437+
"""Tests that add_headers calls the core client's add_headers."""
438+
mock_core_instance = mock_core_client_constructor.return_value
439+
client = ToolboxClient(URL)
440+
headers = {"X-Another-Header": "dynamic_value"}
441+
client.add_headers(headers)
442+
mock_core_instance.add_headers.assert_called_once_with(headers)

0 commit comments

Comments
 (0)