2024-12-03 14:24:40 +00:00
@using AIStudio.Provider
2026-08-30 14:45:14 +00:00
@using AIStudio.Provider.HuggingFace
2024-12-03 14:24:40 +00:00
@using AIStudio.Provider.SelfHosted
2025-05-11 14:57:52 +00:00
@inherits MSGComponentBase
2024-12-03 14:24:40 +00:00
<MudDialog>
<DialogContent>
2026-08-15 09:20:36 +00:00
@if (this.IsEnterpriseConfiguration)
{
<MudAlert Severity="Severity.Info" Class="mb-4">
@T("This embedding provider is managed by your organization. Host, model, and other settings are locked. You can set your own API key below.")
</MudAlert>
}
2024-12-03 14:24:40 +00:00
<MudForm @ref="@this.form" @bind-IsValid="@this.dataIsValid" @bind-Errors="@this.dataIssues">
<MudStack Row="@true" AlignItems="AlignItems.Center">
@* ReSharper disable once CSharpWarnings::CS8974 *@
Merge branch 'main' into chunk-data
Resolved 29 conflicting files. The notable decisions:
Confidence: main's tool-calling gate (RequiredProviderConfidence) and this
branch's local-RAG gate (DataConfidenceLevel) turned out to be the same rule
on the same axis, so they are now one field. Both tool results and data
sources raise it through RequireProviderConfidence(). The gate checks the
level strictly and no longer exempts providers trusted by configuration:
TrustedProviderIds is documented as applying to data-source security checks
only, and organizations set confidence through DataConfidence
.CustomConfidenceScheme instead. The security axis (DataSecurity, ERI,
IsTrustedForDataSourceSecurityChecks) is unchanged.
Provider creation: main's CreateProvider signature won (hfEndpointKind,
capabilityOverrides, no model parameter); tokenizerPath was added to it and
is set for every provider, including the new Hetzner, IONOS and LiteLLM.
Provider and EmbeddingProvider combine the record parameters, Lua parsing and
Lua serialization of both sides.
File types: main's hierarchy (ODT leaf, WORD parent, PowerPoint without the
legacy .ppt, TABULAR instead of DELIMITED_TABLE) plus this branch's
SPREADSHEET parent with ODS and the xlsm/xlsb/xla/xlam extensions, which the
runtime already reads. Both sides had added a conflicting HTML filter; the
reading family keeps the name, and the export path uses a narrow
HTML_DOCUMENT, following the existing LATEX/TEX split.
Runtime: main's file_data.rs is the base, including the prompt-injection
sanitizer and the extraction routes. Token counting and chunk segmentation
moved into take_released, so they act on the text the filter has released
rather than on text it is still holding. A failed count is logged and left
out instead of ending the extraction, because the app counts such a segment
itself.
Data sources: the participating-provider checks of this branch are kept, and
main's GetAllowedDataSources overload now builds on them. DirectChatService
resolves the launched chat's data source options before the check, so filter
and chat see the same options.
.NET and Rust both build clean; I18N regenerated to 4060 keys.
2026-09-05 19:17:42 +00:00
<MudSelect @bind-Value="@this.DataLLMProvider" Label="@T("Provider")" Class="mb-3" OpenIcon="@Icons.Material.Filled.AccountBalance" AdornmentColor="Color.Info" Adornment="Adornment.Start" Disabled="@this.IsEnterpriseConfiguration" Validation="@this.providerValidation.ValidatingProvider">
2024-12-03 14:24:40 +00:00
@foreach (LLMProviders provider in Enum.GetValues(typeof(LLMProviders)))
{
2026-01-09 11:45:21 +00:00
if (provider.ProvideEmbeddingAPI() || provider is LLMProviders.NONE)
2024-12-03 14:24:40 +00:00
{
2025-04-20 10:42:42 +00:00
<MudSelectItem Value="@provider">
2026-08-25 10:46:10 +00:00
<ProviderLabel ProviderType="@provider" CustomIconDataUrl="@(provider == this.DataLLMProvider ? this.DataCustomIconDataUrl : string.Empty)" Text="@provider.ToName()" />
2025-04-20 10:42:42 +00:00
</MudSelectItem>
2024-12-03 14:24:40 +00:00
}
}
</MudSelect>
2025-05-11 14:57:52 +00:00
<MudButton Disabled="@(!this.DataLLMProvider.ShowRegisterButton())" Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.OpenInBrowser" Href="@this.DataLLMProvider.GetCreationURL()" Target="_blank">
@T("Create account")
</MudButton>
2024-12-03 14:24:40 +00:00
</MudStack>
2026-04-10 16:31:20 +00:00
2025-04-20 10:42:42 +00:00
@if (this.DataLLMProvider.IsAPIKeyNeeded(this.DataHost))
{
2026-01-11 15:02:28 +00:00
<SecretInputField Secret="@this.dataAPIKey" SecretChanged="@this.OnAPIKeyChanged" Label="@this.APIKeyText" Validation="@this.providerValidation.ValidatingAPIKey"/>
2025-04-20 10:42:42 +00:00
}
2024-12-03 14:24:40 +00:00
2025-04-20 10:42:42 +00:00
@if (this.DataLLMProvider.IsHostnameNeeded())
{
<MudTextField
T="string"
@bind-Text="@this.DataHostname"
2025-05-11 14:57:52 +00:00
Label="@T("Hostname")"
2025-04-20 10:42:42 +00:00
Class="mb-3"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Dns"
AdornmentColor="Color.Info"
2026-08-15 09:20:36 +00:00
Disabled="@this.IsEnterpriseConfiguration"
2025-04-20 10:42:42 +00:00
Validation="@this.providerValidation.ValidatingHostname"
UserAttributes="@SPELLCHECK_ATTRIBUTES"/>
}
@if (this.DataLLMProvider.IsHostNeeded())
{
2026-08-15 09:20:36 +00:00
<MudSelect T="Host" Value="@this.DataHost" ValueChanged="@this.OnHostChanged" Label="@T("Host")" Class="mb-3" OpenIcon="@Icons.Material.Filled.ExpandMore" AdornmentColor="Color.Info" Adornment="Adornment.Start" Disabled="@this.IsEnterpriseConfiguration" Validation="@this.providerValidation.ValidatingHost">
2025-04-20 10:42:42 +00:00
@foreach (Host host in Enum.GetValues(typeof(Host)))
2024-12-03 14:24:40 +00:00
{
2026-01-09 11:45:21 +00:00
if (host.IsEmbeddingSupported())
2025-04-20 10:42:42 +00:00
{
<MudSelectItem Value="@host">
@host.Name()
</MudSelectItem>
}
2024-12-03 14:24:40 +00:00
}
2025-04-20 10:42:42 +00:00
</MudSelect>
}
2024-12-03 14:24:40 +00:00
2026-08-30 14:45:14 +00:00
@if (this.DataLLMProvider.IsHFInstanceProviderNeeded())
{
<MudSelect T="HFInferenceProvider" Value="@this.HFInferenceProviderId" ValueChanged="@this.OnHFInferenceProviderChanged" Label="@T("Hugging Face Inference Provider")" Class="mb-3" OpenIcon="@Icons.Material.Filled.Dns" AdornmentColor="Color.Info" Adornment="Adornment.Start" Disabled="@this.IsEnterpriseConfiguration" Validation="@this.providerValidation.ValidatingHFInstanceProviderForEmbeddings">
@foreach (HFInferenceProvider inferenceProvider in Enum.GetValues(typeof(HFInferenceProvider)))
{
@if (inferenceProvider.SupportsEmbeddings())
{
<MudSelectItem Value="@inferenceProvider">
@inferenceProvider.ToName()
</MudSelectItem>
}
}
</MudSelect>
<MudJustifiedText Class="mb-3">
@T("Hugging Face offers embeddings through a few of its inference providers only, which is why this list is shorter than the one for chatting.")
</MudJustifiedText>
}
2025-05-11 14:57:52 +00:00
<MudField FullWidth="true" Label="@T("Model selection")" Variant="Variant.Outlined" Class="mb-3">
<MudStack Row="@true" AlignItems="AlignItems.Center" StretchItems="StretchItems.End">
@if (this.DataLLMProvider.IsEmbeddingModelProvidedManually(this.DataHost))
{
<MudTextField
T="string"
@bind-Text="@this.dataManuallyModel"
Label="@T("Model")"
Class="mb-3"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Dns"
AdornmentColor="Color.Info"
2026-08-15 09:20:36 +00:00
Disabled="@this.IsEnterpriseConfiguration"
2025-05-11 14:57:52 +00:00
Validation="@this.ValidateManuallyModel"
UserAttributes="@SPELLCHECK_ATTRIBUTES"
2026-04-10 16:31:20 +00:00
HelperText="@T("Currently, we cannot query the embedding models for the selected provider and/or host. Therefore, please enter the model name manually.")"/>
2025-05-11 14:57:52 +00:00
}
else
{
2026-08-15 09:20:36 +00:00
<MudButton Disabled="@(this.IsEnterpriseConfiguration || !this.DataLLMProvider.CanLoadModels(this.DataHost, this.dataAPIKey))" Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.Refresh" OnClick="@this.ReloadModels">
2025-05-11 14:57:52 +00:00
@T("Load")
</MudButton>
2026-04-10 16:31:20 +00:00
@if (this.availableModels.Count is 0)
2024-12-03 14:24:40 +00:00
{
2025-05-11 14:57:52 +00:00
<MudText Typo="Typo.body1">
@T("No models loaded or available.")
</MudText>
2024-12-03 14:24:40 +00:00
}
2025-05-11 14:57:52 +00:00
else
{
2026-08-15 09:20:36 +00:00
<MudSelect Disabled="@(this.IsEnterpriseConfiguration || this.IsNoneProvider)" @bind-Value="@this.DataModel" Label="@T("Model")"
2025-05-11 14:57:52 +00:00
OpenIcon="@Icons.Material.Filled.FaceRetouchingNatural"
AdornmentColor="Color.Info" Adornment="Adornment.Start"
Validation="@this.providerValidation.ValidatingModel">
@foreach (var model in this.availableModels)
{
<MudSelectItem Value="@model">
@model
</MudSelectItem>
}
</MudSelect>
}
}
</MudStack>
2026-01-18 16:15:18 +00:00
@if (!string.IsNullOrWhiteSpace(this.dataLoadingModelsIssue))
{
<MudAlert Severity="Severity.Error" Class="mt-3">
@this.dataLoadingModelsIssue
</MudAlert>
}
2025-05-11 14:57:52 +00:00
</MudField>
2024-12-03 14:24:40 +00:00
@* ReSharper disable once CSharpWarnings::CS8974 *@
<MudTextField
T="string"
@bind-Text="@this.DataName"
2025-05-11 14:57:52 +00:00
Label="@T("Instance Name")"
2024-12-03 14:24:40 +00:00
Class="mb-3"
MaxLength="40"
Counter="40"
Immediate="@true"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Lightbulb"
AdornmentColor="Color.Info"
2026-08-15 09:20:36 +00:00
Disabled="@this.IsEnterpriseConfiguration"
2024-12-03 14:24:40 +00:00
Validation="@this.providerValidation.ValidatingInstanceName"
2026-07-29 16:47:59 +00:00
UserAttributes="@SPELLCHECK_ATTRIBUTES"/>
2026-05-13 16:13:34 +00:00
@if (this.DataLLMProvider != LLMProviders.NONE)
{
2026-07-29 16:47:59 +00:00
<MudStack>
<MudButton OnClick="@this.ToggleExpertSettings">
@(this.showExpertSettings ? T("Hide Expert Settings") : T("Show Expert Settings"))
</MudButton>
<MudDivider />
<MudCollapse Expanded="@this.showExpertSettings" Class="@this.GetExpertStyles">
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
@T("Please be aware: This section is for experts only. For cloud providers, the selected tokenizer and chunk settings may not match the real embedding model limits exactly.")
</MudJustifiedText>
<MudNumericField
T="int"
@bind-Value="@this.DataTokenLimit"
Label="@T("Token limit")"
Class="mb-3"
Min="1"
Immediate="@true"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Numbers"
AdornmentColor="Color.Info"
Validation="@this.ValidateTokenLimit"
2026-08-10 20:13:13 +00:00
HelperText="@T("Maximum number of tokens sent to the embedding model per chunk. The default is 8,192.")"/>
2026-07-29 16:47:59 +00:00
<MudNumericField
T="int"
@bind-Value="@this.DataEmbeddingBatchSize"
Label="@T("Embedding batch size")"
Class="mb-3"
Min="1"
Immediate="@true"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.FormatListNumbered"
AdornmentColor="Color.Info"
Validation="@this.ValidateEmbeddingBatchSize"
HelperText="@T("How many chunks are sent to the embedding provider at once. The default is 1.")"/>
2026-08-04 16:01:25 +00:00
<MudStack Row="@true" Spacing="3" Class="mb-3" StretchItems="StretchItems.None" AlignItems="AlignItems.Center">
<MudTextField
T="string"
Text="@this.dataFilePath"
TextChanged="@this.OnDataFilePathChanged"
Label="@T("Selected file path for the custom tokenizer")"
Validation="@this.providerValidation.ValidatingCustomTokenizer"
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.AttachFile"
UserAttributes="@SPELLCHECK_ATTRIBUTES"
Variant="Variant.Outlined"
Clearable="@true"
Error="@(!string.IsNullOrWhiteSpace(this.dataCustomTokenizerValidationIssue))"
ErrorText="@this.dataCustomTokenizerValidationIssue"
OnClearButtonClick="@this.ClearPathTokenizer"
/>
<MudButton StartIcon="@Icons.Material.Filled.FolderOpen" Variant="Variant.Outlined" Color="Color.Primary" Disabled="@this.isTokenizerFileDialogOpen" OnClick="@this.OpenTokenizerFileDialog">
@T("Choose File")
</MudButton>
</MudStack>
2026-07-29 16:47:59 +00:00
</MudCollapse>
</MudStack>
2026-04-10 16:31:20 +00:00
}
2024-12-03 14:24:40 +00:00
</MudForm>
2026-04-10 16:31:20 +00:00
@if (this.dataStoreWasAttempted)
{
<Issues IssuesData="@this.dataIssues"/>
}
2024-12-03 14:24:40 +00:00
</DialogContent>
<DialogActions>
2025-05-11 14:57:52 +00:00
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled">
@T("Cancel")
</MudButton>
2024-12-03 14:24:40 +00:00
<MudButton OnClick="@this.Store" Variant="Variant.Filled" Color="Color.Primary">
2026-04-10 16:31:20 +00:00
@if (this.IsEditing)
2024-12-03 14:24:40 +00:00
{
2025-05-11 14:57:52 +00:00
@T("Update")
2024-12-03 14:24:40 +00:00
}
else
{
2025-05-11 14:57:52 +00:00
@T("Add")
2024-12-03 14:24:40 +00:00
}
</MudButton>
</DialogActions>
2026-07-28 14:37:07 +00:00
</MudDialog>