fix(vector_service): Fixes type hinting and removes unnecessary ignores (#19574)

Signed-off-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
-LAN- 2025-05-13 11:29:02 +08:00 committed by GitHub
parent c76d763639
commit f0137be719
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View File

@ -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):

View File

@ -907,4 +907,4 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
```
</CodeGroup>
</Col>
</Row>
</Row>