Skip to content

Commit 16f5ad9

Browse files
committed
remove files
1 parent a9c33c9 commit 16f5ad9

File tree

5 files changed

+62
-8
lines changed

5 files changed

+62
-8
lines changed

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)