Commit Graph

247 Commits

Author SHA1 Message Date
Marco Minerva e1324115f8 Remove footer and update card layout styles
- Removed the `FooterSection` from `MainLayout.razor` and its associated styles in `MainLayout.razor.css`.
- Added top margin to the card in `Ask.razor` for improved spacing.
- Increased height of `.card-body` in both default and media queries for better content display.
- Added CSS rules in `app.css` to reset margin and padding for `body` and `html`.
- Modified binary file `SqlDatabaseVectorSearch_WebApp.png`.
2025-02-25 15:52:58 +01:00
Marco Minerva 9071e130de Enhance documentation and refactor request handling
Updated README.md to clarify functionality and added a link to OpenAPI documentation in MainLayout.razor. Removed unnecessary methods from RequestExtensions.cs for simplification. Streamlined docs.md by removing detailed JSON response examples while retaining key information about response streaming.
2025-02-25 15:17:06 +01:00
Marco Minerva eb368470e8 Update README and image assets for SQL Database Vector Search
- Enhanced README.md with new sections and images for the web app and API.
- Clarified setup instructions and reorganized content.
- Removed SqlDatabaseVectorSearch.png; modified favicon.png and SqlDatabaseVectorSearch_API.png.
- Added new image file: SqlDatabaseVectorSearch_WebApp.png.
2025-02-25 14:56:46 +01:00
Marco Minerva 22522a2d50 Update documentation for VECTOR column migration
Clarified the need to update the Database Migration when changing the size of the `VECTOR` column to match the embedding model. This replaces the previous mention that lacked a specific link to the Database Migration.
2025-02-24 12:02:17 +01:00
Marco Minerva a0a6df9cb3 Add loading state and database migration support
- Updated `Documents.razor` to show a loading spinner when documents are being fetched, introducing an `isLoading` state variable.
- Added `ConfigureDatabaseAsync` method in `Program.cs` for handling database migrations at startup.
- Modified `SqlDatabaseVectorSearch.csproj` to include `Microsoft.EntityFrameworkCore.Tools` for migration management.
- Enhanced documentation in `docs.md` regarding the `Dimensions` property and `VECTOR` column size requirements.
- Created initial migration files to define the database schema for `Documents` and `DocumentChunks` tables.
- Defined `Document` and `DocumentChunk` entities in migration files for data storage and retrieval.
2025-02-24 12:01:22 +01:00
Marco Minerva 2ce3d23e73 Downgrade Microsoft.SemanticKernel package version
The version of the `Microsoft.SemanticKernel` package was changed from `1.38.0` to `1.37.0` in the `SqlDatabaseVectorSearch.csproj` file.
2025-02-21 16:27:22 +01:00
Marco Minerva 08ebc517c8 Refactor navigation and update styles and dependencies
- Rearranged navigation items in `MainLayout.razor`.
- Removed `ToastService` injection and modified key handling in `Ask.razor`.
- Downgraded `Microsoft.SemanticKernel` version in project file.
- Updated CSS styles for sidebar brand icon and navigation item states.
- Fixed error message content in `.blazor-error-boundary` class.
2025-02-21 14:13:25 +01:00
Marco Minerva ae88408823 Merge branch 'master' into ui 2025-02-21 12:19:05 +01:00
Marco Minerva 486d73d662 Update Microsoft.SemanticKernel to version 1.38.0
Updated the `Microsoft.SemanticKernel` package version from
1.37.0 to 1.38.0 in the `SqlDatabaseVectorSearch.csproj` file.
2025-02-21 11:05:39 +01:00
Marco Minerva c22b4100fb Refactor Ask component and improve sidebar styles
- Removed clipboard icon reference and added ElementReference for input field in Ask.razor.
- Introduced OnAfterRenderAsync method to manage input focus.
- Updated app.css with new CSS variables for enhanced sidebar styling.
- Added setFocus function in functions.js to manage element focus.
2025-02-20 15:01:25 +01:00
Marco Minerva b7c8cfff76 Update button types in Ask.razor and improve CSS focus style
- Specified `Type` attributes for buttons in `Ask.razor` to clarify their intended behavior.
- Added `h1:focus` style in `app.css` to remove default outline for focused headings.
2025-02-20 12:19:20 +01:00
Marco Minerva eba0d4c272 Add footer to layout and enhance document handling
- Updated `MainLayout.razor` to include a footer displaying the framework description, styled with new CSS.
- Modified `MainLayout.razor.css` to add styles for the footer.
- Enhanced `Ask.razor` with a new `ToastService` for user notifications and improved message handling.
- Updated `Documents.razor` to restrict file uploads to specific formats and improved error handling with notifications for uploads and deletions.
2025-02-20 11:56:48 +01:00
Marco Minerva 402bf1e570 Merge branch 'master' into ui 2025-02-20 10:42:51 +01:00
Marco Minerva 7922fff402 Enhance question reformulation instructions
Added a line to the `embeddingQuestion` string to emphasize that the reformulated question must explicitly contain the subject. This change clarifies the requirements for the chat service's functionality.
2025-02-20 10:36:58 +01:00
Marco Minerva 8472775333 Add message limit to chat history management
Updated `ChatService` to enforce a message limit based on the new `MessageLimit` property in `AppSettings`. Excess messages are removed before updating the cache to optimize performance. Adjusted `appsettings.json` to reflect the new configuration, changing `MaxInputTokens` from 16385 to 16384 and adding `MessageLimit` with a default value of 20.
2025-02-20 10:30:55 +01:00
Marco Minerva 596aa7cf6f Merge branch 'master' of https://github.com/marcominerva/SqlDatabaseVectorSearch 2025-02-20 10:06:29 +01:00
Marco Minerva b1aa81e4ec Enhance question reformulation in ChatService
Updated the `embeddingQuestion` string to require that the reformulated question explicitly contains the subject of the original question. The reformulation must also be in the same language as the user's question and should not include phrases like "in this chat" or "search for."
2025-02-20 10:06:11 +01:00
Marco Minerva 5262f9f794 Enhance UI and notification handling; add documentation
- Updated `MainLayout.razor` to include a `Toasts` component and removed the `FooterSection`.
- Replaced `Toasts` in `Documents.razor` with a new `ToastService` for notifications, enhancing document upload and deletion processes.
- Modified `Home.razor` to read markdown content from a local file using `IWebHostEnvironment`.
- Removed HTTP client service registration in `Program.cs` and adjusted resilience handling configuration.
- Updated `ChatService.cs` with guidelines for question reformulation.
- Added `docs.md` with setup instructions and details on supported features for the SQL Database Vector Search application.
2025-02-20 10:05:44 +01:00
Marco Minerva e1d83f1051 Delete docs.md 2025-02-20 09:09:05 +01:00
Marco Minerva fd025ce45e Improve async handling in Ask.razor and update markdown URL
- Added `await Task.Yield();` to enhance responsiveness in `Ask.razor`.
- Updated the markdown content source from README to `docs.md` in `Home.razor` for more relevant information.
2025-02-19 17:37:47 +01:00
Marco Minerva a9028929eb Update README.md 2025-02-19 17:37:17 +01:00
Marco Minerva 79e7ddf8b1 Create docs.md 2025-02-19 17:36:46 +01:00
Marco Minerva 5382795529 Enhance Ask.razor UI and functionality
Updated clipboard button to use Button component with Icon.
Added HandleKeyDown event for submitting questions with Enter key.
Modified question handling to support streaming responses.
Refactored CopyToClipboard method to be asynchronous.
2025-02-19 17:33:30 +01:00
Marco Minerva 9f6ac67b26 Enhance chat interface and update styles
Significantly updated `Ask.razor` to improve the chat interface with a new layout for user and assistant messages, added input area for questions, and buttons for submission and reset. Removed the previous count display and introduced asynchronous message handling and a new `Message` class.

Minor change in `Documents.razor` by removing a 2000 ms delay before loading documents.

Updated `Ask.razor.css` with new styles for tooltips, avatars, input fields, card bodies, and progress indicators.

Added or updated `assistant.png` and `user.png` for new avatar images in the chat interface.
2025-02-19 16:48:02 +01:00
Marco Minerva ca51b19ea3 Change page route and update titles in Ask.razor
Updated the route from "/counter" to "/ask". Changed the page title from "Counter" to "Chat with your data" and modified the heading accordingly. The functionality for displaying the current count and the increment button remains intact.
2025-02-18 17:56:02 +01:00
Marco Minerva 9c19b4ec73 Refactor layout and remove unused components
Updated `MainLayout.razor` to include a GitHub link and modified sidebar navigation. Removed `Counter.razor` and integrated its functionality into `Ask.razor`. Enhanced error handling in `Error.razor` and removed request ID display. Deleted `Weather.razor` and its associated content.
2025-02-18 17:54:34 +01:00
Marco Minerva f0cccb00b9 Enhance error handling UI and middleware in ASP.NET
Updated `Error.razor` to provide distinct 404 and 500 error messages with a user-friendly layout, including a home button. Conditionally rendered Request ID display and removed development mode information for a cleaner user experience.

Modified `Program.cs` to change error handling middleware from re-executing the error page to redirecting with error codes, improving error information passed to the error page.
2025-02-18 14:41:16 +01:00
Marco Minerva d1ce7111c3 Enhance document loading and update UI in Blazor app
- Added `StateHasChanged()` call after loading documents in `Documents.razor`.
- Introduced `LoadDocumentsAsync` method for document retrieval.
- Updated page title in `Home.razor` and injected `IHttpClientFactory`.
- Implemented loading spinner and markdown fetching in `OnAfterRenderAsync`.
- Configured HTTP client with resilience handler in `Program.cs`.
2025-02-17 13:02:32 +01:00
Marco Minerva a0c777c138 Update README.md 2025-02-17 12:45:41 +01:00
Marco Minerva b155f8eb2e Update README.md 2025-02-17 12:40:06 +01:00
Marco Minerva be3f0dbf09 Update document handling and styling improvements
- Changed `app.css` path in `App.razor`.
- Refactored `Documents.razor` to improve form handling:
  - Removed `VectorSearchService` injection; added `IServiceProvider` and `IJSRuntime`.
  - Updated header from `<h2>` to `<h4>`.
  - Introduced `uploadDocumentRequest` for form state management.
  - Modified document ID input for optional GUID with validation.
  - Disabled upload button when no file is selected.
  - Enhanced document loading logic with scoped service provider.
  - Updated deletion logic to handle multiple document IDs.

- Added method in `DocumentService.cs` for bulk document deletion.
- Restructured `app.css` for improved styling and new validation/error message styles.
2025-02-17 12:32:12 +01:00
Marco Minerva f9a2bf0bf9 Enhance document upload and sidebar functionality
- Updated `Sidebar2` in `MainLayout.razor` for SQL Vector Search.
- Improved document upload interface in `Documents.razor` with icons and tooltips.
- Adjusted layout to include Document ID input and changed checkbox to `CheckboxInput`.
- Added `documentId` property for handling document uploads.
- Enhanced `SelectableDocument` class with `ContentType` property for better document info.
2025-02-14 18:01:59 +01:00
Marco Minerva 83e8f8ff23 Update document management UI and functionality
- Changed the "Documents" icon in `MainLayout.razor`.
- Added a `ConfirmDialog` component in `Documents.razor` for user confirmations.
- Adjusted the capitalization of the creation date column header.
- Restructured the delete button layout for better responsiveness and changed its icon.
- Updated lifecycle method from `OnInitializedAsync` to `OnAfterRenderAsync` for improved document loading.
- Introduced a new asynchronous method for obtaining local date strings.
- Updated toast messages to use the new date formatting method.
- Added a new method for converting UTC dates to local time.
- Introduced a `SelectableDocument` record class to enhance document management.
2025-02-14 17:38:03 +01:00
Marco Minerva 09f15a9cb7 Enhance application structure and functionality
- Updated README.md for clarity on application features.
- Added using directives and improved service configuration in Program.cs.
- Enhanced error handling and status code management in Program.cs.
- Changed application URL port in launchSettings.json.
- Added package references for Blazor Bootstrap and other libraries.
- Created new HTML structure in App.razor and implemented routing in Routes.razor.
- Updated MainLayout.razor for Blazor Bootstrap layout and sidebar navigation.
- Developed new components: Counter.razor, Documents.razor, Error.razor, Home.razor, and Weather.razor.
- Added utility classes: RequestExtensions.cs and StreamExtensions.cs.
- Updated app.css for custom styles and added favicon.png.
- Created functions.js for local time conversion utility.
2025-02-14 16:58:51 +01:00
Marco Minerva 5a507e972c Add Markdown support and refactor text chunking
Updated README.md to include Markdown file support.
Introduced new endpoint for uploading Markdown documents with MIME type handling.
Removed TextChunkerService and created DefaultTextChunker and MarkdownTextChunker classes implementing ITextChunker.
Updated VectorSearchService to utilize the new chunking interface.
Added MimeMapping package reference in the project file.
2025-02-14 12:06:52 +01:00
Marco Minerva e228d0bdbc Update package versions for dependencies
- Updated `Microsoft.SemanticKernel` to version `1.37.0`.
- Updated `MinimalHelpers.OpenApi` to version `2.1.4`.
- Updated `TinyHelpers.AspNetCore` to version `4.0.19`.
2025-02-14 09:51:16 +01:00
Marco Minerva 4d3172ed05 Update NuGet package versions in project file
Upgraded several NuGet packages in `SqlDatabaseVectorSearch.csproj`:
- `Microsoft.AspNetCore.OpenApi` to version `9.0.2`
- `Microsoft.EntityFrameworkCore.SqlServer` to version `9.0.2`
- `Microsoft.Extensions.Caching.Hybrid` to version `9.2.0-preview.1.25105.6`
- `Microsoft.Extensions.Http.Resilience` to version `9.2.0`

These updates may provide bug fixes, new features, and performance improvements.
2025-02-12 10:06:37 +01:00
Marco Minerva 9e844f8a0f Update service registrations and rename DocumentService methods 2025-02-10 16:27:27 +01:00
Marco Minerva a5f8425e61 Update VectorSearchService and package reference
- Removed `System.Threading` directive from `VectorSearchService.cs`
- Updated `BeginTransactionAsync` call to include `cancellationToken`
- Upgraded `Microsoft.SemanticKernel` package to version `1.36.1`
2025-02-10 16:22:03 +01:00
Marco Minerva a0f1755c85 Add CancellationToken support to async methods #9
Introduce support for `CancellationToken` across various methods to allow for task cancellation and improve responsiveness.
- Update `DecodeAsync` method in `DocxContentDecoder.cs`, `PdfContentDecoder.cs`, `TextContentDecoder.cs`, and `IContentDecoder.cs` to include an optional `CancellationToken` parameter.
- Modify endpoint handlers in `Program.cs` to accept and pass `CancellationToken` parameters.
- Update methods in `ChatService.cs` to include `CancellationToken` parameters.
- Update methods in `DocumentService.cs` to include `CancellationToken` parameters.
- Update methods in `VectorSearchService.cs` to include `CancellationToken` parameters.
These changes ensure that long-running operations can be canceled if needed, improving the application's ability to handle cancellation requests gracefully.
2025-02-10 16:20:35 +01:00
Marco Minerva d0fce6ffd2 Simplify /api/ask-streaming response and update README
The response format for the `/api/ask-streaming` endpoint has been simplified by removing multiple individual elements that contained parts of the answer.

The README.md file was updated to correct the terminology from "tag" to "property" for the *streamState* attribute.
2025-02-07 12:08:03 +01:00
Marco Minerva eeb13e9096 Merge pull request #8 from marcominerva/token_usage
Token usage
2025-02-07 12:04:13 +01:00
Marco Minerva 9312bf35cb Add new endpoints and update README with details
Updated README.md to document new `/api/documents`, `/api/ask`, and `/api/ask-streaming` endpoints, including features like conversation history, token usage, and response streaming. Enhanced Program.cs by adding new endpoints for asking questions and streaming responses, with additional metadata. Updated `documentsApiGroup` to include new document management endpoints.
2025-02-07 12:02:48 +01:00
Marco Minerva f02a1c9b69 Refactor document operations into DocumentService
Refactored Program.cs to use AddAzureSql with new options. Added VectorSearchService and DocumentService as scoped services. Updated documentsApiGroup to use DocumentService for document operations and added a delete document endpoint. Moved document-related methods from VectorSearchService to new DocumentService for better separation of concerns.
2025-02-07 11:30:14 +01:00
Marco Minerva cdd0199e8f Refactor services and update token handling
- Replace `TotalTokenCount` with `EmbeddingTokenCount` in `ImportDocumentResponse`.
- Add `OriginalQuestion` and `ReformulatedQuestion` fields to `QuestionResponse` and a new constructor.
- Add a new constructor to `TokenUsageResponse` to initialize `Question`.
- Add `TextChunkerService` to service collection in `Program.cs`.
- Clarify prompt and update token counting in `ChatService`.
- Differentiate token counting in `TokenizerService` with `CountChatCompletionTokens` and `CountEmbeddingTokens`.
- Update `VectorSearchService` to use `TextChunkerService` and new token counting methods.
- Introduce `TextChunkerService` for text splitting and tokenization.
2025-02-07 10:24:16 +01:00
Marco Minerva fd6c63c9c4 Update Microsoft.SemanticKernel to 1.36.0
Updated the Microsoft.SemanticKernel package version from 1.35.0 to 1.36.0 in the SqlDatabaseVectorSearch.csproj file.
2025-02-05 18:00:37 +01:00
Marco Minerva 8e06979993 Refactor response types and enhance token usage handling 2025-01-30 12:56:33 +01:00
Marco Minerva dd58c547d0 Merge pull request #7 from marcominerva/content_decoders
Add Content decoders
2025-01-29 10:03:40 +01:00
Marco Minerva b8aace05a5 Update Microsoft.SemanticKernel to v1.35.0
Upgraded Microsoft.SemanticKernel package from version 1.34.0 to 1.35.0 in SqlDatabaseVectorSearch.csproj. This update includes new features, bug fixes, and other improvements provided in the latest version.
2025-01-29 10:00:25 +01:00
Marco Minerva af9158873f Add support for DOCX and TXT files, update error handling
Updated README.md to reflect support for PDF, DOCX, and TXT files.
Removed commented-out code in DocxContentDecoder.cs.
Added TextContentDecoder service in Program.cs and updated exception handling middleware.
Updated document upload endpoint description in Program.cs.
Modified VectorSearchService to throw NotSupportedException for unsupported content types.
Added TextContentDecoder class in TextContentDecoder.cs.
2025-01-29 09:58:22 +01:00