From 6229d5e0e06bf0bb535f7fff23c460e63ceab3f3 Mon Sep 17 00:00:00 2001 From: hexastack Date: Thu, 24 Apr 2025 17:02:26 +0100 Subject: [PATCH 1/3] fix: llm blu confidence --- .../extensions/helpers/llm-nlu/index.helper.ts | 4 ++-- api/src/helper/types.ts | 18 +++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/api/src/extensions/helpers/llm-nlu/index.helper.ts b/api/src/extensions/helpers/llm-nlu/index.helper.ts index ab33d7a2..26b1a799 100644 --- a/api/src/extensions/helpers/llm-nlu/index.helper.ts +++ b/api/src/extensions/helpers/llm-nlu/index.helper.ts @@ -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. @@ -168,7 +168,7 @@ export default class LlmNluHelper traits.push({ entity: name, value, - confidence: 100, + confidence: 1, }); } diff --git a/api/src/helper/types.ts b/api/src/helper/types.ts index 95f1601c..a4785983 100644 --- a/api/src/helper/types.ts +++ b/api/src/helper/types.ts @@ -6,6 +6,8 @@ * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). */ +import { z } from 'zod'; + import { SettingCreateDto } from '@/setting/dto/setting.dto'; import { HyphenToUnderscore } from '@/utils/types/extension'; @@ -15,13 +17,15 @@ import BaseNlpHelper from './lib/base-nlp-helper'; import BaseStorageHelper from './lib/base-storage-helper'; export namespace NLU { - export interface ParseEntity { - entity: string; // Entity name - value: string; // Value name - confidence: number; - start?: number; - end?: number; - } + const ParseEntitySchema = z.object({ + entity: z.string(), + value: z.string(), + confidence: z.number().min(0).max(1), + start: z.number().optional(), + end: z.number().optional(), + }); + + export type ParseEntity = z.infer; export interface ParseEntities { entities: ParseEntity[]; From 828fdd96839e1a1d74378031d3fb1a7f8a748e98 Mon Sep 17 00:00:00 2001 From: hexastack Date: Fri, 25 Apr 2025 08:28:31 +0100 Subject: [PATCH 2/3] fix: update confidence~ value --- api/src/extensions/helpers/llm-nlu/index.helper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/extensions/helpers/llm-nlu/index.helper.ts b/api/src/extensions/helpers/llm-nlu/index.helper.ts index 26b1a799..9834a49b 100644 --- a/api/src/extensions/helpers/llm-nlu/index.helper.ts +++ b/api/src/extensions/helpers/llm-nlu/index.helper.ts @@ -146,7 +146,7 @@ export default class LlmNluHelper { entity: 'language', value: language || defaultLanguage.code, - confidence: 100, + confidence: 1, }, ]; for await (const { name, doc, prompt, values } of this From 949c5aded043644356f916755e1f95aa713c76f4 Mon Sep 17 00:00:00 2001 From: hexastack Date: Mon, 5 May 2025 08:16:46 +0100 Subject: [PATCH 3/3] fix: remove unnecessary zod schema --- api/src/helper/types.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/api/src/helper/types.ts b/api/src/helper/types.ts index a4785983..95f1601c 100644 --- a/api/src/helper/types.ts +++ b/api/src/helper/types.ts @@ -6,8 +6,6 @@ * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). */ -import { z } from 'zod'; - import { SettingCreateDto } from '@/setting/dto/setting.dto'; import { HyphenToUnderscore } from '@/utils/types/extension'; @@ -17,15 +15,13 @@ import BaseNlpHelper from './lib/base-nlp-helper'; import BaseStorageHelper from './lib/base-storage-helper'; export namespace NLU { - const ParseEntitySchema = z.object({ - entity: z.string(), - value: z.string(), - confidence: z.number().min(0).max(1), - start: z.number().optional(), - end: z.number().optional(), - }); - - export type ParseEntity = z.infer; + export interface ParseEntity { + entity: string; // Entity name + value: string; // Value name + confidence: number; + start?: number; + end?: number; + } export interface ParseEntities { entities: ParseEntity[];