mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-06 11:49:40 +00:00
Add a drop zone to the custom tokenizer of both provider dialogs
This commit is contained in:
7 files changed
+137
-43
No files matched your search
@@ -425,6 +425,30 @@ public partial class ProviderDialog : MSGComponentBase, ISecretId
|
||||
return this.OnDataFilePathChanged(string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Takes the first dropped path which can serve as a tokenizer.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A provider carries exactly one tokenizer, so a multi-selection cannot be honored as a whole.
|
||||
/// Everything which is not a readable JSON file is skipped rather than handed to the runtime:
|
||||
/// the validation would reject it anyway, and saying so right away names the actual mistake.
|
||||
/// </remarks>
|
||||
/// <param name="paths">The dropped paths.</param>
|
||||
private async Task OnTokenizerPathsDropped(List<string> paths)
|
||||
{
|
||||
foreach (var path in paths)
|
||||
{
|
||||
if (!File.Exists(path) || !FileTypes.IsAllowedPath(path, FileTypes.JSON))
|
||||
continue;
|
||||
|
||||
await this.OnDataFilePathChanged(path);
|
||||
return;
|
||||
}
|
||||
|
||||
this.Logger.LogWarning("None of the {Count} dropped path(s) could be used as a tokenizer.", paths.Count);
|
||||
await this.MessageBus.SendWarning(new(Icons.Material.Filled.Warning, T("Please drop a tokenizer file in the JSON format.")));
|
||||
}
|
||||
|
||||
private async Task OnDataFilePathChanged(string filePath)
|
||||
{
|
||||
this.dataFilePath = filePath;
|
||||
|
||||
Reference in new issue
Block a user