mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
feat(api): add nlp pattern lookup strategy
This commit is contained in:
@@ -95,7 +95,7 @@ describe('NlpValueController', () => {
|
||||
entity: nlpEntities[0].id,
|
||||
value: 'valuetest',
|
||||
expressions: ['synonym1', 'synonym2'],
|
||||
metadata: { firstkey: 'firstvalue', secondKey: 1995 },
|
||||
metadata: {},
|
||||
builtin: false,
|
||||
doc: '',
|
||||
};
|
||||
|
||||
@@ -71,14 +71,17 @@ export class NlpValueController extends BaseController<
|
||||
async create(
|
||||
@Body() createNlpValueDto: NlpValueCreateDto,
|
||||
): Promise<NlpValue> {
|
||||
const nlpEntity = createNlpValueDto.entity
|
||||
? await this.nlpEntityService.findOne(createNlpValueDto.entity!)
|
||||
: null;
|
||||
|
||||
this.validate({
|
||||
dto: createNlpValueDto,
|
||||
allowedIds: {
|
||||
entity: createNlpValueDto.entity
|
||||
? (await this.nlpEntityService.findOne(createNlpValueDto.entity))?.id
|
||||
: null,
|
||||
entity: nlpEntity?.id,
|
||||
},
|
||||
});
|
||||
|
||||
return await this.nlpValueService.create(createNlpValueDto);
|
||||
}
|
||||
|
||||
@@ -171,6 +174,17 @@ export class NlpValueController extends BaseController<
|
||||
@Param('id') id: string,
|
||||
@Body() updateNlpValueDto: NlpValueUpdateDto,
|
||||
): Promise<NlpValue> {
|
||||
const nlpEntity = updateNlpValueDto.entity
|
||||
? await this.nlpEntityService.findOne(updateNlpValueDto.entity!)
|
||||
: null;
|
||||
|
||||
this.validate({
|
||||
dto: updateNlpValueDto,
|
||||
allowedIds: {
|
||||
entity: nlpEntity?.id,
|
||||
},
|
||||
});
|
||||
|
||||
return await this.nlpValueService.updateOne(id, updateNlpValueDto);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user