Refactor FileComponent build method to accept a single path
This commit is contained in:
parent
91b8f12a54
commit
d6f1a9f1f6
1 changed files with 7 additions and 7 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict
|
||||||
|
|
||||||
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
|
||||||
from langflow.interface.custom.custom_component import CustomComponent
|
from langflow.interface.custom.custom_component import CustomComponent
|
||||||
|
|
@ -13,7 +13,7 @@ class FileComponent(CustomComponent):
|
||||||
def build_config(self) -> Dict[str, Any]:
|
def build_config(self) -> Dict[str, Any]:
|
||||||
return {
|
return {
|
||||||
"paths": {
|
"paths": {
|
||||||
"display_name": "Paths",
|
"display_name": "Path",
|
||||||
"field_type": "file",
|
"field_type": "file",
|
||||||
"file_types": TEXT_FILE_TYPES,
|
"file_types": TEXT_FILE_TYPES,
|
||||||
"info": f"Supported file types: {', '.join(TEXT_FILE_TYPES)}",
|
"info": f"Supported file types: {', '.join(TEXT_FILE_TYPES)}",
|
||||||
|
|
@ -39,9 +39,9 @@ class FileComponent(CustomComponent):
|
||||||
|
|
||||||
def build(
|
def build(
|
||||||
self,
|
self,
|
||||||
paths: List[str],
|
path: str,
|
||||||
silent_errors: bool = False,
|
silent_errors: bool = False,
|
||||||
) -> List[Record]:
|
) -> Record:
|
||||||
records = [self.load_file(path, silent_errors) for path in paths]
|
record = self.load_file(path, silent_errors)
|
||||||
self.status = records
|
self.status = record
|
||||||
return records
|
return record
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue