Added a button to regenerate the last AI response (#247)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2025-01-03 21:18:27 +01:00
1 parent 5e445f09fa
commit b2ca49ab92
6 files changed
+109 -31

No files matched your search

@@ -40,10 +40,19 @@ public partial class ContentBlockComponent : ComponentBase
/// </summary>
[Parameter]
public string Class { get; set; } = string.Empty;
[Parameter]
public bool IsLastContentBlock { get; set; } = false;
[Parameter]
public Func<IContent, Task>? RemoveBlockFunc { get; set; }
[Parameter]
public Func<IContent, Task>? RegenerateFunc { get; set; }
[Parameter]
public Func<bool> RegenerateEnabled { get; set; } = () => false;
[Inject]
private RustService RustService { get; init; } = null!;
@@ -143,4 +152,22 @@ public partial class ContentBlockComponent : ComponentBase
if (remove.HasValue && remove.Value)
await this.RemoveBlockFunc(this.Content);
}
private async Task RegenerateBlock()
{
if (this.RegenerateFunc is null)
return;
if(this.Role is not ChatRole.AI)
return;
var regenerate = await this.DialogService.ShowMessageBox(
"Regenerate Message",
"Do you really want to regenerate this message?",
"Yes, regenerate it",
"No, keep it");
if (regenerate.HasValue && regenerate.Value)
await this.RegenerateFunc(this.Content);
}
}