remove unstructured api key check (#18989)

This commit is contained in:
Jyong 2025-04-28 17:26:30 +08:00 committed by GitHub
parent ecade13455
commit b8bb45b106
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -223,8 +223,8 @@ def _extract_text_from_doc(file_content: bytes) -> str:
""" """
from unstructured.partition.api import partition_via_api from unstructured.partition.api import partition_via_api
if not (dify_config.UNSTRUCTURED_API_URL and dify_config.UNSTRUCTURED_API_KEY): if not dify_config.UNSTRUCTURED_API_URL:
raise TextExtractionError("UNSTRUCTURED_API_URL and UNSTRUCTURED_API_KEY must be set") raise TextExtractionError("UNSTRUCTURED_API_URL must be set")
try: try:
with tempfile.NamedTemporaryFile(suffix=".doc", delete=False) as temp_file: with tempfile.NamedTemporaryFile(suffix=".doc", delete=False) as temp_file:
@ -235,7 +235,7 @@ def _extract_text_from_doc(file_content: bytes) -> str:
file=file, file=file,
metadata_filename=temp_file.name, metadata_filename=temp_file.name,
api_url=dify_config.UNSTRUCTURED_API_URL, api_url=dify_config.UNSTRUCTURED_API_URL,
api_key=dify_config.UNSTRUCTURED_API_KEY, api_key=dify_config.UNSTRUCTURED_API_KEY, # type: ignore
) )
os.unlink(temp_file.name) os.unlink(temp_file.name)
return "\n".join([getattr(element, "text", "") for element in elements]) return "\n".join([getattr(element, "text", "") for element in elements])