Fix getting extension in files
This commit is contained in:
parent
37ede63d2d
commit
f7e8526a06
1 changed files with 3 additions and 1 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
from pathlib import Path
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
from langflow.base.data.utils import TEXT_FILE_TYPES, parse_text_file_to_record
|
from langflow.base.data.utils import TEXT_FILE_TYPES, parse_text_file_to_record
|
||||||
|
|
@ -26,7 +27,8 @@ class FileComponent(CustomComponent):
|
||||||
|
|
||||||
def load_file(self, path: str, silent_errors: bool = False) -> Record:
|
def load_file(self, path: str, silent_errors: bool = False) -> Record:
|
||||||
resolved_path = self.resolve_path(path)
|
resolved_path = self.resolve_path(path)
|
||||||
extension = resolved_path.split(".")[-1]
|
path_obj = Path(resolved_path)
|
||||||
|
extension = path_obj.suffix[1:].lower()
|
||||||
if extension == "doc":
|
if extension == "doc":
|
||||||
raise ValueError("doc files are not supported. Please save as .docx")
|
raise ValueError("doc files are not supported. Please save as .docx")
|
||||||
if extension not in TEXT_FILE_TYPES:
|
if extension not in TEXT_FILE_TYPES:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue