diff --git a/api/src/nlp/controllers/nlp-value.controller.ts b/api/src/nlp/controllers/nlp-value.controller.ts index 74a17d48d..1cd3aadb1 100644 --- a/api/src/nlp/controllers/nlp-value.controller.ts +++ b/api/src/nlp/controllers/nlp-value.controller.ts @@ -93,7 +93,9 @@ export class NlpValueController extends BaseController< @Get('count') async filterCount( @Query( - new SearchFilterPipe({ allowedFields: ['entity', 'value'] }), + new SearchFilterPipe({ + allowedFields: ['entity', 'value', 'doc'], + }), ) filters?: TFilterQuery, ) { @@ -142,7 +144,7 @@ export class NlpValueController extends BaseController< @Query(PopulatePipe) populate: string[], @Query( new SearchFilterPipe({ - allowedFields: ['entity', 'value'], + allowedFields: ['entity', 'value', 'doc'], }), ) filters: TFilterQuery, diff --git a/api/src/nlp/dto/nlp-value.dto.ts b/api/src/nlp/dto/nlp-value.dto.ts index 7fecb0e56..5c1c42d93 100644 --- a/api/src/nlp/dto/nlp-value.dto.ts +++ b/api/src/nlp/dto/nlp-value.dto.ts @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Hexastack. All rights reserved. + * Copyright © 2025 Hexastack. All rights reserved. * * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. @@ -39,6 +39,11 @@ export class NlpValueCreateDto { @IsObject() metadata?: Record; + @ApiPropertyOptional({ description: 'Nlp Value Description', type: String }) + @IsString() + @IsOptional() + doc?: string; + @ApiPropertyOptional({ description: 'Nlp value is builtin', type: Boolean }) @IsOptional() @IsBoolean() @@ -77,6 +82,11 @@ export class NlpValueUpdateDto { @IsObjectId({ message: 'Entity must be a valid ObjectId' }) entity?: string | null; + @ApiPropertyOptional({ description: 'Nlp Value Description', type: String }) + @IsString() + @IsOptional() + doc?: string; + @ApiPropertyOptional({ description: 'Nlp value is builtin', type: Boolean }) @IsOptional() @IsBoolean() diff --git a/api/src/nlp/schemas/nlp-value.schema.ts b/api/src/nlp/schemas/nlp-value.schema.ts index a5f2e4bed..5748ccf35 100644 --- a/api/src/nlp/schemas/nlp-value.schema.ts +++ b/api/src/nlp/schemas/nlp-value.schema.ts @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Hexastack. All rights reserved. + * Copyright © 2025 Hexastack. All rights reserved. * * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. @@ -46,6 +46,12 @@ export class NlpValueStub extends BaseSchema { @Prop({ type: JSON, default: {} }) metadata: Record; + /** + * Description of the entity's value purpose. + */ + @Prop({ type: String }) + doc?: string; + /** * Either or not this value a built-in (either fixtures or shipped along with the 3rd party ai). */ diff --git a/frontend/src/components/nlp/components/NlpValue.tsx b/frontend/src/components/nlp/components/NlpValue.tsx index 1864eb431..894bee1c9 100644 --- a/frontend/src/components/nlp/components/NlpValue.tsx +++ b/frontend/src/components/nlp/components/NlpValue.tsx @@ -55,7 +55,7 @@ export const NlpValues = ({ entityId }: { entityId: string }) => { const canHaveSynonyms = nlpEntity?.lookups?.[0] === NlpLookups.keywords; const { onSearch, searchPayload } = useSearch({ $eq: [{ entity: entityId }], - $iLike: ["value"], + $or: ["doc", "value"] }); const { dataGridProps } = useFind( { entity: EntityType.NLP_VALUE }, @@ -111,6 +111,14 @@ export const NlpValues = ({ entityId }: { entityId: string }) => { disableColumnMenu: true, renderHeader, }, + { + flex: 3, + field: "doc", + headerName: t("label.doc"), + sortable: true, + disableColumnMenu: true, + renderHeader, + }, { flex: 3, field: "synonyms", diff --git a/frontend/src/components/nlp/components/NlpValueForm.tsx b/frontend/src/components/nlp/components/NlpValueForm.tsx index f066a62db..e9e154be0 100644 --- a/frontend/src/components/nlp/components/NlpValueForm.tsx +++ b/frontend/src/components/nlp/components/NlpValueForm.tsx @@ -61,6 +61,7 @@ export const NlpValueForm: FC< >({ defaultValues: { value: data?.value || "", + doc: data?.doc || "", expressions: data?.expressions || [], }, }); @@ -84,6 +85,7 @@ export const NlpValueForm: FC< reset({ value: data.value, expressions: data.expressions, + doc: data.doc, }); } else { reset(); @@ -102,6 +104,13 @@ export const NlpValueForm: FC< {...register("value", validationRules.value)} /> + + + {canHaveSynonyms ? ( diff --git a/frontend/src/types/nlp-value.types.ts b/frontend/src/types/nlp-value.types.ts index 92e3de68e..7b7a1e5e5 100644 --- a/frontend/src/types/nlp-value.types.ts +++ b/frontend/src/types/nlp-value.types.ts @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Hexastack. All rights reserved. + * Copyright © 2025 Hexastack. All rights reserved. * * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. @@ -15,6 +15,7 @@ export interface INlpValueAttributes { entity: string; foreign_id?: string; value: string; + doc?: string; expressions?: string[]; metadata?: Record; builtin?: boolean;