Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: wrong token number when using qa_model and answer is updated. (#21574)

NeatGuyCoding33f0457a23fb
diff --git a/api/services/dataset_service.py b/api/services/dataset_service.py
index a697c9ab7fe..ef511857cfa 100644
--- a/api/services/dataset_service.py
+++ b/api/services/dataset_service.py
@@ -2207,6 +2207,7 @@ class SegmentService:
# calc embedding use tokens
if document.doc_form == "qa_model":
+ segment.answer = args.answer
tokens = embedding_model.get_text_embedding_num_tokens(texts=[content + segment.answer])[0]
else:
tokens = embedding_model.get_text_embedding_num_tokens(texts=[content])[0]