Topic/ Domain Specific Chatbot


I’m working on developing a chatbot on Langchain that provides responses specific to a particular topic. However, sometimes the bot produces answers that are off-topic. I’m looking for advice on how to optimize this.

You can add in your system prompt something like:

When the user asks for other topics unrelated to ${main_topic}, reply that you cannot answer.

This will be okay most of the times but there will be times it won’t so you might need a secondary filter, run the query with some classification prompt to check whether it is aligned with the topic or not using the cheapest model that can do the job.