From c9c5b74e7596c431c479f10d8c2edf50c1b1b65d Mon Sep 17 00:00:00 2001 From: Marco Minerva Date: Tue, 10 Jun 2025 12:19:37 +0200 Subject: [PATCH] Update response guidelines in ChatService class Modified response examples and citation rules in ChatService.cs. Changed context from France to Italy, added conditions for including citations, and emphasized formatting requirements. Updated examples to ensure compliance with new guidelines. --- .../Services/ChatService.cs | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/SqlDatabaseVectorSearch/Services/ChatService.cs b/SqlDatabaseVectorSearch/Services/ChatService.cs index 9380f1f..6bb3fde 100644 --- a/SqlDatabaseVectorSearch/Services/ChatService.cs +++ b/SqlDatabaseVectorSearch/Services/ChatService.cs @@ -116,7 +116,7 @@ public class ChatService(IChatCompletionService chatCompletionService, Tokenizer var chat = new ChatHistory(""" You can use only the information provided in this chat to answer questions. If you don't know the answer, reply suggesting to refine the question. - For example, if the user asks "What is the capital of France?" and in this chat there isn't information about France, you should reply something like: + For example, if the user asks "What is the capital of Italy?" and in this chat there isn't information about Italy, you should reply something like: - This information isn't available in the given context - I'm sorry, I don't know the answer to that question - I don't have that information @@ -127,7 +127,7 @@ public class ChatService(IChatCompletionService chatCompletionService, Tokenizer Never answer questions that are not related to this chat. You must answer in the same language as the user's question. For example, if the user asks a question in English, the answer must be in English, no matter the language of the documents. - After the answer, you need to include citations following the XML format below: + After the answer, you need to include citations following the XML format below ONLY IF you know the answer and are providing information from the context. If you do NOT know the answer, DO NOT include the citations section at all. 【exact quote here exact quote here】 @@ -142,23 +142,28 @@ public class ChatService(IChatCompletionService chatCompletionService, Tokenizer 5. NEVER reference citations by number or mention them in your answer text. 6. The citations MUST ALWAYS follow the XML format exactly as shown below. Any other format is NOT ACCEPTED. 7. If you add anything after the citations block, your answer will be considered invalid. + 8. If you do NOT know the answer, DO NOT include the citations block at all. --- Example of a correct answer: - The capital of France is Paris. - 【capital of France is Paris】 + The capital of Italy is Rome. + 【capital of Italy is Rome】 + + Example of a correct answer when you do NOT know the answer: + I'm sorry, I don't know the answer to that question Example of an incorrect answer (NOT ACCEPTED): - The capital of France is Paris. - 【capital of France is Paris】 + The capital of Italy is Rome. + 【capital of Italy is Rome】 Thank you for your question. Another incorrect example (NOT ACCEPTED): - The capital of France is Paris. - 【capital of France is Paris】 - [1] france.pdf, page 1 + The capital of Italy is Rome. + 【capital of Italy is Rome】 + [1] italy.pdf, page 1 --- Only the correct format is accepted. If you do not follow the XML format exactly, or if you add anything after the citations block, your answer will be considered invalid. + If you do NOT know the answer, DO NOT include the citations block at all. """); var prompt = new StringBuilder($"""