From ef257c3f96a03f5c2a48a12059065367e95616fa Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 24 Nov 2023 15:12:25 -0300 Subject: [PATCH] Add list_key_names property to CustomComponent --- .../langflow/interface/custom/custom_component.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/backend/langflow/interface/custom/custom_component.py b/src/backend/langflow/interface/custom/custom_component.py index 5173e17a1..eb8670aba 100644 --- a/src/backend/langflow/interface/custom/custom_component.py +++ b/src/backend/langflow/interface/custom/custom_component.py @@ -5,6 +5,7 @@ from uuid import UUID import yaml from cachetools import TTLCache, cachedmethod from fastapi import HTTPException + from langflow.field_typing.constants import CUSTOM_COMPONENT_SUPPORTED_TYPES from langflow.interface.custom.component import Component from langflow.interface.custom.directory_reader import DirectoryReader @@ -196,6 +197,15 @@ class CustomComponent(Component): return get_credential + @property + def list_key_names(self): + if hasattr(self, "_user_id") and not self._user_id: + raise ValueError(f"User id is not set for {self.__class__.__name__}") + credential_service = get_credential_service() + db_service = get_db_service() + with session_getter(db_service) as session: + return credential_service.list_credentials(user_id=self._user_id, session=session) + @property def get_function(self): return validate.create_function(self.code, self.function_entrypoint_name)