refactor(api): remove remaining legacy field remnants (#37967)

This commit is contained in:
chariri
2026-07-08 09:59:10 +00:00
committed by GitHub
parent 74f177efe6
commit 9465dc2477
10 changed files with 97 additions and 44 deletions
+23 -3
View File
@@ -1,7 +1,7 @@
import re
import tempfile
from pathlib import Path
from typing import Union
from typing import Literal, overload
from urllib.parse import unquote
from configs import dify_config
@@ -40,10 +40,22 @@ USER_AGENT = (
class ExtractProcessor:
@overload
@classmethod
def load_from_upload_file(
cls, upload_file: UploadFile, return_text: Literal[True], is_automatic: bool = False
) -> str: ...
@overload
@classmethod
def load_from_upload_file(
cls, upload_file: UploadFile, return_text: Literal[False] = False, is_automatic: bool = False
) -> list[Document]: ...
@classmethod
def load_from_upload_file(
cls, upload_file: UploadFile, return_text: bool = False, is_automatic: bool = False
) -> Union[list[Document], str]:
) -> list[Document] | str:
extract_setting = ExtractSetting(
datasource_type=DatasourceType.FILE, upload_file=upload_file, document_model="text_model"
)
@@ -53,8 +65,16 @@ class ExtractProcessor:
else:
return cls.extract(extract_setting, is_automatic)
@overload
@classmethod
def load_from_url(cls, url: str, return_text: bool = False) -> Union[list[Document], str]:
def load_from_url(cls, url: str, return_text: Literal[True]) -> str: ...
@overload
@classmethod
def load_from_url(cls, url: str, return_text: Literal[False] = False) -> list[Document]: ...
@classmethod
def load_from_url(cls, url: str, return_text: bool = False) -> list[Document] | str:
response = remote_fetcher.make_request("GET", url, headers={"User-Agent": USER_AGENT})
with tempfile.TemporaryDirectory() as temp_dir: