mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-14 00:34:23 +00:00
Added button to edit last user message (#248)
This commit is contained in:
1 parent
b2ca49ab92
commit
8060fc01dd
5 files changed
+104
-3
No files matched your search
@@ -43,6 +43,9 @@ public partial class ContentBlockComponent : ComponentBase
|
||||
|
||||
[Parameter]
|
||||
public bool IsLastContentBlock { get; set; } = false;
|
||||
|
||||
[Parameter]
|
||||
public bool IsSecondToLastBlock { get; set; } = false;
|
||||
|
||||
[Parameter]
|
||||
public Func<IContent, Task>? RemoveBlockFunc { get; set; }
|
||||
@@ -50,6 +53,12 @@ public partial class ContentBlockComponent : ComponentBase
|
||||
[Parameter]
|
||||
public Func<IContent, Task>? RegenerateFunc { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public Func<IContent, Task>? EditLastBlockFunc { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public Func<IContent, Task>? EditLastUserBlockFunc { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public Func<bool> RegenerateEnabled { get; set; } = () => false;
|
||||
|
||||
@@ -170,4 +179,33 @@ public partial class ContentBlockComponent : ComponentBase
|
||||
if (regenerate.HasValue && regenerate.Value)
|
||||
await this.RegenerateFunc(this.Content);
|
||||
}
|
||||
|
||||
private async Task EditLastBlock()
|
||||
{
|
||||
if (this.EditLastBlockFunc is null)
|
||||
return;
|
||||
|
||||
if(this.Role is not ChatRole.USER)
|
||||
return;
|
||||
|
||||
await this.EditLastBlockFunc(this.Content);
|
||||
}
|
||||
|
||||
private async Task EditLastUserBlock()
|
||||
{
|
||||
if (this.EditLastUserBlockFunc is null)
|
||||
return;
|
||||
|
||||
if(this.Role is not ChatRole.USER)
|
||||
return;
|
||||
|
||||
var edit = await this.DialogService.ShowMessageBox(
|
||||
"Edit Message",
|
||||
"Do you really want to edit this message? In order to edit this message, the AI response will be deleted.",
|
||||
"Yes, remove the AI response and edit it",
|
||||
"No, keep it");
|
||||
|
||||
if (edit.HasValue && edit.Value)
|
||||
await this.EditLastUserBlockFunc(this.Content);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user