From 05453e8eec674a5c9fc3fa6289a0a779f719a40c Mon Sep 17 00:00:00 2001 From: ogabrielluiz Date: Mon, 10 Jun 2024 09:11:52 -0300 Subject: [PATCH 1/9] chore: Add lcov coverage report for pytest --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index abf3e67ec..4592caf9b 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,8 @@ coverage: poetry run pytest --cov \ --cov-config=.coveragerc \ --cov-report xml \ - --cov-report term-missing:skip-covered + --cov-report term-missing:skip-covered \ + --cov-report lcov:coverage/lcov-pytest.info # allow passing arguments to pytest tests: From 05fd2ff67b5dbcce969185bccf0d27bc3abfe4df Mon Sep 17 00:00:00 2001 From: italojohnny Date: Mon, 10 Jun 2024 09:02:57 -0300 Subject: [PATCH 2/9] fix: freeze --- src/backend/base/langflow/graph/graph/base.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/base/langflow/graph/graph/base.py b/src/backend/base/langflow/graph/graph/base.py index 06074ee1d..56b5e8bfe 100644 --- a/src/backend/base/langflow/graph/graph/base.py +++ b/src/backend/base/langflow/graph/graph/base.py @@ -757,6 +757,7 @@ class Graph: await vertex.build( user_id=user_id, inputs=inputs_dict, fallback_to_env_vars=fallback_to_env_vars, files=files ) + await chat_service.set_cache(key=vertex.id, data=vertex) if vertex.result is not None: params = f"{vertex._built_object_repr()}{params}" From 5d34461ab59f4a4b3319fc8e3f0f98f97559bc85 Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Mon, 10 Jun 2024 09:25:52 -0300 Subject: [PATCH 3/9] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20(buttonSendWrapper):?= =?UTF-8?q?=20refactor=20button=20to=20use=20Button=20component=20for=20co?= =?UTF-8?q?nsistency=20=E2=9C=A8=20(buttonSendWrapper):=20add=20variant=20?= =?UTF-8?q?and=20size=20props=20to=20Button=20component=20for=20customizat?= =?UTF-8?q?ion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chatInput/components/buttonSendWrapper/index.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/modals/IOModal/components/chatView/chatInput/components/buttonSendWrapper/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/chatInput/components/buttonSendWrapper/index.tsx index 52a3ff4dc..bf61b2fb9 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/chatInput/components/buttonSendWrapper/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/chatInput/components/buttonSendWrapper/index.tsx @@ -1,4 +1,5 @@ import IconComponent from "../../../../../../../components/genericIconComponent"; +import { Button } from "../../../../../../../components/ui/button"; import { Case } from "../../../../../../../shared/components/caseComponent"; import { FilePreviewType } from "../../../../../../../types/components"; import { classNames } from "../../../../../../../utils/utils"; @@ -21,7 +22,7 @@ const ButtonSendWrapper = ({ files, }: ButtonSendWrapperProps) => { return ( - + ); }; From 1a9bf3aec344f3f65b0e996d22fc17569e781311 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Mon, 10 Jun 2024 09:37:02 -0300 Subject: [PATCH 4/9] status on session --- src/frontend/src/modals/IOModal/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/modals/IOModal/index.tsx b/src/frontend/src/modals/IOModal/index.tsx index e047a3694..79c68169d 100644 --- a/src/frontend/src/modals/IOModal/index.tsx +++ b/src/frontend/src/modals/IOModal/index.tsx @@ -380,7 +380,7 @@ export default function IOModal({ -
+ {/*
-
+ */} From 9fe2d455f3f8f66974e110b5747402d6c0091395 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Mon, 10 Jun 2024 10:51:01 -0300 Subject: [PATCH 5/9] remove id update on db fetch flow --- src/frontend/src/stores/flowsManagerStore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/src/stores/flowsManagerStore.ts b/src/frontend/src/stores/flowsManagerStore.ts index 72df9e9b4..393681b72 100644 --- a/src/frontend/src/stores/flowsManagerStore.ts +++ b/src/frontend/src/stores/flowsManagerStore.ts @@ -85,7 +85,7 @@ const useFlowsManagerStore = create((set, get) => ({ readFlowsFromDatabase() .then((dbData) => { if (dbData) { - const { data, flows } = processFlows(dbData, false); + const { data, flows } = processFlows(dbData); const examples = flows.filter( (flow) => flow.folder_id === starterFolderId, ); From 5ef79e33fa648c853fc7add55c2af07329203665 Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Mon, 10 Jun 2024 11:35:20 -0300 Subject: [PATCH 6/9] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20(csvOutputComponent):?= =?UTF-8?q?=20replace=20FlowPoolObjectType=20with=20VertexBuildTypeAPI=20f?= =?UTF-8?q?or=20type=20consistency=20=F0=9F=92=A1=20(IOFieldView):=20updat?= =?UTF-8?q?e=20console.log=20to=20provide=20more=20detailed=20flowPool=20n?= =?UTF-8?q?ode=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/src/components/csvOutputComponent/index.tsx | 6 +++--- .../src/modals/IOModal/components/IOFieldView/index.tsx | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/frontend/src/components/csvOutputComponent/index.tsx b/src/frontend/src/components/csvOutputComponent/index.tsx index b6f5be515..1d4e342de 100644 --- a/src/frontend/src/components/csvOutputComponent/index.tsx +++ b/src/frontend/src/components/csvOutputComponent/index.tsx @@ -7,7 +7,7 @@ import { CSVViewErrorTitle, } from "../../constants/constants"; import { useDarkStore } from "../../stores/darkStore"; -import { FlowPoolObjectType } from "../../types/chat"; +import { VertexBuildTypeAPI } from "../../types/api"; import { NodeType } from "../../types/flow"; import ForwardedIconComponent from "../genericIconComponent"; import TableComponent from "../tableComponent"; @@ -19,7 +19,7 @@ function CsvOutputComponent({ flowPool, }: { csvNode: NodeType; - flowPool: FlowPoolObjectType; + flowPool: VertexBuildTypeAPI; }) { const csvNodeArtifacts = flowPool?.data?.artifacts?.repr; const jsonString = csvNodeArtifacts?.replace(/'/g, '"'); @@ -67,7 +67,7 @@ function CsvOutputComponent({ if (file) { const { rowData: data, colDefs: columns } = convertCSVToData( file, - separator, + separator ); setRowData(data); setColDefs(columns); diff --git a/src/frontend/src/modals/IOModal/components/IOFieldView/index.tsx b/src/frontend/src/modals/IOModal/components/IOFieldView/index.tsx index e841797be..20cf9f691 100644 --- a/src/frontend/src/modals/IOModal/components/IOFieldView/index.tsx +++ b/src/frontend/src/modals/IOModal/components/IOFieldView/index.tsx @@ -49,7 +49,9 @@ export default function IOFieldView({ (flowPool[node!.id] ?? [])[(flowPool[node!.id]?.length ?? 1) - 1]?.data .results.result ?? ""; - console.log(flowPoolNode?.data?.artifacts?.records); + console.log( + (flowPool[node!.id] ?? [])[(flowPool[node!.id]?.length ?? 1) - 1]?.data + ); function handleOutputType() { if (!node) return <>"No node found!"; From 92b398d29b78dfe9c1f3dda399dddafabb9d506b Mon Sep 17 00:00:00 2001 From: igorrCarvalho Date: Mon, 10 Jun 2024 11:35:40 -0300 Subject: [PATCH 7/9] Refactor: block non supported file types --- .../chatView/chatInput/hooks/use-drag-and-drop.tsx | 4 ++-- .../chatInput/hooks/use-handle-file-change.tsx | 4 ++-- .../chatView/chatInput/hooks/use-upload.tsx | 11 ++--------- .../components/chatView/fileComponent/index.tsx | 2 ++ 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/frontend/src/modals/IOModal/components/chatView/chatInput/hooks/use-drag-and-drop.tsx b/src/frontend/src/modals/IOModal/components/chatView/chatInput/hooks/use-drag-and-drop.tsx index b9f1e2635..7abc8d6e3 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/chatInput/hooks/use-drag-and-drop.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/chatInput/hooks/use-drag-and-drop.tsx @@ -4,7 +4,7 @@ import useAlertStore from "../../../../../../stores/alertStore"; const fsErrorText = "Please ensure your file has one of the following extensions:"; -const snErrorTxt = "png, jpg, jpeg, gif, bmp, webp"; +const snErrorTxt = "png, jpg, jpeg"; const useDragAndDrop = ( setIsDragging, @@ -49,7 +49,7 @@ const useDragAndDrop = ( const handleFiles = (files, setFiles, currentFlowId, setErrorData) => { if (files) { - const allowedExtensions = ["png", "jpg", "jpeg", "gif", "bmp", "webp"]; + const allowedExtensions = ["png", "jpg", "jpeg"]; const file = files?.[0]; const fileExtension = file.name.split(".").pop()?.toLowerCase(); if (!fileExtension || !allowedExtensions.includes(fileExtension)) { diff --git a/src/frontend/src/modals/IOModal/components/chatView/chatInput/hooks/use-handle-file-change.tsx b/src/frontend/src/modals/IOModal/components/chatView/chatInput/hooks/use-handle-file-change.tsx index 6e16587f2..796f99c75 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/chatInput/hooks/use-handle-file-change.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/chatInput/hooks/use-handle-file-change.tsx @@ -4,7 +4,7 @@ import useAlertStore from "../../../../../../stores/alertStore"; const fsErrorText = "Please ensure your file has one of the following extensions:"; -const snErrorTxt = "png, jpg, jpeg, gif, bmp, webp"; +const snErrorTxt = "png, jpg, jpeg"; export const useHandleFileChange = (setFiles, currentFlowId) => { const setErrorData = useAlertStore((state) => state.setErrorData); @@ -14,7 +14,7 @@ export const useHandleFileChange = (setFiles, currentFlowId) => { const fileInput = event.target; const file = fileInput.files?.[0]; if (file) { - const allowedExtensions = ["png", "jpg", "jpeg", "gif", "bmp", "webp"]; + const allowedExtensions = ["png", "jpg", "jpeg"]; const fileExtension = file.name.split(".").pop()?.toLowerCase(); if (!fileExtension || !allowedExtensions.includes(fileExtension)) { diff --git a/src/frontend/src/modals/IOModal/components/chatView/chatInput/hooks/use-upload.tsx b/src/frontend/src/modals/IOModal/components/chatView/chatInput/hooks/use-upload.tsx index f41cada11..a45fd171f 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/chatInput/hooks/use-upload.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/chatInput/hooks/use-upload.tsx @@ -5,7 +5,7 @@ import useAlertStore from "../../../../../../stores/alertStore"; const fsErrorText = "Please ensure your file has one of the following extensions:"; -const snErrorTxt = "png, jpg, jpeg, gif, bmp, webp"; +const snErrorTxt = "png, jpg, jpeg"; const useUpload = (uploadFile, currentFlowId, setFiles, lockChat) => { const setErrorData = useAlertStore((state) => state.setErrorData); @@ -21,14 +21,7 @@ const useUpload = (uploadFile, currentFlowId, setFiles, lockChat) => { const uid = new ShortUniqueId({ length: 3 }); const blob = items[i].getAsFile(); if (blob) { - const allowedExtensions = [ - "png", - "jpg", - "jpeg", - "gif", - "bmp", - "webp", - ]; + const allowedExtensions = ["png", "jpg", "jpeg"]; const fileExtension = blob.name.split(".").pop()?.toLowerCase(); if (!fileExtension || !allowedExtensions.includes(fileExtension)) { diff --git a/src/frontend/src/modals/IOModal/components/chatView/fileComponent/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/fileComponent/index.tsx index b62e0f763..a034b1c40 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/fileComponent/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/fileComponent/index.tsx @@ -32,6 +32,8 @@ export default function FileCard({ BACKEND_URL.length - 1, )}${BASE_URL_API}files/images/${content}`; + console.log(imgSrc); + if (showFile) { if (imgTypes.has(fileType)) { return ( From 7557c7979c2366f3ba53b8406557e73bf5da72b6 Mon Sep 17 00:00:00 2001 From: ogabrielluiz Date: Mon, 10 Jun 2024 12:02:53 -0300 Subject: [PATCH 8/9] refactor: add utility function for converting chroma collection to records --- .../langflow/base/vectorstores/__init__.py | 0 .../base/langflow/base/vectorstores/utils.py | 24 +++++++++++++++++++ .../components/vectorstores/Chroma.py | 5 +++- 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/backend/base/langflow/base/vectorstores/__init__.py create mode 100644 src/backend/base/langflow/base/vectorstores/utils.py diff --git a/src/backend/base/langflow/base/vectorstores/__init__.py b/src/backend/base/langflow/base/vectorstores/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/backend/base/langflow/base/vectorstores/utils.py b/src/backend/base/langflow/base/vectorstores/utils.py new file mode 100644 index 000000000..e8d93ff37 --- /dev/null +++ b/src/backend/base/langflow/base/vectorstores/utils.py @@ -0,0 +1,24 @@ +from langflow.schema import Record + + +def chroma_collection_to_records(collection_dict: dict): + """ + Converts a collection of chroma vectors into a list of records. + + Args: + collection_dict (dict): A dictionary containing the collection of chroma vectors. + + Returns: + list: A list of records, where each record represents a document in the collection. + """ + records = [] + for i, doc in enumerate(collection_dict["documents"]): + record_dict = { + "id": collection_dict["ids"][i], + "document": doc, + } + if "metadatas" in collection_dict: + for key, value in collection_dict["metadatas"][i].items(): + record_dict[key] = value + records.append(Record(**record_dict)) + return records diff --git a/src/backend/base/langflow/components/vectorstores/Chroma.py b/src/backend/base/langflow/components/vectorstores/Chroma.py index 5742aad7b..b7cfad7d4 100644 --- a/src/backend/base/langflow/components/vectorstores/Chroma.py +++ b/src/backend/base/langflow/components/vectorstores/Chroma.py @@ -6,7 +6,7 @@ from langchain_chroma import Chroma from langchain_core.embeddings import Embeddings from langchain_core.retrievers import BaseRetriever from langchain_core.vectorstores import VectorStore - +from langflow.base.vectorstores.utils import chroma_collection_to_records from langflow.custom import CustomComponent from langflow.schema import Record @@ -121,4 +121,7 @@ class ChromaComponent(CustomComponent): client=client, embedding_function=embedding, ) + + store = chroma.get() + self.status = chroma_collection_to_records(store) return chroma From 119bd7397d01ee17a348f3c279d8288c369d607e Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Mon, 10 Jun 2024 12:05:45 -0300 Subject: [PATCH 9/9] =?UTF-8?q?=E2=9C=85=20(actionsMainPage.spec.ts):=20ad?= =?UTF-8?q?d=20steps=20to=20click=20'more-options-modal'=20in=20end-to-end?= =?UTF-8?q?=20tests=20to=20ensure=20modal=20interactions=20are=20tested?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/tests/end-to-end/actionsMainPage.spec.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/frontend/tests/end-to-end/actionsMainPage.spec.ts b/src/frontend/tests/end-to-end/actionsMainPage.spec.ts index 916d09718..e2635cf57 100644 --- a/src/frontend/tests/end-to-end/actionsMainPage.spec.ts +++ b/src/frontend/tests/end-to-end/actionsMainPage.spec.ts @@ -90,6 +90,8 @@ test("search components", async ({ page }) => { await page.getByRole("heading", { name: "Basic Prompting" }).click(); await page.getByText("Chat Input").first().click(); + await page.getByTestId("more-options-modal").click(); + await page.getByTestId("icon-SaveAll").first().click(); await page.keyboard.press("Escape"); await page @@ -98,6 +100,8 @@ test("search components", async ({ page }) => { }) .first() .click(); + await page.getByTestId("more-options-modal").click(); + await page.getByTestId("icon-SaveAll").first().click(); await page.keyboard.press("Escape"); @@ -107,6 +111,8 @@ test("search components", async ({ page }) => { }) .first() .click(); + await page.getByTestId("more-options-modal").click(); + await page.getByTestId("icon-SaveAll").first().click(); await page.keyboard.press("Escape"); await page.getByTestId("icon-ChevronLeft").first().click();