mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-09-29 03:03:38 +00:00
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.
298 lines
18 KiB
Plaintext
298 lines
18 KiB
Plaintext
@using AIStudio.Provider
|
|
@using AIStudio.Provider.HuggingFace
|
|
@using AIStudio.Provider.SelfHosted
|
|
@using AIStudio.Tools.Rust
|
|
@inherits MSGComponentBase
|
|
<MudDialog>
|
|
<DialogContent>
|
|
@if (this.IsEnterpriseConfiguration)
|
|
{
|
|
<MudAlert Severity="Severity.Info" Class="mb-4">
|
|
@T("This provider is managed by your organization. Host, model, and other settings are locked. You can set your own API key below.")
|
|
</MudAlert>
|
|
}
|
|
<MudForm @ref="@this.form" @bind-IsValid="@this.dataIsValid" @bind-Errors="@this.dataIssues">
|
|
<MudStack Row="@true" AlignItems="AlignItems.Center">
|
|
@* ReSharper disable once CSharpWarnings::CS8974 *@
|
|
<MudSelect T="LLMProviders"
|
|
Value="@this.DataLLMProvider"
|
|
ValueChanged="@this.OnProviderChanged"
|
|
Label="@T("Provider")"
|
|
Class="mb-3"
|
|
Disabled="@this.IsEnterpriseConfiguration"
|
|
Validation="@this.providerValidation.ValidatingProvider">
|
|
@foreach (LLMProviders provider in Enum.GetValues(typeof(LLMProviders)))
|
|
{
|
|
<MudSelectItem Value="@provider">
|
|
<ProviderLabel ProviderType="@provider" CustomIconDataUrl="@(provider == this.DataLLMProvider ? this.DataCustomIconDataUrl : string.Empty)" Text="@provider.ToName()" />
|
|
</MudSelectItem>
|
|
}
|
|
</MudSelect>
|
|
<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>
|
|
</MudStack>
|
|
|
|
@if (this.DataLLMProvider.IsAPIKeyNeeded(this.DataHost))
|
|
{
|
|
<SecretInputField Secret="@this.dataAPIKey" SecretChanged="@this.OnAPIKeyChanged" Label="@this.APIKeyText" Validation="@this.providerValidation.ValidatingAPIKey"/>
|
|
}
|
|
|
|
@if (this.DataLLMProvider.IsHostnameNeeded())
|
|
{
|
|
<MudTextField
|
|
T="string"
|
|
@bind-Text="@this.DataHostname"
|
|
Label="@T("Hostname")"
|
|
Class="mb-3"
|
|
Adornment="Adornment.Start"
|
|
AdornmentIcon="@Icons.Material.Filled.Dns"
|
|
AdornmentColor="Color.Info"
|
|
Disabled="@this.IsEnterpriseConfiguration"
|
|
Validation="@this.providerValidation.ValidatingHostname"
|
|
UserAttributes="@SPELLCHECK_ATTRIBUTES"/>
|
|
}
|
|
|
|
@if (this.DataLLMProvider.IsHostNeeded())
|
|
{
|
|
<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">
|
|
@foreach (Host host in Enum.GetValues(typeof(Host)))
|
|
{
|
|
@if (host.IsChatSupported())
|
|
{
|
|
<MudSelectItem Value="@host">
|
|
@host.Name()
|
|
</MudSelectItem>
|
|
}
|
|
}
|
|
</MudSelect>
|
|
}
|
|
|
|
@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.ValidatingHFInstanceProvider">
|
|
@foreach (HFInferenceProvider inferenceProvider in Enum.GetValues(typeof(HFInferenceProvider)))
|
|
{
|
|
@if (inferenceProvider.SupportsChat())
|
|
{
|
|
<MudSelectItem Value="@inferenceProvider">
|
|
@inferenceProvider.ToName()
|
|
</MudSelectItem>
|
|
}
|
|
}
|
|
</MudSelect>
|
|
<MudJustifiedText Class="mb-3">
|
|
@T("Choose which inference provider should answer your requests. When you pick one of the automatic options instead, Hugging Face selects a provider for you and switches to another one when your choice is unavailable.")
|
|
</MudJustifiedText>
|
|
}
|
|
|
|
@if (!this.IsLLMModelSelectionHidden)
|
|
{
|
|
<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.IsLLMModelProvidedManually())
|
|
{
|
|
<MudButton Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.OpenInBrowser" Href="@this.ModelsOverviewURL" Target="_blank">
|
|
@T("Show available models")
|
|
</MudButton>
|
|
<MudTextField
|
|
T="string"
|
|
@bind-Text="@this.dataManuallyModel"
|
|
Label="@T("Model")"
|
|
Adornment="Adornment.Start"
|
|
AdornmentIcon="@Icons.Material.Filled.FaceRetouchingNatural"
|
|
AdornmentColor="Color.Info"
|
|
Disabled="@this.IsEnterpriseConfiguration"
|
|
Validation="@this.ValidateManuallyModel"
|
|
UserAttributes="@SPELLCHECK_ATTRIBUTES"
|
|
HelperText="@T("Currently, we cannot query the models for the selected provider and/or host. Therefore, please enter the model name manually.")"
|
|
/>
|
|
}
|
|
else
|
|
{
|
|
@if (!string.IsNullOrWhiteSpace(this.ModelsOverviewURL))
|
|
{
|
|
<MudButton Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.OpenInBrowser" Href="@this.ModelsOverviewURL" Target="_blank">
|
|
@T("Show available models")
|
|
</MudButton>
|
|
}
|
|
<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">
|
|
@T("Load models")
|
|
</MudButton>
|
|
@if(this.availableModels.Count is 0)
|
|
{
|
|
<MudText Typo="Typo.body1">
|
|
@T("No models loaded or available.")
|
|
</MudText>
|
|
}
|
|
else
|
|
{
|
|
<MudSelect T="Provider.Model"
|
|
Value="@this.DataModel"
|
|
ValueChanged="@(async model => await this.OnModelChanged(model))"
|
|
OpenIcon="@Icons.Material.Filled.FaceRetouchingNatural" AdornmentColor="Color.Info"
|
|
Adornment="Adornment.Start" Disabled="@this.IsEnterpriseConfiguration" Validation="@this.providerValidation.ValidatingModel">
|
|
@foreach (var model in this.availableModels)
|
|
{
|
|
<MudSelectItem Value="@model">
|
|
@model
|
|
</MudSelectItem>
|
|
}
|
|
</MudSelect>
|
|
}
|
|
}
|
|
</MudStack>
|
|
@if (!string.IsNullOrWhiteSpace(this.dataLoadingModelsIssue))
|
|
{
|
|
<MudAlert Severity="Severity.Error" Class="mt-3">
|
|
@this.dataLoadingModelsIssue
|
|
</MudAlert>
|
|
}
|
|
</MudField>
|
|
}
|
|
else
|
|
{
|
|
<MudField FullWidth="true" Label="@T("Model selection")" Variant="Variant.Outlined" Class="mb-3">
|
|
<MudText Typo="Typo.body1">
|
|
@T("This host uses the model configured at the provider level. No model selection is available.")
|
|
</MudText>
|
|
</MudField>
|
|
}
|
|
|
|
@* ReSharper disable once CSharpWarnings::CS8974 *@
|
|
<MudTextField
|
|
T="string"
|
|
@bind-Text="@this.DataInstanceName"
|
|
Label="@T("Instance Name")"
|
|
Class="mb-3"
|
|
MaxLength="40"
|
|
Counter="40"
|
|
Immediate="@true"
|
|
Adornment="Adornment.Start"
|
|
AdornmentIcon="@Icons.Material.Filled.Lightbulb"
|
|
AdornmentColor="Color.Info"
|
|
Disabled="@this.IsEnterpriseConfiguration"
|
|
Validation="@this.providerValidation.ValidatingInstanceName"
|
|
UserAttributes="@SPELLCHECK_ATTRIBUTES"
|
|
/>
|
|
|
|
@if (this.DataLLMProvider != LLMProviders.NONE)
|
|
{
|
|
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
|
|
@T("For better token estimates, you can configure a custom tokenizer for this provider.")
|
|
</MudJustifiedText>
|
|
<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>
|
|
}
|
|
|
|
<MudStack>
|
|
<MudButton OnClick="@this.ToggleExpertSettings">
|
|
@(this.showExpertSettings ? T("Hide Expert Settings") : T("Show Expert Settings"))
|
|
</MudButton>
|
|
<MudDivider />
|
|
<MudCollapse Expanded="@this.showExpertSettings" Class="@this.GetExpertStyles">
|
|
<MudAlert Severity="Severity.Warning" Class="mb-4">
|
|
@T("Please be careful: wrong expert settings can break model usage, disable supported features, or make unsupported features appear available.")
|
|
</MudAlert>
|
|
<MudText Typo="Typo.subtitle2" Class="mb-2">
|
|
@T("Override Model Capabilities")
|
|
</MudText>
|
|
<MudJustifiedText Typo="Typo.body2" Class="mb-4">
|
|
@T("Stored default model capabilities may not reflect its full range. Override them here if needed.")
|
|
</MudJustifiedText>
|
|
<MudStack Class="mb-4" Spacing="2">
|
|
@foreach (var capability in SWITCH_CAPABILITY_OVERRIDES)
|
|
{
|
|
<MudPaper Outlined="@true" Class="pa-3">
|
|
<MudStack Row="@true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween" Wrap="Wrap.Wrap">
|
|
<MudStack Spacing="0">
|
|
<MudText Typo="Typo.body2">
|
|
@this.GetCapabilityOverrideLabel(capability)
|
|
</MudText>
|
|
<MudText Typo="Typo.caption" Color="Color.Secondary">
|
|
@this.GetCapabilityEffectiveLabel(capability)
|
|
</MudText>
|
|
</MudStack>
|
|
<MudStack Row="@true" AlignItems="AlignItems.Center" Spacing="2">
|
|
<MudSwitch T="bool"
|
|
Value="@this.IsCapabilityEnabled(capability)"
|
|
ValueChanged="@(value => this.OnCapabilitySwitchChanged(capability, value))"
|
|
Disabled="@this.IsEnterpriseConfiguration"
|
|
Color="Color.Primary" />
|
|
<MudButton Variant="Variant.Outlined"
|
|
Color="Color.Default"
|
|
Size="Size.Small"
|
|
StartIcon="@Icons.Material.Filled.RestartAlt"
|
|
Disabled="@(this.IsEnterpriseConfiguration || !this.HasCapabilityOverride(capability))"
|
|
OnClick="@(() => this.ResetCapabilityOverride(capability))">
|
|
@T("Reset")
|
|
</MudButton>
|
|
</MudStack>
|
|
</MudStack>
|
|
</MudPaper>
|
|
}
|
|
<MudPaper Outlined="@true" Class="pa-3">
|
|
<MudSelect T="ReasoningOverrideMode"
|
|
Value="@this.GetReasoningOverrideMode()"
|
|
ValueChanged="@this.SetReasoningOverrideMode"
|
|
Label="@T("Reasoning (thinking) behavior")"
|
|
HelperText="@this.GetReasoningOverrideModeDescription(this.GetReasoningOverrideMode())"
|
|
Variant="Variant.Outlined"
|
|
Margin="Margin.Dense"
|
|
OpenIcon="@Icons.Material.Filled.Psychology"
|
|
AdornmentColor="Color.Info"
|
|
Adornment="Adornment.Start"
|
|
Disabled="@this.IsEnterpriseConfiguration">
|
|
@foreach (var mode in REASONING_OVERRIDE_MODES)
|
|
{
|
|
<MudSelectItem Value="@mode">
|
|
@this.GetReasoningOverrideModeLabel(mode)
|
|
</MudSelectItem>
|
|
}
|
|
</MudSelect>
|
|
</MudPaper>
|
|
</MudStack>
|
|
<MudJustifiedText Typo="Typo.body2" Class="mb-4">
|
|
@string.Format(T("The current model uses the {0}."), this.GetCurrentModelApiLabel())
|
|
</MudJustifiedText>
|
|
<MudTextField T="string" Label=@T("Additional API parameters") Variant="Variant.Outlined" Lines="4" AutoGrow="true" MaxLines="10" HelperText=@T("""Add the parameters in proper JSON formatting, e.g., "temperature": 0.5. Remove trailing commas. The usual surrounding curly brackets {} must not be used, though.""") Placeholder="@GetPlaceholderExpertSettings" @bind-Value="@this.AdditionalJsonApiParameters" Immediate="true" Disabled="@this.IsEnterpriseConfiguration" Validation="@this.ValidateAdditionalJsonApiParameters" OnBlur="@this.OnInputChangeExpertSettings"/>
|
|
</MudCollapse>
|
|
</MudStack>
|
|
</MudForm>
|
|
<Issues IssuesData="@this.dataIssues"/>
|
|
</DialogContent>
|
|
<DialogActions>
|
|
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled">
|
|
@T("Cancel")
|
|
</MudButton>
|
|
<MudButton OnClick="@this.Store" Variant="Variant.Filled" Color="Color.Primary">
|
|
@if(this.IsEditing)
|
|
{
|
|
@T("Update")
|
|
}
|
|
else
|
|
{
|
|
@T("Add")
|
|
}
|
|
</MudButton>
|
|
</DialogActions>
|
|
</MudDialog>
|