diff --git a/SqlDatabaseVectorSearch/ContentDecoders/IContentDecoder.cs b/SqlDatabaseVectorSearch/ContentDecoders/IContentDecoder.cs index 4fc8293..7cce285 100644 --- a/SqlDatabaseVectorSearch/ContentDecoders/IContentDecoder.cs +++ b/SqlDatabaseVectorSearch/ContentDecoders/IContentDecoder.cs @@ -5,4 +5,4 @@ public interface IContentDecoder Task> DecodeAsync(Stream stream, string contentType, CancellationToken cancellationToken = default); } -public record class Chunk(int PageNumber, int IndexOnPage, string Content); \ No newline at end of file +public record class Chunk(int? PageNumber, int IndexOnPage, string Content); \ No newline at end of file diff --git a/SqlDatabaseVectorSearch/ContentDecoders/TextContentDecoder.cs b/SqlDatabaseVectorSearch/ContentDecoders/TextContentDecoder.cs index d03e32f..29e76f1 100644 --- a/SqlDatabaseVectorSearch/ContentDecoders/TextContentDecoder.cs +++ b/SqlDatabaseVectorSearch/ContentDecoders/TextContentDecoder.cs @@ -12,6 +12,6 @@ public class TextContentDecoder(IServiceProvider serviceProvider) : IContentDeco var content = await readStream.ReadToEndAsync(cancellationToken); var paragraphs = textChunker.Split(content); - return paragraphs.Select((text, index) => new Chunk(1, index, text)).ToList(); + return paragraphs.Select((text, index) => new Chunk(null, index, text)).ToList(); } } diff --git a/SqlDatabaseVectorSearch/Services/ChatService.cs b/SqlDatabaseVectorSearch/Services/ChatService.cs index cc19d8a..4269efa 100644 --- a/SqlDatabaseVectorSearch/Services/ChatService.cs +++ b/SqlDatabaseVectorSearch/Services/ChatService.cs @@ -127,23 +127,12 @@ 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. - IMPORTANT - CITATION PLACEMENT AND LENGTH: The quote in each MUST be MAXIMUM 5 words, taken word-for-word from the search result. If the quote is longer than 5 words, your answer is INVALID. When you find an answer, you MUST place ALL citations ONLY at the very end of your response, never inside or between sentences. - First provide your complete answer, then add a blank line, then list all citations. + First provide your complete answer, then list all citations. Use this XML format for citations: exact quote here - - STRICT RULES for citations: - - Citations MUST NEVER appear inside, before, or between sentences of your answer. They MUST be grouped together ONLY at the end, after a blank line. - - If you include citations anywhere except at the end, your answer is WRONG and INVALID. - - Always include the citation(s) if there are results. If you don't know the answer, do NOT include citations. - - The quote must be max 5 words, taken word-for-word from the search result, and is the basis for why the citation is relevant. If the quote is longer than 5 words, your answer is INVALID. - - Do NOT refer to the presence of citations; just emit these tags right at the end, with no surrounding text. - - The citations must always be in a list at the end of the response, one after the other. Never add the citations between the actual response text or inside sentences. - - Do NOT add any text after the citations. - - ALWAYS leave a blank line between your answer and the first citation. """); var prompt = new StringBuilder($""" diff --git a/SqlDatabaseVectorSearch/Validators/QuestionValidator.cs b/SqlDatabaseVectorSearch/Validations/QuestionValidator.cs similarity index 84% rename from SqlDatabaseVectorSearch/Validators/QuestionValidator.cs rename to SqlDatabaseVectorSearch/Validations/QuestionValidator.cs index 538f654..c0fa740 100644 --- a/SqlDatabaseVectorSearch/Validators/QuestionValidator.cs +++ b/SqlDatabaseVectorSearch/Validations/QuestionValidator.cs @@ -1,7 +1,7 @@ using FluentValidation; using SqlDatabaseVectorSearch.Models; -namespace SqlDatabaseVectorSearch.Validators; +namespace SqlDatabaseVectorSearch.Validations; public class QuestionValidator : AbstractValidator {