From 0107eecae09d32badf85db0d47a60b3416fec810 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 30 Jan 2024 17:17:58 -0300 Subject: [PATCH] Add get_full_path method to CustomComponent class --- .../custom/custom_component/custom_component.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/backend/langflow/interface/custom/custom_component/custom_component.py b/src/backend/langflow/interface/custom/custom_component/custom_component.py index f946c7695..64839f990 100644 --- a/src/backend/langflow/interface/custom/custom_component/custom_component.py +++ b/src/backend/langflow/interface/custom/custom_component/custom_component.py @@ -5,13 +5,15 @@ from uuid import UUID import yaml from cachetools import TTLCache, cachedmethod from fastapi import HTTPException + from langflow.interface.custom.code_parser.utils import ( extract_inner_type_from_generic_alias, extract_union_types_from_generic_alias, ) from langflow.services.database.models.flow import Flow from langflow.services.database.utils import session_getter -from langflow.services.deps import get_credential_service, get_db_service +from langflow.services.deps import get_credential_service, get_db_service, get_storage_service +from langflow.services.storage.service import StorageService from langflow.utils import validate from .component import Component @@ -34,6 +36,13 @@ class CustomComponent(Component): self.cache = TTLCache(maxsize=1024, ttl=60) super().__init__(**data) + def get_full_path(self, path: str) -> str: + storage_svc: "StorageService" = get_storage_service() + + flow_id = path.split("/")[0] + file_name = path.split("/")[1] + return storage_svc.build_full_path(flow_id, file_name) + def custom_repr(self): if self.repr_value == "": self.repr_value = self.status