You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(langchain-sdk)!: Migrate existing state and APIs to a tools level class. (#171)
# `ToolboxTool` Class
The newly implemented `ToolboxTool` class manages tool state and
supports features like bound params and OAuth.
We have also added the logic as well as state related to bound params to
`ToolboxTool` in #192.
`ToolboxTool` follows a functional approach, meaning it ensures that the
internal tool state remains unchanged and a new copy of the tool is
updated with the new values of auth tokens (or bound params from #192).
## `ToolboxTool` Class Diagram
To better explain, here's a visual diagram of the ToolboxTool class.
The boxes have member function names, and the "red" box means a function
is mutating the internal state, while "green" means it does not change
the internal state (like a C++ `const` function or JS immutable
function). The red box also shows the member variable they mutated.

## Constructor
From the diagram above, it is evident that all the state changes, or
rather setting of the state, is done in the class constructor.
For further reference, here's a visual explanation of the functionality
of the constructor showing which params we add as auth tokens, which
params we add to the underlying schema, and for what the error/warnings
are thrown.

> [!NOTE]
> Documentation updates are done by #193 and the corresponding changes
to the LlamaIndex SDK are done by #203.
# These parameters are removed from the manifest to prevent data
182
-
# validation errors since their values are inferred by the
183
-
# Toolbox service, not provided by the user.
184
-
#
185
-
# Store the permitted authentication sources for each parameter
186
-
# in '_tool_param_auth' for efficient validation in
187
-
# '_validate_auth'.
188
-
ifnotparam.authSources:
189
-
non_auth_params.append(param)
190
-
continue
191
-
192
-
self._tool_param_auth.setdefault(tool_name, {})[
193
-
param.name
194
-
] =param.authSources
195
-
196
-
tool_schema.parameters=non_auth_params
197
-
198
-
# If none of the permitted auth sources of a parameter are
199
-
# registered, raise a warning message to the user.
200
-
ifnotself._validate_auth(tool_name):
201
-
warn(
202
-
f"Some parameters of tool {tool_name} require authentication, but no valid auth sources are registered. Please register the required sources before use."
203
-
)
204
-
205
-
@deprecated("Please use `add_auth_token` instead.")
0 commit comments