From ec5bf2acb2a44c516019455222dda0a194e7d44c Mon Sep 17 00:00:00 2001 From: Marco Minerva Date: Wed, 26 Feb 2025 10:36:50 +0100 Subject: [PATCH] Update Home.razor and project dependencies Refactor Home.razor to replace markdown loading with static HTML content for the SQL Database Vector Search application, including a main heading and feature list. Remove the IWebHostEnvironment dependency. Upgrade package references in SqlDatabaseVectorSearch.csproj for Microsoft.ML.Tokenizers and Microsoft.SemanticKernel. Revise docs.md to focus on supported features instead of setup instructions. Add new SVG files (openai.svg and sqldatabase.svg) for application icons. --- .../Components/Pages/Home.razor | 46 ++++++------------- .../SqlDatabaseVectorSearch.csproj | 8 ++-- SqlDatabaseVectorSearch/wwwroot/docs.md | 15 ------ .../wwwroot/images/openai.svg | 1 + .../wwwroot/images/sqldatabase.svg | 1 + 5 files changed, 19 insertions(+), 52 deletions(-) delete mode 100644 SqlDatabaseVectorSearch/wwwroot/docs.md create mode 100644 SqlDatabaseVectorSearch/wwwroot/images/openai.svg create mode 100644 SqlDatabaseVectorSearch/wwwroot/images/sqldatabase.svg diff --git a/SqlDatabaseVectorSearch/Components/Pages/Home.razor b/SqlDatabaseVectorSearch/Components/Pages/Home.razor index f7336c8..571e0c4 100644 --- a/SqlDatabaseVectorSearch/Components/Pages/Home.razor +++ b/SqlDatabaseVectorSearch/Components/Pages/Home.razor @@ -1,39 +1,19 @@ @page "/" @rendermode @(new InteractiveServerRenderMode(prerender: false)) -@inject IWebHostEnvironment WebHostEnvironment - SQL Database Vector Search -@if (markdown is null) -{ -
- -
-} -else -{ -
-
- @markdown -
-
-} +

SQL Database Vector Search

+

+ How to use the native VECTOR type in Azure SQL Database to perform embeddings and RAG with Azure OpenAI. +

+

+ This application allows to load documents, generate embeddings and save them into the database as Vectors, and perform searches using Vector Search and RAG. Currently, PDF, DOCX, TXT and MD files are supported. Vectors are saved and retrieved with Entity Framework Core using the EFCore.SqlServer.VectorSearch library. Embedding and Chat Completion are integrated with Semantic Kernel. +

-@code -{ - private string markdown = default!; - - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if (!firstRender) - { - return; - } - - var filePath = Path.Combine(WebHostEnvironment.WebRootPath, "docs.md"); - markdown = await File.ReadAllTextAsync(filePath); - - StateHasChanged(); - } -} \ No newline at end of file +

Supported features

+ diff --git a/SqlDatabaseVectorSearch/SqlDatabaseVectorSearch.csproj b/SqlDatabaseVectorSearch/SqlDatabaseVectorSearch.csproj index 4658723..a5b04db 100644 --- a/SqlDatabaseVectorSearch/SqlDatabaseVectorSearch.csproj +++ b/SqlDatabaseVectorSearch/SqlDatabaseVectorSearch.csproj @@ -20,10 +20,10 @@ - - - - + + + + diff --git a/SqlDatabaseVectorSearch/wwwroot/docs.md b/SqlDatabaseVectorSearch/wwwroot/docs.md deleted file mode 100644 index d67a11a..0000000 --- a/SqlDatabaseVectorSearch/wwwroot/docs.md +++ /dev/null @@ -1,15 +0,0 @@ -# SQL Database Vector Search - -## Setup - -- [Create an Azure SQL Database](https://learn.microsoft.com/en-us/azure/azure-sql/database/single-database-create-quickstart) -- Open the [appsettings.json](https://github.com/marcominerva/SqlDatabaseVectorSearch/blob/master/SqlDatabaseVectorSearch/appsettings.json) file and set the connection string to the database and the other settings required by Azure OpenAI - - If your embedding model supports shortening, like **text-embedding-3-small** and **text-embedding-3-large**, and you want to use this feature, you need to set the [`Dimensions`](https://github.com/marcominerva/SqlDatabaseVectorSearch/blob/master/SqlDatabaseVectorSearch/appsettings.json#L17) property to the corresponding value. If your model doesn't provide this feature, or do you want to use the default size, just leave the [`Dimensions`](https://github.com/marcominerva/SqlDatabaseVectorSearch/blob/master/SqlDatabaseVectorSearch/appsettings.json#L17) property to NULL. Keep in mind that **text-embedding-3-small** has a dimension of 1536, while **text-embedding-3-large** uses vectors with 3072 elements, so with this latter model it is mandatory to specify a value (that, as said, must be less or equal to 1998). -- You may need to update the size of the [`VECTOR`](https://github.com/marcominerva/SqlDatabaseVectorSearch/blob/master/SqlDatabaseVectorSearch/DataAccessLayer/ApplicationDbContext.cs?plain=1#L42C1-L42C47) column to match the size of the embedding model. The default value is 1536. Currently, the maximum allowed value is 1998. If you change it, remember to update also the [Database Migration](https://github.com/marcominerva/SqlDatabaseVectorSearch/blob/master/SqlDatabaseVectorSearch/DataAccessLayer/Migrations/00000000000000_Initial.cs?plain=1#L35C1-L35C92). -- Run the application and start importing your documents - -## Supported features - -- Conversation history with question reformulation -- Information about token usage -- Response streaming \ No newline at end of file diff --git a/SqlDatabaseVectorSearch/wwwroot/images/openai.svg b/SqlDatabaseVectorSearch/wwwroot/images/openai.svg new file mode 100644 index 0000000..a0e8f8e --- /dev/null +++ b/SqlDatabaseVectorSearch/wwwroot/images/openai.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/SqlDatabaseVectorSearch/wwwroot/images/sqldatabase.svg b/SqlDatabaseVectorSearch/wwwroot/images/sqldatabase.svg new file mode 100644 index 0000000..4271bd1 --- /dev/null +++ b/SqlDatabaseVectorSearch/wwwroot/images/sqldatabase.svg @@ -0,0 +1 @@ +Icon-databases-130 \ No newline at end of file