• Resolved samiinkinen

    (@samiinkinen)


    AI Engine seems to work perfectly, very easy setup. But the API documentation, especially for the client-side JS part, is fairly limited. I’m trying to use the “system” role in prompt to include guidance for OpenAI API, inserting dynamic content on-the-fly, but no success so far:
    1. Seems that only ai.reply is available for client-side JS, not ai.query?
    2. I made a workaround to tap to fetch API and modify the body content before the request is sent, but it is not clear how that should be modified. Following instructions that ChatGPT gave me, I added “system”:”My guidance string” to the body object, but that did not seem to work. Is there such a parameter as “system”, or should I modify the “messages” array?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Val Meow

    (@valwa)

    Hey @samiinkinen! ??

    The front-end API can only help you manipulate what’s on the client side, such as the already received data and interactions with the chatbot element. If you want to modify the parameters of the query as it is processed by the server before being sent to OpenAI, you can use WordPress AI Engine filters, like mwai_ai_query( $query ), for instance.

    Learn more here: API & Filters | Meow Apps

    Thread Starter samiinkinen

    (@samiinkinen)

    Hey Val!

    Thanks for reply! Yes I did notice the WP filters, but I was wondering whether this could also be done in the front-end, as the data that I wanted to use for dynamic prompting is available there. Anyway, the JS ai.reply is very useful, I’m already using it. I may replace the dynamic prompting by using direct fine-tuning to OpenAI API, but I’ll have to investigate it a bit more.

    Thread Starter samiinkinen

    (@samiinkinen)

    Hey Val!

    A further question related to the WP filters: I started writing a function to save query/reply pair to wpdb, but first I tested:

    add_filter( ‘mwai_ai_reply’, function( $reply, $query ) {
    return $reply;
    } );

    But this always gives the error “Could not parse the buffer”. Why is that, or don’t these filters work when streaming is enabled?

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.