From 16018c1d6f6df04f17dd18dc17a101b26796a516 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 22 Feb 2024 11:57:15 -0300 Subject: [PATCH] Add pinned state to CustomComponent and FrontendNode --- .../custom/custom_component/custom_component.py | 3 +++ .../langflow/template/frontend_node/base.py | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/backend/langflow/interface/custom/custom_component/custom_component.py b/src/backend/langflow/interface/custom/custom_component/custom_component.py index 8a5d72073..687c25439 100644 --- a/src/backend/langflow/interface/custom/custom_component/custom_component.py +++ b/src/backend/langflow/interface/custom/custom_component/custom_component.py @@ -6,6 +6,7 @@ from uuid import UUID import yaml from cachetools import TTLCache, cachedmethod from fastapi import HTTPException + from langflow.interface.custom.code_parser.utils import ( extract_inner_type_from_generic_alias, extract_union_types_from_generic_alias, @@ -35,6 +36,8 @@ class CustomComponent(Component): """The field configuration of the component. Defaults to an empty dictionary.""" field_order: Optional[List[str]] = None """The field order of the component. Defaults to an empty list.""" + pinned: Optional[bool] = False + """The default pinned state of the component. Defaults to False.""" code_class_base_inheritance: ClassVar[str] = "CustomComponent" function_entrypoint_name: ClassVar[str] = "build" function: Optional[Callable] = None diff --git a/src/backend/langflow/template/frontend_node/base.py b/src/backend/langflow/template/frontend_node/base.py index d9f594d34..aadb6c6ea 100644 --- a/src/backend/langflow/template/frontend_node/base.py +++ b/src/backend/langflow/template/frontend_node/base.py @@ -2,6 +2,8 @@ import re from collections import defaultdict from typing import ClassVar, Dict, List, Optional, Union +from pydantic import BaseModel, Field, field_serializer, model_serializer + from langflow.template.field.base import TemplateField from langflow.template.frontend_node.constants import ( CLASSES_TO_REMOVE, @@ -10,7 +12,6 @@ from langflow.template.frontend_node.constants import ( from langflow.template.frontend_node.formatter import field_formatters from langflow.template.template.base import Template from langflow.utils import constants -from pydantic import BaseModel, Field, field_serializer, model_serializer class FieldFormatters(BaseModel): @@ -44,17 +45,31 @@ class FieldFormatters(BaseModel): class FrontendNode(BaseModel): _format_template: bool = True template: Template + """Template for the frontend node.""" description: Optional[str] = None + """Description of the frontend node.""" icon: Optional[str] = None + """Icon of the frontend node.""" is_composition: Optional[bool] = None + """Whether the frontend node is used for composition.""" base_classes: List[str] + """List of base classes for the frontend node.""" name: str = "" + """Name of the frontend node.""" display_name: Optional[str] = "" + """Display name of the frontend node.""" documentation: str = "" + """Documentation of the frontend node.""" custom_fields: Optional[Dict] = defaultdict(list) + """Custom fields of the frontend node.""" output_types: List[str] = [] + """List of output types for the frontend node.""" full_path: Optional[str] = None + """Full path of the frontend node.""" field_formatters: FieldFormatters = Field(default_factory=FieldFormatters) + """Field formatters for the frontend node.""" + pinned: bool = False + """Whether the frontend node is pinned.""" beta: bool = False error: Optional[str] = None