mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-05 13:09:40 +00:00
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Verify (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
55 lines
2.3 KiB
C#
55 lines
2.3 KiB
C#
using AIStudio.Settings;
|
|
using AIStudio.Tools.ToolCallingSystem;
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace AIStudio.Components;
|
|
|
|
public partial class ToolDefaultsConfiguration : MSGComponentBase
|
|
{
|
|
[Parameter]
|
|
public AIStudio.Tools.Components Component { get; set; } = AIStudio.Tools.Components.CHAT;
|
|
|
|
[Parameter]
|
|
public bool IncludeVisibilityToggle { get; set; } = true;
|
|
|
|
[Inject]
|
|
private ToolRegistry ToolRegistry { get; init; } = null!;
|
|
|
|
private List<ConfigurationSelectData<string>> availableTools = [];
|
|
|
|
private string OptionTitle => this.Component is AIStudio.Tools.Components.CHAT ? this.T("Default tools for chat") : this.T("Default tools for this assistant");
|
|
|
|
private string OptionHelp => this.Component is AIStudio.Tools.Components.CHAT
|
|
? this.T("Choose which tools should be preselected for new chats.")
|
|
: this.T("Choose which tools should be preselected for new runs of this assistant.");
|
|
|
|
/// <summary>
|
|
/// Whether preselecting tools is pointless right now.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Only where the toggle above decides whether the user ever sees a tool selection: a hidden
|
|
/// selection makes its defaults meaningless. Without that toggle the assistant reaches its
|
|
/// tools some other way — from a form field of its own, for instance — and the defaults do
|
|
/// apply.
|
|
/// </remarks>
|
|
private bool AreDefaultToolsDisabled =>
|
|
this.IncludeVisibilityToggle &&
|
|
this.Component is not AIStudio.Tools.Components.CHAT &&
|
|
!this.SettingsManager.IsToolSelectionVisible(this.Component);
|
|
|
|
private bool IsToolDisabled(string toolId) => !this.ToolRegistry.IsToolActive(toolId);
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
this.availableTools = (await this.ToolRegistry.GetCatalogAsync(this.Component))
|
|
.Select(x => new ConfigurationSelectData<string>(x.DisplayName, x.Id))
|
|
.ToList();
|
|
await base.OnInitializedAsync();
|
|
}
|
|
|
|
private HashSet<string> GetSelectedValues() => this.ToolRegistry.GetDefaultToolIds(this.Component);
|
|
|
|
private void UpdateSelection(HashSet<string> values) => this.SettingsManager.ConfigurationData.Tools.DefaultToolIdsByComponent[this.Component.ToString()] = [..this.ToolRegistry.NormalizeSelection(values)];
|
|
}
|