Skip to content

Commit 23379fb

Browse files
authored
docs(toolbox-langchain): fix readme (#267)
* docs: fix readme * wrap lines * Update README.md
1 parent 9853831 commit 23379fb

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

packages/toolbox-langchain/README.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,24 +197,34 @@ execution outside of an agent framework.
197197
This section describes how to authenticate the ToolboxClient itself when
198198
connecting to a Toolbox server instance that requires authentication. This is
199199
crucial for securing your Toolbox server endpoint, especially when deployed on
200-
platforms like Cloud Run, GKE, or any environment where unauthenticated access is restricted.
200+
platforms like Cloud Run, GKE, or any environment where unauthenticated access
201+
is restricted.
201202

202-
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.
203+
This client-to-server authentication ensures that the Toolbox server can verify
204+
the identity of the client making the request before any tool is loaded or
205+
called. It is different from [Authenticating Tools](#authenticating-tools),
206+
which deals with providing credentials for specific tools within an already
207+
connected Toolbox session.
203208

204209
### When is Client-to-Server Authentication Needed?
205210

206-
You'll need this type of authentication if your Toolbox server is configured to deny unauthenticated requests. For example:
211+
You'll need this type of authentication if your Toolbox server is configured to
212+
deny unauthenticated requests. For example:
207213

208214
- Your Toolbox server is deployed on Cloud Run and configured to "Require authentication."
209-
- Your server is behind an Identity-Aware Proxy (IAP) or a similar authentication layer.
215+
- Your server is behind an Identity-Aware Proxy (IAP) or a similar
216+
authentication layer.
210217
- You have custom authentication middleware on your self-hosted Toolbox server.
211218

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

215222
### How it works
216223

217-
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).
224+
The `ToolboxClient` allows you to specify functions (or coroutines for the async
225+
client) that dynamically generate HTTP headers for every request sent to the
226+
Toolbox server. The most common use case is to add an Authorization header with
227+
a bearer token (e.g., a Google ID token).
218228

219229
These header-generating functions are called just before each request, ensuring
220230
that fresh credentials or header values can be used.
@@ -228,7 +238,10 @@ You can configure these dynamic headers in two ways:
228238
```python
229239
from toolbox_langchain import ToolboxClient
230240

231-
client = ToolboxClient("toolbox-url", headers={"header1": header1_getter, "header2": header2_getter, ...})
241+
client = ToolboxClient(
242+
"toolbox-url",
243+
client_headers={"header1": header1_getter, "header2": header2_getter, ...}
244+
)
232245
```
233246

234247
1. **After Client Initialization**
@@ -248,7 +261,9 @@ For Toolbox servers hosted on Google Cloud (e.g., Cloud Run) and requiring
248261

249262
### Step by Step Guide for Cloud Run
250263

251-
1. **Configure Permissions**: [Grant](https://cloud.google.com/run/docs/securing/managing-access#service-add-principals) the `roles/run.invoker` IAM role on the Cloud
264+
1. **Configure Permissions**:
265+
[Grant](https://cloud.google.com/run/docs/securing/managing-access#service-add-principals)
266+
the `roles/run.invoker` IAM role on the Cloud
252267
Run service to the principal. This could be your `user account email` or a
253268
`service account`.
254269
2. **Configure Credentials**
@@ -260,14 +275,15 @@ For Toolbox servers hosted on Google Cloud (e.g., Cloud Run) and requiring
260275
3. **Connect to the Toolbox Server**
261276

262277
```python
278+
from toolbox_langchain import ToolboxClient
263279
from toolbox_core import auth_methods
264280

265281
auth_token_provider = auth_methods.aget_google_id_token # can also use sync method
266282
client = ToolboxClient(
267283
URL,
268284
client_headers={"Authorization": auth_token_provider},
269285
)
270-
tools = await client.load_toolset()
286+
tools = client.load_toolset()
271287

272288
# Now, you can use the client as usual.
273289
```
@@ -426,4 +442,4 @@ async def main():
426442

427443
if __name__ == "__main__":
428444
asyncio.run(main())
429-
```
445+
```

0 commit comments

Comments
 (0)