feat(editor): Add AI Assistant support chat (#10656)

This commit is contained in:
Milorad FIlipović
2024-09-05 10:54:35 +02:00
committed by GitHub
parent 899b0a19ef
commit 3a8078068e
12 changed files with 223 additions and 79 deletions

View File

@@ -27,14 +27,16 @@ function onResizeDebounced(data: { direction: string; x: number; width: number }
}
async function onUserMessage(content: string, quickReplyType?: string, isFeedback = false) {
await assistantStore.sendMessage({ text: content, quickReplyType });
const task = 'error';
const solutionCount =
task === 'error'
? assistantStore.chatMessages.filter(
(msg) => msg.role === 'assistant' && !['text', 'event'].includes(msg.type),
).length
: null;
// If there is no current session running, initialize the support chat session
if (!assistantStore.currentSessionId) {
await assistantStore.initSupportChat(content);
} else {
await assistantStore.sendMessage({ text: content, quickReplyType });
}
const task = assistantStore.isSupportChatSessionInProgress ? 'support' : 'error';
const solutionCount = assistantStore.chatMessages.filter(
(msg) => msg.role === 'assistant' && !['text', 'event'].includes(msg.type),
).length;
if (isFeedback) {
telemetry.track('User gave feedback', {
task,