mirror of
https://github.com/leon-ai/leon.git
synced 2024-10-05 13:47:49 +03:00
feat(web app): prevent from sending utterance while Leon is generating answer
This commit is contained in:
parent
0ce1f62c0d
commit
8eefe53473
@ -18,6 +18,7 @@ export default class Client {
|
||||
this._suggestions = []
|
||||
this._answerGenerationId = 'xxx'
|
||||
this._ttsAudioContext = null
|
||||
this._isLeonGeneratingAnswer = false
|
||||
// this._ttsAudioContextes = {}
|
||||
}
|
||||
|
||||
@ -78,6 +79,9 @@ export default class Client {
|
||||
})
|
||||
|
||||
this.socket.on('answer', (data) => {
|
||||
// Leon has finished to answer
|
||||
this._isLeonGeneratingAnswer = false
|
||||
|
||||
/**
|
||||
* Just save the bubble if the newest bubble is from the streaming.
|
||||
* Otherwise, create a new bubble
|
||||
@ -124,6 +128,7 @@ export default class Client {
|
||||
})
|
||||
|
||||
this.socket.on('llm-token', (data) => {
|
||||
this._isLeonGeneratingAnswer = true
|
||||
const previousGenerationId = this._answerGenerationId
|
||||
const newGenerationId = data.generationId
|
||||
this._answerGenerationId = newGenerationId
|
||||
@ -244,6 +249,11 @@ export default class Client {
|
||||
}
|
||||
|
||||
send(keyword) {
|
||||
// Prevent from sending utterance if Leon is still generating text (stream)
|
||||
if (keyword === 'utterance' && this._isLeonGeneratingAnswer) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (this._input.value !== '') {
|
||||
this.socket.emit(keyword, {
|
||||
client: this.client,
|
||||
|
@ -185,11 +185,6 @@
|
||||
"params": ["todos", "list"],
|
||||
"entitiesType": "trim"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"route": "/api/action/unknown/widget-playground/run",
|
||||
"params": []
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"route": "/api/action/social_communication/conversation/setup",
|
||||
@ -215,6 +210,11 @@
|
||||
"route": "/api/action/social_communication/mbti/quiz",
|
||||
"params": []
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"route": "/api/action/unknown/widget-playground/run",
|
||||
"params": []
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"route": "/api/action/utilities/date_time/current_date_time",
|
||||
|
@ -5,6 +5,7 @@ import { LLM_ACTIONS_CLASSIFIER_PATH } from '@/constants'
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
import { SkillDomainHelper } from '@/helpers/skill-domain-helper'
|
||||
|
||||
// TODO: need to handle multi languages
|
||||
const LANG = 'en'
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user