Improve README, add comments, and clean up VectorSearchService

Updated README.md for clarity and additional setup instructions:
- Refined repository description to highlight native Vector type.
- Rephrased note on Vector Support feature for readability.
- Removed mention of EFCore.SqlServer.VectorSearch library.
- Added instructions for updating VECTOR column size and setting Dimension property.

Added comment in Scripts.sql to guide vector size setting in Embedding column.

Cleaned up VectorSearchService.cs by removing unused and commented-out SQL command execution code.
This commit is contained in:
Marco Minerva
2024-10-01 17:35:59 +02:00
parent 1b2ebbd6a3
commit 8c6cc3c969
3 changed files with 10 additions and 28 deletions
@@ -139,27 +139,6 @@ public class VectorSearchService(SqlConnection sqlConnection, ITextEmbeddingGene
ORDER BY VECTOR_DISTANCE('cosine', Embedding, CAST(@QuestionEmbedding AS VECTOR({questionEmbedding.Length})));
""", new { appSettings.MaxRelevantChunks, QuestionEmbedding = JsonSerializer.Serialize(questionEmbedding) });
//await sqlConnection.OpenAsync();
//await using var command = sqlConnection.CreateCommand();
//command.CommandText = $"""
// SELECT TOP (@MaxRelevantChunks) Content
// FROM DocumentChunks
// ORDER BY VECTOR_DISTANCE('cosine', Embedding, CAST(@QuestionEmbedding AS VECTOR({questionEmbedding.Length})));
// """;
//command.Parameters.AddWithValue("@MaxRelevantChunks", appSettings.MaxRelevantChunks);
//command.Parameters.AddWithValue("@QuestionEmbedding", JsonSerializer.Serialize(questionEmbedding));
//var chunks = new List<string>();
//await using var reader = await command.ExecuteReaderAsync();
//while (await reader.ReadAsync())
//{
// var content = reader.GetString(0);
// chunks.Add(content);
//}
var answer = await chatService.AskQuestionAsync(question.ConversationId, chunks, reformulatedQuestion);
return new Response(reformulatedQuestion, answer);
}