From 06c1741f14062239c5f3987a8a246ca1d24145da Mon Sep 17 00:00:00 2001 From: Marco Minerva Date: Tue, 24 Jun 2025 14:53:14 +0200 Subject: [PATCH] Enforce response formatting in ChatService Updated the ChatService class to require that all responses end with a period and a space. Added a condition to include citations in a specified XML format when the answer is known, and to omit citations when the answer is unknown. --- SqlDatabaseVectorSearch/Services/ChatService.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SqlDatabaseVectorSearch/Services/ChatService.cs b/SqlDatabaseVectorSearch/Services/ChatService.cs index 6bb3fde..943edbb 100644 --- a/SqlDatabaseVectorSearch/Services/ChatService.cs +++ b/SqlDatabaseVectorSearch/Services/ChatService.cs @@ -127,7 +127,10 @@ 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. + IMPORTANT: Your answer must always end with a period and a space. + 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