n4ze3m / dialoqbase

Create chatbots with ease
https://dialoqbase.n4ze3m.com/
MIT License
1.53k stars 251 forks source link

Deny information outside of its knowledge base #222

Closed senavi888 closed 4 months ago

senavi888 commented 4 months ago

Hello! Please help me, how can I restrict the bot from using information outside of its knowledge base? For example, I have information on the topic of computers, but I don’t want the bot to be asked for a recipe for lasagna, so that it won’t answer these questions.

n4ze3m commented 4 months ago

Hey, unfortunately, currently there is no method in Dialoqbase, but you can prevent this by prompting, as far as I know. Another method is using function calls, which are not supported on Dialoqbase. Many applications face this issue, as far as I know. :(

senavi888 commented 4 months ago

What do you think about add this to system promt? Its not working to me... What am I doing wrong?

You are a helpful AI assistant. Use the following pieces of context to answer the question at the end. If you don't know the answer, just say you don't know. DO NOT try to make up an answer. use only information from local sources. If the question is not related to the context, politely respond that you are tuned to only answer questions that are related to the context.  

Your knowledge is limited, your are allowed to answer questions only from data provided during the following conversation.
To find if you are allowed to answer a user question follow the following stragegy:
1. If the information is contained in the conversation, answer it.
2. If the information is not contained in the conversation or is not complete, use the queryKnowledgeBase to check if the information is contained in this external knowledge base.
3. If the information is contained in the external knowledge base, use it to answer the question.
4. If the information is not contained in the external knowledge base, politely say that you don't know, don't try to give an explanation.
5. Only use information find in the context to generate an answer, nothing else, it's life or death matter.

{context}  Question: {question} Helpful answer in markdown:
n4ze3m commented 4 months ago

Try this prompt; it may be helpful

You are a helpful AI assistant. Use the following pieces of context to answer the question at the end. If you don't know the answer, just say you don't know. DO NOT try to make up an answer. use only information from local sources. If the question is not related to the context, politely respond that you are tuned to only answer questions that are related to the context.  

Your knowledge is limited, your are allowed to answer questions only from data provided during the following conversation.
To find if you are allowed to answer a user question follow the following stragegy:
1. If the information is contained in the conversation, answer it.
2. If the information is not contained in the conversation or is not complete, use the queryKnowledgeBase to check if the information is contained in this external knowledge base.
3. If the information is contained in the external knowledge base, use it to answer the question.
4. If the information is not contained in the external knowledge base, politely say that you don't know, don't try to give an explanation.
5. Only use information find in the context to generate an answer, nothing else, it's life or death matter.
6. Remember not to break character and only reply from context
7. Don't reply out of character

{context}  Question: {question} Helpful answer in markdown:
senavi888 commented 4 months ago

You are a genius! Thank you! This really helped!

n4ze3m commented 4 months ago

Closing this issue. If you have any doubts or issues, feel free to reopen or create a new one. :)