Update code style, prompt, and dependencies

.editorconfig: Add new code style preferences.
ChatService.cs: Add formatted question to prompt string.
VectorSearchService.cs: Remove TinyHelpers.Extensions using directive.
VectorSearchService.cs: Use paragraphs.Index() in foreach loop.
SqlDatabaseVectorSearch.csproj: Update target framework to net9.0.
SqlDatabaseVectorSearch.csproj: Update package references, remove TinyHelpers.
This commit is contained in:
Marco Minerva
2024-11-21 17:46:50 +01:00
parent b9bcb5c9fd
commit 232be6f083
4 changed files with 8 additions and 8 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:
--- ---
@@ -7,7 +7,6 @@ using Microsoft.SemanticKernel.Text;
using SqlDatabaseVectorSearch.DataAccessLayer; using SqlDatabaseVectorSearch.DataAccessLayer;
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;
using Entities = SqlDatabaseVectorSearch.DataAccessLayer.Entities; using Entities = SqlDatabaseVectorSearch.DataAccessLayer.Entities;
@@ -39,7 +38,7 @@ public class VectorSearchService(ApplicationDbContext dbContext, ITextEmbeddingG
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())
{ {
var documentChunk = new Entities.DocumentChunk { Document = document, Index = index, Content = paragraph!, Embedding = embeddings[index].ToArray() }; var documentChunk = new Entities.DocumentChunk { Document = document, Index = index, Content = paragraph!, Embedding = embeddings[index].ToArray() };
dbContext.DocumentChunks.Add(documentChunk); dbContext.DocumentChunks.Add(documentChunk);
@@ -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>
@@ -10,13 +10,12 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="EFCore.SqlServer.VectorSearch" Version="0.2.0" /> <PackageReference Include="EFCore.SqlServer.VectorSearch" Version="0.2.0" />
<PackageReference Include="EntityFrameworkCore.Exceptions.SqlServer" Version="8.1.3" /> <PackageReference Include="EntityFrameworkCore.Exceptions.SqlServer" Version="8.1.3" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.10" /> <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.10" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="[8.0.11, 9.0.0)" />
<PackageReference Include="Microsoft.SemanticKernel" Version="1.27.0" /> <PackageReference Include="Microsoft.SemanticKernel" Version="1.30.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>