fix:position error when creating segments (#10706)
Some checks are pending
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Waiting to run
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Blocked by required conditions
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Blocked by required conditions

This commit is contained in:
jarvis2f 2024-11-14 21:25:15 +08:00 committed by GitHub
parent 44f57ad9a8
commit 5ff02b469f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1458,6 +1458,7 @@ class SegmentService:
pre_segment_data_list = [] pre_segment_data_list = []
segment_data_list = [] segment_data_list = []
keywords_list = [] keywords_list = []
position = max_position + 1 if max_position else 1
for segment_item in segments: for segment_item in segments:
content = segment_item["content"] content = segment_item["content"]
doc_id = str(uuid.uuid4()) doc_id = str(uuid.uuid4())
@ -1475,7 +1476,7 @@ class SegmentService:
document_id=document.id, document_id=document.id,
index_node_id=doc_id, index_node_id=doc_id,
index_node_hash=segment_hash, index_node_hash=segment_hash,
position=max_position + 1 if max_position else 1, position=position,
content=content, content=content,
word_count=len(content), word_count=len(content),
tokens=tokens, tokens=tokens,
@ -1490,6 +1491,7 @@ class SegmentService:
increment_word_count += segment_document.word_count increment_word_count += segment_document.word_count
db.session.add(segment_document) db.session.add(segment_document)
segment_data_list.append(segment_document) segment_data_list.append(segment_document)
position += 1
pre_segment_data_list.append(segment_document) pre_segment_data_list.append(segment_document)
if "keywords" in segment_item: if "keywords" in segment_item: