+
setIsTweakPage(true)}
+ >
{
saveFlow(flow!);
- setSuccessData({ title: "Changes saved successfully" });
}}
>
void;
data: APIDataType;
setData: (newState: {}) => void;
+ fetchError: boolean;
+ setFetchError: (newState: boolean) => void;
};
export type alertContextType = {
@@ -39,6 +41,8 @@ export type alertContextType = {
removeFromNotificationList: (index: string) => void;
loading: boolean;
setLoading: (newState: boolean) => void;
+ isTweakPage: boolean;
+ setIsTweakPage: (newState: boolean) => void;
};
export type darkContextType = {
diff --git a/src/frontend/src/types/utils/reactflowUtils.ts b/src/frontend/src/types/utils/reactflowUtils.ts
index ecbbda4e4..9944fdba4 100644
--- a/src/frontend/src/types/utils/reactflowUtils.ts
+++ b/src/frontend/src/types/utils/reactflowUtils.ts
@@ -1,4 +1,4 @@
-import { Edge } from "reactflow";
+import { Edge, Node } from "reactflow";
import { NodeType } from "../flow";
export type cleanEdgesType = {
@@ -8,3 +8,8 @@ export type cleanEdgesType = {
};
updateEdge: (edge: Edge[]) => void;
};
+
+export type unselectAllNodesType = {
+ updateNodes: (nodes: Node[]) => void;
+ data: Node[] | null;
+};
diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts
index 13c3973f1..87971ef9b 100644
--- a/src/frontend/src/utils/reactflowUtils.ts
+++ b/src/frontend/src/utils/reactflowUtils.ts
@@ -2,13 +2,17 @@ import _ from "lodash";
import {
Connection,
Edge,
+ Node,
ReactFlowInstance,
ReactFlowJsonObject,
} from "reactflow";
import { specialCharsRegex } from "../constants/constants";
import { APITemplateType } from "../types/api";
import { FlowType, NodeType } from "../types/flow";
-import { cleanEdgesType } from "../types/utils/reactflowUtils";
+import {
+ cleanEdgesType,
+ unselectAllNodesType,
+} from "../types/utils/reactflowUtils";
import { toNormalCase } from "./utils";
export function cleanEdges({
@@ -55,6 +59,14 @@ export function cleanEdges({
updateEdge(newEdges);
}
+export function unselectAllNodes({ updateNodes, data }: unselectAllNodesType) {
+ let newNodes = _.cloneDeep(data);
+ newNodes!.forEach((node: Node) => {
+ node.selected = false;
+ });
+ updateNodes(newNodes!);
+}
+
export function isValidConnection(
{ source, target, sourceHandle, targetHandle }: Connection,
reactFlowInstance: ReactFlowInstance
@@ -247,7 +259,6 @@ export function handleKeyDown(
inputValue: string | string[] | null,
block: string
) {
- console.log(e, inputValue, block);
//condition to fix bug control+backspace on Windows/Linux
if (
(typeof inputValue === "string" &&
diff --git a/src/frontend/src/utils/styleUtils.ts b/src/frontend/src/utils/styleUtils.ts
index f52cb7aec..31a7adf7e 100644
--- a/src/frontend/src/utils/styleUtils.ts
+++ b/src/frontend/src/utils/styleUtils.ts
@@ -62,6 +62,7 @@ import {
TerminalSquare,
Trash2,
Undo,
+ Unplug,
Upload,
UserCog2,
UserMinus2,
@@ -297,5 +298,6 @@ export const nodeIconsLucide: iconsType = {
EyeOff,
Eye,
UserCog2,
- Key
+ Key,
+ Unplug,
};
diff --git a/tests/test_cache.py b/tests/test_cache.py
index 50698c304..edf205a05 100644
--- a/tests/test_cache.py
+++ b/tests/test_cache.py
@@ -1,4 +1,6 @@
import json
+from langflow.services.database.models.base import orjson_dumps
+import orjson
from langflow.graph import Graph
import pytest
@@ -63,9 +65,9 @@ def test_cache_size_limit(basic_data_graph):
nodes = modified_data_graph["nodes"]
node_id = nodes[0]["id"]
# Now we replace all instances ode node_id with a new id in the json
- json_string = json.dumps(modified_data_graph)
+ json_string = orjson_dumps(modified_data_graph)
modified_json_string = json_string.replace(node_id, f"{node_id}_{i}")
- modified_data_graph_new_id = json.loads(modified_json_string)
+ modified_data_graph_new_id = orjson.loads(modified_json_string)
build_langchain_object_with_caching(modified_data_graph_new_id)
assert len(build_langchain_object_with_caching.cache) == 10
diff --git a/tests/test_database.py b/tests/test_database.py
index 52a5daa4c..6976f963a 100644
--- a/tests/test_database.py
+++ b/tests/test_database.py
@@ -1,4 +1,5 @@
-import json
+from langflow.services.database.models.base import orjson_dumps
+import orjson
import pytest
from uuid import UUID, uuid4
@@ -16,7 +17,7 @@ def json_style():
# color: str = Field(index=True)
# emoji: str = Field(index=False)
# flow_id: UUID = Field(default=None, foreign_key="flow.id")
- return json.dumps(
+ return orjson_dumps(
{
"color": "red",
"emoji": "👍",
@@ -25,7 +26,7 @@ def json_style():
def test_create_flow(client: TestClient, json_flow: str):
- flow = json.loads(json_flow)
+ flow = orjson.loads(json_flow)
data = flow["data"]
flow = FlowCreate(name="Test Flow", description="description", data=data)
response = client.post("api/v1/flows/", json=flow.dict())
@@ -41,7 +42,7 @@ def test_create_flow(client: TestClient, json_flow: str):
def test_read_flows(client: TestClient, json_flow: str):
- flow_data = json.loads(json_flow)
+ flow_data = orjson.loads(json_flow)
data = flow_data["data"]
flow = FlowCreate(name="Test Flow", description="description", data=data)
response = client.post("api/v1/flows/", json=flow.dict())
@@ -61,7 +62,7 @@ def test_read_flows(client: TestClient, json_flow: str):
def test_read_flow(client: TestClient, json_flow: str):
- flow = json.loads(json_flow)
+ flow = orjson.loads(json_flow)
data = flow["data"]
flow = FlowCreate(name="Test Flow", description="description", data=data)
response = client.post("api/v1/flows/", json=flow.dict())
@@ -76,7 +77,7 @@ def test_read_flow(client: TestClient, json_flow: str):
def test_update_flow(client: TestClient, json_flow: str):
- flow = json.loads(json_flow)
+ flow = orjson.loads(json_flow)
data = flow["data"]
flow = FlowCreate(name="Test Flow", description="description", data=data)
@@ -97,7 +98,7 @@ def test_update_flow(client: TestClient, json_flow: str):
def test_delete_flow(client: TestClient, json_flow: str):
- flow = json.loads(json_flow)
+ flow = orjson.loads(json_flow)
data = flow["data"]
flow = FlowCreate(name="Test Flow", description="description", data=data)
response = client.post("api/v1/flows/", json=flow.dict())
@@ -108,7 +109,7 @@ def test_delete_flow(client: TestClient, json_flow: str):
def test_create_flows(client: TestClient, session: Session, json_flow: str):
- flow = json.loads(json_flow)
+ flow = orjson.loads(json_flow)
data = flow["data"]
# Create test data
flow_list = FlowListCreate(
@@ -133,7 +134,7 @@ def test_create_flows(client: TestClient, session: Session, json_flow: str):
def test_upload_file(client: TestClient, session: Session, json_flow: str):
- flow = json.loads(json_flow)
+ flow = orjson.loads(json_flow)
data = flow["data"]
# Create test data
flow_list = FlowListCreate(
@@ -142,7 +143,7 @@ def test_upload_file(client: TestClient, session: Session, json_flow: str):
FlowCreate(name="Flow 2", description="description", data=data),
]
)
- file_contents = json.dumps(flow_list.dict())
+ file_contents = orjson_dumps(flow_list.dict())
response = client.post(
"api/v1/flows/upload/",
files={"file": ("examples.json", file_contents, "application/json")},
@@ -161,7 +162,7 @@ def test_upload_file(client: TestClient, session: Session, json_flow: str):
def test_download_file(client: TestClient, session: Session, json_flow):
- flow = json.loads(json_flow)
+ flow = orjson.loads(json_flow)
data = flow["data"]
# Create test data
flow_list = FlowListCreate(
@@ -202,7 +203,7 @@ def test_get_nonexistent_flow(client: TestClient):
def test_update_flow_idempotency(client: TestClient, json_flow: str):
- flow_data = json.loads(json_flow)
+ flow_data = orjson.loads(json_flow)
data = flow_data["data"]
flow_data = FlowCreate(name="Test Flow", description="description", data=data)
response = client.post("api/v1/flows/", json=flow_data.dict())
@@ -214,7 +215,7 @@ def test_update_flow_idempotency(client: TestClient, json_flow: str):
def test_update_nonexistent_flow(client: TestClient, json_flow: str):
- flow_data = json.loads(json_flow)
+ flow_data = orjson.loads(json_flow)
data = flow_data["data"]
uuid = uuid4()
updated_flow = FlowCreate(
diff --git a/tests/test_loading.py b/tests/test_loading.py
index 11fa8e471..e5c409c93 100644
--- a/tests/test_loading.py
+++ b/tests/test_loading.py
@@ -1,5 +1,4 @@
import json
-
import pytest
from langchain.chains.base import Chain
from langflow.processing.process import load_flow_from_json