Skip to content

Commit 909f7c2

Browse files
author
MohamedAliBouhaouala
committed
fix: remove async from block score calculation
1 parent c46071f commit 909f7c2

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

api/src/chat/services/block.service.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,13 +434,13 @@ describe('BlockService', () => {
434434
describe('calculateBlockScore', () => {
435435
const nlpPenaltyFactor = 0.9;
436436
it('should calculate the correct NLP score for a block', async () => {
437-
const score = await blockService.calculateBlockScore(
437+
const score = blockService.calculateBlockScore(
438438
mockNlpPatternsSetOne,
439439
mockNlpEntitiesSetOne,
440440
mockNlpCacheMap,
441441
nlpPenaltyFactor,
442442
);
443-
const score2 = await blockService.calculateBlockScore(
443+
const score2 = blockService.calculateBlockScore(
444444
mockNlpPatternsSetTwo,
445445
mockNlpEntitiesSetOne,
446446
mockNlpCacheMap,
@@ -453,13 +453,13 @@ describe('BlockService', () => {
453453
});
454454

455455
it('should calculate the correct NLP score for a block and apply penalties ', async () => {
456-
const score = await blockService.calculateBlockScore(
456+
const score = blockService.calculateBlockScore(
457457
mockNlpPatternsSetOne,
458458
mockNlpEntitiesSetOne,
459459
mockNlpCacheMap,
460460
nlpPenaltyFactor,
461461
);
462-
const score2 = await blockService.calculateBlockScore(
462+
const score2 = blockService.calculateBlockScore(
463463
mockNlpPatternsSetThree,
464464
mockNlpEntitiesSetOne,
465465
mockNlpCacheMap,
@@ -473,7 +473,7 @@ describe('BlockService', () => {
473473

474474
it('should return 0 if no matching entities are found', async () => {
475475
const nlpCacheMap: NlpCacheMap = new Map();
476-
const score = await blockService.calculateBlockScore(
476+
const score = blockService.calculateBlockScore(
477477
mockNlpPatternsSetTwo,
478478
mockNlpEntitiesSetOne,
479479
nlpCacheMap,

api/src/chat/services/block.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ export class BlockService extends BaseService<
412412
const block = blocks[i];
413413
const patterns = matchedPatterns[i];
414414
// If compatible, calculate the NLP score for this block
415-
const nlpScore: number = await this.calculateBlockScore(
415+
const nlpScore: number = this.calculateBlockScore(
416416
patterns,
417417
nlp,
418418
nlpCacheMap,
@@ -445,12 +445,12 @@ export class BlockService extends BaseService<
445445
* @param nlpPenaltyFactor - A multiplier applied to scores when the pattern match type is 'entity'.
446446
* @returns A numeric score representing how well the block matches the given NLP context.
447447
*/
448-
async calculateBlockScore(
448+
calculateBlockScore(
449449
patterns: NlpPattern[],
450450
nlp: NLU.ParseEntities,
451451
nlpCacheMap: NlpCacheMap,
452452
nlpPenaltyFactor: number,
453-
): Promise<number> {
453+
): number {
454454
// Compute individual pattern scores using the cache
455455
const patternScores: number[] = patterns.map((pattern) => {
456456
const entityData = nlpCacheMap.get(pattern.entity);

0 commit comments

Comments
 (0)