From 804ff06d8203637024eb29a5037cfe210019d025 Mon Sep 17 00:00:00 2001 From: -LAN- Date: Tue, 13 May 2025 10:56:38 +0800 Subject: [PATCH] fix(vector_service): Fixes type hinting and removes unnecessary ignores Signed-off-by: -LAN- --- api/services/vector_service.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/services/vector_service.py b/api/services/vector_service.py index 18d10cc528..58292c59f4 100644 --- a/api/services/vector_service.py +++ b/api/services/vector_service.py @@ -21,8 +21,9 @@ class VectorService: def create_segments_vector( cls, keywords_list: Optional[list[list[str]]], segments: list[DocumentSegment], dataset: Dataset, doc_form: str ): - documents = [] + documents: list[Document] = [] + document: Document | None = None for segment in segments: if doc_form == IndexType.PARENT_CHILD_INDEX: document = db.session.query(DatasetDocument).filter_by(id=segment.document_id).first() @@ -62,7 +63,7 @@ class VectorService: raise ValueError("The knowledge base index technique is not high quality!") cls.generate_child_chunks(segment, document, dataset, embedding_model_instance, processing_rule, False) else: - document = Document( # type: ignore + document = Document( page_content=segment.content, metadata={ "doc_id": segment.index_node_id, @@ -74,7 +75,7 @@ class VectorService: documents.append(document) if len(documents) > 0: index_processor = IndexProcessorFactory(doc_form).init_index_processor() - index_processor.load(dataset, documents, with_keywords=True, keywords_list=keywords_list) # type: ignore + index_processor.load(dataset, documents, with_keywords=True, keywords_list=keywords_list) @classmethod def update_segment_vector(cls, keywords: Optional[list[str]], segment: DocumentSegment, dataset: Dataset):