-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into toolsAndOthersBugs
- Loading branch information
Showing
16 changed files
with
297 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 24 additions & 16 deletions
40
src/backend/base/langflow/components/helpers/IDGenerator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,37 @@ | ||
import uuid | ||
from typing import Any, Optional | ||
|
||
from langflow.custom import CustomComponent | ||
from langflow.schema.dotdict import dotdict | ||
from langflow.custom import Component | ||
from langflow.io import MessageTextInput, Output | ||
from langflow.schema import dotdict | ||
from langflow.schema.message import Message | ||
|
||
|
||
class IDGeneratorComponent(CustomComponent): | ||
class IDGeneratorComponent(Component): | ||
display_name = "ID Generator" | ||
description = "Generates a unique ID." | ||
icon = "fingerprint" | ||
name = "IDGenerator" | ||
|
||
def update_build_config( # type: ignore | ||
self, build_config: dotdict, field_value: Any, field_name: Optional[str] = None | ||
): | ||
inputs = [ | ||
MessageTextInput( | ||
name="unique_id", | ||
display_name="Value", | ||
info="The generated unique ID.", | ||
refresh_button=True, | ||
), | ||
] | ||
|
||
outputs = [ | ||
Output(display_name="ID", name="id", method="generate_id"), | ||
] | ||
|
||
def update_build_config(self, build_config: dotdict, field_value: Any, field_name: Optional[str] = None): | ||
if field_name == "unique_id": | ||
build_config[field_name]["value"] = str(uuid.uuid4()) | ||
return build_config | ||
|
||
def build_config(self): | ||
return { | ||
"unique_id": { | ||
"display_name": "Value", | ||
"refresh_button": True, | ||
} | ||
} | ||
|
||
def build(self, unique_id: str) -> str: | ||
return unique_id | ||
def generate_id(self) -> Message: | ||
unique_id = self.unique_id or str(uuid.uuid4()) | ||
self.status = f"Generated ID: {unique_id}" | ||
return Message(text=unique_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.