Skip to content

Commit 17ba6d7

Browse files
authored
docs(toolbox-llamaindex): fix readme (#269)
* docs(toolbox-llamaindex): fix readme * fix * Update README.md * make load_toolset async
1 parent 5b806f1 commit 17ba6d7

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

packages/toolbox-llamaindex/README.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,22 +173,31 @@ connecting to a Toolbox server instance that requires authentication. This is
173173
crucial for securing your Toolbox server endpoint, especially when deployed on
174174
platforms like Cloud Run, GKE, or any environment where unauthenticated access is restricted.
175175

176-
This client-to-server authentication ensures that the Toolbox server can verify the identity of the client making the request before any tool is loaded or called. It is different from [Authenticating Tools](#authenticating-tools), which deals with providing credentials for specific tools within an already connected Toolbox session.
176+
This client-to-server authentication ensures that the Toolbox server can verify
177+
the identity of the client making the request before any tool is loaded or
178+
called. It is different from [Authenticating Tools](#authenticating-tools),
179+
which deals with providing credentials for specific tools within an already
180+
connected Toolbox session.
177181

178182
### When is Client-to-Server Authentication Needed?
179183

180-
You'll need this type of authentication if your Toolbox server is configured to deny unauthenticated requests. For example:
184+
You'll need this type of authentication if your Toolbox server is configured to
185+
deny unauthenticated requests. For example:
181186

182187
- Your Toolbox server is deployed on Cloud Run and configured to "Require authentication."
183-
- Your server is behind an Identity-Aware Proxy (IAP) or a similar authentication layer.
188+
- Your server is behind an Identity-Aware Proxy (IAP) or a similar
189+
authentication layer.
184190
- You have custom authentication middleware on your self-hosted Toolbox server.
185191

186192
Without proper client authentication in these scenarios, attempts to connect or
187193
make calls (like `load_tool`) will likely fail with `Unauthorized` errors.
188194

189195
### How it works
190196

191-
The `ToolboxClient` (and `ToolboxSyncClient`) allows you to specify functions (or coroutines for the async client) that dynamically generate HTTP headers for every request sent to the Toolbox server. The most common use case is to add an Authorization header with a bearer token (e.g., a Google ID token).
197+
The `ToolboxClient` allows you to specify functions (or coroutines for the async
198+
client) that dynamically generate HTTP headers for every request sent to the
199+
Toolbox server. The most common use case is to add an Authorization header with
200+
a bearer token (e.g., a Google ID token).
192201

193202
These header-generating functions are called just before each request, ensuring
194203
that fresh credentials or header values can be used.
@@ -202,7 +211,10 @@ You can configure these dynamic headers in two ways:
202211
```python
203212
from toolbox_llamaindex import ToolboxClient
204213

205-
client = ToolboxClient("toolbox-url", headers={"header1": header1_getter, "header2": header2_getter, ...})
214+
client = ToolboxClient(
215+
"toolbox-url",
216+
client_headers={"header1": header1_getter, "header2": header2_getter, ...}
217+
)
206218
```
207219

208220
1. **After Client Initialization**
@@ -234,14 +246,15 @@ For Toolbox servers hosted on Google Cloud (e.g., Cloud Run) and requiring
234246
3. **Connect to the Toolbox Server**
235247

236248
```python
249+
from toolbox_llamaindex import ToolboxClient
237250
from toolbox_core import auth_methods
238251

239252
auth_token_provider = auth_methods.aget_google_id_token # can also use sync method
240253
client = ToolboxClient(
241254
URL,
242255
client_headers={"Authorization": auth_token_provider},
243256
)
244-
tools = await client.load_toolset()
257+
tools = await client.aload_toolset()
245258

246259
# Now, you can use the client as usual.
247260
```

0 commit comments

Comments
 (0)