fix: rename nlp to nlu namespace

This commit is contained in:
Mohamed Marrouchi
2024-12-09 14:16:08 +01:00
parent f9caf0f458
commit dcf5097750
9 changed files with 25 additions and 29 deletions

View File

@@ -6,7 +6,7 @@
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/
import { Nlp } from '@/helper/types';
import { NLU } from '@/helper/types';
import { NlpParseResultType, RasaNlu } from '../types';
@@ -100,7 +100,7 @@ export const nlpParseResult: NlpParseResultType = {
text: 'Hello Joe',
};
export const nlpBestGuess: Nlp.ParseEntities = {
export const nlpBestGuess: NLU.ParseEntities = {
entities: [
{
start: 5,

View File

@@ -11,7 +11,7 @@ import { Injectable } from '@nestjs/common';
import { HelperService } from '@/helper/helper.service';
import BaseNlpHelper from '@/helper/lib/base-nlp-helper';
import { Nlp } from '@/helper/types';
import { NLU } from '@/helper/types';
import { LanguageService } from '@/i18n/services/language.service';
import { LoggerService } from '@/logger/logger.service';
import { NlpEntity, NlpEntityFull } from '@/nlp/schemas/nlp-entity.schema';
@@ -191,10 +191,10 @@ export default class CoreNluHelper extends BaseNlpHelper<
async filterEntitiesByConfidence(
nlp: NlpParseResultType,
threshold: boolean,
): Promise<Nlp.ParseEntities> {
): Promise<NLU.ParseEntities> {
try {
let minConfidence = 0;
const guess: Nlp.ParseEntities = {
const guess: NLU.ParseEntities = {
entities: nlp.entities.slice(),
};
if (threshold) {
@@ -255,7 +255,7 @@ export default class CoreNluHelper extends BaseNlpHelper<
text: string,
threshold: boolean,
project: string = 'current',
): Promise<Nlp.ParseEntities> {
): Promise<NLU.ParseEntities> {
try {
const settings = await this.getSettings();
const { data: nlp } =

View File

@@ -12,7 +12,7 @@ import Handlebars from 'handlebars';
import { HelperService } from '@/helper/helper.service';
import BaseNlpHelper from '@/helper/lib/base-nlp-helper';
import { LLM, Nlp } from '@/helper/types';
import { LLM, NLU } from '@/helper/types';
import { LanguageService } from '@/i18n/services/language.service';
import { LoggerService } from '@/logger/logger.service';
import { NlpEntityFull } from '@/nlp/schemas/nlp-entity.schema';
@@ -103,7 +103,7 @@ export default class LlmNluHelper
private findKeywordEntities(
text: string,
entity: NlpEntityFull,
): Nlp.ParseEntity[] {
): NLU.ParseEntity[] {
return entity.values
.flatMap(({ value, expressions }) => {
const allValues = [value, ...expressions];
@@ -128,7 +128,7 @@ export default class LlmNluHelper
.filter((v) => !!v);
}
async predict(text: string): Promise<Nlp.ParseEntities> {
async predict(text: string): Promise<NLU.ParseEntities> {
const settings = await this.getSettings();
const helper = await this.helperService.getDefaultLlmHelper();
const defaultLanguage = await this.languageService.getDefaultLanguage();
@@ -143,7 +143,7 @@ export default class LlmNluHelper
},
);
const traits: Nlp.ParseEntity[] = [
const traits: NLU.ParseEntity[] = [
{
entity: 'language',
value: language || defaultLanguage.code,