Skip to content

Commit 6484abd

Browse files
authored
doc: Improve docstrings for toolbox-langchain methods. (#172)
* doc: Improve docstrings for toolbox-langchain methods. * doc: Fix grammatical errors
1 parent 14bc4ee commit 6484abd

File tree

2 files changed

+38
-33
lines changed

2 files changed

+38
-33
lines changed

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

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(
6262
bound_params: A mapping of parameter names to their bound
6363
values.
6464
strict: If True, raises a ValueError if any of the given bound
65-
parameters are missing from the schema or require
65+
parameters is missing from the schema or requires
6666
authentication. If False, only issues a warning.
6767
"""
6868

@@ -260,7 +260,7 @@ def __create_copy(
260260
bound values or functions to retrieve the values. These params
261261
will be merged with the existing bound params.
262262
strict: If True, raises a ValueError if any of the given bound
263-
parameters are missing from the schema or require
263+
parameters is missing from the schema or requires
264264
authentication. If False, only issues a warning.
265265
266266
Returns:
@@ -297,16 +297,18 @@ def add_auth_tokens(
297297
auth_tokens: A dictionary of authentication source names to the
298298
functions that return corresponding ID token.
299299
strict: If True, a ValueError is raised if any of the provided auth
300-
tokens are already bound. If False, only a warning is issued.
300+
parameters is already bound. If False, only a warning is issued.
301301
302302
Returns:
303303
A new AsyncToolboxTool instance that is a deep copy of the current
304304
instance, with added auth tokens.
305305
306306
Raises:
307-
ValueError: If the provided auth tokens are already registered.
308-
ValueError: If the provided auth tokens are already bound and strict
309-
is True.
307+
ValueError: If any of the provided auth parameters is already
308+
registered.
309+
ValueError: If any of the provided auth parameters is already bound
310+
and strict is True.
311+
310312
"""
311313

312314
# Check if the authentication source is already registered.
@@ -332,17 +334,17 @@ def add_auth_token(
332334
Args:
333335
auth_source: The name of the authentication source.
334336
get_id_token: A function that returns the ID token.
335-
strict: If True, a ValueError is raised if any of the provided auth
336-
token is already bound. If False, only a warning is issued.
337+
strict: If True, a ValueError is raised if the provided auth
338+
parameter is already bound. If False, only a warning is issued.
337339
338340
Returns:
339341
A new ToolboxTool instance that is a deep copy of the current
340342
instance, with added auth token.
341343
342344
Raises:
343-
ValueError: If the provided auth token is already registered.
344-
ValueError: If the provided auth token is already bound and strict
345-
is True.
345+
ValueError: If the provided auth parameter is already registered.
346+
ValueError: If the provided auth parameter is already bound and
347+
strict is True.
346348
"""
347349
return self.add_auth_tokens({auth_source: get_id_token}, strict=strict)
348350

@@ -359,17 +361,18 @@ def bind_params(
359361
bound_params: A dictionary of the bound parameter name to the
360362
value or function of the bound value.
361363
strict: If True, a ValueError is raised if any of the provided bound
362-
params are not defined in the tool's schema, or require
364+
params is not defined in the tool's schema, or requires
363365
authentication. If False, only a warning is issued.
364366
365367
Returns:
366368
A new AsyncToolboxTool instance that is a deep copy of the current
367369
instance, with added bound params.
368370
369371
Raises:
370-
ValueError: If the provided bound params are already bound.
371-
ValueError: if the provided bound params are not defined in the tool's schema, or require
372-
authentication, and strict is True.
372+
ValueError: If any of the provided bound params is already bound.
373+
ValueError: if any of the provided bound params is not defined in
374+
the tool's schema, or requires authentication, and strict is
375+
True.
373376
"""
374377

375378
# Check if the parameter is already bound.
@@ -399,9 +402,9 @@ def bind_param(
399402
param_name: The name of the bound parameter.
400403
param_value: The value of the bound parameter, or a callable that
401404
returns the value.
402-
strict: If True, a ValueError is raised if any of the provided bound
403-
params is not defined in the tool's schema, or requires
404-
authentication. If False, only a warning is issued.
405+
strict: If True, a ValueError is raised if the provided bound param
406+
is not defined in the tool's schema, or requires authentication.
407+
If False, only a warning is issued.
405408
406409
Returns:
407410
A new ToolboxTool instance that is a deep copy of the current

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

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,17 @@ def add_auth_tokens(
9494
auth_tokens: A dictionary of authentication source names to the
9595
functions that return corresponding ID token.
9696
strict: If True, a ValueError is raised if any of the provided auth
97-
tokens are already bound. If False, only a warning is issued.
97+
parameters is already bound. If False, only a warning is issued.
9898
9999
Returns:
100100
A new ToolboxTool instance that is a deep copy of the current
101101
instance, with added auth tokens.
102102
103103
Raises:
104-
ValueError: If the provided auth tokens are already registered.
105-
ValueError: If the provided auth tokens are already bound and strict
106-
is True.
104+
ValueError: If any of the provided auth parameters is already
105+
registered.
106+
ValueError: If any of the provided auth parameters is already bound
107+
and strict is True.
107108
"""
108109
return ToolboxTool(
109110
self.__async_tool.add_auth_tokens(auth_tokens, strict),
@@ -121,17 +122,17 @@ def add_auth_token(
121122
Args:
122123
auth_source: The name of the authentication source.
123124
get_id_token: A function that returns the ID token.
124-
strict: If True, a ValueError is raised if any of the provided auth
125-
token is already bound. If False, only a warning is issued.
125+
strict: If True, a ValueError is raised if the provided auth
126+
parameter is already bound. If False, only a warning is issued.
126127
127128
Returns:
128129
A new ToolboxTool instance that is a deep copy of the current
129130
instance, with added auth token.
130131
131132
Raises:
132-
ValueError: If the provided auth token is already registered.
133-
ValueError: If the provided auth token is already bound and strict
134-
is True.
133+
ValueError: If the provided auth parameter is already registered.
134+
ValueError: If the provided auth parameter is already bound and
135+
strict is True.
135136
"""
136137
return ToolboxTool(
137138
self.__async_tool.add_auth_token(auth_source, get_id_token, strict),
@@ -152,17 +153,18 @@ def bind_params(
152153
bound_params: A dictionary of the bound parameter name to the
153154
value or function of the bound value.
154155
strict: If True, a ValueError is raised if any of the provided bound
155-
params are not defined in the tool's schema, or require
156+
params is not defined in the tool's schema, or requires
156157
authentication. If False, only a warning is issued.
157158
158159
Returns:
159160
A new ToolboxTool instance that is a deep copy of the current
160161
instance, with added bound params.
161162
162163
Raises:
163-
ValueError: If the provided bound params are already bound.
164-
ValueError: if the provided bound params are not defined in the tool's schema, or require
165-
authentication, and strict is True.
164+
ValueError: If any of the provided bound params is already bound.
165+
ValueError: if any of the provided bound params is not defined in
166+
the tool's schema, or require authentication, and strict is
167+
True.
166168
"""
167169
return ToolboxTool(
168170
self.__async_tool.bind_params(bound_params, strict),
@@ -184,8 +186,8 @@ def bind_param(
184186
param_name: The name of the bound parameter.
185187
param_value: The value of the bound parameter, or a callable that
186188
returns the value.
187-
strict: If True, a ValueError is raised if any of the provided bound
188-
params is not defined in the tool's schema, or requires
189+
strict: If True, a ValueError is raised if the provided bound
190+
param is not defined in the tool's schema, or requires
189191
authentication. If False, only a warning is issued.
190192
191193
Returns:

0 commit comments

Comments
 (0)