Ask chat completion to respond an empty string if it doesn't have an answer

With OpenAI.ChatCompletion, I am trying to summarise some titles related to given concepts.
Model: gpt-3.5-turbo
Temperature: 0.8
The rest of the values are default.

My prompt is like this:

Summarise the titles below, which are delimited with triple quotes, about the concept ‘Football’.
- Messi’s next challenge!!
- Transfer season in UK is just started!!
…(and so on…)

There are cases that the given text has no relation with the concept, according to API, and it answers such:
- There are no titles related to the given concept ‘Football’.

Instead of such an answer, I’d like to have an empty response. Therefore, I am adding a line in my prompt like:
If there are no titles related to the given concept found, do not output anything.

However, it still keeps returning the generic answer instead of an empty string.

How can I construct my prompt for this?

1 Like

Instead of telling it not to output, how about telling it to output something (e.g. NO-OUTPUT) in that case? Then just check for it.


I just tried with “EMPTY” meanwhile looking for answers and it worked!

If you want no response from model use “<|im_end|>”

1 Like

Also note one of these follows the directions without interjection…

1 Like