Merge remote-tracking branch 'origin/cz/mergeAll' into fix/minor_ui_adjustments

This commit is contained in:
Lucas Oliveira 2024-06-10 12:10:53 -03:00
commit 4552fdcb53
15 changed files with 57 additions and 26 deletions

View file

@ -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:

View file

@ -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

View file

@ -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

View file

@ -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}"

View file

@ -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, '"');

View file

@ -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!"</>;

View file

@ -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 (
<button
<Button
className={classNames(
"form-modal-send-button",
noInput
@ -32,6 +33,8 @@ const ButtonSendWrapper = ({
)}
disabled={lockChat || saveLoading}
onClick={(): void => send()}
variant="none"
size="none"
>
<Case
condition={
@ -45,7 +48,7 @@ const ButtonSendWrapper = ({
/>
</Case>
<Case condition={noInput}>
<Case condition={noInput && !lockChat}>
<IconComponent
name="Zap"
className="form-modal-play-icon"
@ -65,7 +68,7 @@ const ButtonSendWrapper = ({
aria-hidden="true"
/>
</Case>
</button>
</Button>
);
};

View file

@ -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)) {

View file

@ -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)) {

View file

@ -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)) {

View file

@ -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 (

View file

@ -380,7 +380,7 @@ export default function IOModal({
</div>
</ShadTooltip>
</Button>
<div>
{/* <div>
<ShadTooltip
styleClasses="z-50"
content={
@ -404,7 +404,7 @@ export default function IOModal({
)}
></div>
</ShadTooltip>
</div>
</div> */}
</div>
</div>
</div>

View file

@ -85,7 +85,7 @@ const useFlowsManagerStore = create<FlowsManagerStoreType>((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,
);

View file

@ -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();