mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: handle dependency injection in chat module
This commit is contained in:
parent
df3c552aa3
commit
8f6028a49b
@ -16,11 +16,9 @@ import { AttachmentModel } from '@/attachment/schemas/attachment.schema';
|
||||
import { AttachmentService } from '@/attachment/services/attachment.service';
|
||||
import { ChannelModule } from '@/channel/channel.module';
|
||||
import { CmsModule } from '@/cms/cms.module';
|
||||
import { NlpEntityRepository } from '@/nlp/repositories/nlp-entity.repository';
|
||||
import { NlpSampleEntityRepository } from '@/nlp/repositories/nlp-sample-entity.repository';
|
||||
import { NlpValueRepository } from '@/nlp/repositories/nlp-value.repository';
|
||||
import { UserModule } from '@/user/user.module';
|
||||
|
||||
import { NlpModule } from '@/nlp/nlp.module';
|
||||
import { BlockController } from './controllers/block.controller';
|
||||
import { CategoryController } from './controllers/category.controller';
|
||||
import { ContextVarController } from './controllers/context-var.controller';
|
||||
@ -71,6 +69,7 @@ import { SubscriberService } from './services/subscriber.service';
|
||||
AttachmentModule,
|
||||
EventEmitter2,
|
||||
UserModule,
|
||||
NlpModule,
|
||||
],
|
||||
controllers: [
|
||||
CategoryController,
|
||||
@ -88,9 +87,6 @@ import { SubscriberService } from './services/subscriber.service';
|
||||
MessageRepository,
|
||||
SubscriberRepository,
|
||||
ConversationRepository,
|
||||
NlpEntityRepository,
|
||||
NlpSampleEntityRepository,
|
||||
NlpValueRepository,
|
||||
CategoryService,
|
||||
ContextVarService,
|
||||
LabelService,
|
||||
@ -114,3 +110,4 @@ import { SubscriberService } from './services/subscriber.service';
|
||||
],
|
||||
})
|
||||
export class ChatModule {}
|
||||
|
||||
|
@ -60,7 +60,7 @@ export const patternSchema = z.union([
|
||||
|
||||
export type Pattern = z.infer<typeof patternSchema>;
|
||||
|
||||
export type MatchResult = {
|
||||
export type NlpPatternMatchResult = {
|
||||
block: BlockFull;
|
||||
matchedPattern: NlpPattern[];
|
||||
};
|
||||
|
@ -39,8 +39,8 @@ import {
|
||||
StdOutgoingSystemEnvelope,
|
||||
} from '../schemas/types/message';
|
||||
import {
|
||||
MatchResult,
|
||||
NlpPattern,
|
||||
NlpPatternMatchResult,
|
||||
PayloadPattern,
|
||||
} from '../schemas/types/pattern';
|
||||
import { Payload, StdQuickReply } from '../schemas/types/quick-reply';
|
||||
@ -201,17 +201,16 @@ export class BlockService extends BaseService<
|
||||
// This ensures that only blocks with valid matches are kept, and blocks with no matches are excluded,
|
||||
// all while iterating through the list only once.
|
||||
|
||||
const matchesWithPatterns = filteredBlocks.reduce<MatchResult[]>(
|
||||
(acc, b) => {
|
||||
const matchesWithPatterns = filteredBlocks.reduce<
|
||||
NlpPatternMatchResult[]
|
||||
>((acc, b) => {
|
||||
const matchedPattern = this.matchNLP(nlp, b);
|
||||
|
||||
if (matchedPattern && matchedPattern.length > 0) {
|
||||
acc.push({ block: b, matchedPattern });
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
[],
|
||||
);
|
||||
}, []);
|
||||
|
||||
// @TODO Make nluPenaltyFactor configurable in UI settings
|
||||
const nluPenaltyFactor = 0.95;
|
||||
|
Loading…
Reference in New Issue
Block a user