feat: implement nlp based blocks prioritization strategy

feat: add weight to nlp entity schema and readapt

feat: remove commented obsolete code

feat: restore settings

feat: apply feedback

fix: re-adapt unit tests

feat: priority scoring re-calculation & enabling weight modification in builtin nlp entities

fix: remove obsolete code

feat: refine unit tests, apply mr coderabbit suggestions

fix: minor refactoring

feat: add nlp cache map type

feat: refine builtin nlp entities weight updates

feat: add more test cases and refine edge case handling

feat: add weight validation in UI

fix: apply feedback

feat: add a penalty factor & fix unit tests

feat: add documentation

fix: correct syntax

fix: remove stale log statement

fix: enforce nlp entity weight restrictions

fix: correct typo in docs

fix: typos in docs

fix: fix formatting for function comment

fix: restore matchNLP function previous code

fix: remove blank line, make updateOne asynchronous

fix: add AND operator in docs

fix: handle dependency injection in chat module

feat: refactor to use findAndPopulate in block score calculation

feat: refine caching mechanisms

feat: add typing and enforce safety checks

fix: remove typo

fix: remove async from block score calculation

fix: remove typo

fix: correct linting

fix: refine nlp pattern type check

fix: decompose code into helper utils,  add nlp entity dto validation, remove type casting

fix: minor refactoring

feat: refactor current implementation
This commit is contained in:
Mohamed Marrouchi
2025-03-26 13:11:07 +01:00
committed by Mohamed Marrouchi
parent 0db40680dc
commit bab2e3082f
31 changed files with 1061 additions and 49 deletions

View File

@@ -167,6 +167,16 @@ const NlpEntity = () => {
resizable: false,
renderHeader,
},
{
maxWidth: 210,
field: "weight",
headerName: t("label.weight"),
renderCell: (val) => <Chip label={val.value} variant="title" />,
sortable: true,
disableColumnMenu: true,
resizable: false,
renderHeader,
},
{
maxWidth: 90,
field: "builtin",

View File

@@ -60,6 +60,7 @@ export const NlpEntityVarForm: FC<ComponentFormProps<INlpEntity>> = ({
name: nlpEntity?.name || "",
doc: nlpEntity?.doc || "",
lookups: nlpEntity?.lookups || ["keywords"],
weight: nlpEntity?.weight || 1,
},
});
const validationRules = {
@@ -82,6 +83,7 @@ export const NlpEntityVarForm: FC<ComponentFormProps<INlpEntity>> = ({
reset({
name: nlpEntity.name,
doc: nlpEntity.doc,
weight: nlpEntity.weight,
});
} else {
reset();
@@ -121,6 +123,7 @@ export const NlpEntityVarForm: FC<ComponentFormProps<INlpEntity>> = ({
required
autoFocus
helperText={errors.name ? errors.name.message : null}
disabled={nlpEntity?.builtin}
/>
</ContentItem>
<ContentItem>
@@ -128,8 +131,35 @@ export const NlpEntityVarForm: FC<ComponentFormProps<INlpEntity>> = ({
label={t("label.doc")}
{...register("doc")}
multiline={true}
disabled={nlpEntity?.builtin}
/>
</ContentItem>
<ContentItem>
<Input
label={t("label.weight")}
{...register("weight", {
valueAsNumber: true,
required: t("message.weight_required_error"),
min: {
value: 1,
message: t("message.weight_positive_integer_error"),
},
validate: (value) =>
value && Number.isInteger(value) && value! > 0
? true
: t("message.weight_positive_integer_error"),
})}
type="number"
inputProps={{
min: 1,
step: 1,
inputMode: "numeric",
pattern: "[1-9][0-9]*",
}}
error={!!errors.weight}
helperText={errors.weight?.message}
/>
</ContentItem>
</ContentContainer>
</form>
</Wrapper>