-
0.8
+
0.0
ยท
{t('feature.annotation.scoreThreshold.easyMatch', { ns: 'appDebug' })}
diff --git a/web/app/components/base/features/new-feature-panel/annotation-reply/use-annotation-config.ts b/web/app/components/base/features/new-feature-panel/annotation-reply/use-annotation-config.ts
index c74175846d..64c714df4e 100644
--- a/web/app/components/base/features/new-feature-panel/annotation-reply/use-annotation-config.ts
+++ b/web/app/components/base/features/new-feature-panel/annotation-reply/use-annotation-config.ts
@@ -53,7 +53,7 @@ const useAnnotationConfig = ({
setAnnotationConfig(produce(annotationConfig, (draft: AnnotationReplyConfig) => {
draft.enabled = true
draft.embedding_model = embeddingModel
- if (!draft.score_threshold)
+ if (draft.score_threshold === undefined || draft.score_threshold === null)
draft.score_threshold = ANNOTATION_DEFAULT.score_threshold
}))
}
diff --git a/web/service/annotation.spec.ts b/web/service/annotation.spec.ts
new file mode 100644
index 0000000000..60af578108
--- /dev/null
+++ b/web/service/annotation.spec.ts
@@ -0,0 +1,28 @@
+import { AnnotationEnableStatus } from '@/app/components/app/annotation/type'
+import { updateAnnotationStatus } from './annotation'
+import { post } from './base'
+
+vi.mock('./base', () => ({
+ post: vi.fn(),
+}))
+
+describe('annotation service', () => {
+ beforeEach(() => {
+ vi.clearAllMocks()
+ })
+
+ it('should preserve zero score threshold when updating annotation status', () => {
+ updateAnnotationStatus('app-1', AnnotationEnableStatus.enable, {
+ embedding_model_name: 'model',
+ embedding_provider_name: 'provider',
+ }, 0)
+
+ expect(post).toHaveBeenCalledWith('apps/app-1/annotation-reply/enable', {
+ body: {
+ embedding_model_name: 'model',
+ embedding_provider_name: 'provider',
+ score_threshold: 0,
+ },
+ })
+ })
+})
diff --git a/web/service/annotation.ts b/web/service/annotation.ts
index 8a19425044..ba8c560b1f 100644
--- a/web/service/annotation.ts
+++ b/web/service/annotation.ts
@@ -7,7 +7,7 @@ export const fetchAnnotationConfig = (appId: string) => {
}
export const updateAnnotationStatus = (appId: string, action: AnnotationEnableStatus, embeddingModel?: EmbeddingModelConfig, score?: number) => {
let body: any = {
- score_threshold: score || ANNOTATION_DEFAULT.score_threshold,
+ score_threshold: score ?? ANNOTATION_DEFAULT.score_threshold,
}
if (embeddingModel) {
body = {