• Resolved igortitarenko

    (@igortitarenko)


    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}}

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter igortitarenko

    (@igortitarenko)

    I found those sneaky tabs in Settings section and turned on the debugging. Here is the new log. Still can’t detect the function name or extract function arguments as $reply->needFeedbacks is empty.

    [29-Jul-2025 00:54:22 UTC] [AI Engine Queries] ========================================
    [29-Jul-2025 00:54:22 UTC] [AI Engine Queries] Starting Meow_MWAI_Query_Text to gpt-4.1-nano
    [29-Jul-2025 00:54:22 UTC] [AI Engine Queries] Using Responses API
    [29-Jul-2025 00:54:22 UTC] [AI Engine Queries] Request URL: https://api.openai.com/v1/responses
    [29-Jul-2025 00:54:22 UTC] [AI Engine Queries] Request Body: {
    "model": "gpt-4.1-nano",
    "stream": true,
    "instructions": "On input \"test\" use function getCurrentUserInfo. Use \"John Doe\" as argument. Tell me, what the color of the day is.",
    "input": [
    {
    "role": "assistant",
    "content": "What is your product or service?"
    },
    {
    "role": "user",
    "content": [
    {
    "type": "input_text",
    "text": "test"
    }
    ]
    }
    ],
    "max_output_tokens": 16384,
    "temperature": 0.8000000000000000444089209850062616169452667236328125
    }
    [29-Jul-2025 00:54:22 UTC] [AI Engine Queries] No tools included in request
    [29-Jul-2025 00:54:22 UTC] [AI Engine Queries] --> Request to: https://api.openai.com/v1/responses
    [29-Jul-2025 00:54:22 UTC] {
    "model": "gpt-4.1-nano",
    "stream": true,
    "instructions": "On input \"test\" use function getCurrentUserInfo. Use \"John Doe\" as argument. Tell me, what the color of the day is.",
    "input": [
    {
    "role": "assistant",
    "content": "What is your product or service?"
    },
    {
    "role": "user",
    "content": [
    {
    "type": "input_text",
    "text": "test"
    }
    ]
    }
    ],
    "max_output_tokens": 16384,
    "temperature": 0.8000000000000000444089209850062616169452667236328125
    }
    [29-Jul-2025 00:54:22 UTC] [AI Engine Queries] Streaming from: https://api.openai.com/v1/responses
    [29-Jul-2025 00:54:22 UTC] [AI Engine Queries] Event: {"type":"response.created"}
    [29-Jul-2025 00:54:22 UTC] [AI Engine Queries] Event: {"type":"response.in_progress"}
    [29-Jul-2025 00:54:22 UTC] [AI Engine Queries] Event: {"type":"response.output_item.added","item_type":"message","name":null,"call_id":null}
    [29-Jul-2025 00:54:22 UTC] [AI Engine Queries] Event: {"type":"response.content_part.added"}
    [29-Jul-2025 00:54:22 UTC] [AI Engine Queries] Event: {"type":"response.output_text.delta"}
    [29-Jul-2025 00:54:22 UTC] [AI Engine Queries] Event: {"type":"response.output_text.delta"}
    [29-Jul-2025 00:54:22 UTC] [AI Engine Queries] Event: {"type":"response.output_text.delta"}
    [29-Jul-2025 00:54:22 UTC] [AI Engine Queries] Event: {"type":"response.output_text.delta"}
    [29-Jul-2025 00:54:22 UTC] [AI Engine Queries] Event: {"type":"response.output_text.delta"}
    [29-Jul-2025 00:54:22 UTC] [AI Engine Queries] Event: {"type":"response.output_text.delta"}
    [29-Jul-2025 00:54:22 UTC] [AI Engine Queries] Current streamToolCalls count: 0
    [29-Jul-2025 00:54:22 UTC] [AI Engine Queries] Output 0 type: message, status: completed
    [29-Jul-2025 00:54:23 UTC] [AI Engine Queries] Streaming Response Collected:
    [29-Jul-2025 00:54:23 UTC] {
    "id": "resp_68881bbe993c81a28d3b5a6e7d9759850907cf5bcb0d76aa",
    "model": "gpt-4.1-nano-2025-04-14",
    "content_length": 29,
    "content_preview": "The color of the day is blue.",
    "tool_calls": "none",
    "usage": {
    "input_tokens": null,
    "output_tokens": null,
    "cost": null
    }
    }
    [29-Jul-2025 00:54:23 UTC] MWAI_AI_REPLY Reply: {"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"}}
    [29-Jul-2025 00:54:23 UTC] MWAI_AI_REPLY Feedbacks: []
    [29-Jul-2025 00:54:23 UTC] MWAI_AI_REPLY Query: {"message":"test","instructions":"On input \"test\" use function getCurrentUserInfo. Use \"John Doe\" as argument. 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}}
    [29-Jul-2025 00:54:23 UTC] [AI Engine Queries] Query completed
    [29-Jul-2025 00:54:23 UTC] [AI Engine Queries] ========================================
    Thread Starter igortitarenko

    (@igortitarenko)

    Actually, I’m a bit of an idiot. I just read in the documentation, that Method 2 won’t appear in Chatbot GUI, but the bot will still be aware of the function.

    So, to summarize.
    Code Engine and Method 1 still don’t work for me.
    Method 2 works fine. The one just needs to stop skipping lines in documentation.

    • This reply was modified 5 months, 3 weeks ago by igortitarenko.
    Plugin Support Val Meow

    (@valwa)

    Hey @igortitarenko! 👋

    Function Calling is a PRO feature, and this forum is reserved for the free version of the plugin as per WordPress guidelines. Please contact us directly through your Meow Apps account if you’re experiencing an issue with the PRO version. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.