Function calling issues
-
Hello.
AI Engine 2.9.5
Code Engine 0.3.5
WordPress 6.8.2
AI Engine Settings/General/Streaming is Enabled, Settings/General/Event Logs is Enabled.
mwai log in the /uploads/ folder is empty.I’m having a few issues with function calling.
1. I tried to use Code Engine plugin to set a Callable PHP function. Function test went fine, but the function does not appear in the Chatbot interface of AI Engine plugin.2. Using Method 1 and Method 2 as per documentation here (https://ai.thehiddendocs.com/use-function-calling/) doesn’t work for me.
A few weeks ago combining Method 2 of Part 1 and Method 1 of Part 2 allowed to set a mail sending function with PHP. Now that code doesn’t work.
What works now is combining Method 1 of Part 1 and Method 2 of Part 2. With a caveat: I cannot detect the call and have to change the chatbot feedback globally.mwai_ai_feedback filter pretty much doesn’t work. $reply->needFeedbacks array doesn’t exist.
Here is the code that currently works:
add_filter('mwai_functions_list', function ($functions) {
error_log('test mwai_functions_list');
$functions[] = Meow_MWAI_Query_Function::fromJson([
'id' => 'userInfo',
'type' => 'manual',
'name' => 'getCurrentUserInfo',
'desc' => 'Get the current user information.',
]);
return $functions;
}, 10, 1);
function getCurrentUserInfo()
{
return "Color of the day is grey with the shade of red";
}
add_filter('mwai_ai_feedback', function ($result, $function, $args) {
error_log('MWAI_AI_FEEDBACK Result: ' . json_encode($result));
error_log('MWAI_AI_FEEDBACK Function: ' . json_encode($function));
error_log('MWAI_AI_FEEDBACK Args: ' . json_encode($args));
return getCurrentUserInfo();
}, 10, 3);
add_filter('mwai_ai_reply', function ($reply, $query) {
error_log('MWAI_AI_REPLY Value: ' . json_encode($reply));
error_log('MWAI_AI_REPLY Query: ' . json_encode($query));
$reply->result = getCurrentUserInfo();
return $reply;
}, 10, 2);In WordPress debug log it returns the following:
[28-Jul-2025 23:51:49 UTC] MWAI_AI_REPLY Value: {"result":"The color of the day is blue.","results":["The color of the day is blue."],"usage":{"prompt_tokens":8,"completion_tokens":7,"total_tokens":15,"price":null,"queries":1},"system":{"class":"Meow_MWAI_Reply"}}
[28-Jul-2025 23:51:49 UTC] MWAI_AI_REPLY Query: {"message":"test","instructions":"On input \"test\" use function getCurrentUserInfo. Tell me, what the color of the day is.","ai":{"model":"gpt-4.1-nano","feature":"completion","maxTokens":16384,"temperature":0.8000000000000000444089209850062616169452667236328125},"system":{"class":"Meow_MWAI_Query_Text","envId":"xxx","scope":"chatbot","session":"xxx","maxMessages":15}}
You must be logged in to reply to this topic.