feat: add description attribute for nlu values

This commit is contained in:
Mohamed Marrouchi 2025-03-21 12:15:01 +01:00
parent e0a77302cc
commit 0b902031fa
5 changed files with 37 additions and 3 deletions

View File

@ -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: * 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. * 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() @IsObject()
metadata?: Record<string, any>; metadata?: Record<string, any>;
@ApiPropertyOptional({ type: String })
@IsString()
@IsOptional()
doc?: string;
@ApiPropertyOptional({ description: 'Nlp value is builtin', type: Boolean }) @ApiPropertyOptional({ description: 'Nlp value is builtin', type: Boolean })
@IsOptional() @IsOptional()
@IsBoolean() @IsBoolean()
@ -77,6 +82,11 @@ export class NlpValueUpdateDto {
@IsObjectId({ message: 'Entity must be a valid ObjectId' }) @IsObjectId({ message: 'Entity must be a valid ObjectId' })
entity?: string | null; entity?: string | null;
@ApiPropertyOptional({ type: String })
@IsString()
@IsOptional()
doc?: string;
@ApiPropertyOptional({ description: 'Nlp value is builtin', type: Boolean }) @ApiPropertyOptional({ description: 'Nlp value is builtin', type: Boolean })
@IsOptional() @IsOptional()
@IsBoolean() @IsBoolean()

View File

@ -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: * 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. * 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: {} }) @Prop({ type: JSON, default: {} })
metadata: Record<string, any>; metadata: Record<string, any>;
/**
* 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). * Either or not this value a built-in (either fixtures or shipped along with the 3rd party ai).
*/ */

View File

@ -111,6 +111,14 @@ export const NlpValues = ({ entityId }: { entityId: string }) => {
disableColumnMenu: true, disableColumnMenu: true,
renderHeader, renderHeader,
}, },
{
flex: 3,
field: "doc",
headerName: t("label.doc"),
sortable: true,
disableColumnMenu: true,
renderHeader,
},
{ {
flex: 3, flex: 3,
field: "synonyms", field: "synonyms",

View File

@ -61,6 +61,7 @@ export const NlpValueForm: FC<
>({ >({
defaultValues: { defaultValues: {
value: data?.value || "", value: data?.value || "",
doc: data?.doc || "",
expressions: data?.expressions || [], expressions: data?.expressions || [],
}, },
}); });
@ -84,6 +85,7 @@ export const NlpValueForm: FC<
reset({ reset({
value: data.value, value: data.value,
expressions: data.expressions, expressions: data.expressions,
doc: data.doc,
}); });
} else { } else {
reset(); reset();
@ -102,6 +104,13 @@ export const NlpValueForm: FC<
{...register("value", validationRules.value)} {...register("value", validationRules.value)}
/> />
</ContentItem> </ContentItem>
<ContentItem>
<Input
label={t("label.doc")}
{...register("doc")}
multiline={true}
/>
</ContentItem>
{canHaveSynonyms ? ( {canHaveSynonyms ? (
<ContentItem> <ContentItem>

View File

@ -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: * 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. * 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; entity: string;
foreign_id?: string; foreign_id?: string;
value: string; value: string;
doc?: string;
expressions?: string[]; expressions?: string[];
metadata?: Record<string, any>; metadata?: Record<string, any>;
builtin?: boolean; builtin?: boolean;