Skip to content

chore(toolbox-llamaindex): remove add_headers feature #280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 8 additions & 19 deletions packages/toolbox-llamaindex/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,27 +204,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_llamaindex import ToolboxClient

client = ToolboxClient(
"toolbox-url",
client_headers={"header1": header1_getter, "header2": header2_getter, ...}
)
```

1. **After Client Initialization**

```python
from toolbox_llamaindex import ToolboxClient
```python
from toolbox_llamaindex 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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +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)
13 changes: 0 additions & 13 deletions packages/toolbox-llamaindex/src/toolbox_llamaindex/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,16 +292,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)
8 changes: 0 additions & 8 deletions packages/toolbox-llamaindex/tests/test_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
9 changes: 0 additions & 9 deletions packages/toolbox-llamaindex/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,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_llamaindex.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)