mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-09 19:06:51 +08:00
chore: avoid implicit optional in type annotations of method (#8727)
This commit is contained in:
@@ -162,7 +162,7 @@ class RelytVector(BaseVector):
|
||||
else:
|
||||
return None
|
||||
|
||||
def delete_by_uuids(self, ids: list[str] = None):
|
||||
def delete_by_uuids(self, ids: Optional[list[str]] = None):
|
||||
"""Delete by vector IDs.
|
||||
|
||||
Args:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Any
|
||||
from typing import Any, Optional
|
||||
|
||||
from configs import dify_config
|
||||
from core.embedding.cached_embedding import CacheEmbedding
|
||||
@@ -25,7 +25,7 @@ class AbstractVectorFactory(ABC):
|
||||
|
||||
|
||||
class Vector:
|
||||
def __init__(self, dataset: Dataset, attributes: list = None):
|
||||
def __init__(self, dataset: Dataset, attributes: Optional[list] = None):
|
||||
if attributes is None:
|
||||
attributes = ["doc_id", "dataset_id", "document_id", "doc_hash"]
|
||||
self._dataset = dataset
|
||||
@@ -106,7 +106,7 @@ class Vector:
|
||||
case _:
|
||||
raise ValueError(f"Vector store {vector_type} is not supported.")
|
||||
|
||||
def create(self, texts: list = None, **kwargs):
|
||||
def create(self, texts: Optional[list] = None, **kwargs):
|
||||
if texts:
|
||||
embeddings = self._embeddings.embed_documents([document.page_content for document in texts])
|
||||
self._vector_processor.create(texts=texts, embeddings=embeddings, **kwargs)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import re
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
from typing import Optional, Union
|
||||
from urllib.parse import unquote
|
||||
|
||||
from configs import dify_config
|
||||
@@ -84,7 +84,7 @@ class ExtractProcessor:
|
||||
|
||||
@classmethod
|
||||
def extract(
|
||||
cls, extract_setting: ExtractSetting, is_automatic: bool = False, file_path: str = None
|
||||
cls, extract_setting: ExtractSetting, is_automatic: bool = False, file_path: Optional[str] = None
|
||||
) -> list[Document]:
|
||||
if extract_setting.datasource_type == DatasourceType.FILE.value:
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from core.rag.extractor.extractor_base import BaseExtractor
|
||||
from core.rag.models.document import Document
|
||||
@@ -17,7 +18,7 @@ class UnstructuredEpubExtractor(BaseExtractor):
|
||||
def __init__(
|
||||
self,
|
||||
file_path: str,
|
||||
api_url: str = None,
|
||||
api_url: Optional[str] = None,
|
||||
):
|
||||
"""Initialize with file path."""
|
||||
self._file_path = file_path
|
||||
|
||||
Reference in New Issue
Block a user