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: 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 294f9c645..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 @@ -123,6 +123,5 @@ class ChromaComponent(CustomComponent): ) store = chroma.get() - self.status = store - + self.status = chroma_collection_to_records(store) return chroma 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}" diff --git a/src/frontend/src/components/csvOutputComponent/index.tsx b/src/frontend/src/components/csvOutputComponent/index.tsx index b6f5be515..0b9a9d76e 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, '"'); diff --git a/src/frontend/src/modals/IOModal/components/IOFieldView/index.tsx b/src/frontend/src/modals/IOModal/components/IOFieldView/index.tsx index e841797be..7b1fba1ca 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!">; 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 ( - + ); }; 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 ( diff --git a/src/frontend/src/modals/IOModal/index.tsx b/src/frontend/src/modals/IOModal/index.tsx index 4bfb42025..9a3674780 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({ -