mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-17 15:38:00 +00:00
background embed
This commit is contained in:
1 parent
e3cb7e9734
commit
ac677c5ac7
20 files changed
+1623
-98
No files matched your search
@@ -25,7 +25,17 @@
|
||||
|
||||
<MudSpacer/>
|
||||
|
||||
<MudStack AlignItems="AlignItems.Center">
|
||||
@if (this.embeddingOverview.IsVisible)
|
||||
{
|
||||
<MudNavMenu>
|
||||
<MudTooltip Text="@this.EmbeddingNavigationTooltip" Placement="Placement.Right">
|
||||
<MudNavLink Href="@this.embeddingItem.Path" Match="@(this.embeddingItem.MatchAll ? NavLinkMatch.All : NavLinkMatch.Prefix)" Icon="@this.embeddingItem.Icon" Style="@this.embeddingItem.SetColorStyle(this.SettingsManager)" Class="custom-icon-color">
|
||||
@T("Data sync")
|
||||
</MudNavLink>
|
||||
</MudTooltip>
|
||||
</MudNavMenu>
|
||||
}
|
||||
<MudStack AlignItems="AlignItems.Center" Class="pb-2">
|
||||
<MudToolBar WrapContent="true">
|
||||
<VoiceRecorder />
|
||||
</MudToolBar>
|
||||
@@ -53,8 +63,23 @@
|
||||
</MudNavMenu>
|
||||
|
||||
<MudSpacer/>
|
||||
|
||||
<MudStack AlignItems="AlignItems.Center">
|
||||
|
||||
@if (this.embeddingOverview.IsVisible)
|
||||
{
|
||||
<MudNavMenu>
|
||||
@if (this.SettingsManager.ConfigurationData.App.NavigationBehavior is NavBehavior.NEVER_EXPAND_USE_TOOLTIPS)
|
||||
{
|
||||
<MudTooltip Text="@this.EmbeddingNavigationTooltip" Placement="Placement.Right">
|
||||
<MudNavLink Href="@this.embeddingItem.Path" Match="@(this.embeddingItem.MatchAll ? NavLinkMatch.All : NavLinkMatch.Prefix)" Icon="@this.embeddingItem.Icon" Style="@this.embeddingItem.SetColorStyle(this.SettingsManager)" Class="custom-icon-color"/>
|
||||
</MudTooltip>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudNavLink Href="@this.embeddingItem.Path" Match="@(this.embeddingItem.MatchAll ? NavLinkMatch.All : NavLinkMatch.Prefix)" Icon="@this.embeddingItem.Icon" Style="@this.embeddingItem.SetColorStyle(this.SettingsManager)" Class="custom-icon-color"/>
|
||||
}
|
||||
</MudNavMenu>
|
||||
}
|
||||
<MudStack AlignItems="AlignItems.Center" Class="pb-2">
|
||||
<MudToolBar WrapContent="true">
|
||||
<VoiceRecorder />
|
||||
</MudToolBar>
|
||||
@@ -79,4 +104,4 @@
|
||||
</MudLayout>
|
||||
</MudPaper>
|
||||
|
||||
<MudThemeProvider @ref="@this.themeProvider" Theme="@this.ColorTheme" IsDarkMode="@this.useDarkMode" />
|
||||
<MudThemeProvider @ref="@this.themeProvider" Theme="@this.ColorTheme" IsDarkMode="@this.useDarkMode" />
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using AIStudio.Dialogs;
|
||||
using AIStudio.Settings;
|
||||
using AIStudio.Settings.DataModel;
|
||||
@@ -38,6 +39,9 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
||||
|
||||
[Inject]
|
||||
private MudTheme ColorTheme { get; init; } = null!;
|
||||
|
||||
[Inject]
|
||||
private DataSourceEmbeddingService DataSourceEmbeddingService { get; init; } = null!;
|
||||
|
||||
private ILanguagePlugin Lang { get; set; } = PluginFactory.BaseLanguage;
|
||||
|
||||
@@ -56,7 +60,9 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
||||
private bool startupCompleted;
|
||||
private readonly SemaphoreSlim mandatoryInfoDialogSemaphore = new(1, 1);
|
||||
|
||||
private DataSourceEmbeddingOverview embeddingOverview = new(false, true, DataSourceEmbeddingState.COMPLETED, 0, 0, 0, string.Empty);
|
||||
private IReadOnlyCollection<NavBarItem> navItems = [];
|
||||
private NavBarItem embeddingItem = new NavBarItem(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, false);
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
@@ -87,6 +93,7 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
||||
|
||||
// Ensure that all settings are loaded:
|
||||
await this.SettingsManager.LoadSettings();
|
||||
await this.DataSourceEmbeddingService.QueueAllInternalDataSourcesAsync();
|
||||
|
||||
// Register this component with the message bus:
|
||||
this.MessageBus.RegisterComponent(this);
|
||||
@@ -94,7 +101,7 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
||||
[
|
||||
Event.UPDATE_AVAILABLE, Event.CONFIGURATION_CHANGED, Event.COLOR_THEME_CHANGED, Event.SHOW_ERROR,
|
||||
Event.SHOW_WARNING, Event.SHOW_SUCCESS, Event.STARTUP_PLUGIN_SYSTEM, Event.PLUGINS_RELOADED,
|
||||
Event.INSTALL_UPDATE, Event.STARTUP_COMPLETED,
|
||||
Event.INSTALL_UPDATE, Event.STARTUP_COMPLETED, Event.RAG_EMBEDDING_STATUS_CHANGED,
|
||||
]);
|
||||
|
||||
// Set the snackbar for the update service:
|
||||
@@ -114,6 +121,7 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
||||
await this.themeProvider.WatchSystemDarkModeAsync(this.SystemeThemeChanged);
|
||||
await this.UpdateThemeConfiguration();
|
||||
this.LoadNavItems();
|
||||
this.LoadEmbeddingItem();
|
||||
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
@@ -175,6 +183,7 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
||||
|
||||
await this.UpdateThemeConfiguration();
|
||||
this.LoadNavItems();
|
||||
this.LoadEmbeddingItem();
|
||||
this.StateHasChanged();
|
||||
if (this.startupCompleted)
|
||||
_ = this.EnsureMandatoryInfosAcceptedAsync();
|
||||
@@ -263,6 +272,7 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
||||
this.Lang = await this.SettingsManager.GetActiveLanguagePlugin();
|
||||
I18N.Init(this.Lang);
|
||||
this.LoadNavItems();
|
||||
this.LoadEmbeddingItem();
|
||||
|
||||
await this.InvokeAsync(this.StateHasChanged);
|
||||
if (this.startupCompleted)
|
||||
@@ -273,6 +283,12 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
||||
this.startupCompleted = true;
|
||||
_ = this.EnsureMandatoryInfosAcceptedAsync();
|
||||
break;
|
||||
|
||||
case Event.RAG_EMBEDDING_STATUS_CHANGED:
|
||||
this.LoadNavItems();
|
||||
this.LoadEmbeddingItem();
|
||||
this.StateHasChanged();
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -306,6 +322,32 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
||||
yield return new(T("Settings"), Icons.Material.Filled.Settings, palette.DarkLighten, palette.GrayLight, Routes.SETTINGS, false);
|
||||
}
|
||||
|
||||
private void LoadEmbeddingItem()
|
||||
{
|
||||
this.embeddingOverview = this.DataSourceEmbeddingService.GetOverview();
|
||||
var palette = this.ColorTheme.GetCurrentPalette(this.SettingsManager);
|
||||
(string icon, string lightcolor, string darkcolor) embeddingIcon = this.embeddingOverview.State switch
|
||||
{
|
||||
(DataSourceEmbeddingState.FAILED) => (Icons.Material.Filled.Warning, palette.Error.Value, "#d32f2f"),
|
||||
(DataSourceEmbeddingState.QUEUED) => (Icons.Material.Filled.Sync, palette.Info.Value, "#1976d2"),
|
||||
_ => (Icons.Material.Filled.Sync, palette.Warning.Value, "#d29f00"),
|
||||
};
|
||||
this.embeddingItem = new NavBarItem(T("Embeddings"), embeddingIcon.icon, embeddingIcon.lightcolor, embeddingIcon.darkcolor, Routes.EMBEDDINGS, false);
|
||||
}
|
||||
|
||||
private string EmbeddingNavigationTooltip => this.embeddingOverview.State switch
|
||||
{
|
||||
DataSourceEmbeddingState.QUEUED => T("Embeddings are waiting to be processed."),
|
||||
DataSourceEmbeddingState.RUNNING => string.Format(
|
||||
T("Embeddings are running: {0} of {1} files are indexed."),
|
||||
this.embeddingOverview.IndexedFiles,
|
||||
this.embeddingOverview.TotalFiles),
|
||||
DataSourceEmbeddingState.FAILED => this.embeddingOverview.FailedFiles > 0
|
||||
? string.Format(T("Some embeddings failed. {0} file(s) need attention."), this.embeddingOverview.FailedFiles)
|
||||
: T("Some embeddings failed and need attention."),
|
||||
_ => this.embeddingOverview.NavLabel,
|
||||
};
|
||||
|
||||
private async Task ShowUpdateDialog()
|
||||
{
|
||||
if(this.currentUpdateResponse is null)
|
||||
|
||||
Reference in new issue
Block a user