diff --git a/src/backend/base/langflow/api/v1/store.py b/src/backend/base/langflow/api/v1/store.py index 41842466737..23023da788a 100644 --- a/src/backend/base/langflow/api/v1/store.py +++ b/src/backend/base/langflow/api/v1/store.py @@ -61,7 +61,7 @@ async def check_if_store_has_api_key( return {"has_api_key": api_key is not None, "is_valid": is_valid} -@router.post("/components/", response_model=CreateComponentResponse, status_code=201) +@router.post("/components/", status_code=201) async def share_component( component: StoreComponentCreate, store_api_key: Annotated[str, Depends(get_user_store_api_key)], @@ -123,7 +123,7 @@ async def get_components( raise HTTPException(status_code=500, detail=str(exc)) from exc -@router.get("/components/{component_id}", response_model=DownloadComponentResponse) +@router.get("/components/{component_id}") async def download_component( component_id: UUID, store_api_key: Annotated[str, Depends(get_user_store_api_key)], diff --git a/src/backend/base/langflow/components/Notion/__init__.py b/src/backend/base/langflow/components/Notion/__init__.py index bcbab1feb15..9e50918fa43 100644 --- a/src/backend/base/langflow/components/Notion/__init__.py +++ b/src/backend/base/langflow/components/Notion/__init__.py @@ -9,11 +9,11 @@ __all__ = [ "AddContentToPage", - "NotionPageCreator", "NotionDatabaseProperties", "NotionListPages", - "NotionUserList", "NotionPageContent", - "NotionSearch", + "NotionPageCreator", "NotionPageUpdate", + "NotionSearch", + "NotionUserList", ] diff --git a/src/backend/base/langflow/components/assemblyai/__init__.py b/src/backend/base/langflow/components/assemblyai/__init__.py index f192f02dcad..8272a8c922d 100644 --- a/src/backend/base/langflow/components/assemblyai/__init__.py +++ b/src/backend/base/langflow/components/assemblyai/__init__.py @@ -8,6 +8,6 @@ "AssemblyAIGetSubtitles", "AssemblyAILeMUR", "AssemblyAIListTranscripts", - "AssemblyAITranscriptionJobPoller", "AssemblyAITranscriptionJobCreator", + "AssemblyAITranscriptionJobPoller", ] diff --git a/src/backend/base/langflow/components/crewai/__init__.py b/src/backend/base/langflow/components/crewai/__init__.py index d601c7b1cce..df927444908 100644 --- a/src/backend/base/langflow/components/crewai/__init__.py +++ b/src/backend/base/langflow/components/crewai/__init__.py @@ -10,6 +10,6 @@ "HierarchicalCrewComponent", "HierarchicalTaskComponent", "SequentialCrewComponent", - "SequentialTaskComponent", "SequentialTaskAgentComponent", + "SequentialTaskComponent", ] diff --git a/src/backend/base/langflow/components/data/__init__.py b/src/backend/base/langflow/components/data/__init__.py index 820f683b810..770713cca63 100644 --- a/src/backend/base/langflow/components/data/__init__.py +++ b/src/backend/base/langflow/components/data/__init__.py @@ -12,8 +12,8 @@ "CSVToDataComponent", "DirectoryComponent", "FileComponent", + "JSONToDataComponent", "SQLExecutorComponent", "URLComponent", "WebhookComponent", - "JSONToDataComponent", ] diff --git a/src/backend/base/langflow/components/embeddings/__init__.py b/src/backend/base/langflow/components/embeddings/__init__.py index 100ff9ade10..0d17fe35704 100644 --- a/src/backend/base/langflow/components/embeddings/__init__.py +++ b/src/backend/base/langflow/components/embeddings/__init__.py @@ -20,6 +20,7 @@ "AstraVectorizeComponent", "AzureOpenAIEmbeddingsComponent", "CohereEmbeddingsComponent", + "EmbeddingSimilarityComponent", "GoogleGenerativeAIEmbeddingsComponent", "HuggingFaceInferenceAPIEmbeddingsComponent", "LMStudioEmbeddingsComponent", @@ -27,7 +28,6 @@ "NVIDIAEmbeddingsComponent", "OllamaEmbeddingsComponent", "OpenAIEmbeddingsComponent", - "EmbeddingSimilarityComponent", "TextEmbedderComponent", "VertexAIEmbeddingsComponent", ] diff --git a/src/backend/base/langflow/components/helpers/__init__.py b/src/backend/base/langflow/components/helpers/__init__.py index f545a46cc57..7300242624c 100644 --- a/src/backend/base/langflow/components/helpers/__init__.py +++ b/src/backend/base/langflow/components/helpers/__init__.py @@ -10,8 +10,8 @@ "CreateListComponent", "CurrentDateComponent", "IDGeneratorComponent", + "MemoryComponent", "OutputParserComponent", - "StructuredOutputComponent", "StoreMessageComponent", - "MemoryComponent", + "StructuredOutputComponent", ] diff --git a/src/backend/base/langflow/components/langchain_utilities/__init__.py b/src/backend/base/langflow/components/langchain_utilities/__init__.py index 42f1939f909..819cc4af5a9 100644 --- a/src/backend/base/langflow/components/langchain_utilities/__init__.py +++ b/src/backend/base/langflow/components/langchain_utilities/__init__.py @@ -28,32 +28,32 @@ from .xml import XMLAgentComponent __all__ = [ + "CSVAgentComponent", "CharacterTextSplitterComponent", "ConversationChainComponent", - "CSVAgentComponent", "FakeEmbeddingsComponent", "HtmlLinkExtractorComponent", "JSONDocumentBuilder", "JsonAgentComponent", - "LangChainHubPromptComponent", - "LanguageRecursiveTextSplitterComponent", "LLMCheckerChainComponent", "LLMMathChainComponent", + "LangChainHubPromptComponent", + "LanguageRecursiveTextSplitterComponent", "NaturalLanguageTextSplitterComponent", "OpenAIToolsAgentComponent", "OpenAPIAgentComponent", "RecursiveCharacterTextSplitterComponent", "RetrievalQAComponent", "RunnableExecComponent", - "SelfQueryRetrieverComponent", - "SpiderTool", "SQLAgentComponent", "SQLDatabaseComponent", "SQLGeneratorComponent", + "SelfQueryRetrieverComponent", + "SemanticTextSplitterComponent", + "SpiderTool", "ToolCallingAgentComponent", "VectoStoreRetrieverComponent", "VectorStoreInfoComponent", "VectorStoreRouterAgentComponent", "XMLAgentComponent", - "SemanticTextSplitterComponent", ] diff --git a/src/backend/base/langflow/components/langchain_utilities/json.py b/src/backend/base/langflow/components/langchain_utilities/json.py index 05732c83044..e241ac5fce2 100644 --- a/src/backend/base/langflow/components/langchain_utilities/json.py +++ b/src/backend/base/langflow/components/langchain_utilities/json.py @@ -34,7 +34,7 @@ class JsonAgentComponent(LCAgentComponent): def build_agent(self) -> AgentExecutor: path = Path(self.path) - if path.suffix in ("yaml", "yml"): + if path.suffix in {"yaml", "yml"}: with path.open(encoding="utf-8") as file: yaml_dict = yaml.safe_load(file) spec = JsonSpec(dict_=yaml_dict) diff --git a/src/backend/base/langflow/components/langchain_utilities/openapi.py b/src/backend/base/langflow/components/langchain_utilities/openapi.py index 2b58295f383..3e662e7d524 100644 --- a/src/backend/base/langflow/components/langchain_utilities/openapi.py +++ b/src/backend/base/langflow/components/langchain_utilities/openapi.py @@ -25,7 +25,7 @@ class OpenAPIAgentComponent(LCAgentComponent): def build_agent(self) -> AgentExecutor: path = Path(self.path) - if path.suffix in ("yaml", "yml"): + if path.suffix in {"yaml", "yml"}: with path.open(encoding="utf-8") as file: yaml_dict = yaml.safe_load(file) spec = JsonSpec(dict_=yaml_dict) diff --git a/src/backend/base/langflow/components/logic/__init__.py b/src/backend/base/langflow/components/logic/__init__.py index 039d6c52d7e..7833224edf4 100644 --- a/src/backend/base/langflow/components/logic/__init__.py +++ b/src/backend/base/langflow/components/logic/__init__.py @@ -8,12 +8,12 @@ from .sub_flow import SubFlowComponent __all__ = [ + "ConditionalRouterComponent", "DataConditionalRouterComponent", "FlowToolComponent", "ListenComponent", "NotifyComponent", + "PassMessageComponent", "RunFlowComponent", "SubFlowComponent", - "ConditionalRouterComponent", - "PassMessageComponent", ] diff --git a/src/backend/base/langflow/components/memories/__init__.py b/src/backend/base/langflow/components/memories/__init__.py index 292950c4281..f53bf0a735c 100644 --- a/src/backend/base/langflow/components/memories/__init__.py +++ b/src/backend/base/langflow/components/memories/__init__.py @@ -7,7 +7,7 @@ __all__ = [ "AstraDBChatMemory", "CassandraChatMemory", + "Mem0MemoryComponent", "RedisIndexChatMemory", "ZepChatMemory", - "Mem0MemoryComponent", ] diff --git a/src/backend/base/langflow/components/memories/mem0_chat_memory.py b/src/backend/base/langflow/components/memories/mem0_chat_memory.py index 251a1c79817..6f5310c74ab 100644 --- a/src/backend/base/langflow/components/memories/mem0_chat_memory.py +++ b/src/backend/base/langflow/components/memories/mem0_chat_memory.py @@ -103,13 +103,13 @@ def build_mem0(self) -> Memory: def ingest_data(self) -> Memory: """Ingests a new message into Mem0 memory and returns the updated memory instance.""" - mem0_memory = self.existing_memory if self.existing_memory else self.build_mem0() + mem0_memory = self.existing_memory or self.build_mem0() if not self.ingest_message or not self.user_id: logger.warning("Missing 'ingest_message' or 'user_id'; cannot ingest data.") return mem0_memory - metadata = self.metadata if self.metadata else {} + metadata = self.metadata or {} logger.info("Ingesting message for user_id: %s", self.user_id) diff --git a/src/backend/base/langflow/components/models/aiml.py b/src/backend/base/langflow/components/models/aiml.py index c974f54011d..b91291f91f9 100644 --- a/src/backend/base/langflow/components/models/aiml.py +++ b/src/backend/base/langflow/components/models/aiml.py @@ -60,7 +60,7 @@ class AIMLModelComponent(LCModelComponent): @override def update_build_config(self, build_config: dict, field_value: str, field_name: str | None = None): - if field_name in ("api_key", "aiml_api_base", "model_name"): + if field_name in {"api_key", "aiml_api_base", "model_name"}: aiml = AimlModels() aiml.get_aiml_models() build_config["model_name"]["options"] = aiml.chat_models diff --git a/src/backend/base/langflow/components/processing/__init__.py b/src/backend/base/langflow/components/processing/__init__.py index 727dac795a6..6ce274f756f 100644 --- a/src/backend/base/langflow/components/processing/__init__.py +++ b/src/backend/base/langflow/components/processing/__init__.py @@ -12,16 +12,16 @@ from .update_data import UpdateDataComponent __all__ = [ + "CombineTextComponent", "CreateDataComponent", - "ExtractDataKeyComponent", "DataFilterComponent", + "ExtractDataKeyComponent", + "JSONCleaner", "MergeDataComponent", "MessageToDataComponent", "ParseDataComponent", - "SelectDataComponent", - "UpdateDataComponent", "ParseJSONDataComponent", - "JSONCleaner", - "CombineTextComponent", + "SelectDataComponent", "SplitTextComponent", + "UpdateDataComponent", ] diff --git a/src/backend/base/langflow/components/tools/__init__.py b/src/backend/base/langflow/components/tools/__init__.py index c8265e929b4..3039c846f65 100644 --- a/src/backend/base/langflow/components/tools/__init__.py +++ b/src/backend/base/langflow/components/tools/__init__.py @@ -33,15 +33,15 @@ "BingSearchAPIComponent", "CalculatorToolComponent", "DuckDuckGoSearchComponent", + "ExaSearchToolkit", "GleanSearchAPIComponent", "GoogleSearchAPIComponent", "GoogleSerperAPIComponent", - "ExaSearchToolkit", "PythonCodeStructuredTool", "PythonREPLToolComponent", "RetrieverToolComponent", - "SearchAPIComponent", "SearXNGToolComponent", + "SearchAPIComponent", "SerpAPIComponent", "TavilySearchToolComponent", "WikidataAPIComponent", diff --git a/src/backend/base/langflow/components/tools/youtube_transcripts.py b/src/backend/base/langflow/components/tools/youtube_transcripts.py index ee7c1b15514..0dc9247cd85 100644 --- a/src/backend/base/langflow/components/tools/youtube_transcripts.py +++ b/src/backend/base/langflow/components/tools/youtube_transcripts.py @@ -95,7 +95,7 @@ def build_youtube_transcripts(self) -> Data | list[Data]: else TranscriptFormat.CHUNKS, chunk_size_seconds=self.chunk_size_seconds, language=self.language.split(",") if self.language else ["en"], - translation=self.translation if self.translation else None, + translation=self.translation or None, ) transcripts = loader.load() @@ -140,7 +140,7 @@ def youtube_transcripts( else TranscriptFormat.CHUNKS, chunk_size_seconds=chunk_size_seconds, language=language.split(",") if language else ["en"], - translation=translation if translation else None, + translation=translation or None, ) transcripts = loader.load() diff --git a/src/backend/base/langflow/components/vectorstores/__init__.py b/src/backend/base/langflow/components/vectorstores/__init__.py index 7ac64d89063..e097665814f 100644 --- a/src/backend/base/langflow/components/vectorstores/__init__.py +++ b/src/backend/base/langflow/components/vectorstores/__init__.py @@ -42,8 +42,8 @@ "RedisVectorStoreComponent", "SupabaseVectorStoreComponent", "UpstashVectorStoreComponent", - "VectaraVectorStoreComponent", "VectaraRagComponent", "VectaraSelfQueryRetriverComponent", + "VectaraVectorStoreComponent", "WeaviateVectorStoreComponent", ] diff --git a/src/backend/base/langflow/events/event_manager.py b/src/backend/base/langflow/events/event_manager.py index 2400a36c309..152b6152498 100644 --- a/src/backend/base/langflow/events/event_manager.py +++ b/src/backend/base/langflow/events/event_manager.py @@ -62,7 +62,7 @@ def register_event( def send_event(self, *, event_type: Literal["message", "error", "warning", "info", "token"], data: LoggableType): try: - if isinstance(data, dict) and event_type in ["message", "error", "warning", "info", "token"]: + if isinstance(data, dict) and event_type in {"message", "error", "warning", "info", "token"}: data = create_event_by_type(event_type, **data) except TypeError as e: logger.debug(f"Error creating playground event: {e}") diff --git a/src/backend/base/langflow/graph/edge/base.py b/src/backend/base/langflow/graph/edge/base.py index 13f257cba58..34decce8c0c 100644 --- a/src/backend/base/langflow/graph/edge/base.py +++ b/src/backend/base/langflow/graph/edge/base.py @@ -195,13 +195,13 @@ def __repr__(self) -> str: def __hash__(self) -> int: return hash(self.__repr__()) - def __eq__(self, __o: object) -> bool: - if not isinstance(__o, Edge): + def __eq__(self, /, other: object) -> bool: + if not isinstance(other, Edge): return False return ( - self._source_handle == __o._source_handle - and self._target_handle == __o._target_handle - and self.target_param == __o.target_param + self._source_handle == other._source_handle + and self._target_handle == other._target_handle + and self.target_param == other.target_param ) def __str__(self) -> str: diff --git a/src/backend/base/langflow/graph/graph/base.py b/src/backend/base/langflow/graph/graph/base.py index c1e79d9ac1f..b1a80036032 100644 --- a/src/backend/base/langflow/graph/graph/base.py +++ b/src/backend/base/langflow/graph/graph/base.py @@ -1072,7 +1072,7 @@ def from_payload( else: return graph - def __eq__(self, other: object) -> bool: + def __eq__(self, /, other: object) -> bool: if not isinstance(other, Graph): return False return self.__repr__() == other.__repr__() diff --git a/src/backend/base/langflow/graph/graph/constants.py b/src/backend/base/langflow/graph/graph/constants.py index b5a1e411d58..a3c0bf85cb8 100644 --- a/src/backend/base/langflow/graph/graph/constants.py +++ b/src/backend/base/langflow/graph/graph/constants.py @@ -6,7 +6,7 @@ class Finish: def __bool__(self) -> bool: return True - def __eq__(self, other): + def __eq__(self, /, other): return isinstance(other, Finish) diff --git a/src/backend/base/langflow/graph/vertex/base.py b/src/backend/base/langflow/graph/vertex/base.py index fb4110918cb..56f5de2a051 100644 --- a/src/backend/base/langflow/graph/vertex/base.py +++ b/src/backend/base/langflow/graph/vertex/base.py @@ -845,16 +845,16 @@ def add_edge(self, edge: CycleEdge) -> None: def __repr__(self) -> str: return f"Vertex(display_name={self.display_name}, id={self.id}, data={self.data})" - def __eq__(self, __o: object) -> bool: + def __eq__(self, /, other: object) -> bool: try: - if not isinstance(__o, Vertex): + if not isinstance(other, Vertex): return False # We should create a more robust comparison # for the Vertex class - ids_are_equal = self.id == __o.id + ids_are_equal = self.id == other.id # self.data is a dict and we need to compare them # to check if they are equal - data_are_equal = self.data == __o.data + data_are_equal = self.data == other.data except AttributeError: return False else: diff --git a/src/backend/base/langflow/schema/data.py b/src/backend/base/langflow/schema/data.py index 65b120a03f4..05367b2e5a4 100644 --- a/src/backend/base/langflow/schema/data.py +++ b/src/backend/base/langflow/schema/data.py @@ -204,7 +204,7 @@ def __str__(self) -> str: def __contains__(self, key) -> bool: return key in self.data - def __eq__(self, other): + def __eq__(self, /, other): return isinstance(other, Data) and self.data == other.data diff --git a/src/backend/base/langflow/schema/message.py b/src/backend/base/langflow/schema/message.py index 5b4ddb2f568..e3ef7e1e7d2 100644 --- a/src/backend/base/langflow/schema/message.py +++ b/src/backend/base/langflow/schema/message.py @@ -104,7 +104,7 @@ def validate_files(cls, value): value = [value] return value - def model_post_init(self, __context: Any) -> None: + def model_post_init(self, /, _context: Any) -> None: new_files: list[Any] = [] for file in self.files or []: if is_image_file(file):