Managing Limits

First, you need to enable the Insights feature. Go to the dashboard of AI Engine and check the corresponding option:

Notion Image

This will add a new tab in AI Engine settings. Now you can go to the “Insights” tab. Here, you will find a list of all the queries that are being made to your chatbot. You can also set limits here.

By the way, if you want to see the logs of any of these queries, you will need to go to the “Settings” tab and enable the “Queries Data” option.

Once you have enabled the limits, you have different settings that you can tweak, such as the number and type of credits (Queries, Tokens, and Dollars). You can also set the timeframe for each of these limits to reset.

Notion Image

Be careful, there are three different settings tabs here: User, Guests, and System. Take a look at the message that will be sent by the chatbot when the user reaches its limit for each of those.

The “System” setting will apply to every type of user. It’s kind of like your website’s maximum limit, so make sure to set this up correctly as well.

Notion Image
Notion Image

If you want to customize the limits based on your users’ roles or any meta data please refer to our documentation on the matter : https://meowapps.com/ai-engine/faq/#limits-users-customers

How to check user’s usage

The usage is not a value you can see directly, as it’s not a meta that’s stored per user—it’s calculated on the fly whenever your user makes a query. The system compares the number of queries in the user’s history to the max credits allowed over the specified timeframe.

You can visualize that by using the following shortcodes:

[mwai_stats display="debug"]
[mwai_stats_current display="usage"]
Notion Image

Non credits limitation

If you are looking for ways to block access from different parameters, such as time (only available from 2 p.m to 4 p.m), currently, there are no out-of-the-box features to accomplish this. However, you can achieve it yourself by using AI Engine filters. By using the mwai_ai_allowed($allowed, $query, $limits) function, you can check the timing of the user’s query and return an error message if the timeframe is not suitable for you.

You can also come up with a solution on the client side. Using JavaScript, you can check the current time and then select the chatbot using its ID to disable it. You can do this by either hiding it or disabling the input with CSS, or even deleting the DOM element.

Can I use a membership plugin?

You can define a limit on the number of credits (queries, tokens, or dollars) a user can spend over a given time frame (month, day, year). When a query is made, the plugin checks the history of queries during that period and verifies whether the number of queries, tokens, or dollars exceeds the chosen value. That’s it.

The plugin doesn’t need to know whether you’re using a third-party plugin to manage roles or access—it just needs to know the number of credits you allow to be used. This value can be dynamically adjusted using filters:

  • mwai_stats_credits($credits, $userId) → modifies the number of credits (allows you to create your own system)
  • mwai_stats_coins($price, $stats, $atts) → modifies the coins (lets you convert the price you personally pay to OpenAI into your own system of coins that you share with your users)

So in your case, you can use the mwai_stats_credits filter to fetch the user’s metadata and return its value. This will override the credits you set manually in the Limits settings. Then, when the plugin checks the query history over the timeframe, it will compare the number of credits (X—your WooCommerce metadata) against the credits used in recent queries.

Let’s assume your user has a corresponding “custom_credits” value. When a user purchases credits, you just need to add them to this number.

add_filter( 'mwai_stats_credits', function ( $credits, $userId ) {
    $user = get_userdata( $userId );
    if ( !empty( $user->custom_credits ) ) {
        $credits = $user->custom_credits;
    }

    return $credits;
}, 10, 2);

Go read our documentation over there : FAQ | Meow Apps ! 🐈

Soon, the AI Engine will propose a new system for the Timeframes, which will make it easier for you to create subscription logics:

Rolling Window: Limits are based on the queries made in the preceding period, continuously updating. For example, within the last day up to the current moment. Ideal to avoid sudden spikes in number of queries.

Fixed Window: Limits are based on a defined calendar period, resetting at the start of each new period. For instance, limits reset daily at midnight. Ideal for predictable usage patterns.

Subscription Window: Limits reset based on the anniversary of the user’s first query, e.g., monthly on the same day as the first ever query. This day can be overriden through a WordPress filter. Ideal for subscription-based services.

Assistants (OpenAI)

GPTs are custom models (like the assistants) but they are solely usable on OpenAI’s website. Assistants let you create custom models and use them as you want, using an API like AI Engine does. You can of course use GPT-4 to create your own assistants.

First, you will need to access the AI Engine dashboard and, under the “Server Modules” tab, enable the Assistants feature.

Notion Image

This action will generate a new tab where you can view all of your OpenAI assistants.

Notion Image

To create them, head to the OpenAI Assistants dashboard.

Notion Image

Once you’ve created one or have some assistants ready, return to the AI Engine Assistants tab and click the refresh button in the top right corner. You should see it/them appear in the table.

Notion Image

There’s no need to return to this tab anymore. Now that the assistant is available, let’s proceed to use it!

If you don’t see your assistants after refreshing the list, make sure that your server can communicate with OpenAI and that your WordPress REST API is operational and you have the right permalinks configured.

For this, navigate to the chatbot tab where you operate your regular chatbots for AI Engine. Select or create a new chatbot, and in the Main Setting section, you will be able to change the chatbot mode to assistant.

Notion Image
Notion Image

And it’s done! You are now using your OpenAI assistant directly within AI Engine. Have fun! 😊

Organizations’ assistants

You can connect to your OpenAI account and go to the API Keys section to select your default organization. If it’s already the case, switch to personal, confirm the dialog box, and switch back to your organization to reset. Then, you’ll need to create a new API Key so that the header matches. Once this is done, you can refresh the assistant in AI Engine, and you should see it appear! 😊

Notion Image