Input types working with the handles
This commit is contained in:
parent
3f7fb8a1b4
commit
29dbc3ff31
5 changed files with 20 additions and 29 deletions
|
|
@ -9,7 +9,8 @@ export default function ChatInputNode({ data }) {
|
||||||
<Handle
|
<Handle
|
||||||
type="target"
|
type="target"
|
||||||
position={Position.Right}
|
position={Position.Right}
|
||||||
id="b"
|
id={data.name}
|
||||||
|
isValidConnection={({sourceHandle, targetHandle}) => (targetHandle === sourceHandle || data.types[targetHandle] === sourceHandle || sourceHandle === 'str')}
|
||||||
className="-mr-1 bg-transparent border-solid border-l-8 border-l-blue-600 border-y-transparent border-y-8 border-r-0 rounded-none"
|
className="-mr-1 bg-transparent border-solid border-l-8 border-l-blue-600 border-y-transparent border-y-8 border-r-0 rounded-none"
|
||||||
></Handle>
|
></Handle>
|
||||||
<div className="flex gap-3 text-lg font-medium text-white items-center">
|
<div className="flex gap-3 text-lg font-medium text-white items-center">
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,9 @@ export default function ChatOutputNode({ data }) {
|
||||||
<div className="prompt-node relative rounded-lg solid border flex justify-center align-center py-3 px-6 bg-blue-600">
|
<div className="prompt-node relative rounded-lg solid border flex justify-center align-center py-3 px-6 bg-blue-600">
|
||||||
<Handle
|
<Handle
|
||||||
type="source"
|
type="source"
|
||||||
|
isConnectable={false}
|
||||||
position={Position.Left}
|
position={Position.Left}
|
||||||
id="b"
|
id="str"
|
||||||
className="ml-1 bg-transparent border-solid border-l-8 border-l-white border-y-transparent border-y-8 border-r-0 rounded-none"
|
className="ml-1 bg-transparent border-solid border-l-8 border-l-white border-y-transparent border-y-8 border-r-0 rounded-none"
|
||||||
></Handle>
|
></Handle>
|
||||||
<div className="flex gap-3 text-lg font-medium text-white items-center">
|
<div className="flex gap-3 text-lg font-medium text-white items-center">
|
||||||
|
|
|
||||||
|
|
@ -13,16 +13,6 @@ export default function GenericNode({ data }) {
|
||||||
const Icon = nodeIcons[data.type];
|
const Icon = nodeIcons[data.type];
|
||||||
return (
|
return (
|
||||||
<div className="prompt-node relative bg-white w-96 rounded-lg solid border flex flex-col justify-center">
|
<div className="prompt-node relative bg-white w-96 rounded-lg solid border flex flex-col justify-center">
|
||||||
<Tooltip title="teste">
|
|
||||||
<Handle
|
|
||||||
type="source"
|
|
||||||
position={Position.Left}
|
|
||||||
id="b"
|
|
||||||
isConnectable={false}
|
|
||||||
className="ml-1 bg-transparent border-solid border-l-8 border-y-transparent border-y-8 border-r-0 rounded-none"
|
|
||||||
style={{borderLeftColor: nodeColors[data.type]}}
|
|
||||||
></Handle>
|
|
||||||
</Tooltip>
|
|
||||||
<div className="w-full flex items-center justify-between p-4 bg-gray-50 border-b ">
|
<div className="w-full flex items-center justify-between p-4 bg-gray-50 border-b ">
|
||||||
<div className="flex items-center gap-4 text-lg">
|
<div className="flex items-center gap-4 text-lg">
|
||||||
<Icon
|
<Icon
|
||||||
|
|
@ -39,18 +29,15 @@ export default function GenericNode({ data }) {
|
||||||
</div>
|
</div>
|
||||||
{Object.keys(data.node.template).map((t, idx) => (
|
{Object.keys(data.node.template).map((t, idx) => (
|
||||||
<div key={idx} className="w-full mt-5">
|
<div key={idx} className="w-full mt-5">
|
||||||
{data.node.template[t].type === "dropdown" ? (
|
<Tooltip title={t + ": " + data.node.template[t].type}>
|
||||||
<Dropdown
|
<Handle
|
||||||
title={data.node.template[t].title}
|
type="source"
|
||||||
value={data.node.template[t].options[0]}
|
position={Position.Left}
|
||||||
options={data.node.template[t].options}
|
id={data.node.template[t].type}
|
||||||
onSelect={() => {}}
|
className="ml-1 bg-transparent border-solid border-l-8 border-y-transparent border-y-8 border-r-0 rounded-none"
|
||||||
/>
|
style={{borderLeftColor: nodeColors[data.type], marginTop: ((idx*30)-50) + "px"}}
|
||||||
) : data.node.template[t].type === "str" ? (
|
></Handle>
|
||||||
<></>
|
</Tooltip>
|
||||||
) : (
|
|
||||||
<></>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
<div className="w-full mt-5"></div>
|
<div className="w-full mt-5"></div>
|
||||||
|
|
@ -64,7 +51,8 @@ export default function GenericNode({ data }) {
|
||||||
<Handle
|
<Handle
|
||||||
type="target"
|
type="target"
|
||||||
position={Position.Right}
|
position={Position.Right}
|
||||||
id="b"
|
id={data.name}
|
||||||
|
isValidConnection={({sourceHandle, targetHandle}) => (targetHandle === sourceHandle || data.types[targetHandle] === sourceHandle || sourceHandle === 'str')}
|
||||||
className="-mr-1 bg-transparent border-solid border-l-8 border-y-transparent border-y-8 border-r-0 rounded-none"
|
className="-mr-1 bg-transparent border-solid border-l-8 border-y-transparent border-y-8 border-r-0 rounded-none"
|
||||||
style={{borderLeftColor: nodeColors[data.type]}}
|
style={{borderLeftColor: nodeColors[data.type]}}
|
||||||
></Handle>
|
></Handle>
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@ export default function InputNode({ data }) {
|
||||||
<Handle
|
<Handle
|
||||||
type="target"
|
type="target"
|
||||||
position={Position.Right}
|
position={Position.Right}
|
||||||
id="b"
|
id={data.name}
|
||||||
|
isValidConnection={({sourceHandle, targetHandle}) => (targetHandle === sourceHandle || data.types[targetHandle] === sourceHandle || sourceHandle === 'str')}
|
||||||
className="-mr-1 bg-transparent border-solid border-l-8 border-y-transparent border-y-8 border-r-0 rounded-none"
|
className="-mr-1 bg-transparent border-solid border-l-8 border-y-transparent border-y-8 border-r-0 rounded-none"
|
||||||
style={{borderLeftColor: nodeColors[data.type]}}
|
style={{borderLeftColor: nodeColors[data.type]}}
|
||||||
></Handle>
|
></Handle>
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,9 @@ export default function FlowPage() {
|
||||||
const [reactFlowInstance, setReactFlowInstance] = useState(null);
|
const [reactFlowInstance, setReactFlowInstance] = useState(null);
|
||||||
const onConnect = useCallback(
|
const onConnect = useCallback(
|
||||||
(params) => {
|
(params) => {
|
||||||
console.log(params)
|
/* console.log(params)
|
||||||
console.log(reactFlowInstance.getNodes())
|
console.log(reactFlowInstance.getNodes())
|
||||||
console.log(getConnectedNodes(params,reactFlowInstance.getNodes()))
|
console.log(getConnectedNodes(params,reactFlowInstance.getNodes())) */
|
||||||
setEdges((eds) => addEdge({...params}, eds))
|
setEdges((eds) => addEdge({...params}, eds))
|
||||||
},
|
},
|
||||||
[reactFlowInstance]
|
[reactFlowInstance]
|
||||||
|
|
@ -72,7 +72,7 @@ export default function FlowPage() {
|
||||||
id: newId,
|
id: newId,
|
||||||
type: data.name === 'str' ? 'inputNode' : (data.name === 'chatInput' ? 'chatInputNode' : (data.name === 'chatOutput' ? 'chatOutputNode' : 'genericNode')),
|
type: data.name === 'str' ? 'inputNode' : (data.name === 'chatInput' ? 'chatInputNode' : (data.name === 'chatOutput' ? 'chatOutputNode' : 'genericNode')),
|
||||||
position,
|
position,
|
||||||
data: { ...data, onDelete: () => {setNodes(reactFlowInstance.getNodes().filter((n)=>n.id !== newId))} },
|
data: { ...data, instance: reactFlowInstance, onDelete: () => {setNodes(reactFlowInstance.getNodes().filter((n)=>n.id !== newId))} },
|
||||||
};
|
};
|
||||||
setNodes((nds) => nds.concat(newNode));
|
setNodes((nds) => nds.concat(newNode));
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue