Add list_key_names property to CustomComponent
This commit is contained in:
parent
b9a526b72e
commit
ef257c3f96
1 changed files with 10 additions and 0 deletions
|
|
@ -5,6 +5,7 @@ from uuid import UUID
|
||||||
import yaml
|
import yaml
|
||||||
from cachetools import TTLCache, cachedmethod
|
from cachetools import TTLCache, cachedmethod
|
||||||
from fastapi import HTTPException
|
from fastapi import HTTPException
|
||||||
|
|
||||||
from langflow.field_typing.constants import CUSTOM_COMPONENT_SUPPORTED_TYPES
|
from langflow.field_typing.constants import CUSTOM_COMPONENT_SUPPORTED_TYPES
|
||||||
from langflow.interface.custom.component import Component
|
from langflow.interface.custom.component import Component
|
||||||
from langflow.interface.custom.directory_reader import DirectoryReader
|
from langflow.interface.custom.directory_reader import DirectoryReader
|
||||||
|
|
@ -196,6 +197,15 @@ class CustomComponent(Component):
|
||||||
|
|
||||||
return get_credential
|
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
|
@property
|
||||||
def get_function(self):
|
def get_function(self):
|
||||||
return validate.create_function(self.code, self.function_entrypoint_name)
|
return validate.create_function(self.code, self.function_entrypoint_name)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue