2025-02-15 14:41:12 +00:00
@using AIStudio.Settings.DataModel
2026-08-03 17:45:47 +00:00
@using AIStudio.Provider
2025-05-18 19:31:15 +00:00
@inherits MSGComponentBase
2025-02-15 14:41:12 +00:00
2025-01-13 18:51:26 +00:00
<MudDialog>
<DialogContent>
<MudForm @ref="@this.form" @bind-IsValid="@this.dataIsValid" @bind-Errors="@this.dataIssues">
@* ReSharper disable once CSharpWarnings::CS8974 *@
<MudTextField
T="string"
@bind-Text="@this.dataName"
2025-05-18 19:31:15 +00:00
Label="@T("Data Source Name")"
2025-01-13 18:51:26 +00:00
Class="mb-6"
MaxLength="40"
Counter="40"
Immediate="@true"
Validation="@this.dataSourceValidation.ValidatingName"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Lightbulb"
AdornmentColor="Color.Info"
UserAttributes="@SPELLCHECK_ATTRIBUTES"
2025-12-08 19:53:46 +00:00
Variant="Variant.Outlined"
/>
<MudTextField
T="string"
@bind-Text="@this.dataDescription"
Label="@T("Description")"
Class="mb-6"
MaxLength="200"
Counter="200"
Immediate="@true"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Description"
AdornmentColor="Color.Info"
HelperText="@T("Describe what data this directory contains to help the AI select it.")"
UserAttributes="@SPELLCHECK_ATTRIBUTES"
Variant="Variant.Outlined"
Lines="3"
2025-01-13 18:51:26 +00:00
/>
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
2025-05-18 19:31:15 +00:00
@T("Select a root directory for this data source. All data in this directory and all its subdirectories will be processed for this data source.")
2025-01-13 18:51:26 +00:00
</MudJustifiedText>
2026-08-03 15:53:31 +00:00
@if (!this.CanChangeSourceAndEmbedding)
{
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined" Class="mb-3">
@T("This data source already has indexed embeddings. Delete and recreate it to change the folder path or embedding model.")
</MudAlert>
}
2026-08-04 16:01:25 +00:00
@if (this.CanChangeSourceAndEmbedding)
{
<SelectDirectory @bind-Directory="@this.dataPath" Label="@T("Selected base directory for this data source")" DirectoryDialogTitle="@T("Select the base directory")" Validation="@this.dataSourceValidation.ValidatePath" />
}
else
{
<MudTextField
T="string"
Text="@this.dataPath"
Label="@T("Selected base directory for this data source")"
Class="mb-3"
ReadOnly="@true"
Validation="@this.dataSourceValidation.ValidatePath"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Folder"
UserAttributes="@SPELLCHECK_ATTRIBUTES"
Variant="Variant.Outlined"
/>
}
2025-01-13 18:51:26 +00:00
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
2025-05-18 19:31:15 +00:00
@T("In order for the AI to be able to determine the appropriate data at any time, you must choose an embedding method.")
2025-01-13 18:51:26 +00:00
</MudJustifiedText>
2026-08-04 16:01:25 +00:00
@if (this.CanChangeSourceAndEmbedding)
{
2026-08-05 13:05:17 +00:00
<MudSelect @bind-Value="@this.dataEmbeddingId" Label="@T("Embedding")" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.dataSourceValidation.ValidateEmbeddingProviderAccess">
2026-08-04 16:01:25 +00:00
@foreach (var embedding in this.AvailableEmbeddings)
{
<MudSelectItem Value="@embedding.Value">
@embedding.Name
</MudSelectItem>
}
</MudSelect>
}
else
{
<MudTextField
T="string"
Text="@this.SelectedEmbeddingNameText"
Label="@T("Embedding")"
Class="mb-3"
ReadOnly="@true"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.DataObject"
AdornmentColor="Color.Info"
Variant="Variant.Outlined"
/>
}
2025-01-13 18:51:26 +00:00
@if (!string.IsNullOrWhiteSpace(this.dataEmbeddingId))
{
if (this.SelectedCloudEmbedding)
{
2026-07-28 18:22:37 +00:00
<DataSourceCloudEmbeddingWarning DataSourceType="DataSourceType.LOCAL_DIRECTORY" SourcePath="@this.dataPath" @bind-UserAcknowledged="@this.dataUserAcknowledgedCloudEmbedding" Validation="@this.dataSourceValidation.ValidateUserAcknowledgedCloudEmbedding"/>
2025-01-13 18:51:26 +00:00
}
else
{
<MudJustifiedText Typo="Typo.body1" Color="Color.Tertiary" Class="mb-3">
2025-05-18 19:31:15 +00:00
@T("The embedding you selected runs locally or in your organization. Your data is not sent to the cloud.")
2025-01-13 18:51:26 +00:00
</MudJustifiedText>
}
}
2025-05-30 20:39:16 +00:00
<ManagePandocDependency IntroText="@T("For some data types, such as Office files, MindWork AI Studio requires the open-source application Pandoc.")"/>
2025-02-15 14:41:12 +00:00
2026-08-05 13:05:17 +00:00
<MudSelect @bind-Value="@this.dataComplianceLevel" Text="@this.dataComplianceLevel.GetName()" Label="@T("Compliance level")" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Validation="@this.dataSourceValidation.ValidateDataSourceComplianceLevel">
2026-08-03 17:45:47 +00:00
@foreach (var level in this.ComplianceLevels)
{
<MudSelectItem Value="@level.Value">
@level.Name
</MudSelectItem>
}
</MudSelect>
2025-05-26 17:53:31 +00:00
2026-08-05 13:05:17 +00:00
<MudStack Class="mb-3">
<MudButton OnClick="@this.ToggleExpertSettings" Variant="Variant.Text" Color="Color.Primary" StartIcon="@Icons.Material.Filled.Tune">
@(this.showExpertSettings ? T("Hide Expert Settings") : T("Show Expert Settings"))
</MudButton>
<MudDivider/>
<MudCollapse Expanded="@this.showExpertSettings" Class="@this.GetExpertStyles">
@if (!string.IsNullOrWhiteSpace(this.dataEmbeddingId))
{
<MudTextField
T="string"
Text="@this.SelectedEmbeddingTokenizerText"
Label="@T("Tokenizer")"
Class="mb-3"
ReadOnly="@true"
Variant="Variant.Outlined"
Adornment="Adornment.Start"
2026-08-10 20:06:26 +00:00
AdornmentIcon="@Icons.Material.Filled.TextFields"
2026-08-05 13:05:17 +00:00
AdornmentColor="Color.Info"/>
}
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
@T("Optional expert settings for how this data source is split before embedding.")
</MudJustifiedText>
<MudNumericField
T="int"
@bind-Value="@this.dataMaxChunkTokenLength"
Label="@T("Token limit")"
Class="mb-3"
Min="0"
Immediate="@true"
Validation="@this.ValidateMaxChunkTokenLength"
HelperText="@T("Maximum number of tokens per chunk for this data source. Use 0 to use the embedding provider setting.")"
Variant="Variant.Outlined"
Adornment="Adornment.Start"
2026-08-10 20:06:26 +00:00
AdornmentIcon="@Icons.Material.Filled.FormatListNumbered"
2026-08-05 13:05:17 +00:00
AdornmentColor="Color.Info"/>
<MudNumericField
T="int"
@bind-Value="@this.dataChunkOverlapTokenLength"
Label="@T("Token overlap")"
Min="0"
Immediate="@true"
Validation="@this.ValidateChunkOverlapTokenLength"
HelperText="@T("Number of tokens repeated at the start of the next chunk. Use 0 to use the default overlap.")"
Variant="Variant.Outlined"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.CompareArrows"
AdornmentColor="Color.Info"/>
2026-08-10 20:06:26 +00:00
<MudNumericField
T="ushort"
Min="10"
@bind-Value="@this.dataMaxMatches"
Label="@T("How many matches do you want at most per query?")"
Variant="Variant.Outlined"
Step="10"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Search"
AdornmentColor="Color.Info"/>
2026-08-05 13:05:17 +00:00
</MudCollapse>
</MudStack>
2025-01-13 18:51:26 +00:00
</MudForm>
<Issues IssuesData="@this.dataIssues"/>
</DialogContent>
<DialogActions>
2025-05-18 19:31:15 +00:00
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled">
@T("Cancel")
</MudButton>
2025-01-13 18:51:26 +00:00
<MudButton OnClick="@this.Store" Variant="Variant.Filled" Color="Color.Primary">
@if(this.IsEditing)
{
2025-05-18 19:31:15 +00:00
@T("Update")
2025-01-13 18:51:26 +00:00
}
else
{
2025-05-18 19:31:15 +00:00
@T("Add")
2025-01-13 18:51:26 +00:00
}
</MudButton>
</DialogActions>
2026-07-29 16:47:59 +00:00
</MudDialog>