You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhance language handling and formatting in ChatService
Updated system prompts in ChatService to emphasize that responses must match the user's question language. Added formatting requirements for answers, including the need for a period before citations. Clarified citation format and adjusted prompt construction for improved readability.
Copy file name to clipboardExpand all lines: SqlDatabaseVectorSearch/Services/ChatService.cs
+7-5Lines changed: 7 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,8 @@ public class ChatService(IChatCompletionService chatCompletionService, Tokenizer
19
19
You are a helpful assistant that reformulates questions to perform embeddings search.
20
20
Your task is to reformulate the question taking into account the context of the chat.
21
21
The reformulated question must always explicitly contain the subject of the question.
22
-
You must reformulate the question in the same language of the user's question. For example, if the user asks a question in English, the answer must be in English.
22
+
You MUST reformulate the question in the SAME language as the user's question. For example, if the user asks a question in English, the reformulated question MUST be in English. If the user asks in Italian, the reformulated question MUST be in Italian.
23
+
23
24
Never add "in this chat", "in the context of this chat", "in the context of our conversation", "search for" or something like that in your answer.
24
25
""";
25
26
@@ -35,15 +36,16 @@ The reformulated question must always explicitly contain the subject of the ques
35
36
- I'm sorry, I don't have enough information to answer that question.
36
37
37
38
Never answer questions that are not related to this chat.
38
-
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.
39
+
40
+
LANGUAGE RULE: You MUST ALWAYS 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. If the user asks in Italian, the answer MUST be in Italian. This rule applies NO MATTER what language the documents are written in. The language of your response must match the language of the question, NOT the language of the documents.
39
41
40
42
FORMATTING REQUIREMENT: Your answer MUST ALWAYS end with a period followed by a space before the citations block.
41
43
If your answer doesn't naturally end with a period, you MUST add one followed by a space.
42
44
43
45
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.
0 commit comments