This commit updates the field types in the `prompt.py` and `formatter/base.py` modules. The `DefaultPromptField` class in `prompt.py` now inherits from `InputField` instead of `TemplateField`. Similarly, the `format` method in the `FieldFormatter` class in `formatter/base.py` now accepts an `InputField` parameter instead of a `TemplateField` parameter. These changes ensure consistency and improve the accuracy of the code.
17 lines
554 B
Python
17 lines
554 B
Python
import random
|
|
|
|
from langflow.custom import CustomComponent
|
|
from langflow.field_typing import InputField
|
|
|
|
|
|
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": InputField(display_name="Param", options=self.refresh_values)}
|
|
|
|
def build(self, param: int):
|
|
return param
|