Skip to content

Commit 523fac2

Browse files
committed
Enhance response formatting in ChatService
Updated response guidelines in ChatService.cs to clarify requirements for answer formatting, including citation rules and examples of correct and incorrect responses. Binary differences noted in SqlDatabaseVectorSearch_WebApp.png, indicating modifications to the image file.
1 parent 13c0bee commit 523fac2

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

SqlDatabaseVectorSearch/Services/ChatService.cs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,18 @@ private ChatHistory CreateChatAsync(IEnumerable<Entities.DocumentChunk> chunks,
117117
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.
118118
119119
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:
120-
- This information isn't available in the given context
121-
- I'm sorry, I don't know the answer to that question
122-
- I don't have that information
123-
- I don't know
124-
- Given the context, I can't answer that question
125-
- I'm sorry, I don't have enough information to answer that question
120+
- This information isn't available in the given context.
121+
- I'm sorry, I don't know the answer to that question.
122+
- I don't have that information.
123+
- I don't know.
124+
- Given the context, I can't answer that question.
125+
- I'm sorry, I don't have enough information to answer that question.
126126
127127
Never answer questions that are not related to this chat.
128128
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.
129129
130-
IMPORTANT: Your answer must always end with a period and a space.
130+
FORMATTING REQUIREMENT: Your answer MUST ALWAYS end with a period followed by a space before the citations block.
131+
If your answer doesn't naturally end with a period, you MUST add one followed by a space.
131132
132133
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.
133134
@@ -146,27 +147,30 @@ 5. NEVER reference citations by number or mention them in your answer text.
146147
6. The citations MUST ALWAYS follow the XML format exactly as shown below. Any other format is NOT ACCEPTED.
147148
7. If you add anything after the citations block, your answer will be considered invalid.
148149
8. If you do NOT know the answer, DO NOT include the citations block at all.
150+
9. ALWAYS check that your answer ends with a period followed by a space before adding citations.
149151
150152
---
151153
Example of a correct answer:
152154
The capital of Italy is Rome.
153155
【<citation document-id="123" chunk-id="456" filename="italy.pdf" page-number="1" index-on-page="1">capital of Italy is Rome</citation>】
154-
156+
155157
Example of a correct answer when you do NOT know the answer:
156-
I'm sorry, I don't know the answer to that question
157-
158+
I'm sorry, I don't know the answer to that question.
159+
158160
Example of an incorrect answer (NOT ACCEPTED):
159-
The capital of Italy is Rome.
161+
The capital of Italy is Rome
160162
【<citation document-id="123" chunk-id="456" filename="italy.pdf" page-number="1" index-on-page="1">capital of Italy is Rome</citation>】
161163
Thank you for your question.
162-
164+
163165
Another incorrect example (NOT ACCEPTED):
164166
The capital of Italy is Rome.
165167
【<citation document-id="123" chunk-id="456" filename="italy.pdf" page-number="1" index-on-page="1">capital of Italy is Rome</citation>】
166168
[1] italy.pdf, page 1
167169
---
170+
168171
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.
169172
If you do NOT know the answer, DO NOT include the citations block at all.
173+
Remember to ALWAYS end your answer with a period followed by a space before adding citations.
170174
""");
171175

172176
var prompt = new StringBuilder($"""
34 KB
Loading

0 commit comments

Comments
 (0)