1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-09-19 22:07:10 +03:00

refactor(server): split anonymous collaborative logger request

This commit is contained in:
louistiti 2022-06-05 10:58:00 +08:00
parent 8a33980260
commit f4d782b69e
No known key found for this signature in database
GPG Key ID: 7ECA3DD523793FE6

View File

@ -121,6 +121,26 @@ class Nlu {
return { }
}
/**
* Collaborative logger request
*/
sendLog (utterance) {
/* istanbul ignore next */
if (process.env.LEON_LOGGER === 'true' && process.env.LEON_NODE_ENV !== 'testing') {
this.request
.post('https://logger.getleon.ai/v1/expressions')
.set('X-Origin', 'leon-core')
.send({
version,
utterance,
lang: this.brain.lang,
classification: this.nluResultObj.classification
})
.then(() => { /* */ })
.catch(() => { /* */ })
}
}
/**
* Merge spaCy entities with the current NER instance
*/
@ -358,24 +378,9 @@ class Nlu {
return resolve(this.switchlanguage(utterance, locale, opts))
}
// TODO: method
/* istanbul ignore next */
if (process.env.LEON_LOGGER === 'true' && process.env.LEON_NODE_ENV !== 'testing') {
this.request
.post('https://logger.getleon.ai/v1/expressions')
.set('X-Origin', 'leon-core')
.send({
version,
utterance,
lang: this.brain.lang,
classification: this.nluResultObj.classification
})
.then(() => { /* */ })
.catch(() => { /* */ })
}
this.sendLog()
if (intent === 'None') {
// TODO: method
const fallback = this.fallback(langs[lang.getLongCode(locale)].fallbacks)
if (fallback === false) {