diff --git a/backend/files/system/openai/create-bot.post.hl b/backend/files/system/openai/create-bot.post.hl index c177f26bbe..29516f1cf3 100644 --- a/backend/files/system/openai/create-bot.post.hl +++ b/backend/files/system/openai/create-bot.post.hl @@ -316,8 +316,14 @@ try // Providing feedback to caller. sockets.signal:x:@.feedback-channel args - message:Done creating your machine learning model, remember to vectorize it before attempting to use it - type:success + message:Remember to vectorize before attempting to use your model + type:info + + // Informing user that we're done. + sockets.signal:x:@.arguments/*/feedback-channel + args + message:Done! + type:success // Returning success to caller. unwrap:x:+/* diff --git a/backend/files/system/openai/import-page.post.hl b/backend/files/system/openai/import-page.post.hl index 9f470d75d9..e5b69556c1 100644 --- a/backend/files/system/openai/import-page.post.hl +++ b/backend/files/system/openai/import-page.post.hl @@ -80,7 +80,7 @@ fork type:success sockets.signal:x:@.arguments/*/feedback-channel args - message:Done creating OpenAI training data from page + message:Done! type:success // Basic logging. diff --git a/backend/files/system/openai/import-url.post.hl b/backend/files/system/openai/import-url.post.hl index 4402877053..57c56326d5 100644 --- a/backend/files/system/openai/import-url.post.hl +++ b/backend/files/system/openai/import-url.post.hl @@ -90,7 +90,7 @@ signal:magic.ai.crawl-site .feedback-channel:x:@.arguments/*/feedback-channel sockets.signal:x:@.arguments/*/feedback-channel args - message:Successfull scraped URL(s), remember to vectorize your model before using it + message:Done! type:success diff --git a/backend/files/system/openai/magic.startup/crawling/magic.ai.crawl-site.hl b/backend/files/system/openai/magic.startup/crawling/magic.ai.crawl-site.hl index 60ac1dbb99..42731ef67f 100644 --- a/backend/files/system/openai/magic.startup/crawling/magic.ai.crawl-site.hl +++ b/backend/files/system/openai/magic.startup/crawling/magic.ai.crawl-site.hl @@ -193,21 +193,27 @@ slots.create:magic.ai.crawl-site threshold:x:@.arguments/*/threshold feedback-channel:x:@.arguments/*/feedback-channel - // Signaling frontend that we're waiting for n seconds. - strings.concat - .:"Waiting for " - math.divide:x:@.arguments/*/delay - .:int:1000 - .:" seconds to avoid exhausting web server" - unwrap:x:+/** - sockets.signal:x:@.arguments/*/feedback-channel - args - message:x:@strings.concat - type:info - sleep:100 + // Verifying we've got more snippets before applying Crawl-Delay + if + neq:x:@.dp/# + get-value:x:@signal/@signal/*/urls/0/- + .lambda - // Sleeping for [delay] milliseconds to avoid exhausting web server. - sleep:x:@.arguments/*/delay + // Signaling frontend that we're waiting for n seconds. + strings.concat + .:"Waiting for " + math.divide:x:@.arguments/*/delay + .:int:1000 + .:" seconds to avoid exhausting web server" + unwrap:x:+/** + sockets.signal:x:@.arguments/*/feedback-channel + args + message:x:@strings.concat + type:info + sleep:100 + + // Sleeping for [delay] milliseconds to avoid exhausting web server. + sleep:x:@.arguments/*/delay .catch diff --git a/backend/files/system/openai/magic.startup/magic.ai.vectorise.hl b/backend/files/system/openai/magic.startup/magic.ai.vectorise.hl index 4b1c2ca337..ed4bc9c34a 100644 --- a/backend/files/system/openai/magic.startup/magic.ai.vectorise.hl +++ b/backend/files/system/openai/magic.startup/magic.ai.vectorise.hl @@ -63,8 +63,9 @@ select id, prompt, completion // Signaling frontend. strings.concat - .:"Vectorising " + .:"Vectorizing: \"" get-value:x:@.dp/#/*/prompt + .:"\"" unwrap:x:+/*/args/*/message sockets.signal:x:@.arguments/*/feedback-channel args @@ -241,12 +242,6 @@ insert into vss_ml_training_snippets (rowid, embedding_vss) not exists (select rowid from vss_ml_training_snippets vss2 where vss2.rowid = ts.id)" type:x:@.arguments/*/type - // Done with everything, notifying frontend. - sockets.signal:x:@.arguments/*/feedback-channel - args - message:Your machine learning model was successfully vectorised - type:info - // Basic logging. log.info:Done with creating vectors for model type:x:@.arguments/*/type diff --git a/backend/files/system/openai/vectorise.post.hl b/backend/files/system/openai/vectorise.post.hl index 4fdb134dcb..159b800c51 100644 --- a/backend/files/system/openai/vectorise.post.hl +++ b/backend/files/system/openai/vectorise.post.hl @@ -39,6 +39,11 @@ fork add:x:./*/signal get-nodes:x:@.arguments/* signal:magic.ai.vectorise + .onafter + sockets.signal:x:@.arguments/*/feedback-channel + args + message:Done! + type:success // Returning success to caller. return diff --git a/frontend/src/app/_general/services/openai.service.ts b/frontend/src/app/_general/services/openai.service.ts index c790e32207..8130c96429 100644 --- a/frontend/src/app/_general/services/openai.service.ts +++ b/frontend/src/app/_general/services/openai.service.ts @@ -164,10 +164,11 @@ export class OpenAIService { /** * Vectorises all snippets in the specified type. */ - vectorise(type: string) { + vectorise(type: string, channel: string) { return this.httpService.post('/magic/system/openai/vectorise', { type, + ['feedback-channel']: channel, }); } diff --git a/frontend/src/app/_protected/pages/create/chatbot-wizard/chatbot-wizard.component.ts b/frontend/src/app/_protected/pages/create/chatbot-wizard/chatbot-wizard.component.ts index 5f1514c286..ef6be97804 100644 --- a/frontend/src/app/_protected/pages/create/chatbot-wizard/chatbot-wizard.component.ts +++ b/frontend/src/app/_protected/pages/create/chatbot-wizard/chatbot-wizard.component.ts @@ -270,7 +270,7 @@ export class ChatbotWizardComponent implements OnInit, OnDestroy { * Too many snippets according to license, still we'll vectorise the model explicitly to make sure * user gets at least a somewhat working chatbot to embed on page. */ - this.openAIService.vectorise(this.model).subscribe({ + this.openAIService.vectorise(this.model, feedbackChannel).subscribe({ next: () => { console.log('Vectorising started'); diff --git a/frontend/src/app/_protected/pages/manage/machine-learning/components/machine-learning-import-feedback/machine-learning-import-feedback.component.ts b/frontend/src/app/_protected/pages/manage/machine-learning/components/machine-learning-import-feedback/machine-learning-import-feedback.component.ts index bf0d097fe7..94f9d62307 100644 --- a/frontend/src/app/_protected/pages/manage/machine-learning/components/machine-learning-import-feedback/machine-learning-import-feedback.component.ts +++ b/frontend/src/app/_protected/pages/manage/machine-learning/components/machine-learning-import-feedback/machine-learning-import-feedback.component.ts @@ -75,8 +75,7 @@ export class MachineLearningImportFeedbackComponent implements OnInit, OnDestroy this.hubConnection.start().then(() => { - this.generalService.showLoading(); - if (this.data.site === true) { + if (this.data.mode === 'site') { this.openAIService.importUrl( this.data.url, this.data.type, @@ -96,7 +95,7 @@ export class MachineLearningImportFeedbackComponent implements OnInit, OnDestroy this.generalService.showFeedback('Something went wrong as we tried to start import', 'errorMessage'); } }); - } else { + } else if (this.data.mode === 'single-page') { this.openAIService.importPage( this.data.url, this.data.type, @@ -112,7 +111,20 @@ export class MachineLearningImportFeedbackComponent implements OnInit, OnDestroy this.generalService.showFeedback('Something went wrong as we tried to spice your model', 'errorMessage'); } }); - } + } else if (this.data.mode === 'vectorize') { + + this.openAIService.vectorise(this.data.type, result.result).subscribe({ + next: () => { + + this.generalService.hideLoading(); + }, + error: () => { + + this.generalService.hideLoading(); + this.generalService.showFeedback('Something went wrong as we tried to create embeddings for model', 'errorMessage'); + } + }); + } }); }, error: () => { diff --git a/frontend/src/app/_protected/pages/manage/machine-learning/machine-learning-models/machine-learning-models.component.ts b/frontend/src/app/_protected/pages/manage/machine-learning/machine-learning-models/machine-learning-models.component.ts index 36c35b5eb5..0160d5792e 100644 --- a/frontend/src/app/_protected/pages/manage/machine-learning/machine-learning-models/machine-learning-models.component.ts +++ b/frontend/src/app/_protected/pages/manage/machine-learning/machine-learning-models/machine-learning-models.component.ts @@ -168,7 +168,7 @@ export class MachineLearningModelsComponent implements OnInit { max: result.max, threshold: result.threshold, summarize: result.summarize, - site: true, + mode: 'site' } }); } @@ -233,17 +233,14 @@ export class MachineLearningModelsComponent implements OnInit { }).afterClosed().subscribe((result: string) => { if (result === 'confirm') { - - this.openAIService.vectorise(el.type).subscribe({ - next: () => { - - this.generalService.showFeedback('Started creating embeddings of model', 'successMessage'); - this.generalService.hideLoading(); - }, - error: () => { - - this.generalService.hideLoading(); - this.generalService.showFeedback('Something went wrong as we tried to create embeddings for model', 'errorMessage'); + this.dialog + .open(MachineLearningImportFeedbackComponent, { + width: '80vw', + maxWidth: '1280px', + data: { + url: result, + type: el.type, + mode: 'vectorize' } }); } diff --git a/frontend/src/app/_protected/pages/manage/machine-learning/machine-learning-training-data/machine-learning-training-data.component.ts b/frontend/src/app/_protected/pages/manage/machine-learning/machine-learning-training-data/machine-learning-training-data.component.ts index 63c2115e80..b840636c58 100644 --- a/frontend/src/app/_protected/pages/manage/machine-learning/machine-learning-training-data/machine-learning-training-data.component.ts +++ b/frontend/src/app/_protected/pages/manage/machine-learning/machine-learning-training-data/machine-learning-training-data.component.ts @@ -127,7 +127,7 @@ export class MachineLearningTrainingDataComponent implements OnInit { max: result.max, threshold: result.threshold, summarize: result.summarize, - site: false, + mode: 'single-page' } }); }