mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 15:39:46 +00:00
Implemented send to chat feature
This commit is contained in:
parent
f24143c1ae
commit
5e4768584b
@ -45,6 +45,8 @@ public abstract partial class AssistantBase : ComponentBase
|
|||||||
|
|
||||||
protected virtual bool ShowDedicatedProgress => false;
|
protected virtual bool ShowDedicatedProgress => false;
|
||||||
|
|
||||||
|
protected virtual ChatThread ConvertToChatThread => this.chatThread ?? new();
|
||||||
|
|
||||||
protected virtual IReadOnlyList<IButtonData> FooterButtons => [];
|
protected virtual IReadOnlyList<IButtonData> FooterButtons => [];
|
||||||
|
|
||||||
protected static readonly Dictionary<string, object?> USER_INPUT_ATTRIBUTES = new();
|
protected static readonly Dictionary<string, object?> USER_INPUT_ATTRIBUTES = new();
|
||||||
@ -53,7 +55,7 @@ public abstract partial class AssistantBase : ComponentBase
|
|||||||
protected MudForm? form;
|
protected MudForm? form;
|
||||||
protected bool inputIsValid;
|
protected bool inputIsValid;
|
||||||
|
|
||||||
private ChatThread? chatThread;
|
protected ChatThread? chatThread;
|
||||||
private ContentBlock? resultingContentBlock;
|
private ContentBlock? resultingContentBlock;
|
||||||
private string[] inputIssues = [];
|
private string[] inputIssues = [];
|
||||||
private bool isProcessing;
|
private bool isProcessing;
|
||||||
@ -164,7 +166,7 @@ public abstract partial class AssistantBase : ComponentBase
|
|||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task SendToAssistant(SendTo assistant, SendToButton sendToButton)
|
private Task SendToAssistant(SendTo destination, SendToButton sendToButton)
|
||||||
{
|
{
|
||||||
var contentToSend = sendToButton.UseResultingContentBlockData switch
|
var contentToSend = sendToButton.UseResultingContentBlockData switch
|
||||||
{
|
{
|
||||||
@ -176,7 +178,7 @@ public abstract partial class AssistantBase : ComponentBase
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
var (eventItem, path) = assistant switch
|
var (eventItem, path) = destination switch
|
||||||
{
|
{
|
||||||
SendTo.AGENDA_ASSISTANT => (Event.SEND_TO_AGENDA_ASSISTANT, Path.ASSISTANT_AGENDA),
|
SendTo.AGENDA_ASSISTANT => (Event.SEND_TO_AGENDA_ASSISTANT, Path.ASSISTANT_AGENDA),
|
||||||
SendTo.CODING_ASSISTANT => (Event.SEND_TO_CODING_ASSISTANT, Path.ASSISTANT_CODING),
|
SendTo.CODING_ASSISTANT => (Event.SEND_TO_CODING_ASSISTANT, Path.ASSISTANT_CODING),
|
||||||
@ -186,10 +188,22 @@ public abstract partial class AssistantBase : ComponentBase
|
|||||||
SendTo.GRAMMAR_SPELLING_ASSISTANT => (Event.SEND_TO_GRAMMAR_SPELLING_ASSISTANT, Path.ASSISTANT_GRAMMAR_SPELLING),
|
SendTo.GRAMMAR_SPELLING_ASSISTANT => (Event.SEND_TO_GRAMMAR_SPELLING_ASSISTANT, Path.ASSISTANT_GRAMMAR_SPELLING),
|
||||||
SendTo.TEXT_SUMMARIZER_ASSISTANT => (Event.SEND_TO_TEXT_SUMMARIZER_ASSISTANT, Path.ASSISTANT_SUMMARIZER),
|
SendTo.TEXT_SUMMARIZER_ASSISTANT => (Event.SEND_TO_TEXT_SUMMARIZER_ASSISTANT, Path.ASSISTANT_SUMMARIZER),
|
||||||
|
|
||||||
|
SendTo.CHAT => (Event.SEND_TO_CHAT, Path.CHAT),
|
||||||
|
|
||||||
_ => (Event.NONE, Path.ASSISTANTS),
|
_ => (Event.NONE, Path.ASSISTANTS),
|
||||||
};
|
};
|
||||||
|
|
||||||
MessageBus.INSTANCE.DeferMessage(this, eventItem, contentToSend);
|
switch (destination)
|
||||||
|
{
|
||||||
|
case SendTo.CHAT:
|
||||||
|
MessageBus.INSTANCE.DeferMessage(this, eventItem, this.ConvertToChatThread);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
MessageBus.INSTANCE.DeferMessage(this, eventItem, contentToSend);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
this.NavigationManager.NavigateTo(path);
|
this.NavigationManager.NavigateTo(path);
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
using AIStudio.Chat;
|
||||||
using AIStudio.Tools;
|
using AIStudio.Tools;
|
||||||
|
|
||||||
namespace AIStudio.Components.Pages.Agenda;
|
namespace AIStudio.Components.Pages.Agenda;
|
||||||
@ -100,7 +101,12 @@ public partial class AssistantAgenda : AssistantBaseCore
|
|||||||
Self = SendTo.AGENDA_ASSISTANT,
|
Self = SendTo.AGENDA_ASSISTANT,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
|
||||||
|
{
|
||||||
|
SystemPrompt = SystemPrompts.DEFAULT,
|
||||||
|
};
|
||||||
|
|
||||||
private string inputTopic = string.Empty;
|
private string inputTopic = string.Empty;
|
||||||
private string inputName = string.Empty;
|
private string inputName = string.Empty;
|
||||||
private string inputContent = string.Empty;
|
private string inputContent = string.Empty;
|
||||||
|
@ -62,6 +62,24 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable
|
|||||||
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.Chat.PreselectedProvider);
|
this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.Chat.PreselectedProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<ChatThread>(Event.SEND_TO_CHAT).FirstOrDefault();
|
||||||
|
if (deferredContent is not null)
|
||||||
|
{
|
||||||
|
this.chatThread = deferredContent;
|
||||||
|
if (this.chatThread is not null)
|
||||||
|
{
|
||||||
|
var firstUserBlock = this.chatThread.Blocks.FirstOrDefault(x => x.Role == ChatRole.USER);
|
||||||
|
if (firstUserBlock is not null)
|
||||||
|
{
|
||||||
|
this.chatThread.Name = firstUserBlock.Content switch
|
||||||
|
{
|
||||||
|
ContentText textBlock => this.ExtractThreadName(textBlock.Text),
|
||||||
|
_ => "Thread"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using AIStudio.Chat;
|
||||||
using AIStudio.Tools;
|
using AIStudio.Tools;
|
||||||
|
|
||||||
namespace AIStudio.Components.Pages.GrammarSpelling;
|
namespace AIStudio.Components.Pages.GrammarSpelling;
|
||||||
@ -35,6 +36,11 @@ public partial class AssistantGrammarSpelling : AssistantBaseCore
|
|||||||
GetText = () => string.IsNullOrWhiteSpace(this.correctedText) ? this.inputText : this.correctedText
|
GetText = () => string.IsNullOrWhiteSpace(this.correctedText) ? this.inputText : this.correctedText
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
|
||||||
|
{
|
||||||
|
SystemPrompt = SystemPrompts.DEFAULT,
|
||||||
|
};
|
||||||
|
|
||||||
#region Overrides of ComponentBase
|
#region Overrides of ComponentBase
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using AIStudio.Chat;
|
||||||
using AIStudio.Tools;
|
using AIStudio.Tools;
|
||||||
|
|
||||||
namespace AIStudio.Components.Pages.RewriteImprove;
|
namespace AIStudio.Components.Pages.RewriteImprove;
|
||||||
@ -36,6 +37,11 @@ public partial class AssistantRewriteImprove : AssistantBaseCore
|
|||||||
GetText = () => string.IsNullOrWhiteSpace(this.rewrittenText) ? this.inputText : this.rewrittenText,
|
GetText = () => string.IsNullOrWhiteSpace(this.rewrittenText) ? this.inputText : this.rewrittenText,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
|
||||||
|
{
|
||||||
|
SystemPrompt = SystemPrompts.DEFAULT,
|
||||||
|
};
|
||||||
|
|
||||||
#region Overrides of ComponentBase
|
#region Overrides of ComponentBase
|
||||||
|
|
||||||
|
@ -11,4 +11,6 @@ public enum SendTo
|
|||||||
AGENDA_ASSISTANT,
|
AGENDA_ASSISTANT,
|
||||||
CODING_ASSISTANT,
|
CODING_ASSISTANT,
|
||||||
TEXT_SUMMARIZER_ASSISTANT,
|
TEXT_SUMMARIZER_ASSISTANT,
|
||||||
|
|
||||||
|
CHAT,
|
||||||
}
|
}
|
@ -14,6 +14,8 @@ public static class SendToExtensions
|
|||||||
SendTo.AGENDA_ASSISTANT => "Agenda Assistant",
|
SendTo.AGENDA_ASSISTANT => "Agenda Assistant",
|
||||||
SendTo.CODING_ASSISTANT => "Coding Assistant",
|
SendTo.CODING_ASSISTANT => "Coding Assistant",
|
||||||
|
|
||||||
|
SendTo.CHAT => "New Chat",
|
||||||
|
|
||||||
_ => "Send to ...",
|
_ => "Send to ...",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using AIStudio.Chat;
|
||||||
using AIStudio.Tools;
|
using AIStudio.Tools;
|
||||||
|
|
||||||
namespace AIStudio.Components.Pages.TextSummarizer;
|
namespace AIStudio.Components.Pages.TextSummarizer;
|
||||||
@ -31,6 +32,11 @@ public partial class AssistantTextSummarizer : AssistantBaseCore
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
|
||||||
|
{
|
||||||
|
SystemPrompt = SystemPrompts.DEFAULT,
|
||||||
|
};
|
||||||
|
|
||||||
private string inputText = string.Empty;
|
private string inputText = string.Empty;
|
||||||
private bool isAgentRunning;
|
private bool isAgentRunning;
|
||||||
private CommonLanguages selectedTargetLanguage;
|
private CommonLanguages selectedTargetLanguage;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using AIStudio.Chat;
|
||||||
using AIStudio.Tools;
|
using AIStudio.Tools;
|
||||||
|
|
||||||
namespace AIStudio.Components.Pages.Translation;
|
namespace AIStudio.Components.Pages.Translation;
|
||||||
@ -27,6 +28,11 @@ public partial class AssistantTranslation : AssistantBaseCore
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected override ChatThread ConvertToChatThread => (this.chatThread ?? new()) with
|
||||||
|
{
|
||||||
|
SystemPrompt = SystemPrompts.DEFAULT,
|
||||||
|
};
|
||||||
|
|
||||||
private bool liveTranslation;
|
private bool liveTranslation;
|
||||||
private bool isAgentRunning;
|
private bool isAgentRunning;
|
||||||
private string inputText = string.Empty;
|
private string inputText = string.Empty;
|
||||||
|
@ -16,7 +16,7 @@ public enum Event
|
|||||||
HAS_CHAT_UNSAVED_CHANGES,
|
HAS_CHAT_UNSAVED_CHANGES,
|
||||||
RESET_CHAT_STATE,
|
RESET_CHAT_STATE,
|
||||||
|
|
||||||
// Send assistant events:
|
// Send events:
|
||||||
SEND_TO_GRAMMAR_SPELLING_ASSISTANT,
|
SEND_TO_GRAMMAR_SPELLING_ASSISTANT,
|
||||||
SEND_TO_ICON_FINDER_ASSISTANT,
|
SEND_TO_ICON_FINDER_ASSISTANT,
|
||||||
SEND_TO_REWRITE_ASSISTANT,
|
SEND_TO_REWRITE_ASSISTANT,
|
||||||
@ -24,4 +24,5 @@ public enum Event
|
|||||||
SEND_TO_AGENDA_ASSISTANT,
|
SEND_TO_AGENDA_ASSISTANT,
|
||||||
SEND_TO_CODING_ASSISTANT,
|
SEND_TO_CODING_ASSISTANT,
|
||||||
SEND_TO_TEXT_SUMMARIZER_ASSISTANT,
|
SEND_TO_TEXT_SUMMARIZER_ASSISTANT,
|
||||||
|
SEND_TO_CHAT,
|
||||||
}
|
}
|
@ -178,6 +178,6 @@
|
|||||||
"contentHash": "FHNOatmUq0sqJOkTx+UF/9YK1f180cnW5FVqnQMvYUN0elp6wFzbtPSiqbo1/ru8ICp43JM1i7kKkk6GsNGHlA=="
|
"contentHash": "FHNOatmUq0sqJOkTx+UF/9YK1f180cnW5FVqnQMvYUN0elp6wFzbtPSiqbo1/ru8ICp43JM1i7kKkk6GsNGHlA=="
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"net8.0/osx-x64": {}
|
"net8.0/osx-arm64": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,2 +1,3 @@
|
|||||||
# v0.8.10, build 172
|
# v0.8.10, build 172
|
||||||
|
- Added the possibility to send any assistant context to a new chat session for further questions
|
||||||
- Improved the coding assistant's language handling when creating the corresponding prompt
|
- Improved the coding assistant's language handling when creating the corresponding prompt
|
Loading…
Reference in New Issue
Block a user