Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:position error when creating segments #10706

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion api/services/dataset_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,7 @@ def multi_create_segment(cls, segments: list, document: Document, dataset: Datas
pre_segment_data_list = []
segment_data_list = []
keywords_list = []
position = max_position + 1 if max_position else 1
for segment_item in segments:
content = segment_item["content"]
doc_id = str(uuid.uuid4())
Expand All @@ -1475,7 +1476,7 @@ def multi_create_segment(cls, segments: list, document: Document, dataset: Datas
document_id=document.id,
index_node_id=doc_id,
index_node_hash=segment_hash,
position=max_position + 1 if max_position else 1,
position=position,
content=content,
word_count=len(content),
tokens=tokens,
Expand All @@ -1490,6 +1491,7 @@ def multi_create_segment(cls, segments: list, document: Document, dataset: Datas
increment_word_count += segment_document.word_count
db.session.add(segment_document)
segment_data_list.append(segment_document)
position += 1

pre_segment_data_list.append(segment_document)
if "keywords" in segment_item:
Expand Down