Add test for custom component with TemplateField
This commit is contained in:
parent
a74b86e93b
commit
d670d0fd93
3 changed files with 39 additions and 0 deletions
17
tests/data/component_with_templatefield.py
Normal file
17
tests/data/component_with_templatefield.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import random
|
||||
|
||||
from langflow import CustomComponent
|
||||
from langflow.template.field.base import TemplateField
|
||||
|
||||
|
||||
class TestComponent(CustomComponent):
|
||||
def refresh_values(self):
|
||||
# This is a function that will be called every time the component is updated
|
||||
# and should return a list of random strings
|
||||
return [f"Random {random.randint(1, 100)}" for _ in range(5)]
|
||||
|
||||
def build_config(self):
|
||||
return {"param": TemplateField(display_name="Param", options=self.refresh_values)}
|
||||
|
||||
def build(self, param: int):
|
||||
return param
|
||||
Loading…
Add table
Add a link
Reference in a new issue