A toolkit with its handlers: handle runs a tool call.
Attributes#
| Attribute | Type | Description |
|---|---|---|
tools | Mapping[str, AnyTool] | |
services | Context[Any] = field(repr=False) |
Functions#
__init__#
__init__(tools, services) -> None| Parameter | Type | Description |
|---|---|---|
tools | Mapping[str, AnyTool] | |
services | Context[Any] |
handle#
handle(name, params, tool_call_id=None, options=None) -> Effect[Stream[HandlerResult, HE_co | AiError, R_co], AiError, R_co]The results of calling the tool name with params (as the
model sent them, decoded with options): preliminary values, then
the final one. Invalid parameters, a handler failure or an invalid
result fail the stream in "error" mode and are a failed result in
"return" mode.
| Parameter | Type | Description |
|---|---|---|
name | str | |
params | object | |
tool_call_id | str | None = None | |
options | S.ParseOptions | None = None |
Returns Effect[Stream[HandlerResult, HE_co | AiError, R_co], AiError, R_co]
def handle(
self,
name: str,
params: object,
tool_call_id: str | None = None,
options: S.ParseOptions | None = None,
) -> Effect[Stream[HandlerResult, HE_co | AiError, R_co], AiError, R_co]:
"""The results of calling the tool ``name`` with ``params`` (as the
model sent them, decoded with ``options``): preliminary values, then
the final one. Invalid parameters, a handler failure or an invalid
result fail the stream in ``"error"`` mode and are a failed result in
``"return"`` mode."""
return cast("Any", _handle(self, name, params, tool_call_id, options or {}))