mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-09-13 19:53:37 +00:00
Co-authored-by: krut_ni <nils.kruthoff@dlr.de> Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
98 lines
6.2 KiB
Plaintext
98 lines
6.2 KiB
Plaintext
@inherits MSGComponentBase
|
|
|
|
<div class="d-flex">
|
|
<MudTooltip Text="@this.ToolButtonTooltip" Placement="Placement.Top">
|
|
<MudIconButton Icon="@Icons.Material.Filled.Build" Class="@this.PopoverButtonClasses" OnClick="@this.ToggleSelection"/>
|
|
</MudTooltip>
|
|
|
|
<MudPopover Open="@this.showSelection" AnchorOrigin="Origin.TopLeft" TransformOrigin="Origin.BottomLeft" DropShadow="@true" Class="border-solid border-4 rounded-lg">
|
|
<MudCard>
|
|
<MudCardHeader>
|
|
<CardHeaderContent>
|
|
<MudStack Row="true" AlignItems="AlignItems.Center">
|
|
<MudText Typo="Typo.h5">@T("Tool Selection")</MudText>
|
|
<MudSpacer />
|
|
</MudStack>
|
|
</CardHeaderContent>
|
|
</MudCardHeader>
|
|
<MudCardContent Style="min-width: 28em; max-height: 60vh; max-width: 48vw; overflow: auto;">
|
|
<MudText Typo="Typo.body1" Class="mb-3">
|
|
@T("Tools allow the LLM to perform targeted additional actions such as web searches or reading web pages.")
|
|
</MudText>
|
|
@if (!this.SupportsTools)
|
|
{
|
|
<MudText Typo="Typo.body1">@this.UnsupportedToolsMessage</MudText>
|
|
}
|
|
else if (this.Disabled)
|
|
{
|
|
<MudAlert Dense="@true" Severity="Severity.Info" Variant="Variant.Outlined" Class="mb-3">
|
|
@T("Tool changes are locked while a response is running. Your current selection is shown below and applies again from the next message once the run is finished.")
|
|
</MudAlert>
|
|
}
|
|
else if (this.catalog.Count == 0)
|
|
{
|
|
<MudText Typo="Typo.body1">@T("No tools are available in this context.")</MudText>
|
|
}
|
|
|
|
@if (this.SupportsTools && this.catalog.Count > 0)
|
|
{
|
|
@foreach (var item in this.catalog)
|
|
{
|
|
var isSelected = this.SelectedToolIds.Contains(item.Definition.Id);
|
|
var isConfigured = item.ConfigurationState.IsConfigured;
|
|
var providerConfidenceHint = this.GetProviderConfidenceHint(item);
|
|
<MudPaper Class="pa-2 mb-2 border rounded-lg">
|
|
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween">
|
|
@*
|
|
Everything but the settings button switches the tool, so aiming for the
|
|
small switch is optional. The button spans that part of the row, which
|
|
keeps the settings button outside of it without any event plumbing.
|
|
*@
|
|
<MudButton Variant="Variant.Text" Color="Color.Default" Class="px-2 py-1 justify-start"
|
|
Style="min-width:auto; text-transform:none; flex-grow:1;"
|
|
Disabled="@this.IsRowDisabled(item)" OnClick="@(async () => await this.ToggleToolFromRow(item))">
|
|
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
|
|
@*
|
|
The switch only shows the state; the surrounding button does the switching.
|
|
It therefore takes no pointer events at all: its label reaches past the visible
|
|
switch and would otherwise swallow the clicks landing in that strip.
|
|
*@
|
|
<MudSwitch T="bool" Color="Color.Primary" Value="@isSelected" ReadOnly="@true" Disabled="@this.IsRowDisabled(item)" Style="pointer-events: none;" />
|
|
<MudIcon Icon="@item.Implementation.Icon" Color="Color.Info" />
|
|
@if (!item.IsActive)
|
|
{
|
|
<MudTooltip Text="@T("This tool has been disabled by your organization.")">
|
|
<MudIcon Icon="@Icons.Material.Filled.Lock" Color="Color.Error" Size="Size.Small" />
|
|
</MudTooltip>
|
|
}
|
|
<MudTooltip Text="@item.Implementation.GetDescription()">
|
|
<MudText Typo="Typo.body1">@item.Implementation.GetDisplayName()</MudText>
|
|
</MudTooltip>
|
|
</MudStack>
|
|
</MudButton>
|
|
<MudIconButton Icon="@Icons.Material.Filled.Settings" OnClick="@(async () => await this.OpenSettings(item.Definition.Id))" />
|
|
</MudStack>
|
|
@if (!isConfigured)
|
|
{
|
|
<MudText Typo="Typo.caption" Color="Color.Warning">@(string.IsNullOrWhiteSpace(item.ConfigurationState.Message) ? T("Required settings are missing. Configure this tool before enabling it.") : item.ConfigurationState.Message)</MudText>
|
|
}
|
|
@if (!item.IsActive)
|
|
{
|
|
<MudText Typo="Typo.caption" Color="Color.Warning">@T("This tool has been disabled by your organization.")</MudText>
|
|
}
|
|
@if (!string.IsNullOrWhiteSpace(providerConfidenceHint))
|
|
{
|
|
<MudText Typo="Typo.caption" Color="Color.Warning">@providerConfidenceHint</MudText>
|
|
}
|
|
</MudPaper>
|
|
}
|
|
}
|
|
</MudCardContent>
|
|
<MudCardActions>
|
|
<MudSpacer />
|
|
<MudButton Variant="Variant.Filled" OnClick="@this.Hide">@T("Close")</MudButton>
|
|
</MudCardActions>
|
|
</MudCard>
|
|
</MudPopover>
|
|
</div>
|