Add UUIDGeneratorComponent to generate unique IDs
This commit is contained in:
parent
cb95de9e1f
commit
891e8a04ac
1 changed files with 18 additions and 0 deletions
18
src/backend/langflow/components/utilities/IDGenerator.py
Normal file
18
src/backend/langflow/components/utilities/IDGenerator.py
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
from langflow import CustomComponent
|
||||||
|
|
||||||
|
|
||||||
|
class UUIDGeneratorComponent(CustomComponent):
|
||||||
|
documentation: str = "http://docs.langflow.org/components/custom"
|
||||||
|
display_name = "Unique ID Generator"
|
||||||
|
description = "Generates a unique ID."
|
||||||
|
|
||||||
|
def generate(self, *args, **kwargs):
|
||||||
|
return str(uuid.uuid4().hex)
|
||||||
|
|
||||||
|
def build_config(self):
|
||||||
|
return {"unique_id": {"display_name": "Value", "value": self.generate}}
|
||||||
|
|
||||||
|
def build(self, unique_id: str) -> str:
|
||||||
|
return unique_id
|
||||||
Loading…
Add table
Add a link
Reference in a new issue