From 01fef3733b5a2a098e82956151c3bde433c08e87 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 26 Jan 2024 13:37:00 -0300 Subject: [PATCH 1/7] Add unique constraints and new fixes --- .../b2fa308044b5_add_unique_constraints.py | 59 +++++++++++++++++++ .../versions/bc2f01c40e4a_new_fixes.py | 50 ++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 src/backend/langflow/alembic/versions/b2fa308044b5_add_unique_constraints.py create mode 100644 src/backend/langflow/alembic/versions/bc2f01c40e4a_new_fixes.py diff --git a/src/backend/langflow/alembic/versions/b2fa308044b5_add_unique_constraints.py b/src/backend/langflow/alembic/versions/b2fa308044b5_add_unique_constraints.py new file mode 100644 index 000000000..e24d5a72f --- /dev/null +++ b/src/backend/langflow/alembic/versions/b2fa308044b5_add_unique_constraints.py @@ -0,0 +1,59 @@ +"""Add unique constraints + +Revision ID: b2fa308044b5 +Revises: 0b8757876a7c +Create Date: 2024-01-26 13:31:14.797548 + +""" +from typing import Sequence, Union + +import sqlalchemy as sa +import sqlmodel +from alembic import op + +# revision identifiers, used by Alembic. +revision: str = 'b2fa308044b5' +down_revision: Union[str, None] = '0b8757876a7c' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + try: + op.drop_table('flowstyle') + with op.batch_alter_table('flow', schema=None) as batch_op: + batch_op.add_column(sa.Column('is_component', sa.Boolean(), nullable=True)) + batch_op.add_column(sa.Column('updated_at', sa.DateTime(), nullable=True)) + batch_op.add_column(sa.Column('folder', sqlmodel.sql.sqltypes.AutoString(), nullable=True)) + batch_op.add_column(sa.Column('user_id', sqlmodel.sql.sqltypes.GUID(), nullable=True)) + batch_op.create_index(batch_op.f('ix_flow_user_id'), ['user_id'], unique=False) + batch_op.create_foreign_key(None, 'user', ['user_id'], ['id']) + except Exception: + pass + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + try: + with op.batch_alter_table('flow', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_index(batch_op.f('ix_flow_user_id')) + batch_op.drop_column('user_id') + batch_op.drop_column('folder') + batch_op.drop_column('updated_at') + batch_op.drop_column('is_component') + + op.create_table('flowstyle', + sa.Column('color', sa.VARCHAR(), nullable=False), + sa.Column('emoji', sa.VARCHAR(), nullable=False), + sa.Column('flow_id', sa.CHAR(length=32), nullable=True), + sa.Column('id', sa.CHAR(length=32), nullable=False), + sa.ForeignKeyConstraint(['flow_id'], ['flow.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('id') + ) + except Exception: + pass + # ### end Alembic commands ### diff --git a/src/backend/langflow/alembic/versions/bc2f01c40e4a_new_fixes.py b/src/backend/langflow/alembic/versions/bc2f01c40e4a_new_fixes.py new file mode 100644 index 000000000..3ad7ba5f3 --- /dev/null +++ b/src/backend/langflow/alembic/versions/bc2f01c40e4a_new_fixes.py @@ -0,0 +1,50 @@ +"""New fixes + +Revision ID: bc2f01c40e4a +Revises: b2fa308044b5 +Create Date: 2024-01-26 13:34:14.496769 + +""" +from typing import Sequence, Union + +import sqlalchemy as sa +import sqlmodel +from alembic import op + +# revision identifiers, used by Alembic. +revision: str = 'bc2f01c40e4a' +down_revision: Union[str, None] = 'b2fa308044b5' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + try: + with op.batch_alter_table('flow', schema=None) as batch_op: + batch_op.add_column(sa.Column('is_component', sa.Boolean(), nullable=True)) + batch_op.add_column(sa.Column('updated_at', sa.DateTime(), nullable=True)) + batch_op.add_column(sa.Column('folder', sqlmodel.sql.sqltypes.AutoString(), nullable=True)) + batch_op.add_column(sa.Column('user_id', sqlmodel.sql.sqltypes.GUID(), nullable=True)) + batch_op.create_index(batch_op.f('ix_flow_user_id'), ['user_id'], unique=False) + batch_op.create_foreign_key('flow_user_id_fkey' + , 'user', ['user_id'], ['id']) + except Exception: + pass + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + try: + with op.batch_alter_table('flow', schema=None) as batch_op: + batch_op.drop_constraint('flow_user_id_fkey', type_='foreignkey') + batch_op.drop_index(batch_op.f('ix_flow_user_id')) + batch_op.drop_column('user_id') + batch_op.drop_column('folder') + batch_op.drop_column('updated_at') + batch_op.drop_column('is_component') + except Exception: + pass + + # ### end Alembic commands ### From 89a8a6a0be3f9b1a3c8678894d3af4ac76ae8d69 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 26 Jan 2024 13:37:48 -0300 Subject: [PATCH 2/7] Update version number in pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8abaf6ebe..4536ba982 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langflow" -version = "0.6.5a9" +version = "0.6.5a10" description = "A Python package with a built-in web application" authors = ["Logspace "] maintainers = [ From e011d1f6dc2e513eb3fea203eab54fff0cf075a4 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 26 Jan 2024 14:08:38 -0300 Subject: [PATCH 3/7] Refactor import order and remove unnecessary samesite attribute in set_cookie() calls --- src/backend/langflow/api/v1/login.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/langflow/api/v1/login.py b/src/backend/langflow/api/v1/login.py index b8fa48577..d0fa0e446 100644 --- a/src/backend/langflow/api/v1/login.py +++ b/src/backend/langflow/api/v1/login.py @@ -1,4 +1,4 @@ -from fastapi import Request, Response, APIRouter, Depends, HTTPException, status +from fastapi import APIRouter, Depends, HTTPException, Request, Response, status from fastapi.security import OAuth2PasswordRequestForm from sqlmodel import Session @@ -33,8 +33,8 @@ async def login_to_get_access_token( if user: tokens = create_user_tokens(user_id=user.id, db=db, update_last_login=True) - response.set_cookie("refresh_token_lf", tokens["refresh_token"], httponly=True, secure=True, samesite="strict") - response.set_cookie("access_token_lf", tokens["access_token"], httponly=False, secure=True, samesite="strict") + response.set_cookie("refresh_token_lf", tokens["refresh_token"], httponly=True, secure=True) + response.set_cookie("access_token_lf", tokens["access_token"], httponly=False, secure=True) return tokens else: raise HTTPException( From a2ca8a62e75f2ba3842d0e5959c01d3ac38a41e9 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 26 Jan 2024 14:09:48 -0300 Subject: [PATCH 4/7] Bumped version to 0.6.5a11 in pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4536ba982..678d25995 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langflow" -version = "0.6.5a10" +version = "0.6.5a11" description = "A Python package with a built-in web application" authors = ["Logspace "] maintainers = [ From a5f91da7d4e99f773d7a75064e6deffa1b992772 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 26 Jan 2024 15:17:30 -0300 Subject: [PATCH 5/7] Update cookie settings in login.py --- src/backend/langflow/api/v1/login.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backend/langflow/api/v1/login.py b/src/backend/langflow/api/v1/login.py index d0fa0e446..29db59855 100644 --- a/src/backend/langflow/api/v1/login.py +++ b/src/backend/langflow/api/v1/login.py @@ -33,8 +33,8 @@ async def login_to_get_access_token( if user: tokens = create_user_tokens(user_id=user.id, db=db, update_last_login=True) - response.set_cookie("refresh_token_lf", tokens["refresh_token"], httponly=True, secure=True) - response.set_cookie("access_token_lf", tokens["access_token"], httponly=False, secure=True) + response.set_cookie("refresh_token_lf", tokens["refresh_token"], httponly=True) + response.set_cookie("access_token_lf", tokens["access_token"], httponly=False) return tokens else: raise HTTPException( @@ -50,7 +50,7 @@ async def auto_login( ): if settings_service.auth_settings.AUTO_LOGIN: tokens = create_user_longterm_token(db) - response.set_cookie("access_token_lf", tokens["access_token"], httponly=False, secure=True, samesite="strict") + response.set_cookie("access_token_lf", tokens["access_token"], httponly=False) return tokens raise HTTPException( @@ -67,8 +67,8 @@ async def refresh_token(request: Request, response: Response): token = request.cookies.get("refresh_token_lf") if token: tokens = create_refresh_token(token) - response.set_cookie("refresh_token_lf", tokens["refresh_token"], httponly=True, secure=True, samesite="strict") - response.set_cookie("access_token_lf", tokens["access_token"], httponly=False, secure=True, samesite="strict") + response.set_cookie("refresh_token_lf", tokens["refresh_token"], httponly=True) + response.set_cookie("access_token_lf", tokens["access_token"], httponly=False) return tokens else: raise HTTPException( From e63878b2f1ffc843afcd743a2c1d04d94825876e Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 26 Jan 2024 15:18:00 -0300 Subject: [PATCH 6/7] Update version to 0.6.5a12 in pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 678d25995..5d1140a4e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langflow" -version = "0.6.5a11" +version = "0.6.5a12" description = "A Python package with a built-in web application" authors = ["Logspace "] maintainers = [ From 2aa273166d7743e19cdfe6f7782a247581dfdef0 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Mon, 29 Jan 2024 17:36:00 -0300 Subject: [PATCH 7/7] Fix input fields behavior when node is not selected --- src/frontend/src/CustomNodes/GenericNode/index.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index ea9f49845..c8f2d2349 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -80,6 +80,13 @@ export default function GenericNode({ countHandles(); }, [data, data.node]); + useEffect(() => { + if (!selected) { + setInputName(false); + setInputDescription(false); + } + }, [selected]); + // State for outline color const sseData = useFlowStore((state) => state.sseData); const isBuilding = useFlowStore((state) => state.isBuilding);