Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add dynamic metadata to components + search on sidebar #3945

Merged
merged 7 commits into from
Sep 27, 2024
2 changes: 1 addition & 1 deletion src/backend/base/langflow/base/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

STREAM_INFO_TEXT = "Stream the response from the model. Streaming works only in Chat."

NODE_FORMAT_ATTRIBUTES = ["beta", "icon", "display_name", "description", "output_types", "edited"]
NODE_FORMAT_ATTRIBUTES = ["beta", "icon", "display_name", "description", "output_types", "edited", "metadata"]


FIELD_FORMAT_ATTRIBUTES = [
Expand Down
7 changes: 7 additions & 0 deletions src/backend/base/langflow/custom/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ def getattr_return_list_of_values_from_dict(value):
return []


def getattr_return_dict(value):
if isinstance(value, dict):
return value
return {}


ATTR_FUNC_MAPPING: dict[str, Callable] = {
"display_name": getattr_return_str,
"description": getattr_return_str,
Expand All @@ -63,4 +69,5 @@ def getattr_return_list_of_values_from_dict(value):
"_inputs": getattr_return_list_of_values_from_dict,
"outputs": getattr_return_list_of_object,
"inputs": getattr_return_list_of_object,
"metadata": getattr_return_dict,
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from langflow.inputs.inputs import InputTypes

BACKWARDS_COMPATIBLE_ATTRIBUTES = ["user_id", "vertex", "tracing_service"]
CONFIG_ATTRIBUTES = ["_display_name", "_description", "_icon", "_name"]
CONFIG_ATTRIBUTES = ["_display_name", "_description", "_icon", "_name", "_metadata"]


class Component(CustomComponent):
Expand All @@ -40,6 +40,7 @@ class Component(CustomComponent):
code_class_base_inheritance: ClassVar[str] = "Component"
_output_logs: dict[str, Log] = {}
_current_output: str = ""
_metadata: dict = {}

def __init__(self, **kwargs):
# if key starts with _ it is a config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
"frozen": false,
"icon": "ChatInput",
"lf_version": "1.0.16",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -380,6 +381,7 @@
"frozen": false,
"icon": "ChatOutput",
"lf_version": "1.0.16",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -588,6 +590,7 @@
"frozen": false,
"icon": "OpenAI",
"lf_version": "1.0.16",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -1166,6 +1169,7 @@
"frozen": false,
"icon": "calculator",
"lf_version": "1.0.16",
"metadata": {},
"official": false,
"output_types": [],
"outputs": [
Expand Down Expand Up @@ -1277,6 +1281,7 @@
"code"
],
"frozen": false,
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
],
"frozen": false,
"icon": "ChatInput",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -323,6 +324,7 @@
],
"frozen": false,
"icon": "prompts",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -443,6 +445,7 @@
],
"frozen": false,
"icon": "ChatOutput",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -644,6 +647,7 @@
],
"frozen": false,
"icon": "OpenAI",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
],
"frozen": false,
"icon": "layout-template",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -287,6 +288,7 @@
],
"frozen": false,
"icon": "braces",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -423,6 +425,7 @@
],
"frozen": false,
"icon": "prompts",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -664,6 +667,7 @@
],
"frozen": false,
"icon": "ChatOutput",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -865,6 +869,7 @@
],
"frozen": false,
"icon": "OpenAI",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@
],
"frozen": false,
"icon": "CrewAI",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -874,6 +875,7 @@
],
"frozen": false,
"icon": "OpenAI",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -1164,6 +1166,7 @@
],
"frozen": false,
"icon": "ChatOutput",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -1349,6 +1352,7 @@
],
"frozen": false,
"icon": "CrewAI",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -1488,6 +1492,7 @@
],
"frozen": false,
"icon": "CrewAI",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -1742,6 +1747,7 @@
],
"frozen": false,
"icon": "CrewAI",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -2001,6 +2007,7 @@
],
"frozen": false,
"icon": "OpenAI",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -2295,6 +2302,7 @@
"is_composition": null,
"is_input": null,
"is_output": null,
"metadata": {},
"name": "",
"output_types": [],
"outputs": [
Expand Down Expand Up @@ -2409,6 +2417,7 @@
],
"frozen": false,
"icon": "ChatInput",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -2616,6 +2625,7 @@
"edited": false,
"field_order": [],
"frozen": false,
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -2733,6 +2743,7 @@
],
"frozen": false,
"icon": "OpenAI",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -3147,6 +3158,7 @@
],
"frozen": false,
"icon": "OpenAI",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -3585,6 +3597,7 @@
],
"frozen": false,
"icon": "OpenAI",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -3881,6 +3894,7 @@
"is_composition": null,
"is_input": null,
"is_output": null,
"metadata": {},
"name": "",
"output_types": [],
"outputs": [
Expand Down Expand Up @@ -4047,6 +4061,7 @@
"search_params"
],
"frozen": false,
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
],
"frozen": false,
"icon": "prompts",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -305,6 +306,7 @@
],
"frozen": false,
"icon": "ChatInput",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -521,6 +523,7 @@
],
"frozen": false,
"icon": "ChatOutput",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -722,6 +725,7 @@
],
"frozen": false,
"icon": "OpenAI",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -1009,6 +1013,7 @@
],
"frozen": false,
"icon": "braces",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down Expand Up @@ -1141,6 +1146,7 @@
],
"frozen": false,
"icon": "file-text",
"metadata": {},
"output_types": [],
"outputs": [
{
Expand Down
Loading