mirror of
https://github.com/leon-ai/leon.git
synced 2024-09-19 22:07:10 +03:00
refactor: do not call any core singletons during setup
This commit is contained in:
parent
a03afa78be
commit
994cca7bf4
@ -156,17 +156,6 @@ export default class NER {
|
||||
}
|
||||
}
|
||||
|
||||
public anonymizeEntities(
|
||||
utterance: NLPUtterance,
|
||||
entities: NEREntity[]
|
||||
): NLPUtterance {
|
||||
entities.forEach((entity) => {
|
||||
utterance = utterance.replace(entity.sourceText, `{${entity.entity}}`)
|
||||
})
|
||||
|
||||
return utterance
|
||||
}
|
||||
|
||||
/**
|
||||
* Get spaCy entities from the TCP server
|
||||
*/
|
||||
|
@ -294,7 +294,11 @@ export default class NLU {
|
||||
const processingTimeEnd = Date.now()
|
||||
const processingTime = processingTimeEnd - processingTimeStart
|
||||
|
||||
Telemetry.utterance(this.nluResult, processedData?.executionTime || 0)
|
||||
Telemetry.utterance(
|
||||
BRAIN.lang,
|
||||
this.nluResult,
|
||||
processedData?.executionTime || 0
|
||||
)
|
||||
|
||||
return resolve({
|
||||
processingTime, // In ms, total time
|
||||
|
@ -4,7 +4,8 @@ import axios from 'axios'
|
||||
import osName from 'os-name'
|
||||
import getos from 'getos'
|
||||
|
||||
import type { NLUResult } from '@/core/nlp/types'
|
||||
import type { ShortLanguageCode } from '@/types'
|
||||
import type { NLUResult, NEREntity, NLPUtterance } from '@/core/nlp/types'
|
||||
import {
|
||||
IS_TELEMETRY_ENABLED,
|
||||
INSTANCE_ID,
|
||||
@ -17,7 +18,6 @@ import {
|
||||
TCP_SERVER_VERSION,
|
||||
TTS_PROVIDER
|
||||
} from '@/constants'
|
||||
import { BRAIN, NER } from '@/core'
|
||||
import { SystemHelper } from '@/helpers/system-helper'
|
||||
import { SkillDomainHelper } from '@/helpers/skill-domain-helper'
|
||||
import { LogHelper } from '@/helpers/log-helper'
|
||||
@ -103,6 +103,7 @@ export class Telemetry {
|
||||
}
|
||||
|
||||
public static async utterance(
|
||||
lang: ShortLanguageCode,
|
||||
nluResult: NLUResult,
|
||||
executionTime: number
|
||||
): Promise<void> {
|
||||
@ -130,10 +131,9 @@ export class Telemetry {
|
||||
triggeredSkill,
|
||||
triggeredAction,
|
||||
probability,
|
||||
language: BRAIN.lang,
|
||||
language: lang,
|
||||
executionTime,
|
||||
// TODO: await because when github.com + hi fast = not anonymized
|
||||
value: await NER.anonymizeEntities(utterance, entities),
|
||||
value: this.anonymizeEntities(utterance, entities),
|
||||
triggeredSkillVersion: skill.version,
|
||||
triggeredSkillBridge: skill.bridge
|
||||
}
|
||||
@ -210,4 +210,15 @@ export class Telemetry {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static anonymizeEntities(
|
||||
utterance: NLPUtterance,
|
||||
entities: NEREntity[]
|
||||
): NLPUtterance {
|
||||
entities.forEach((entity) => {
|
||||
utterance = utterance.replace(entity.sourceText, `{${entity.entity}}`)
|
||||
})
|
||||
|
||||
return utterance
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user