chore: remove useless code in knowledge_retrieval_node (#4412)

This commit is contained in:
VoidIsVoid 2024-05-15 15:24:40 +08:00 committed by GitHub
parent 97b65f9b4b
commit a76ae2d756
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -146,7 +146,6 @@ class KnowledgeRetrievalNode(BaseNode):
if 'score' in item.metadata and item.metadata['score']:
document_score_list[item.metadata['doc_id']] = item.metadata['score']
document_context_list = []
index_node_ids = [document.metadata['doc_id'] for document in all_documents]
segments = DocumentSegment.query.filter(
DocumentSegment.dataset_id.in_(dataset_ids),
@ -160,11 +159,6 @@ class KnowledgeRetrievalNode(BaseNode):
sorted_segments = sorted(segments,
key=lambda segment: index_node_id_to_position.get(segment.index_node_id,
float('inf')))
for segment in sorted_segments:
if segment.answer:
document_context_list.append(f'question:{segment.content} answer:{segment.answer}')
else:
document_context_list.append(segment.content)
for segment in sorted_segments:
dataset = Dataset.query.filter_by(