Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add description attribute for nlu values #840

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions api/src/nlp/controllers/nlp-value.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ export class NlpValueController extends BaseController<
@Get('count')
async filterCount(
@Query(
new SearchFilterPipe<NlpValue>({ allowedFields: ['entity', 'value'] }),
new SearchFilterPipe<NlpValue>({
allowedFields: ['entity', 'value', 'doc'],
}),
)
filters?: TFilterQuery<NlpValue>,
) {
Expand Down Expand Up @@ -142,7 +144,7 @@ export class NlpValueController extends BaseController<
@Query(PopulatePipe) populate: string[],
@Query(
new SearchFilterPipe<NlpValue>({
allowedFields: ['entity', 'value'],
allowedFields: ['entity', 'value', 'doc'],
}),
)
filters: TFilterQuery<NlpValue>,
Expand Down
12 changes: 11 additions & 1 deletion api/src/nlp/dto/nlp-value.dto.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -39,6 +39,11 @@ export class NlpValueCreateDto {
@IsObject()
metadata?: Record<string, any>;

@ApiPropertyOptional({ description: 'Nlp Value Description', type: String })
@IsString()
@IsOptional()
doc?: string;

@ApiPropertyOptional({ description: 'Nlp value is builtin', type: Boolean })
@IsOptional()
@IsBoolean()
Expand Down Expand Up @@ -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()
Expand Down
8 changes: 7 additions & 1 deletion api/src/nlp/schemas/nlp-value.schema.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -46,6 +46,12 @@ export class NlpValueStub extends BaseSchema {
@Prop({ type: JSON, default: {} })
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).
*/
Expand Down
10 changes: 9 additions & 1 deletion frontend/src/components/nlp/components/NlpValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const NlpValues = ({ entityId }: { entityId: string }) => {
const canHaveSynonyms = nlpEntity?.lookups?.[0] === NlpLookups.keywords;
const { onSearch, searchPayload } = useSearch<INlpValue>({
$eq: [{ entity: entityId }],
$iLike: ["value"],
$or: ["doc", "value"]
});
const { dataGridProps } = useFind(
{ entity: EntityType.NLP_VALUE },
Expand Down Expand Up @@ -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",
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/components/nlp/components/NlpValueForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const NlpValueForm: FC<
>({
defaultValues: {
value: data?.value || "",
doc: data?.doc || "",
expressions: data?.expressions || [],
},
});
Expand All @@ -84,6 +85,7 @@ export const NlpValueForm: FC<
reset({
value: data.value,
expressions: data.expressions,
doc: data.doc,
});
} else {
reset();
Expand All @@ -102,6 +104,13 @@ export const NlpValueForm: FC<
{...register("value", validationRules.value)}
/>
</ContentItem>
<ContentItem>
<Input
label={t("label.doc")}
{...register("doc")}
multiline={true}
/>
</ContentItem>

{canHaveSynonyms ? (
<ContentItem>
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/types/nlp-value.types.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -15,6 +15,7 @@ export interface INlpValueAttributes {
entity: string;
foreign_id?: string;
value: string;
doc?: string;
expressions?: string[];
metadata?: Record<string, any>;
builtin?: boolean;
Expand Down