mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 22:19:48 +00:00
Ensure unique names for embedding methods and retrieval processes
This commit is contained in:
parent
67ab9c6d97
commit
36c65849ea
@ -414,6 +414,7 @@ public partial class AssistantERI : AssistantBaseCore
|
||||
var dialogParameters = new DialogParameters<EmbeddingMethodDialog>
|
||||
{
|
||||
{ x => x.IsEditing, false },
|
||||
{ x => x.UsedEmbeddingMethodNames, this.embeddings.Select(n => n.EmbeddingName).ToList() },
|
||||
};
|
||||
|
||||
var dialogReference = await this.DialogService.ShowAsync<EmbeddingMethodDialog>("Add Embedding Method", dialogParameters, DialogOptions.FULLSCREEN);
|
||||
@ -435,6 +436,8 @@ public partial class AssistantERI : AssistantBaseCore
|
||||
{ x => x.DataDescription, embeddingInfo.Description },
|
||||
{ x => x.DataUsedWhen, embeddingInfo.UsedWhen },
|
||||
{ x => x.DataLink, embeddingInfo.Link },
|
||||
|
||||
{ x => x.UsedEmbeddingMethodNames, this.embeddings.Select(n => n.EmbeddingName).ToList() },
|
||||
{ x => x.IsEditing, true },
|
||||
};
|
||||
|
||||
@ -471,6 +474,7 @@ public partial class AssistantERI : AssistantBaseCore
|
||||
{
|
||||
{ x => x.IsEditing, false },
|
||||
{ x => x.AvailableEmbeddings, this.embeddings },
|
||||
{ x => x.UsedRetrievalProcessNames, this.retrievalProcesses.Select(n => n.Name).ToList() },
|
||||
};
|
||||
|
||||
var dialogReference = await this.DialogService.ShowAsync<RetrievalProcessDialog>("Add Retrieval Process", dialogParameters, DialogOptions.FULLSCREEN);
|
||||
@ -495,6 +499,7 @@ public partial class AssistantERI : AssistantBaseCore
|
||||
|
||||
{ x => x.IsEditing, true },
|
||||
{ x => x.AvailableEmbeddings, this.embeddings },
|
||||
{ x => x.UsedRetrievalProcessNames, this.retrievalProcesses.Select(n => n.Name).ToList() },
|
||||
};
|
||||
|
||||
var dialogReference = await this.DialogService.ShowAsync<EmbeddingMethodDialog>("Edit Retrieval Process", dialogParameters, DialogOptions.FULLSCREEN);
|
||||
|
@ -40,6 +40,12 @@ public partial class EmbeddingMethodDialog : ComponentBase
|
||||
[Parameter]
|
||||
public string DataLink { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The embedding method names that are already used. The user must choose a unique name.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public IReadOnlyList<string> UsedEmbeddingMethodNames { get; set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Should the dialog be in editing mode?
|
||||
/// </summary>
|
||||
@ -89,6 +95,9 @@ public partial class EmbeddingMethodDialog : ComponentBase
|
||||
if (name.Length > 26)
|
||||
return "The embedding name must not be longer than 26 characters.";
|
||||
|
||||
if (this.UsedEmbeddingMethodNames.Contains(name))
|
||||
return $"The embedding method name '{name}' is already used. Please choose a unique name.";
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,12 @@ public partial class RetrievalProcessDialog : ComponentBase
|
||||
[Parameter]
|
||||
public IReadOnlyList<EmbeddingInfo> AvailableEmbeddings { get; set; } = new List<EmbeddingInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// The retrieval process names that are already used. The user must choose a unique name.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public IReadOnlyList<string> UsedRetrievalProcessNames { get; set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Should the dialog be in editing mode?
|
||||
/// </summary>
|
||||
@ -103,6 +109,9 @@ public partial class RetrievalProcessDialog : ComponentBase
|
||||
if (name.Length > 26)
|
||||
return "The retrieval process name must not be longer than 26 characters.";
|
||||
|
||||
if (this.UsedRetrievalProcessNames.Contains(name))
|
||||
return $"The retrieval process name '{name}' must be unique. Please choose a different name.";
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user