Fix custom component index function
This commit is contained in:
parent
90ee49225b
commit
a16725b6c7
2 changed files with 11 additions and 1 deletions
|
|
@ -5,6 +5,7 @@ from typing import Any, ClassVar, Optional
|
||||||
|
|
||||||
from cachetools import TTLCache, cachedmethod
|
from cachetools import TTLCache, cachedmethod
|
||||||
from fastapi import HTTPException
|
from fastapi import HTTPException
|
||||||
|
|
||||||
from langflow.interface.custom.code_parser import CodeParser
|
from langflow.interface.custom.code_parser import CodeParser
|
||||||
from langflow.utils import validate
|
from langflow.utils import validate
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,6 @@ class CustomComponent(Component):
|
||||||
|
|
||||||
return get_credential
|
return get_credential
|
||||||
|
|
||||||
@property
|
|
||||||
def list_key_names(self):
|
def list_key_names(self):
|
||||||
if hasattr(self, "_user_id") and not self._user_id:
|
if hasattr(self, "_user_id") and not self._user_id:
|
||||||
raise ValueError(f"User id is not set for {self.__class__.__name__}")
|
raise ValueError(f"User id is not set for {self.__class__.__name__}")
|
||||||
|
|
@ -206,6 +205,16 @@ class CustomComponent(Component):
|
||||||
with session_getter(db_service) as session:
|
with session_getter(db_service) as session:
|
||||||
return credential_service.list_credentials(user_id=self._user_id, session=session)
|
return credential_service.list_credentials(user_id=self._user_id, session=session)
|
||||||
|
|
||||||
|
def index(self, value: int = 0):
|
||||||
|
"""Returns a function that returns the value at the given index in the iterable."""
|
||||||
|
|
||||||
|
def get_index(iterable: List[Any]):
|
||||||
|
if iterable:
|
||||||
|
return iterable[value]
|
||||||
|
return iterable
|
||||||
|
|
||||||
|
return get_index
|
||||||
|
|
||||||
@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