, data) {
event.dataTransfer.effectAllowed = "move";
- if (nodeType === "promptNode") {
- json = JSON.stringify(prompt);
- }
- if (nodeType === "modelNode") {
- json = JSON.stringify(llm_chain);
- }
- if (nodeType === "chainNode") {
- json = JSON.stringify({ content: "" });
- }
- if (nodeType === "agentNode") {
- json = JSON.stringify({ content: "" });
- }
- if (nodeType === "toolNode") {
- json = JSON.stringify({ content: "" });
- }
- if (nodeType === "memoryNode") {
- json = JSON.stringify({ content: "" });
- }
- event.dataTransfer.setData("json", json);
+ event.dataTransfer.setData("json", JSON.stringify(data));
}
return (
@@ -51,7 +31,7 @@ export default function ExtraSidebar() {
draggable
className={" cursor-grab border-l-8 rounded-l-md"}
style={{ borderLeftColor: nodeColors[d] }}
- onDragStart={(event) => onDragStart(event, "promptNode")}
+ onDragStart={(event) => onDragStart(event, {type: d, name:t, node: data[d][t]})}
>
{t}
diff --git a/space_flow/src/pages/FlowPage/index.tsx b/space_flow/src/pages/FlowPage/index.tsx
index 97a5cbf69..bfbc8f413 100644
--- a/space_flow/src/pages/FlowPage/index.tsx
+++ b/space_flow/src/pages/FlowPage/index.tsx
@@ -18,6 +18,7 @@ import axios from "axios";
import { generateUiNode } from "../../controllers/UiGenerator";
import Chat from "../../components/chatComponent";
import { getAll } from "../../controllers/NodesServices";
+import GenericNode from "../../CustomNodes/GenericNode";
const nodeTypes = {
promptNode: PromptNode,
@@ -25,7 +26,8 @@ const nodeTypes = {
chainNode: ChainNode,
agentNode: AgentNode,
toolNode: ToolsNode,
- memoryNode:MemoryNode
+ memoryNode:MemoryNode,
+ genericNode:GenericNode,
};
export default function FlowPage() {
@@ -72,12 +74,8 @@ export default function FlowPage() {
event.preventDefault();
const reactflowBounds = reactFlowWrapper.current.getBoundingClientRect();
- const type = event.dataTransfer.getData("application/reactflow");
let data = JSON.parse(event.dataTransfer.getData("json"));
// check if the dropped element is valid
- if (typeof type === "undefined" || !type) {
- return;
- }
const position = reactFlowInstance.project({
x: event.clientX - reactflowBounds.left,
@@ -85,9 +83,9 @@ export default function FlowPage() {
});
const newNode = {
id: getId(),
- type,
+ type: 'genericNode',
position,
- data: { ...data, delete: () => console.log("asdsdsadad") },
+ data: { ...data, onDelete: () => console.log("asdsdsadad"), onRun: () => {} },
};
setNodes((nds) => nds.concat(newNode));
},