311 Commits

Author SHA1 Message Date
Marco Minerva f0c92b32f2 Merge pull request #17 from marcominerva/agent-framework
Refactor to Microsoft.Agents.AI and improve embedding workflows
2026-07-31 16:39:34 +02:00
Marco Minerva d910205339 Refactor: Replace ContextProvider with DocumentContextProviderService
Replaces the ContextProvider class with DocumentContextProviderService, moving vector search logic into its own file. Updates dependency injection and all usages to reference the new service. The service uses embeddings and Entity Framework for vector-based text search, returning relevant document chunks. Removes unused usings and references to ContextProvider.
2026-07-31 16:38:48 +02:00
Marco Minerva 3a765fdccf Refactor embedding workflow: add ExtractChunksExecutor
Refactored the embedding workflow to introduce ExtractChunksExecutor, responsible for content decoding and chunk extraction before embedding generation. Registered ExtractChunksExecutor and GenerateEmbeddingExecutor as singletons, and StoreEmbeddingExecutor as scoped in DI. Updated workflow to sequence ExtractChunksExecutor → GenerateEmbeddingExecutor → StoreEmbeddingExecutor. Modified GenerateEmbeddingExecutor to accept ExtractChunksResponse. Updated ChatClientAgentOptions usage to use object initializers for clarity. Added ExtractChunksExecutor.cs.
2026-07-31 16:37:02 +02:00
Marco Minerva 601e075b03 Remove SqlDatabaseVectorSearch.mp4 binary file
The binary file SqlDatabaseVectorSearch.mp4 was deleted from the codebase to reduce repository size and remove unnecessary assets. No code functionality is affected by this change.
2026-07-29 16:28:35 +02:00
Marco Minerva 7384de18c4 Add .NET 10, Minimal API, Blazor badges to README
Enhanced the project README by adding badges for .NET 10, Minimal API, and Blazor support to the project title. This highlights the technologies and features supported by the project for better visibility and clarity.
2026-07-29 15:28:31 +02:00
Marco Minerva 5a8ea33f7c Use named parameter for prerender in render mode
Updated <HeadOutlet> and <Routes> to use the named parameter 'prerender: false' with InteractiveServerRenderMode, improving code clarity and consistency with named parameter usage.
2026-07-29 15:26:46 +02:00
Marco Minerva 5b453dd033 Refactor message scrolling and cleanup Error.razor
Moved message scrolling logic to OnAfterRenderAsync to ensure DOM updates before scrolling, using Task.Yield() after StateHasChanged. Removed redundant EnsureMessageIsVisibleAsync calls. Cleaned up Error.razor by removing unused usings and the rendermode directive.
2026-07-29 15:22:01 +02:00
Marco Minerva d4c88ab10f Remove TraceHttpClientHandler and update DI setup
Removed the custom TraceHttpClientHandler and switched OpenAIClient initialization to use the default HTTP transport. Cleaned up unused using directives. Updated SqlDatabaseVectorSearch_WebApp.png with a new version.
2026-07-28 16:17:45 +02:00
Marco Minerva 832d21ec9e Revamp sidebar with modern color palette and styles
Updated sidebar CSS to use a blue and neutral color palette, added vertical gradient backgrounds and box-shadows, and enhanced navigation item styles with rounded corners, transitions, and bold active states. Adjusted icon colors and updated comments for new color inheritance approach.
2026-07-28 16:10:33 +02:00
Marco Minerva 96c81b7dc3 Improve output token usage display formatting
Refactored the output token usage details to show reasoning tokens as an indented HTML line using a <span> with Bootstrap classes for indentation and smaller text, instead of a parenthetical note. Updated logic to use ReasoningTokenCount.HasValue for improved clarity.
2026-07-28 16:04:13 +02:00
Marco Minerva 6f2e928542 Refactor token usage HTML generation for clarity
Refactored HTML generation by introducing a sections array for easier extension and maintainability. Updated FormatTokenUsageDetails to require non-null UsageDetails and display reasoning tokens as a detail within output tokens, improving clarity and reducing redundancy. Only non-null sections are rendered, simplifying the logic.
2026-07-28 15:56:59 +02:00
Marco Minerva 20bf98b131 Improve copy-to-clipboard UX in Ask.razor
Refactored the copy button to use per-message state, displaying a checkmark icon and "Copied!" tooltip when a message is copied. Simplified state management, removed unused references, and updated the Reset method to clear copied state. Enhanced Ask.razor.css to minimize button chrome and improve interactive states for a cleaner UI.
2026-07-28 15:42:07 +02:00
Marco Minerva 54609d1718 Enhance file upload validation and UX consistency
- Tooltip and file input now use `UploadDocument` properties for supported types and max size.
- File input's `accept` attribute set from `UploadDocument.AcceptedFileTypes`.
- Added `<ValidationMessage>` for file input errors.
- Stream size limit uses `UploadDocument.MaxFileSize`.
- Introduced `GetDocumentId()` for parsing document IDs.
- Simplified LINQ in `DeleteSelectedDocuments`.
- `UploadDocument` implements `IValidatableObject` for:
  - GUID format validation.
  - Supported extension checks.
  - File size enforcement.
- Centralized constants for extensions, types, and max size in `UploadDocument`.
2026-07-28 15:33:09 +02:00
Marco Minerva 7d413aa0b3 Disable upload form during upload; update citation template
The file upload form in Documents.razor is now wrapped in a <fieldset> that disables all controls while uploading, using a new isUploading flag to manage state and UI updates. The upload button's loading state is also handled. In Program.cs, the citation template was revised to require supporting excerpts of about 20-30 words instead of 15-20 words.
2026-07-28 15:23:19 +02:00
Marco Minerva 3390d94c81 Replace progress bar with animated typing indicator
Replaced the chat progress bar in Ask.razor with a modern animated "typing indicator" using three bouncing dots. Updated Ask.razor.css to remove old progress bar styles and add new keyframes and accessibility improvements for the typing dots. This enhances user experience by clearly signaling when the assistant is responding.
2026-07-28 15:18:33 +02:00
Marco Minerva a225d61b3f Redesign chat progress bar with new gradient animation
The chat UI progress bar was visually updated: height increased to 6px, background made more transparent, and corners fully rounded. The indeterminate bar now uses a gradient with a moving highlight animation, which is slower for users with reduced motion preferences. Animation duration and style were refined for improved accessibility and aesthetics.
2026-07-28 15:16:25 +02:00
Marco Minerva f9f75cdf7c Clarify SQL Server support, improve docs and UI text
Updated documentation and UI to clarify support for both Azure SQL Database and SQL Server 2025+ for native VECTOR type storage and search. Improved README with accurate prerequisites, setup instructions, and detailed ModelId usage guidance. Clarified streaming response availability in both Blazor and API. Fixed typos and improved wording in UI messages. Enhanced code comments for clarity and accuracy, including ModelId guidance in appsettings.json.
2026-07-28 15:14:17 +02:00
Marco Minerva dc26a3d2e9 Improve UI/UX for chat, documents, and home pages
- Chat page: Add empty state, clarify tooltips/placeholders, and enhance error/copy messages.
- Documents page: Add chunking/embedding info, clarify file support, show document count badge, and display empty state. Refactor table/button markup and improve upload toasts.
- Home page: Redesign with hero section, icons, workflow cards, and styled features list. Clarify README link.
- Add Home.razor.css for new visual styles.
2026-07-28 14:57:57 +02:00
Marco Minerva 9f0d4f6402 Refine icons, colors, and UI feedback for clarity
Update icon choices and colors across the Blazor app for improved visual clarity and consistency. Use explicit InteractiveServerRenderMode in App.razor. Replace sidebar, header, and navigation icons with filled or colorized variants in MainLayout.razor. Update Ask.razor and Documents.razor with more descriptive icons. Enhance reconnect modal messaging and button visibility. Adjust app.css for individual sidebar icon colors and brand icon styling. Remove EFCore.SqlServer.VectorSearch from the home page feature list to focus on Agent Framework. These changes improve UI feedback, accessibility, and maintainability.
2026-07-28 12:56:21 +02:00
Marco Minerva ded1fba498 Flexible DbContext SQL provider selection and config
Replaced AddSqlServer with AddDbContext for ApplicationDbContext, enabling dynamic provider selection based on the connection string. Now uses UseAzureSql for Azure SQL targets and UseSqlServer with retry logic otherwise. Configured all queries to use NoTracking for improved performance.
2026-07-28 12:37:11 +02:00
Marco Minerva 96fd8adf0f Refactor embedding request creation and processing
Consolidate embedding request logic into a new EmbeddingRequest record with static factory methods for IFormFile and stream input. Remove FormFileToEmbeddingRequestExecutor and FormFileEmbeddingRequest, updating all usages and dependency injection accordingly. Clean up related code in Program.cs, VectorSearchService, and _Imports.razor. Enhance XML documentation for EmbeddingRequest to clarify intent and usage.
2026-07-27 17:57:30 +02:00
Marco Minerva c7138d571c Switch to Agent Framework, update SSE protocol and docs
Updated README.md and Home.razor to document migration from Semantic Kernel to Microsoft Agent Framework, detailing new orchestration, document import, question reformulation, and RAG agent workflows. Revised API and streaming response examples to use Server-Sent Events (SSE) with event names Start, Delta, and End. Refactored AskEndpoints.cs to use .NET 8 ServerSentEvents API and yield SseItem<Response> with correct event names. Updated Ask.razor, Documents.razor, and VectorSearchService.cs to use StreamState.Delta instead of Append, and replaced StateHasChanged() with await InvokeAsync(StateHasChanged) for async UI updates. Removed MaxInputTokens and MaxOutputTokens from AppSettings.cs and appsettings.json.
2026-07-27 17:44:23 +02:00
Marco Minerva d5b0e1606f Clarify and update sources section formatting rules
The instructions for formatting the sources section at the end of answers were revised for clarity and precision. Instead of multiple separate citation rules, the new guidance requires using a provided template, with the sources and page labels localized to the user's language. The updated rules specify omitting the page label and number if not available, and explicitly prohibit headings or links in the sources section. The formatting example was also updated to match these changes.
2026-07-27 17:22:09 +02:00
Marco Minerva 3b06b0e0f9 Refactor Sources section formatting in output
Updated the "Sources" section header and changed the source list from bullets to a numbered format (e.g., "[1] SourceName"). Each source now includes its excerpt and a separator line ("---"). Removed the "### Excerpts" section and extra blank lines, consolidating sources and excerpts for improved clarity.
2026-07-27 17:19:34 +02:00
Marco Minerva 57ba80bae4 Update citation formatting rules for Markdown output
Clarifies citation formatting: the sources label must be localized and in standard-size italic text (not a heading or bold). Citations now require the source name in bold, followed by the localized page label and page number if available, then a colon and 15-20 italicized words from the excerpt. Source names are not links, and only actually used, non-duplicate sources are included. Example formats are updated accordingly.
2026-07-27 17:16:25 +02:00
Marco Minerva b2394208cc Improve DI, citation formatting, and search result output
- Inject IServiceScopeFactory in Documents.razor for better DI and async scope creation.
- Update citation formatting in Program.cs: sources now appear as a localized, numbered Markdown list with block quotes.
- Use a helper for consistent source/page formatting in TextSearchProviderOptions.
- Simplify RawRepresentation in VectorSearchService to just the page number.
2026-07-24 18:03:53 +02:00
Marco Minerva f474d8fe82 Add Response ctor overload, agent Ids, and metadata fields
- Added a new Response constructor overload for simpler instantiation with conversationId, streamState, and optional tokenUsageResponse.
- Updated AddAIAgent registrations for "ReformulationAgent" and "RagAgent" to set Id to the lower-cased key.
- Modified VectorSearchService to use the new Response constructor, omitting now-optional parameters.
- Enhanced ContextProvider: TextSearchResult now includes a RawRepresentation property with chunk metadata (Id, DocumentId, PageNumber, IndexOnPage, Content).
2026-07-24 17:38:12 +02:00
Marco Minerva 6c3e539272 Refactor scope creation and update namespace imports
Replaced `IServiceProvider` with `IServiceScopeFactory` for async scope creation, updated injected services and usages, switched namespace import from `System.Text.RegularExpressions` to `Microsoft.Extensions.AI`, and simplified the `FormatTokenUsageDetails` method signature to use the unqualified `UsageDetails` type.
2026-07-24 17:32:08 +02:00
Marco Minerva 7af4214d6d Refactor models, update usage tracking, and clean citations
- Enabled additional C# code style suggestions in .editorconfig.
- Removed citation rendering and extraction from Ask.razor.
- Deleted Citation, ChatResponse, and TokenUsage models and references.
- Updated TokenUsageResponse to use UsageDetails from Microsoft.Extensions.AI.
- Refactored Response model: removed citations, added ConversationId, and adopted new token usage structure.
- Updated HybridCacheSessionStoreService with new cache key format and DeleteSessionAsync method.
- Refactored VectorSearchService to remove AppSettings dependency, update method signatures, and use UsageDetails for token tracking.
- Updated NuGet package references in SqlDatabaseVectorSearch.csproj.
2026-07-24 17:27:52 +02:00
Marco Minerva a39a81166a Refactor: migrate to Microsoft.Agents.AI for RAG/chat
Replaced SemanticKernel with Microsoft.Agents.AI and agent-based abstractions for chat and RAG workflows. Removed ChatService in favor of AIAgent instances for question reformulation and answering. Added agent registration/configuration in Program.cs, new RagResponse record, and ContextProvider for context search. Introduced HybridCacheSessionStoreService for session persistence. Switched to direct OpenAIClient usage with request tracing. Reduced max relevant context chunks to 30. Removed SemanticKernel from project references and suppressed MEAI001 warning. Refactored code for improved style and DI alignment.
2026-06-17 16:25:09 +02:00
Marco Minerva 8a761ddcd7 Refactor document import to workflow-based architecture
Replaces the direct import logic with a workflow using Microsoft.Agents.AI.Workflows. Adds executors for file conversion, embedding generation, and storage. Updates dependency injection, API endpoint, and UI to use the new workflow. Replaces ImportDocumentResponse with StoreEmbeddingResponse. Adds required NuGet packages.
2026-06-17 12:35:30 +02:00
Marco Minerva 14f983307e Improve validation and naming in PlainTextChunker
Refactored PlainTextChunker to add input validation, null checks, and argument validation in public methods. Renamed SplitMarkDownLines to SplitMarkdownLines for consistency and updated all references. Centralized line ending normalization and token count validation into dedicated methods. Enhanced error handling with clearer messages and exception types. Simplified paragraph merging logic and ensured GetDefaultTokenCount returns at least 1 for non-empty input. Updated MarkdownTextChunker to use the corrected method name.
2026-06-16 15:55:11 +02:00
Marco Minerva 5624f73640 Refactor: replace SemanticKernel with Agents.AI.OpenAI
Removed Microsoft.SemanticKernel dependencies in favor of Microsoft.Agents.AI.OpenAI for embedding and chat services. Updated DI registrations in Program.cs to use OpenAIClient. Reimplemented text chunking with a new PlainTextChunker class, updating DefaultTextChunker and MarkdownTextChunker accordingly. Updated .csproj to add new package references and suppress related analyzer warnings.
2026-06-15 17:58:30 +02:00
Marco Minerva 4dcd7c9fdc Update NuGet package versions in project file
Updated several NuGet package references in SqlDatabaseVectorSearch.csproj to their latest versions, including EntityFrameworkCore.Exceptions.SqlServer, Microsoft.AspNetCore.OpenApi, Microsoft.EntityFrameworkCore.SqlServer, Microsoft.EntityFrameworkCore.Tools, Microsoft.Extensions.Caching.Hybrid, Microsoft.Extensions.Http.Resilience, Microsoft.SemanticKernel, Swashbuckle.AspNetCore.SwaggerUI, and TinyHelpers.AspNetCore. No other changes were made.
semantic-kernel
2026-06-15 17:41:53 +02:00
Marco Minerva 69759d595f Update NuGet package versions to latest releases
Updated package references in SqlDatabaseVectorSearch.csproj:
- Microsoft.AspNetCore.OpenApi to 10.0.7
- Microsoft.EntityFrameworkCore.SqlServer to 10.0.7
- Microsoft.EntityFrameworkCore.Tools to 10.0.7
- Microsoft.SemanticKernel to 1.76.0
2026-05-11 16:14:26 +02:00
Marco Minerva b3ffddeaca Update guidance and upgrade NuGet package versions
Clarified ConfigureAwait(false) usage in copilot-instructions.md for library vs ASP.NET Core scenarios. Upgraded multiple NuGet dependencies in SqlDatabaseVectorSearch.csproj to their latest versions for improved compatibility and features.
2026-04-15 12:10:05 +02:00
Marco Minerva 2b5188aa7c Update NuGet package dependencies to latest versions
Upgraded several NuGet packages in SqlDatabaseVectorSearch.csproj, including Microsoft.AspNetCore.OpenApi, EntityFrameworkCore.SqlServer/Tools, Microsoft.Extensions.Caching.Hybrid, Microsoft.Extensions.Http.Resilience, Microsoft.SemanticKernel, Swashbuckle.AspNetCore.SwaggerUI, and TinyHelpers.AspNetCore to their latest patch releases. No other code or configuration changes were made.
2026-02-27 10:46:54 +01:00
Marco Minerva cc1e62f1d5 Update NuGet packages and solution items
Removed copilot instructions from solution items. Upgraded MimeMapping to v4.0.0 and Swashbuckle.AspNetCore.SwaggerUI to v10.1.1 in the project file.
2026-02-03 09:42:41 +01:00
Marco Minerva e1323573d0 Update Microsoft.SemanticKernel to version 1.70.0
Upgraded the Microsoft.SemanticKernel NuGet package in SqlDatabaseVectorSearch.csproj from version 1.69.0 to 1.70.0 to incorporate the latest features and improvements.
2026-01-29 10:06:08 +01:00
Marco Minerva c94b117eb0 Update NuGet package dependencies to latest versions
Updated several NuGet packages in SqlDatabaseVectorSearch.csproj:
- Microsoft.AspNetCore.OpenApi, Microsoft.EntityFrameworkCore.SqlServer, and Tools to 10.0.2
- Microsoft.Extensions.Caching.Hybrid and Http.Resilience to 10.2.0
- Microsoft.SemanticKernel to 1.69.0
- MimeMapping to 3.2.0
- TinyHelpers.AspNetCore to 4.1.15
2026-01-21 16:45:10 +01:00
Marco Minerva 04d777c9d5 Improve docx parsing, chunk ordering, and DB config
- Add null check for Document in DocxContentDecoder to prevent exceptions.
- Set DocumentChunk.Id to auto-generate in ApplicationDbContext.
- Order vector search results by cosine similarity for relevance.
2026-01-13 14:43:14 +01:00
Marco Minerva 1ae1db2628 Improve vector search relevance and update NuGet packages
- Order document chunks by cosine vector distance for better relevance in VectorSearchService; limit results to MaxRelevantChunks.
- Update multiple NuGet dependencies to latest versions for improved stability and features.
2026-01-09 10:54:58 +01:00
Marco Minerva 89ff8e9c6e Update NuGet packages: FluentValidation, SemanticKernel
Updated the following NuGet package dependencies in the
`SqlDatabaseVectorSearch.csproj` file:

- `FluentValidation.DependencyInjectionExtensions` updated
  from version `12.1.0` to `12.1.1` to incorporate potential
  bug fixes and improvements.
- `Microsoft.SemanticKernel` updated from version `1.67.1`
  to `1.68.0` to include enhancements and new functionality.

These updates aim to improve stability, performance, and
compatibility of the project.
2025-12-05 17:00:44 +01:00
Marco Minerva b0fe3cb827 Update CSS and upgrade Blazor.Bootstrap package
Reduced `.card-body` height in `Ask.razor.css` for screens with a minimum width of 768px. Updated `Blazor.Bootstrap` package in `SqlDatabaseVectorSearch.csproj` from version 3.4.0 to 3.5.0.
2025-11-25 09:46:18 +01:00
Marco Minerva e4700a4e28 Update README with screenshots and .NET 10 prerequisite
Added screenshots for the Web App and Web API to README for better visualization of the application. Updated the .NET SDK prerequisite from version 9 to version 10. Fixed a minor formatting issue in the description of Semantic Kernel and EFCore.SqlServer.VectorSearch.
2025-11-19 16:13:11 +01:00
Marco Minerva 4242bcc0c7 Update README: .NET 10 badge
Updated the README.md to replace the .NET 9 badge with a .NET 10 badge, reflecting compatibility with the newer version.
2025-11-19 14:51:54 +01:00
Marco Minerva d6c0e6630f Rename and enhance ChatService methods
Renamed `CreateQuestionAsync` to `CreateReformulateQuestionAsync` for clearer intent. Updated `CreateChatAsync` to include a new `ChatSystemPrompt` property in `AzureOpenAIPromptExecutionSettings` and modified `ChatHistory` initialization to simplify setup. Removed redundant `prompt` string construction and added user messages directly to `ChatHistory`.

Updated `VectorSearchService` to use the renamed `CreateReformulateQuestionAsync` method for consistency. These changes improve code clarity, maintainability, and functionality.
2025-11-17 15:49:42 +01:00
Marco Minerva dba2fb1c41 Update to stable version and enhance OpenAPI configuration
Updated `ProductVersion` in `ApplicationDbContextModelSnapshot.cs`
to target the stable release version `10.0.0`.

Added `TinyHelpers.AspNetCore.OpenApi` to `Program.cs` and
enabled OpenAPI options by uncommenting `RemoveServerList`
and `AddDefaultProblemDetailsResponse`. These changes improve
API documentation and error handling.
2025-11-17 10:20:36 +01:00
Marco Minerva 502c8756b1 Update C# version in guidelines to C# 14
Updated the copilot-instructions.md file to reflect the use of the latest version of C#, changing the reference from "C# 13" to "C# 14". This ensures the guidelines remain up-to-date with the latest language features.
2025-11-13 18:05:10 +01:00
Marco Minerva 522da4d5d0 Refactor embeddings and add reconnect modal
Enhanced support for SQL Server's `SqlVector<float>` for embeddings, replacing `float[]` to improve vector search compatibility. Added a reconnect modal for better handling of server disconnections, including UI, styles, and JavaScript logic.

Upgraded to .NET 10.0 and EF Core 10.0, updated dependencies, and improved token counting logic for embeddings. Updated documentation and configuration files to reflect these changes. Migrated database schema to support `SqlVector<float>`.
2025-11-13 17:59:06 +01:00