From 6618efc4098c4d527e8988a33a1618cf3dcd55a0 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 3 Oct 2023 17:59:48 -0300 Subject: [PATCH 1/9] =?UTF-8?q?=F0=9F=94=A8=20refactor(base.py):=20remove?= =?UTF-8?q?=20unused=20import=20from=20langchain=20module=20in=20base.py?= =?UTF-8?q?=20=F0=9F=94=A8=20refactor(base.py):=20remove=20unused=20import?= =?UTF-8?q?=20from=20langchain.utilities=20module=20in=20base.py=20?= =?UTF-8?q?=F0=9F=94=A8=20refactor(base.py):=20remove=20unused=20import=20?= =?UTF-8?q?from=20langchain.requests=20module=20in=20base.py=20?= =?UTF-8?q?=F0=9F=94=A8=20refactor(base.py):=20remove=20unused=20import=20?= =?UTF-8?q?from=20langchain.sql=5Fdatabase=20module=20in=20base.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/utilities/base.py | 4 ++-- src/backend/langflow/interface/wrappers/base.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/langflow/interface/utilities/base.py b/src/backend/langflow/interface/utilities/base.py index 665143da2..bfc7cb11e 100644 --- a/src/backend/langflow/interface/utilities/base.py +++ b/src/backend/langflow/interface/utilities/base.py @@ -1,6 +1,6 @@ from typing import Dict, List, Optional, Type -from langchain import SQLDatabase, utilities +from langchain import utilities from langflow.custom.customs import get_custom_nodes from langflow.interface.base import LangChainTypeCreator @@ -32,7 +32,7 @@ class UtilityCreator(LangChainTypeCreator): utility_name: import_class(f"langchain.utilities.{utility_name}") for utility_name in utilities.__all__ } - self.type_dict["SQLDatabase"] = SQLDatabase + self.type_dict["SQLDatabase"] = utilities.SQLDatabase # Filter according to settings.utilities self.type_dict = { name: utility diff --git a/src/backend/langflow/interface/wrappers/base.py b/src/backend/langflow/interface/wrappers/base.py index c4399fb3e..de631101a 100644 --- a/src/backend/langflow/interface/wrappers/base.py +++ b/src/backend/langflow/interface/wrappers/base.py @@ -1,6 +1,6 @@ from typing import Dict, List, Optional -from langchain import requests, sql_database +from langchain.utilities import requests, sql_database from langflow.interface.base import LangChainTypeCreator from loguru import logger From 9c70a3fe20b7e1dbb41453a5d24a6408121660d4 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 3 Oct 2023 18:13:41 -0300 Subject: [PATCH 2/9] =?UTF-8?q?=F0=9F=90=9B=20fix(manager.py):=20add=20ins?= =?UTF-8?q?pector=20to=20check=20if=20table=20"flow"=20exists=20before=20c?= =?UTF-8?q?reating=20tables=20again?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The change was made to fix a bug where the tables were being recreated even if they already existed. By adding an inspector to check if the table "flow" exists before recreating the tables, we can prevent unnecessary table creation and improve performance. --- src/backend/langflow/services/database/manager.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/langflow/services/database/manager.py b/src/backend/langflow/services/database/manager.py index 18364cd62..4cb715323 100644 --- a/src/backend/langflow/services/database/manager.py +++ b/src/backend/langflow/services/database/manager.py @@ -171,6 +171,7 @@ class DatabaseService(Service): # Now check if the table "flow" exists, if not, something went wrong # and we need to create the tables again. + inspector = inspect(self.engine) table_names = inspector.get_table_names() for table in current_tables: if table not in table_names: From 9751c5cb6272e03d3c831361b0bb5664b4e4ecfd Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 3 Oct 2023 18:14:32 -0300 Subject: [PATCH 3/9] =?UTF-8?q?=F0=9F=94=92=20test(test=5Fsetup=5Fsuperuse?= =?UTF-8?q?r.py):=20add=20mock=20for=20verify=5Fpassword=20function=20to?= =?UTF-8?q?=20fix=20test=20failure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_setup_superuser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_setup_superuser.py b/tests/test_setup_superuser.py index 6cf4b3a3a..137c98763 100644 --- a/tests/test_setup_superuser.py +++ b/tests/test_setup_superuser.py @@ -12,9 +12,10 @@ from langflow.services.utils import ( @patch("langflow.services.getters.get_settings_service") @patch("langflow.services.utils.create_super_user") +@patch("langflow.services.utils.verify_password") @patch("langflow.services.getters.get_session") def test_setup_superuser( - mock_get_session, mock_create_super_user, mock_get_settings_service + mock_get_session, mock_create_super_user, mock_get_settings_service, mock_verify ): # Test when AUTO_LOGIN is True calls = [] From 2b7062a3ec6c0192e54d52053c648e34c23d5561 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 3 Oct 2023 21:32:25 -0300 Subject: [PATCH 4/9] =?UTF-8?q?=F0=9F=94=A7=20chore(chat.py):=20refactor?= =?UTF-8?q?=20error=20logging=20in=20try=5Frunning=5Fcelery=5Ftask=20funct?= =?UTF-8?q?ion=20to=20improve=20readability=20and=20reduce=20noise=20?= =?UTF-8?q?=F0=9F=90=9B=20fix(chat.py):=20change=20error=20logging=20level?= =?UTF-8?q?=20from=20error=20to=20debug=20in=20try=5Frunning=5Fcelery=5Fta?= =?UTF-8?q?sk=20function=20to=20reduce=20noise?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/v1/chat.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/backend/langflow/api/v1/chat.py b/src/backend/langflow/api/v1/chat.py index c25c4bde2..6fdfb8897 100644 --- a/src/backend/langflow/api/v1/chat.py +++ b/src/backend/langflow/api/v1/chat.py @@ -239,8 +239,7 @@ def try_running_celery_task(vertex): task = build_vertex.delay(vertex) vertex.task_id = task.id except Exception as exc: - logger.exception(exc) - logger.error("Error running task in celery, running locally") + logger.debug(f"Error running task in celery: {exc}") vertex.task_id = None vertex.build() return vertex From f25e390e8c41b8c48d5dbe021859582d4eaab2c2 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 3 Oct 2023 21:33:45 -0300 Subject: [PATCH 5/9] =?UTF-8?q?=F0=9F=90=9B=20fix(utils.py):=20handle=5Fpa?= =?UTF-8?q?rtial=5Fvariables=20now=20filters=20out=20partial=20variables?= =?UTF-8?q?=20with=20None=20values=20to=20prevent=20errors=20in=20LangChai?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/initialize/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/langflow/interface/initialize/utils.py b/src/backend/langflow/interface/initialize/utils.py index 199626de5..a93375cb7 100644 --- a/src/backend/langflow/interface/initialize/utils.py +++ b/src/backend/langflow/interface/initialize/utils.py @@ -49,7 +49,7 @@ def handle_format_kwargs(prompt, params: Dict): def handle_partial_variables(prompt, format_kwargs: Dict): partial_variables = format_kwargs.copy() partial_variables = { - key: value for key, value in partial_variables.items() if value + key: value for key, value in partial_variables.items() if value is not None } # Remove handle_keys otherwise LangChain raises an error partial_variables.pop("handle_keys", None) From ef83859d710732613d4715a4b78b31d66720277c Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 3 Oct 2023 21:41:07 -0300 Subject: [PATCH 6/9] =?UTF-8?q?=F0=9F=94=96=20chore(pyproject.toml):=20upd?= =?UTF-8?q?ate=20package=20version=20to=200.5.0a7=20for=20langflow=20?= =?UTF-8?q?=F0=9F=94=96=20chore(pyproject.toml):=20update=20langchain=20de?= =?UTF-8?q?pendency=20to=20version=200.0.306=20for=20compatibility=20impro?= =?UTF-8?q?vements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 17f97b2ce..a0e687551 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langflow" -version = "0.5.0a6" +version = "0.5.0a7" description = "A Python package with a built-in web application" authors = ["Logspace "] maintainers = [ @@ -33,7 +33,7 @@ google-search-results = "^2.4.1" google-api-python-client = "^2.79.0" typer = "^0.9.0" gunicorn = "^21.2.0" -langchain = "^0.0.303" +langchain = "^0.0.306" openai = "^0.27.8" pandas = "2.0.3" chromadb = "^0.3.21" From 5058daab16870789fdcbc286590adfb0ee7d20c2 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 3 Oct 2023 21:42:14 -0300 Subject: [PATCH 7/9] =?UTF-8?q?=F0=9F=94=92=20chore(poetry.lock):=20update?= =?UTF-8?q?=20langchain=20package=20version=20from=200.0.303=20to=200.0.30?= =?UTF-8?q?6=20=F0=9F=93=A6=20chore(poetry.lock):=20update=20langchain=20p?= =?UTF-8?q?ackage=20files=20with=20new=20version=200.0.306=20and=20corresp?= =?UTF-8?q?onding=20hashes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🔒 chore(poetry.lock): update package versions The package versions in poetry.lock have been updated to the latest compatible versions. This ensures that the project is using the most up-to-date dependencies and improves compatibility and security. 🔧 chore(dependencies): update extended-testing, openai, and tiktoken versions - Update extended-testing dependencies to include new packages: anthropic, arxiv, and motor - Update openai dependency to include tiktoken version 0.3.2 to 0.6.0 - No changes to javascript, llms, qdrant, and text-helpers dependencies 🔒 chore(poetry.lock): update traitlets package version from 5.11.1 to 5.11.2 to fix a bug and improve functionality 🔐 chore(poetry.lock): update content-hash for traitlets package to ensure integrity and security of the package --- poetry.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/poetry.lock b/poetry.lock index 089e3e4a1..d74ad3096 100644 --- a/poetry.lock +++ b/poetry.lock @@ -3335,13 +3335,13 @@ zookeeper = ["kazoo (>=2.8.0)"] [[package]] name = "langchain" -version = "0.0.303" +version = "0.0.306" description = "Building applications with LLMs through composability" optional = false python-versions = ">=3.8.1,<4.0" files = [ - {file = "langchain-0.0.303-py3-none-any.whl", hash = "sha256:1745961f66b60bc3b513820a34c560dd37c4ba4b7499ba82545dc4816d0133bd"}, - {file = "langchain-0.0.303.tar.gz", hash = "sha256:84d2727eb8b3b27a9d0aa0da9f05408c2564a4a923c7d5b154a16e488430e725"}, + {file = "langchain-0.0.306-py3-none-any.whl", hash = "sha256:ca565a82f9147e2a80587aa386565b77c1e90c50934210fbfb3df67a7535483a"}, + {file = "langchain-0.0.306.tar.gz", hash = "sha256:f6baca557dcf2ec3f19f59b54a9d3550f9bc10827b27b550c503033acc0bcba2"}, ] [package.dependencies] @@ -3360,16 +3360,16 @@ SQLAlchemy = ">=1.4,<3" tenacity = ">=8.1.0,<9.0.0" [package.extras] -all = ["O365 (>=2.0.26,<3.0.0)", "aleph-alpha-client (>=2.15.0,<3.0.0)", "amadeus (>=8.1.0)", "arxiv (>=1.4,<2.0)", "atlassian-python-api (>=3.36.0,<4.0.0)", "awadb (>=0.3.9,<0.4.0)", "azure-ai-formrecognizer (>=3.2.1,<4.0.0)", "azure-ai-vision (>=0.11.1b1,<0.12.0)", "azure-cognitiveservices-speech (>=1.28.0,<2.0.0)", "azure-cosmos (>=4.4.0b1,<5.0.0)", "azure-identity (>=1.12.0,<2.0.0)", "beautifulsoup4 (>=4,<5)", "clarifai (>=9.1.0)", "clickhouse-connect (>=0.5.14,<0.6.0)", "cohere (>=4,<5)", "deeplake (>=3.6.8,<4.0.0)", "docarray[hnswlib] (>=0.32.0,<0.33.0)", "duckduckgo-search (>=3.8.3,<4.0.0)", "elasticsearch (>=8,<9)", "esprima (>=4.0.1,<5.0.0)", "faiss-cpu (>=1,<2)", "google-api-python-client (==2.70.0)", "google-auth (>=2.18.1,<3.0.0)", "google-search-results (>=2,<3)", "gptcache (>=0.1.7)", "html2text (>=2020.1.16,<2021.0.0)", "huggingface_hub (>=0,<1)", "jinja2 (>=3,<4)", "jq (>=1.4.1,<2.0.0)", "lancedb (>=0.1,<0.2)", "langkit (>=0.0.6,<0.1.0)", "lark (>=1.1.5,<2.0.0)", "libdeeplake (>=0.0.60,<0.0.61)", "librosa (>=0.10.0.post2,<0.11.0)", "lxml (>=4.9.2,<5.0.0)", "manifest-ml (>=0.0.1,<0.0.2)", "marqo (>=1.2.4,<2.0.0)", "momento (>=1.5.0,<2.0.0)", "nebula3-python (>=3.4.0,<4.0.0)", "neo4j (>=5.8.1,<6.0.0)", "networkx (>=2.6.3,<3.0.0)", "nlpcloud (>=1,<2)", "nltk (>=3,<4)", "nomic (>=1.0.43,<2.0.0)", "openai (>=0,<1)", "openlm (>=0.0.5,<0.0.6)", "opensearch-py (>=2.0.0,<3.0.0)", "pdfminer-six (>=20221105,<20221106)", "pexpect (>=4.8.0,<5.0.0)", "pgvector (>=0.1.6,<0.2.0)", "pinecone-client (>=2,<3)", "pinecone-text (>=0.4.2,<0.5.0)", "psycopg2-binary (>=2.9.5,<3.0.0)", "pymongo (>=4.3.3,<5.0.0)", "pyowm (>=3.3.0,<4.0.0)", "pypdf (>=3.4.0,<4.0.0)", "pytesseract (>=0.3.10,<0.4.0)", "python-arango (>=7.5.9,<8.0.0)", "pyvespa (>=0.33.0,<0.34.0)", "qdrant-client (>=1.3.1,<2.0.0)", "rdflib (>=6.3.2,<7.0.0)", "redis (>=4,<5)", "requests-toolbelt (>=1.0.0,<2.0.0)", "sentence-transformers (>=2,<3)", "singlestoredb (>=0.7.1,<0.8.0)", "tensorflow-text (>=2.11.0,<3.0.0)", "tigrisdb (>=1.0.0b6,<2.0.0)", "tiktoken (>=0.3.2,<0.4.0)", "torch (>=1,<3)", "transformers (>=4,<5)", "weaviate-client (>=3,<4)", "wikipedia (>=1,<2)", "wolframalpha (==5.0.0)"] +all = ["O365 (>=2.0.26,<3.0.0)", "aleph-alpha-client (>=2.15.0,<3.0.0)", "amadeus (>=8.1.0)", "arxiv (>=1.4,<2.0)", "atlassian-python-api (>=3.36.0,<4.0.0)", "awadb (>=0.3.9,<0.4.0)", "azure-ai-formrecognizer (>=3.2.1,<4.0.0)", "azure-ai-vision (>=0.11.1b1,<0.12.0)", "azure-cognitiveservices-speech (>=1.28.0,<2.0.0)", "azure-cosmos (>=4.4.0b1,<5.0.0)", "azure-identity (>=1.12.0,<2.0.0)", "beautifulsoup4 (>=4,<5)", "clarifai (>=9.1.0)", "clickhouse-connect (>=0.5.14,<0.6.0)", "cohere (>=4,<5)", "deeplake (>=3.6.8,<4.0.0)", "docarray[hnswlib] (>=0.32.0,<0.33.0)", "duckduckgo-search (>=3.8.3,<4.0.0)", "elasticsearch (>=8,<9)", "esprima (>=4.0.1,<5.0.0)", "faiss-cpu (>=1,<2)", "google-api-python-client (==2.70.0)", "google-auth (>=2.18.1,<3.0.0)", "google-search-results (>=2,<3)", "gptcache (>=0.1.7)", "html2text (>=2020.1.16,<2021.0.0)", "huggingface_hub (>=0,<1)", "jinja2 (>=3,<4)", "jq (>=1.4.1,<2.0.0)", "lancedb (>=0.1,<0.2)", "langkit (>=0.0.6,<0.1.0)", "lark (>=1.1.5,<2.0.0)", "libdeeplake (>=0.0.60,<0.0.61)", "librosa (>=0.10.0.post2,<0.11.0)", "lxml (>=4.9.2,<5.0.0)", "manifest-ml (>=0.0.1,<0.0.2)", "marqo (>=1.2.4,<2.0.0)", "momento (>=1.5.0,<2.0.0)", "nebula3-python (>=3.4.0,<4.0.0)", "neo4j (>=5.8.1,<6.0.0)", "networkx (>=2.6.3,<4)", "nlpcloud (>=1,<2)", "nltk (>=3,<4)", "nomic (>=1.0.43,<2.0.0)", "openai (>=0,<1)", "openlm (>=0.0.5,<0.0.6)", "opensearch-py (>=2.0.0,<3.0.0)", "pdfminer-six (>=20221105,<20221106)", "pexpect (>=4.8.0,<5.0.0)", "pgvector (>=0.1.6,<0.2.0)", "pinecone-client (>=2,<3)", "pinecone-text (>=0.4.2,<0.5.0)", "psycopg2-binary (>=2.9.5,<3.0.0)", "pymongo (>=4.3.3,<5.0.0)", "pyowm (>=3.3.0,<4.0.0)", "pypdf (>=3.4.0,<4.0.0)", "pytesseract (>=0.3.10,<0.4.0)", "python-arango (>=7.5.9,<8.0.0)", "pyvespa (>=0.33.0,<0.34.0)", "qdrant-client (>=1.3.1,<2.0.0)", "rdflib (>=6.3.2,<7.0.0)", "redis (>=4,<5)", "requests-toolbelt (>=1.0.0,<2.0.0)", "sentence-transformers (>=2,<3)", "singlestoredb (>=0.7.1,<0.8.0)", "tensorflow-text (>=2.11.0,<3.0.0)", "tigrisdb (>=1.0.0b6,<2.0.0)", "tiktoken (>=0.3.2,<0.6.0)", "torch (>=1,<3)", "transformers (>=4,<5)", "weaviate-client (>=3,<4)", "wikipedia (>=1,<2)", "wolframalpha (==5.0.0)"] azure = ["azure-ai-formrecognizer (>=3.2.1,<4.0.0)", "azure-ai-vision (>=0.11.1b1,<0.12.0)", "azure-cognitiveservices-speech (>=1.28.0,<2.0.0)", "azure-core (>=1.26.4,<2.0.0)", "azure-cosmos (>=4.4.0b1,<5.0.0)", "azure-identity (>=1.12.0,<2.0.0)", "azure-search-documents (==11.4.0b8)", "openai (>=0,<1)"] clarifai = ["clarifai (>=9.1.0)"] cohere = ["cohere (>=4,<5)"] docarray = ["docarray[hnswlib] (>=0.32.0,<0.33.0)"] embeddings = ["sentence-transformers (>=2,<3)"] -extended-testing = ["amazon-textract-caller (<2)", "assemblyai (>=0.17.0,<0.18.0)", "atlassian-python-api (>=3.36.0,<4.0.0)", "beautifulsoup4 (>=4,<5)", "bibtexparser (>=1.4.0,<2.0.0)", "cassio (>=0.1.0,<0.2.0)", "chardet (>=5.1.0,<6.0.0)", "dashvector (>=1.0.1,<2.0.0)", "esprima (>=4.0.1,<5.0.0)", "faiss-cpu (>=1,<2)", "feedparser (>=6.0.10,<7.0.0)", "geopandas (>=0.13.1,<0.14.0)", "gitpython (>=3.1.32,<4.0.0)", "gql (>=3.4.1,<4.0.0)", "html2text (>=2020.1.16,<2021.0.0)", "jinja2 (>=3,<4)", "jq (>=1.4.1,<2.0.0)", "lxml (>=4.9.2,<5.0.0)", "markdownify (>=0.11.6,<0.12.0)", "mwparserfromhell (>=0.6.4,<0.7.0)", "mwxml (>=0.3.3,<0.4.0)", "newspaper3k (>=0.2.8,<0.3.0)", "openai (>=0,<1)", "openapi-schema-pydantic (>=1.2,<2.0)", "pandas (>=2.0.1,<3.0.0)", "pdfminer-six (>=20221105,<20221106)", "pgvector (>=0.1.6,<0.2.0)", "psychicapi (>=0.8.0,<0.9.0)", "py-trello (>=0.19.0,<0.20.0)", "pymupdf (>=1.22.3,<2.0.0)", "pypdf (>=3.4.0,<4.0.0)", "pypdfium2 (>=4.10.0,<5.0.0)", "pyspark (>=3.4.0,<4.0.0)", "rank-bm25 (>=0.2.2,<0.3.0)", "rapidfuzz (>=3.1.1,<4.0.0)", "requests-toolbelt (>=1.0.0,<2.0.0)", "scikit-learn (>=1.2.2,<2.0.0)", "sqlite-vss (>=0.1.2,<0.2.0)", "streamlit (>=1.18.0,<2.0.0)", "sympy (>=1.12,<2.0)", "telethon (>=1.28.5,<2.0.0)", "timescale-vector (>=0.0.1,<0.0.2)", "tqdm (>=4.48.0)", "xata (>=1.0.0a7,<2.0.0)", "xmltodict (>=0.13.0,<0.14.0)"] +extended-testing = ["amazon-textract-caller (<2)", "anthropic (>=0.3.11,<0.4.0)", "arxiv (>=1.4,<2.0)", "assemblyai (>=0.17.0,<0.18.0)", "atlassian-python-api (>=3.36.0,<4.0.0)", "beautifulsoup4 (>=4,<5)", "bibtexparser (>=1.4.0,<2.0.0)", "cassio (>=0.1.0,<0.2.0)", "chardet (>=5.1.0,<6.0.0)", "dashvector (>=1.0.1,<2.0.0)", "esprima (>=4.0.1,<5.0.0)", "faiss-cpu (>=1,<2)", "feedparser (>=6.0.10,<7.0.0)", "geopandas (>=0.13.1,<0.14.0)", "gitpython (>=3.1.32,<4.0.0)", "gql (>=3.4.1,<4.0.0)", "html2text (>=2020.1.16,<2021.0.0)", "jinja2 (>=3,<4)", "jq (>=1.4.1,<2.0.0)", "lxml (>=4.9.2,<5.0.0)", "markdownify (>=0.11.6,<0.12.0)", "motor (>=3.3.1,<4.0.0)", "mwparserfromhell (>=0.6.4,<0.7.0)", "mwxml (>=0.3.3,<0.4.0)", "newspaper3k (>=0.2.8,<0.3.0)", "openai (>=0,<1)", "openapi-schema-pydantic (>=1.2,<2.0)", "pandas (>=2.0.1,<3.0.0)", "pdfminer-six (>=20221105,<20221106)", "pgvector (>=0.1.6,<0.2.0)", "psychicapi (>=0.8.0,<0.9.0)", "py-trello (>=0.19.0,<0.20.0)", "pymupdf (>=1.22.3,<2.0.0)", "pypdf (>=3.4.0,<4.0.0)", "pypdfium2 (>=4.10.0,<5.0.0)", "pyspark (>=3.4.0,<4.0.0)", "rank-bm25 (>=0.2.2,<0.3.0)", "rapidfuzz (>=3.1.1,<4.0.0)", "requests-toolbelt (>=1.0.0,<2.0.0)", "scikit-learn (>=1.2.2,<2.0.0)", "sqlite-vss (>=0.1.2,<0.2.0)", "streamlit (>=1.18.0,<2.0.0)", "sympy (>=1.12,<2.0)", "telethon (>=1.28.5,<2.0.0)", "timescale-vector (>=0.0.1,<0.0.2)", "tqdm (>=4.48.0)", "xata (>=1.0.0a7,<2.0.0)", "xmltodict (>=0.13.0,<0.14.0)"] javascript = ["esprima (>=4.0.1,<5.0.0)"] llms = ["clarifai (>=9.1.0)", "cohere (>=4,<5)", "huggingface_hub (>=0,<1)", "manifest-ml (>=0.0.1,<0.0.2)", "nlpcloud (>=1,<2)", "openai (>=0,<1)", "openlm (>=0.0.5,<0.0.6)", "torch (>=1,<3)", "transformers (>=4,<5)"] -openai = ["openai (>=0,<1)", "tiktoken (>=0.3.2,<0.4.0)"] +openai = ["openai (>=0,<1)", "tiktoken (>=0.3.2,<0.6.0)"] qdrant = ["qdrant-client (>=1.3.1,<2.0.0)"] text-helpers = ["chardet (>=5.1.0,<6.0.0)"] @@ -7112,13 +7112,13 @@ telegram = ["requests"] [[package]] name = "traitlets" -version = "5.11.1" +version = "5.11.2" description = "Traitlets Python configuration system" optional = false python-versions = ">=3.8" files = [ - {file = "traitlets-5.11.1-py3-none-any.whl", hash = "sha256:2351372ff87fc912c483d1cb6aa466573d5f44eb4ed9e602c8d0ac012c9daece"}, - {file = "traitlets-5.11.1.tar.gz", hash = "sha256:813584bb569ac4a098c64ca494e8a3bbfef42e37c36a6132bca554aabd111480"}, + {file = "traitlets-5.11.2-py3-none-any.whl", hash = "sha256:98277f247f18b2c5cabaf4af369187754f4fb0e85911d473f72329db8a7f4fae"}, + {file = "traitlets-5.11.2.tar.gz", hash = "sha256:7564b5bf8d38c40fa45498072bf4dc5e8346eb087bbf1e2ae2d8774f6a0f078e"}, ] [package.extras] @@ -8141,4 +8141,4 @@ local = ["ctransformers", "llama-cpp-python", "sentence-transformers"] [metadata] lock-version = "2.0" python-versions = ">=3.9,<3.11" -content-hash = "2a8b9c0ccf18c3c6a25d0c05fcd88e6ab92e6e65c180ff5a243c8bbd96a5131a" +content-hash = "8fa78f602b71fd7e740481cc65fdf1c59946da8bcfe39879248afa5c0d1430db" From 3724876620425b8137cc996d76a47b6d116a2582 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 3 Oct 2023 22:14:32 -0300 Subject: [PATCH 8/9] =?UTF-8?q?=F0=9F=90=9B=20fix(utils.py):=20remove=20un?= =?UTF-8?q?necessary=20check=20for=20None=20value=20in=20handle=5Fpartial?= =?UTF-8?q?=5Fvariables=20function=20=F0=9F=94=80=20refactor(utils.py):=20?= =?UTF-8?q?simplify=20dictionary=20comprehension=20in=20handle=5Fpartial?= =?UTF-8?q?=5Fvariables=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/initialize/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/langflow/interface/initialize/utils.py b/src/backend/langflow/interface/initialize/utils.py index a93375cb7..199626de5 100644 --- a/src/backend/langflow/interface/initialize/utils.py +++ b/src/backend/langflow/interface/initialize/utils.py @@ -49,7 +49,7 @@ def handle_format_kwargs(prompt, params: Dict): def handle_partial_variables(prompt, format_kwargs: Dict): partial_variables = format_kwargs.copy() partial_variables = { - key: value for key, value in partial_variables.items() if value is not None + key: value for key, value in partial_variables.items() if value } # Remove handle_keys otherwise LangChain raises an error partial_variables.pop("handle_keys", None) From 78c54d673672e18d68c9fbbd28e639e93e9c1fa9 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Wed, 4 Oct 2023 09:03:03 -0300 Subject: [PATCH 9/9] =?UTF-8?q?=F0=9F=90=9B=20fix(manager.py):=20handle=20?= =?UTF-8?q?table=20creation=20errors=20and=20log=20warnings=20for=20existi?= =?UTF-8?q?ng=20tables=20=E2=9C=A8=20feat(manager.py):=20improve=20table?= =?UTF-8?q?=20creation=20process=20by=20checking=20if=20tables=20already?= =?UTF-8?q?=20exist=20before=20creating=20them?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../langflow/services/database/manager.py | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/backend/langflow/services/database/manager.py b/src/backend/langflow/services/database/manager.py index 4cb715323..c743387eb 100644 --- a/src/backend/langflow/services/database/manager.py +++ b/src/backend/langflow/services/database/manager.py @@ -6,6 +6,7 @@ from langflow.services.database.utils import Result, TableResults from langflow.services.getters import get_settings_service from sqlalchemy import inspect import sqlalchemy as sa +from sqlalchemy.exc import OperationalError from sqlmodel import SQLModel, Session, create_engine from loguru import logger from alembic.config import Config @@ -157,20 +158,27 @@ class DatabaseService(Service): from sqlalchemy import inspect inspector = inspect(self.engine) - current_tables = ["flow", "user", "apikey"] table_names = inspector.get_table_names() + current_tables = ["flow", "user", "apikey"] + if table_names and all(table in table_names for table in current_tables): logger.debug("Database and tables already exist") return - logger.debug("Creating database and tables") - try: - SQLModel.metadata.create_all(self.engine) - except Exception as exc: - logger.error(f"Error creating database and tables: {exc}") - raise RuntimeError("Error creating database and tables") from exc - # Now check if the table "flow" exists, if not, something went wrong - # and we need to create the tables again. + logger.debug("Creating database and tables") + + for table in SQLModel.metadata.sorted_tables: + try: + table.create(self.engine, checkfirst=True) + except OperationalError as oe: + logger.warning( + f"Table {table} already exists, skipping. Exception: {oe}" + ) + except Exception as exc: + logger.error(f"Error creating table {table}: {exc}") + raise RuntimeError(f"Error creating table {table}") from exc + + # Now check if the required tables exist, if not, something went wrong. inspector = inspect(self.engine) table_names = inspector.get_table_names() for table in current_tables: