diff --git a/app/MindWork AI Studio/Pages/Embeddings.razor.cs b/app/MindWork AI Studio/Pages/Embeddings.razor.cs index 3a4b8d0e..a094de7d 100644 --- a/app/MindWork AI Studio/Pages/Embeddings.razor.cs +++ b/app/MindWork AI Studio/Pages/Embeddings.razor.cs @@ -1,4 +1,5 @@ using AIStudio.Components; +using AIStudio.Settings.DataModel; using AIStudio.Tools.Services; using Microsoft.AspNetCore.Components; @@ -10,6 +11,9 @@ public partial class Embeddings : MSGComponentBase [Inject] private DataSourceEmbeddingService DataSourceEmbeddingService { get; init; } = null!; + [Inject] + private NavigationManager NavigationManager { get; init; } = null!; + private IReadOnlyList Statuses { get; set; } = []; private int TotalIndexedFiles => this.Statuses.Sum(status => status.IndexedFiles); @@ -20,6 +24,17 @@ public partial class Embeddings : MSGComponentBase protected override async Task OnInitializedAsync() { + // + // This page belongs to the local RAG preview feature. Unlike the other preview pages, it + // has a route of its own, so it can be reached by typing the address even while the feature + // is switched off. There is nothing to show in that case. + // + if (!PreviewFeatures.PRE_RAG_2024.IsEnabled(this.SettingsManager)) + { + this.NavigationManager.NavigateTo(Routes.HOME); + return; + } + this.ApplyFilters([], [ Event.RAG_EMBEDDING_STATUS_CHANGED, Event.CONFIGURATION_CHANGED ]); await base.OnInitializedAsync(); this.ReloadStatuses(); diff --git a/app/MindWork AI Studio/Tools/RAG/RAGProcesses/AISrcSelWithRetCtxVal.cs b/app/MindWork AI Studio/Tools/RAG/RAGProcesses/AISrcSelWithRetCtxVal.cs index fec742fe..ed0ea76d 100644 --- a/app/MindWork AI Studio/Tools/RAG/RAGProcesses/AISrcSelWithRetCtxVal.cs +++ b/app/MindWork AI Studio/Tools/RAG/RAGProcesses/AISrcSelWithRetCtxVal.cs @@ -35,7 +35,13 @@ public sealed class AISrcSelWithRetCtxVal : IRagProcess // // 1. Check if the user wants to bind any data sources to the chat: // - if (chatThread.DataSourceOptions.IsEnabled()) + // + // Data sources are a preview feature. The check belongs here rather than in the options + // themselves: a chat keeps its data source options while the feature is switched off, and + // organizations may preselect data sources through a configuration plugin. Without this, + // such a chat would still run the entire RAG process with the feature disabled. + // + if (PreviewFeatures.PRE_RAG_2024.IsEnabled(settings) && chatThread.DataSourceOptions.IsEnabled()) { LOGGER.LogInformation("Data sources are enabled for this chat."); diff --git a/app/MindWork AI Studio/Tools/Services/DataSourceEmbeddingService.cs b/app/MindWork AI Studio/Tools/Services/DataSourceEmbeddingService.cs index 967f81ea..1c054e7e 100644 --- a/app/MindWork AI Studio/Tools/Services/DataSourceEmbeddingService.cs +++ b/app/MindWork AI Studio/Tools/Services/DataSourceEmbeddingService.cs @@ -1057,6 +1057,19 @@ public sealed partial class DataSourceEmbeddingService( private bool IsSupportedInternalDataSource(IDataSource dataSource) { + // + // Local RAG is a preview feature, so nothing here may run while it is switched off. This is + // the one place to decide that: every path which scans files, starts a watcher, creates the + // index database or sends text to an embedding provider asks this question first. + // + // Checking the feature instead of relying on "no data sources configured" also covers the + // case where somebody enabled the feature, configured local data sources, and switched the + // feature off again. Their data sources stay in the settings, and without this check the + // service would keep indexing them. + // + if (!PreviewFeatures.PRE_RAG_2024.IsEnabled(settingsManager)) + return false; + return dataSource is DataSourceLocalDirectory or DataSourceLocalFile; }