Deprecated since 1.6.0
Use kimaai_chatbot_tool_call instead. It will be removed in 1.8.0.
When it fires
Right after kimaai_chatbot_tool_call, with the same arguments, but only when no callback of that filter answered the call. It still works, and WordPress gives its deprecation notice when a callback is hooked to it. Despite its name it is not limited to streamed answers. Move to kimaai_chatbot_tool_call at a priority below 10.
With KimaAI Pro it gets no calls: the tool router answers every tool on kimaai_chatbot_tool_call at priority 10, so the result is never null here. In the free version it runs for a tool that no callback of the new filter answered.
Parameters
| Name | Type | Description |
|---|---|---|
result | mixed | Null, or the result an earlier callback of this filter returned. |
name | string | The tool’s name. |
args | array | The arguments the model sent, decoded from JSON. |
payload | array | The same payload as in kimaai_chatbot_tool_call. |
Returns
mixed: Null to leave the call unanswered, else the tool’s result.
Example
add_filter(
'kimaai_stream_tool_call',
function ($result, string $name, array $args) {
if ($result !== null || $name !== 'my_gift_wrap_price') {
return $result;
}
return ['price' => '3.50 EUR', 'note' => 'Gift wrap is free on orders over 50 EUR.'];
},
10,
3
);
More examples
The same with kimaai_chatbot_tool_call, which also runs with KimaAI Pro:
add_filter(
'kimaai_chatbot_tool_call',
function ($result, string $name, array $args) {
if ($result !== null || $name !== 'my_gift_wrap_price') {
return $result;
}
return ['price' => '3.50 EUR', 'note' => 'Gift wrap is free on orders over 50 EUR.'];
},
5,
3
);
Related
kimaai_chatbot_tool_call: the replacement.