Update code style, ChatService, VectorSearch, and .NET 9.0

Updated .editorconfig with new code style preferences.
Enhanced ChatService prompt string with a new directive.
Modified VectorSearchService using directives and tuple order.
Upgraded SqlDatabaseVectorSearch to target .NET 9.0 and updated packages.
This commit is contained in:
Marco Minerva
2024-11-21 17:51:35 +01:00
parent 3373fa42fe
commit aadab97133
4 changed files with 6 additions and 6 deletions
+1
View File
@@ -131,6 +131,7 @@ csharp_prefer_braces = true:silent
csharp_prefer_simple_using_statement = true:suggestion csharp_prefer_simple_using_statement = true:suggestion
csharp_style_namespace_declarations = file_scoped:suggestion csharp_style_namespace_declarations = file_scoped:suggestion
csharp_style_prefer_method_group_conversion = true:silent csharp_style_prefer_method_group_conversion = true:silent
csharp_prefer_system_threading_lock = true:suggestion
# Expression-level preferences # Expression-level preferences
csharp_prefer_simple_default_expression = true:suggestion csharp_prefer_simple_default_expression = true:suggestion
@@ -55,6 +55,7 @@ public class ChatService(IMemoryCache cache, IChatCompletionService chatCompleti
} }
prompt.AppendLine($""" prompt.AppendLine($"""
===== =====
Answer the following question: Answer the following question:
--- ---
@@ -9,7 +9,6 @@ using Microsoft.SemanticKernel.Embeddings;
using Microsoft.SemanticKernel.Text; using Microsoft.SemanticKernel.Text;
using SqlDatabaseVectorSearch.Models; using SqlDatabaseVectorSearch.Models;
using SqlDatabaseVectorSearch.Settings; using SqlDatabaseVectorSearch.Settings;
using TinyHelpers.Extensions;
using UglyToad.PdfPig; using UglyToad.PdfPig;
using UglyToad.PdfPig.DocumentLayoutAnalysis.TextExtractor; using UglyToad.PdfPig.DocumentLayoutAnalysis.TextExtractor;
@@ -45,7 +44,7 @@ public class VectorSearchService(SqlConnection sqlConnection, ITextEmbeddingGene
var embeddings = await textEmbeddingGenerationService.GenerateEmbeddingsAsync(paragraphs); var embeddings = await textEmbeddingGenerationService.GenerateEmbeddingsAsync(paragraphs);
// Save the document chunks and the corresponding embedding in the database. // Save the document chunks and the corresponding embedding in the database.
foreach (var (paragraph, index) in paragraphs.WithIndex()) foreach (var (index, paragraph) in paragraphs.Index())
{ {
await sqlConnection.ExecuteAsync($""" await sqlConnection.ExecuteAsync($"""
INSERT INTO DocumentChunks (DocumentId, [Index], Content, Embedding) INSERT INTO DocumentChunks (DocumentId, [Index], Content, Embedding)
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<NoWarn>$(NoWarn);SKEXP0001;SKEXP0010;SKEXP0050;</NoWarn> <NoWarn>$(NoWarn);SKEXP0001;SKEXP0010;SKEXP0050;</NoWarn>
@@ -9,13 +9,12 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Dapper" Version="2.1.35" /> <PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.10" /> <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" /> <PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
<PackageReference Include="Microsoft.SemanticKernel" Version="1.27.0" /> <PackageReference Include="Microsoft.SemanticKernel" Version="1.27.0" />
<PackageReference Include="MinimalHelpers.OpenApi" Version="2.0.17" /> <PackageReference Include="MinimalHelpers.OpenApi" Version="2.0.17" />
<PackageReference Include="PdfPig" Version="0.1.9" /> <PackageReference Include="PdfPig" Version="0.1.9" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.9.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="7.0.0" />
<PackageReference Include="TinyHelpers" Version="3.1.18" />
<PackageReference Include="TinyHelpers.AspNetCore" Version="3.1.19" /> <PackageReference Include="TinyHelpers.AspNetCore" Version="3.1.19" />
</ItemGroup> </ItemGroup>