mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-05 03:09:40 +00:00
Add ERI server assistant (#231)
This commit is contained in:
1 parent
cdf717ad5f
commit
8cbef49d89
76 files changed
+3581
-153
No files matched your search
@@ -1,7 +1,7 @@
|
||||
@typeparam T
|
||||
@inherits EnumSelectionBase
|
||||
|
||||
<MudStack Row="@true" AlignItems="AlignItems.Center" Class="mb-3">
|
||||
<MudStack Row="@true" Class="mb-3">
|
||||
<MudSelect T="@T" Value="@this.Value" ValueChanged="@this.SelectionChanged" AdornmentIcon="@this.Icon" Adornment="Adornment.Start" Label="@this.Label" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateSelection">
|
||||
@foreach (var value in Enum.GetValues<T>())
|
||||
{
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<MudStack Row="@true" Spacing="3" Class="mb-3" StretchItems="StretchItems.None" AlignItems="AlignItems.Center">
|
||||
<MudTextField
|
||||
T="string"
|
||||
Text="@this.Directory"
|
||||
Label="@this.Label"
|
||||
ReadOnly="@true"
|
||||
Adornment="Adornment.Start"
|
||||
AdornmentIcon="@Icons.Material.Filled.Folder"
|
||||
UserAttributes="@SPELLCHECK_ATTRIBUTES"
|
||||
Variant="Variant.Outlined"
|
||||
/>
|
||||
|
||||
<MudButton StartIcon="@Icons.Material.Filled.FolderOpen" Variant="Variant.Outlined" Color="Color.Primary" Disabled="this.Disabled" OnClick="@this.OpenDirectoryDialog">
|
||||
Choose Directory
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
@@ -0,0 +1,60 @@
|
||||
using AIStudio.Settings;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace AIStudio.Components;
|
||||
|
||||
public partial class SelectDirectory : ComponentBase
|
||||
{
|
||||
[Parameter]
|
||||
public string Directory { get; set; } = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<string> DirectoryChanged { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool Disabled { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string Label { get; set; } = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public string DirectoryDialogTitle { get; set; } = "Select Directory";
|
||||
|
||||
[Inject]
|
||||
private SettingsManager SettingsManager { get; init; } = null!;
|
||||
|
||||
[Inject]
|
||||
public RustService RustService { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected ILogger<SelectDirectory> Logger { get; init; } = null!;
|
||||
|
||||
private static readonly Dictionary<string, object?> SPELLCHECK_ATTRIBUTES = new();
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
// Configure the spellchecking for the instance name input:
|
||||
this.SettingsManager.InjectSpellchecking(SPELLCHECK_ATTRIBUTES);
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void InternalDirectoryChanged(string directory)
|
||||
{
|
||||
this.Directory = directory;
|
||||
this.DirectoryChanged.InvokeAsync(directory);
|
||||
}
|
||||
|
||||
private async Task OpenDirectoryDialog()
|
||||
{
|
||||
var response = await this.RustService.SelectDirectory(this.DirectoryDialogTitle, string.IsNullOrWhiteSpace(this.Directory) ? null : this.Directory);
|
||||
this.Logger.LogInformation($"The user selected the directory '{response.SelectedDirectory}'.");
|
||||
|
||||
if (!response.UserCancelled)
|
||||
this.InternalDirectoryChanged(response.SelectedDirectory);
|
||||
}
|
||||
}
|
||||
@@ -38,8 +38,6 @@ public partial class Workspaces : ComponentBase
|
||||
public bool ExpandRootNodes { get; set; } = true;
|
||||
|
||||
private const Placement WORKSPACE_ITEM_TOOLTIP_PLACEMENT = Placement.Bottom;
|
||||
|
||||
public static readonly Guid WORKSPACE_ID_BIAS = Guid.Parse("82050a4e-ee92-43d7-8ee5-ab512f847e02");
|
||||
|
||||
private readonly List<TreeItemData<ITreeItem>> treeItems = new();
|
||||
|
||||
@@ -53,8 +51,6 @@ public partial class Workspaces : ComponentBase
|
||||
// - Those initial tree items cannot have children
|
||||
// - When assigning the tree items to the MudTreeViewItem component, we must set the Value property to the value of the item
|
||||
//
|
||||
|
||||
await this.EnsureBiasWorkspace();
|
||||
await this.LoadTreeItems();
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
@@ -408,18 +404,6 @@ public partial class Workspaces : ComponentBase
|
||||
await this.LoadTreeItems();
|
||||
}
|
||||
|
||||
private async Task EnsureBiasWorkspace()
|
||||
{
|
||||
var workspacePath = Path.Join(SettingsManager.DataDirectory, "workspaces", WORKSPACE_ID_BIAS.ToString());
|
||||
|
||||
if(Path.Exists(workspacePath))
|
||||
return;
|
||||
|
||||
Directory.CreateDirectory(workspacePath);
|
||||
var workspaceNamePath = Path.Join(workspacePath, "name");
|
||||
await File.WriteAllTextAsync(workspaceNamePath, "Bias of the Day", Encoding.UTF8);
|
||||
}
|
||||
|
||||
private async Task DeleteWorkspace(string? workspacePath)
|
||||
{
|
||||
if(workspacePath is null)
|
||||
|
||||
Reference in new issue
Block a user