Add Block Categories To which GPT Should not respond or send defualt response

I have implemented the GPT-4 model in my chat Flutter app. I want to set a predefined list of categories to be locked when a query is made so that GPT should not respond or send premade default text in its response.

I have made a list of words and made a function to iterate through words in the list (blocked words) that can be present in the query. If a word is found, query is not sent to GPT, and a default response is sent to the user. But I want to set predefined categories, not words, that the GPT should understand and respond to accordingly, as I have also implemented Parental Control, but that is not efficient. because it checks words in the list to block words, not categories.

Please let me know how I can achieve this in my Flutter app.
I’m looking forward to hearing from you.
Kind regards.

Hi. Someone will undoubtedly give you a better answer than this but this is how I would brute force it. I would add a ‘suffix’ to the prompt stating “”“Respond with “Null” if this request relates to the following topics. [List of topics]”“”, then add conditional logic based on if the response is Null or not.

You may add this to the prompt:

if you find the answer inappropriate for minors just answer with “I am sorry, but the generated content was flagged harmful”

Or you should have a look into this: