Skip to content

Commit 63be312

Browse files
Configure data sources (#259)
1 parent 06f66fd commit 63be312

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3388
-283
lines changed

app/ERIClientV1/Client.Generated.cs

+1,277
Large diffs are not rendered by default.

app/ERIClientV1/ERIClientV1.csproj

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<LangVersion>latest</LangVersion>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
</Project>

app/MindWork AI Studio.sln

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Microsoft Visual Studio Solution File, Format Version 12.00
33
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MindWork AI Studio", "MindWork AI Studio\MindWork AI Studio.csproj", "{059FDFCC-7D0B-474E-9F20-B9C437DF1CDD}"
44
EndProject
5+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ERIClients", "ERIClients", "{5C2AF789-287B-4FCB-B675-7273D8CD4579}"
6+
EndProject
7+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ERIClientV1", "ERIClientV1\ERIClientV1.csproj", "{9E35A273-0FA6-4BD5-8880-A1DDAC106926}"
8+
EndProject
59
Global
610
GlobalSection(SolutionConfigurationPlatforms) = preSolution
711
Debug|Any CPU = Debug|Any CPU
@@ -12,5 +16,12 @@ Global
1216
{059FDFCC-7D0B-474E-9F20-B9C437DF1CDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
1317
{059FDFCC-7D0B-474E-9F20-B9C437DF1CDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
1418
{059FDFCC-7D0B-474E-9F20-B9C437DF1CDD}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{9E35A273-0FA6-4BD5-8880-A1DDAC106926}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20+
{9E35A273-0FA6-4BD5-8880-A1DDAC106926}.Debug|Any CPU.Build.0 = Debug|Any CPU
21+
{9E35A273-0FA6-4BD5-8880-A1DDAC106926}.Release|Any CPU.ActiveCfg = Release|Any CPU
22+
{9E35A273-0FA6-4BD5-8880-A1DDAC106926}.Release|Any CPU.Build.0 = Release|Any CPU
23+
EndGlobalSection
24+
GlobalSection(NestedProjects) = preSolution
25+
{9E35A273-0FA6-4BD5-8880-A1DDAC106926} = {5C2AF789-287B-4FCB-B675-7273D8CD4579}
1526
EndGlobalSection
1627
EndGlobal

app/MindWork AI Studio/Assistants/ERI/AssistantERI.razor

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ else
5252
<MudButton Disabled="@this.AreServerPresetsBlocked" OnClick="@this.AddERIServer" Variant="Variant.Filled" Color="Color.Primary">
5353
Add ERI server preset
5454
</MudButton>
55-
<MudButton OnClick="@this.RemoveERIServer" Disabled="@(this.AreServerPresetsBlocked || this.IsNoneERIServerSelected)" Variant="Variant.Filled" Color="Color.Primary">
55+
<MudButton OnClick="@this.RemoveERIServer" Disabled="@(this.AreServerPresetsBlocked || this.IsNoneERIServerSelected)" Variant="Variant.Filled" Color="Color.Error">
5656
Delete this server preset
5757
</MudButton>
5858
</MudStack>
@@ -346,4 +346,4 @@ else
346346
</MudText>
347347

348348
<MudTextSwitch Label="Should we write the generated code to the file system?" Disabled="@this.IsNoneERIServerSelected" @bind-Value="@this.writeToFilesystem" LabelOn="Yes, please write or update all generated code to the file system" LabelOff="No, just show me the code" />
349-
<SelectDirectory Label="Base directory where to write the code" @bind-Directory="@this.baseDirectory" Disabled="@(this.IsNoneERIServerSelected || !this.writeToFilesystem)" DirectoryDialogTitle="Select the target directory for the ERI server"/>
349+
<SelectDirectory Label="Base directory where to write the code" @bind-Directory="@this.baseDirectory" Disabled="@(this.IsNoneERIServerSelected || !this.writeToFilesystem)" DirectoryDialogTitle="Select the target directory for the ERI server" Validation="@this.ValidateDirectory" />

app/MindWork AI Studio/Assistants/ERI/AssistantERI.razor.cs

+11
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,17 @@ private bool IsAuthDescriptionOptional()
739739

740740
return null;
741741
}
742+
743+
private string? ValidateDirectory(string path)
744+
{
745+
if(!this.writeToFilesystem)
746+
return null;
747+
748+
if(string.IsNullOrWhiteSpace(path))
749+
return "Please provide a base directory for the ERI server to write files to.";
750+
751+
return null;
752+
}
742753

743754
private string GetMultiSelectionAuthText(List<Auth> selectedValues)
744755
{

app/MindWork AI Studio/Components/SelectDirectory.razor

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Text="@this.Directory"
55
Label="@this.Label"
66
ReadOnly="@true"
7+
Validation="@this.Validation"
78
Adornment="Adornment.Start"
89
AdornmentIcon="@Icons.Material.Filled.Folder"
910
UserAttributes="@SPELLCHECK_ATTRIBUTES"

app/MindWork AI Studio/Components/SelectDirectory.razor.cs

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public partial class SelectDirectory : ComponentBase
2121
[Parameter]
2222
public string DirectoryDialogTitle { get; set; } = "Select Directory";
2323

24+
[Parameter]
25+
public Func<string, string?> Validation { get; set; } = _ => null;
26+
2427
[Inject]
2528
private SettingsManager SettingsManager { get; init; } = null!;
2629

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<MudStack Row="@true" Spacing="3" Class="mb-3" StretchItems="StretchItems.None" AlignItems="AlignItems.Center">
2+
<MudTextField
3+
T="string"
4+
Text="@this.File"
5+
Label="@this.Label"
6+
ReadOnly="@true"
7+
Validation="@this.Validation"
8+
Adornment="Adornment.Start"
9+
AdornmentIcon="@Icons.Material.Filled.AttachFile"
10+
UserAttributes="@SPELLCHECK_ATTRIBUTES"
11+
Variant="Variant.Outlined"
12+
/>
13+
14+
<MudButton StartIcon="@Icons.Material.Filled.FolderOpen" Variant="Variant.Outlined" Color="Color.Primary" Disabled="this.Disabled" OnClick="@this.OpenFileDialog">
15+
Choose File
16+
</MudButton>
17+
</MudStack>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using AIStudio.Settings;
2+
3+
using Microsoft.AspNetCore.Components;
4+
5+
namespace AIStudio.Components;
6+
7+
public partial class SelectFile : ComponentBase
8+
{
9+
[Parameter]
10+
public string File { get; set; } = string.Empty;
11+
12+
[Parameter]
13+
public EventCallback<string> FileChanged { get; set; }
14+
15+
[Parameter]
16+
public bool Disabled { get; set; }
17+
18+
[Parameter]
19+
public string Label { get; set; } = string.Empty;
20+
21+
[Parameter]
22+
public string FileDialogTitle { get; set; } = "Select File";
23+
24+
[Parameter]
25+
public Func<string, string?> Validation { get; set; } = _ => null;
26+
27+
[Inject]
28+
private SettingsManager SettingsManager { get; init; } = null!;
29+
30+
[Inject]
31+
public RustService RustService { get; set; } = null!;
32+
33+
[Inject]
34+
protected ILogger<SelectDirectory> Logger { get; init; } = null!;
35+
36+
private static readonly Dictionary<string, object?> SPELLCHECK_ATTRIBUTES = new();
37+
38+
#region Overrides of ComponentBase
39+
40+
protected override async Task OnInitializedAsync()
41+
{
42+
// Configure the spellchecking for the instance name input:
43+
this.SettingsManager.InjectSpellchecking(SPELLCHECK_ATTRIBUTES);
44+
await base.OnInitializedAsync();
45+
}
46+
47+
#endregion
48+
49+
private void InternalFileChanged(string file)
50+
{
51+
this.File = file;
52+
this.FileChanged.InvokeAsync(file);
53+
}
54+
55+
private async Task OpenFileDialog()
56+
{
57+
var response = await this.RustService.SelectFile(this.FileDialogTitle, string.IsNullOrWhiteSpace(this.File) ? null : this.File);
58+
this.Logger.LogInformation($"The user selected the file '{response.SelectedFilePath}'.");
59+
60+
if (!response.UserCancelled)
61+
this.InternalFileChanged(response.SelectedFilePath);
62+
}
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
@using AIStudio.Settings
2+
@using AIStudio.Settings.DataModel
3+
@inherits SettingsPanelBase
4+
5+
@if (PreviewFeatures.PRE_RAG_2024.IsEnabled(this.SettingsManager))
6+
{
7+
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.IntegrationInstructions" HeaderText="Configure Data Sources">
8+
<PreviewPrototype/>
9+
<MudText Typo="Typo.h4" Class="mb-3">
10+
Configured Data Sources
11+
</MudText>
12+
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
13+
You might configure different data sources. A data source can include one file, all files
14+
in a directory, or data from your company. Later, you can incorporate these data sources
15+
as needed when the AI requires this data to complete a certain task.
16+
</MudJustifiedText>
17+
18+
<MudTable Items="@this.SettingsManager.ConfigurationData.DataSources" Hover="@true" Class="border-dashed border rounded-lg">
19+
<ColGroup>
20+
<col style="width: 3em;"/>
21+
<col/>
22+
<col style="width: 12em;"/>
23+
<col style="width: 12em;"/>
24+
<col style="width: 40em;"/>
25+
</ColGroup>
26+
<HeaderContent>
27+
<MudTh>#</MudTh>
28+
<MudTh>Name</MudTh>
29+
<MudTh>Type</MudTh>
30+
<MudTh>Embedding</MudTh>
31+
<MudTh Style="text-align: left;">Actions</MudTh>
32+
</HeaderContent>
33+
<RowTemplate>
34+
<MudTd>@context.Num</MudTd>
35+
<MudTd>@context.Name</MudTd>
36+
<MudTd>@context.Type.GetDisplayName()</MudTd>
37+
<MudTd>@this.GetEmbeddingName(context)</MudTd>
38+
39+
<MudTd Style="text-align: left;">
40+
@if (context is IERIDataSource)
41+
{
42+
@* <MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.Info" Class="ma-2" OnClick="() => this.ShowInformation(context)"> *@
43+
@* Show Information *@
44+
@* </MudButton> *@
45+
}
46+
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.Edit" Class="ma-2" OnClick="() => this.EditDataSource(context)">
47+
Edit
48+
</MudButton>
49+
<MudButton Variant="Variant.Filled" Color="Color.Error" StartIcon="@Icons.Material.Filled.Delete" Class="ma-2" OnClick="() => this.DeleteDataSource(context)">
50+
Delete
51+
</MudButton>
52+
</MudTd>
53+
</RowTemplate>
54+
</MudTable>
55+
56+
@if (this.SettingsManager.ConfigurationData.DataSources.Count == 0)
57+
{
58+
<MudText Typo="Typo.h6" Class="mt-3">No data sources configured yet.</MudText>
59+
}
60+
61+
<MudMenu EndIcon="@Icons.Material.Filled.KeyboardArrowDown" Label="Add Data Source" Color="Color.Primary" Variant="Variant.Filled" AnchorOrigin="Origin.CenterCenter" TransformOrigin="Origin.TopLeft" Class="mt-3 mb-6">
62+
<MudMenuItem OnClick="() => this.AddDataSource(DataSourceType.ERI_V1)">External Data (ERI-Server v1)</MudMenuItem>
63+
<MudMenuItem OnClick="() => this.AddDataSource(DataSourceType.LOCAL_DIRECTORY)">Local Directory</MudMenuItem>
64+
<MudMenuItem OnClick="() => this.AddDataSource(DataSourceType.LOCAL_FILE)">Local File</MudMenuItem>
65+
</MudMenu>
66+
</ExpansionPanel>
67+
}

0 commit comments

Comments
 (0)