From 7fd28733f9e34f2e2516ec328473706560ef0920 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 11:05:25 +0000 Subject: [PATCH 001/171] Bump braces from 3.0.2 to 3.0.3 in /scripts/aws Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3. - [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md) - [Commits](https://github.com/micromatch/braces/compare/3.0.2...3.0.3) --- updated-dependencies: - dependency-name: braces dependency-type: indirect ... Signed-off-by: dependabot[bot] --- scripts/aws/package-lock.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/aws/package-lock.json b/scripts/aws/package-lock.json index c1be6a071..1f99ebc3f 100644 --- a/scripts/aws/package-lock.json +++ b/scripts/aws/package-lock.json @@ -1950,12 +1950,12 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -2763,9 +2763,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "dependencies": { "to-regex-range": "^5.0.1" From 0f8cd9e5720a3568f998656f999239e9f15c54af Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 25 Jun 2024 14:42:19 -0300 Subject: [PATCH 002/171] chore: Update authContext imports and remove duplicate imports --- src/frontend/src/contexts/authContext.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/frontend/src/contexts/authContext.tsx b/src/frontend/src/contexts/authContext.tsx index 50a0cf4e7..cfdbdfb4f 100644 --- a/src/frontend/src/contexts/authContext.tsx +++ b/src/frontend/src/contexts/authContext.tsx @@ -12,10 +12,6 @@ import { useGlobalVariablesStore } from "../stores/globalVariablesStore/globalVa import { useStoreStore } from "../stores/storeStore"; import { Users } from "../types/api"; import { AuthContextType } from "../types/contexts/auth"; -import { useGlobalVariablesStore } from "../stores/globalVariablesStore/globalVariables"; -import { useStoreStore } from "../stores/storeStore"; -import { Users } from "../types/api"; -import { AuthContextType } from "../types/contexts/auth"; const initialValue: AuthContextType = { isAdmin: false, From 4ed879ff56e859cdaa2c9657a917feeeca380a2b Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 25 Jun 2024 14:56:29 -0300 Subject: [PATCH 003/171] Refactor telemetry service payload field names for consistency --- src/backend/base/langflow/api/v1/chat.py | 30 +++++++++---------- src/backend/base/langflow/api/v1/endpoints.py | 19 ++++++++---- .../langflow/services/telemetry/schema.py | 24 +++++++-------- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/src/backend/base/langflow/api/v1/chat.py b/src/backend/base/langflow/api/v1/chat.py index dc44d498b..e19342568 100644 --- a/src/backend/base/langflow/api/v1/chat.py +++ b/src/backend/base/langflow/api/v1/chat.py @@ -121,9 +121,9 @@ async def retrieve_vertices_order( background_tasks.add_task( telemetry_service.log_package_playground, PlaygroundPayload( - seconds=int(time.perf_counter() - start_time), - componentCount=components_count, - success=True, + playgroundSeconds=int(time.perf_counter() - start_time), + playgroundComponentCount=components_count, + playgroundSuccess=True, ), ) return VerticesOrderResponse(ids=first_layer, run_id=graph._run_id, vertices_to_run=vertices_to_run) @@ -131,10 +131,10 @@ async def retrieve_vertices_order( background_tasks.add_task( telemetry_service.log_package_playground, PlaygroundPayload( - seconds=int(time.perf_counter() - start_time), - componentCount=components_count, - success=False, - errorMessage=str(exc), + playgroundSeconds=int(time.perf_counter() - start_time), + playgroundComponentCount=components_count, + playgroundSuccess=False, + playgroundErrorMessage=str(exc), ), ) if "stream or streaming set to True" in str(exc): @@ -280,10 +280,10 @@ async def build_vertex( background_tasks.add_task( telemetry_service.log_package_component, ComponentPayload( - name=vertex_id, - seconds=int(time.perf_counter() - start_time), - success=valid, - errorMessage=params, + componentName=vertex_id, + componentSeconds=int(time.perf_counter() - start_time), + componentSuccess=valid, + componentErrorMessage=params, ), ) return build_response @@ -291,10 +291,10 @@ async def build_vertex( background_tasks.add_task( telemetry_service.log_package_component, ComponentPayload( - name=vertex_id, - seconds=int(time.perf_counter() - start_time), - success=False, - errorMessage=str(exc), + componentName=vertex_id, + componentSeconds=int(time.perf_counter() - start_time), + componentSuccess=False, + componentErrorMessage=str(exc), ), ) logger.error(f"Error building Component:\n\n{exc}") diff --git a/src/backend/base/langflow/api/v1/endpoints.py b/src/backend/base/langflow/api/v1/endpoints.py index d8b5e9da8..92358111a 100644 --- a/src/backend/base/langflow/api/v1/endpoints.py +++ b/src/backend/base/langflow/api/v1/endpoints.py @@ -209,7 +209,7 @@ async def simplified_run_flow( end_time = time.perf_counter() background_tasks.add_task( telemetry_service.log_package_run, - RunPayload(IsWebhook=False, seconds=int(end_time - start_time), success=True, errorMessage=""), + RunPayload(runIsWebhook=False, runSeconds=int(end_time - start_time), runSuccess=True, runErrorMessage=""), ) return result @@ -217,7 +217,9 @@ async def simplified_run_flow( end_time = time.perf_counter() background_tasks.add_task( telemetry_service.log_package_run, - RunPayload(IsWebhook=False, seconds=int(end_time - start_time), success=False, errorMessage=str(exc)), + RunPayload( + runIsWebhook=False, runSeconds=int(end_time - start_time), runSuccess=False, runErrorMessage=str(exc) + ), ) if "badly formed hexadecimal UUID string" in str(exc): # This means the Flow ID is not a valid UUID which means it can't find the flow @@ -231,7 +233,9 @@ async def simplified_run_flow( logger.exception(exc) background_tasks.add_task( telemetry_service.log_package_run, - RunPayload(IsWebhook=False, seconds=int(end_time - start_time), success=False, errorMessage=str(exc)), + RunPayload( + runIsWebhook=False, runSeconds=int(end_time - start_time), runSuccess=False, runErrorMessage=str(exc) + ), ) raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(exc)) from exc @@ -290,14 +294,19 @@ async def webhook_run_flow( ) background_tasks.add_task( telemetry_service.log_package_run, - RunPayload(IsWebhook=True, seconds=int(time.perf_counter() - start_time), success=True, errorMessage=""), + RunPayload( + runIsWebhook=True, runSeconds=int(time.perf_counter() - start_time), runSuccess=True, runErrorMessage="" + ), ) return {"message": "Task started in the background", "status": "in progress"} except Exception as exc: background_tasks.add_task( telemetry_service.log_package_run, RunPayload( - IsWebhook=True, seconds=int(time.perf_counter() - start_time), success=False, errorMessage=str(exc) + runIsWebhook=True, + runSeconds=int(time.perf_counter() - start_time), + runSuccess=False, + runErrorMessage=str(exc), ), ) if "Flow ID is required" in str(exc) or "Request body is empty" in str(exc): diff --git a/src/backend/base/langflow/services/telemetry/schema.py b/src/backend/base/langflow/services/telemetry/schema.py index bba7a23e4..9d62e128a 100644 --- a/src/backend/base/langflow/services/telemetry/schema.py +++ b/src/backend/base/langflow/services/telemetry/schema.py @@ -2,10 +2,10 @@ from pydantic import BaseModel class RunPayload(BaseModel): - IsWebhook: bool = False - seconds: int - success: bool - errorMessage: str = "" + runIsWebhook: bool = False + runSeconds: int + runSuccess: bool + runErrorMessage: str = "" class ShutdownPayload(BaseModel): @@ -23,14 +23,14 @@ class VersionPayload(BaseModel): class PlaygroundPayload(BaseModel): - seconds: int - componentCount: int | None = None - success: bool - errorMessage: str = "" + playgroundSeconds: int + playgroundComponentCount: int | None = None + playgroundSuccess: bool + playgroundErrorMessage: str = "" class ComponentPayload(BaseModel): - name: str - seconds: int - success: bool - errorMessage: str + componentName: str + componentSeconds: int + componentSuccess: bool + componentErrorMessage: str From 4365e3d2d8e6a27e238e13686a10acf7a2681718 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 25 Jun 2024 14:59:33 -0300 Subject: [PATCH 004/171] chore: Update package versions in pyproject.toml files --- pyproject.toml | 2 +- src/backend/base/pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8ffb4ccf5..1bd744a36 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langflow" -version = "1.0.4" +version = "1.0.5" description = "A Python package with a built-in web application" authors = ["Langflow "] maintainers = [ diff --git a/src/backend/base/pyproject.toml b/src/backend/base/pyproject.toml index 100bcbd2b..6f305ea85 100644 --- a/src/backend/base/pyproject.toml +++ b/src/backend/base/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langflow-base" -version = "0.0.80" +version = "0.0.81" description = "A Python package with a built-in web application" authors = ["Langflow "] maintainers = [ From b05455a9b865b7da4395387646fcaa3b4b7d09c0 Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Tue, 25 Jun 2024 16:17:47 -0300 Subject: [PATCH 005/171] refactor: Ensure flow names are unique by appending a number if necessary --- src/backend/base/langflow/api/v1/flows.py | 27 ++++++++--------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/backend/base/langflow/api/v1/flows.py b/src/backend/base/langflow/api/v1/flows.py index d735a314b..99c678151 100644 --- a/src/backend/base/langflow/api/v1/flows.py +++ b/src/backend/base/langflow/api/v1/flows.py @@ -1,4 +1,5 @@ from datetime import datetime, timezone +import re from typing import List from uuid import UUID @@ -46,8 +47,14 @@ def create_flow( select(Flow).where(Flow.name.like(f"{flow.name} (%")).where(Flow.user_id == current_user.id) # type: ignore ).all() if flows: - numbers = [int(flow.name.split("(")[1].split(")")[0]) for flow in flows] - flow.name = f"{flow.name} ({max(numbers) + 1})" + extract_number = re.compile(r"\((\d+)\)$") + numbers = [] + for flow in flows: + result = extract_number.search(flow.name) + if result: + numbers.append(int(result.groups(1)[0])) + if numbers: + flow.name = f"{flow.name} ({max(numbers) + 1})" else: flow.name = f"{flow.name} (1)" # Now check if the endpoint is unique @@ -210,22 +217,6 @@ def update_flow( db_flow.webhook = webhook_component is not None db_flow.updated_at = datetime.now(timezone.utc) - # First check if the flow.name is unique - # there might be flows with name like: "MyFlow", "MyFlow (1)", "MyFlow (2)" - # so we need to check if the name is unique with `like` operator - # if we find a flow with the same name, we add a number to the end of the name - # based on the highest number found - flow_from_db = session.exec(select(Flow).where(Flow.id == flow_id, Flow.user_id == current_user.id)).first() - if flow_from_db: - flows = session.exec( - select(Flow).where(Flow.name.like(f"{flow.name} (%")).where(Flow.user_id == current_user.id) # type: ignore - ).all() - if flows: - numbers = [int(flow.name.split("(")[1].split(")")[0]) for flow in flows] - flow.name = f"{flow.name} ({max(numbers) + 1})" - else: - flow.name = f"{flow.name} (1)" - if db_flow.folder_id is None: default_folder = session.exec(select(Folder).where(Folder.name == DEFAULT_FOLDER_NAME)).first() if default_folder: From 946638c2688f4f047ee6141e22b16ae941b781ec Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Tue, 25 Jun 2024 16:32:17 -0300 Subject: [PATCH 006/171] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20(flows.py):=20rena?= =?UTF-8?q?me=20loop=20variable=20flow=20to=20=5Fflow=20to=20avoid=20shado?= =?UTF-8?q?wing=20and=20improve=20readability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/base/langflow/api/v1/flows.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/base/langflow/api/v1/flows.py b/src/backend/base/langflow/api/v1/flows.py index 99c678151..54e4fc5e5 100644 --- a/src/backend/base/langflow/api/v1/flows.py +++ b/src/backend/base/langflow/api/v1/flows.py @@ -49,8 +49,8 @@ def create_flow( if flows: extract_number = re.compile(r"\((\d+)\)$") numbers = [] - for flow in flows: - result = extract_number.search(flow.name) + for _flow in flows: + result = extract_number.search(_flow.name) if result: numbers.append(int(result.groups(1)[0])) if numbers: From 4faf84ebeef21fdbbc89579d227e28127a882ad2 Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Tue, 25 Jun 2024 16:32:17 -0300 Subject: [PATCH 007/171] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20(flows.py):=20rena?= =?UTF-8?q?me=20loop=20variable=20flow=20to=20=5Fflow=20to=20avoid=20shado?= =?UTF-8?q?wing=20and=20improve=20readability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/base/langflow/api/v1/flows.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/base/langflow/api/v1/flows.py b/src/backend/base/langflow/api/v1/flows.py index 99c678151..54e4fc5e5 100644 --- a/src/backend/base/langflow/api/v1/flows.py +++ b/src/backend/base/langflow/api/v1/flows.py @@ -49,8 +49,8 @@ def create_flow( if flows: extract_number = re.compile(r"\((\d+)\)$") numbers = [] - for flow in flows: - result = extract_number.search(flow.name) + for _flow in flows: + result = extract_number.search(_flow.name) if result: numbers.append(int(result.groups(1)[0])) if numbers: From edd15fc0a23d3ec2fa47889b6bb2edabe6228bbb Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Tue, 25 Jun 2024 17:57:49 -0300 Subject: [PATCH 008/171] fix settings flow save button --- .../editFlowSettingsComponent/index.tsx | 18 +++++----------- .../src/modals/flowSettingsModal/index.tsx | 21 +++++++++++++++++-- src/frontend/src/utils/utils.ts | 8 +++++++ 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/frontend/src/components/editFlowSettingsComponent/index.tsx b/src/frontend/src/components/editFlowSettingsComponent/index.tsx index b15e0c369..34cd39180 100644 --- a/src/frontend/src/components/editFlowSettingsComponent/index.tsx +++ b/src/frontend/src/components/editFlowSettingsComponent/index.tsx @@ -4,7 +4,7 @@ import { Label } from "../../components/ui/label"; import { Textarea } from "../../components/ui/textarea"; import useFlowsManagerStore from "../../stores/flowsManagerStore"; import { InputProps } from "../../types/components"; -import { cn } from "../../utils/utils"; +import { cn, isEndpointNameValid } from "../../utils/utils"; export const EditFlowSettings: React.FC = ({ name, @@ -17,7 +17,7 @@ export const EditFlowSettings: React.FC = ({ setEndpointName, }: InputProps): JSX.Element => { const [isMaxLength, setIsMaxLength] = useState(false); - const [isEndpointNameValid, setIsEndpointNameValid] = useState(true); + const [validEndpointName, setValidEndpointName] = useState(true); const [isInvalidName, setIsInvalidName] = useState(false); const currentFlow = useFlowsManagerStore((state) => state.currentFlow); @@ -34,10 +34,6 @@ export const EditFlowSettings: React.FC = ({ invalid = true; break; } - if (value === currentFlow?.name) { - invalid = true; - break; - } invalid = false; } setIsInvalidName(invalid); @@ -51,12 +47,8 @@ export const EditFlowSettings: React.FC = ({ const handleEndpointNameChange = (event: ChangeEvent) => { // Validate the endpoint name // use this regex r'^[a-zA-Z0-9_-]+$' - const isValid = - (/^[a-zA-Z0-9_-]+$/.test(event.target.value) && - event.target.value.length <= maxLength) || - // empty is also valid - event.target.value.length === 0; - setIsEndpointNameValid(isValid); + const isValid = isEndpointNameValid(event.target.value, maxLength); + setValidEndpointName(isValid); setEndpointName!(event.target.value); }; @@ -129,7 +121,7 @@ export const EditFlowSettings: React.FC = ({