parent
e10c4ee4cd
commit
f94e81f48b
|
@ -34,8 +34,8 @@ type CustomNodeData = {
|
|||
block_id: string;
|
||||
};
|
||||
|
||||
const Sidebar: React.FC<{isOpen: boolean, availableNodes: Block[], addNode: (id: string, name: string) => void}> =
|
||||
({isOpen, availableNodes, addNode}) => {
|
||||
const Sidebar: React.FC<{ isOpen: boolean, availableNodes: Block[], addNode: (id: string, name: string) => void }> =
|
||||
({ isOpen, availableNodes, addNode }) => {
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
|
||||
if (!isOpen) return null;
|
||||
|
@ -61,7 +61,7 @@ const Sidebar: React.FC<{isOpen: boolean, availableNodes: Block[], addNode: (id:
|
|||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
const FlowEditor: React.FC<{ flowID?: string; className?: string }> = ({
|
||||
flowID,
|
||||
|
@ -261,8 +261,7 @@ const FlowEditor: React.FC<{ flowID?: string; className?: string }> = ({
|
|||
return inputData;
|
||||
};
|
||||
|
||||
|
||||
const runAgent = async () => {
|
||||
const saveAgent = async () => {
|
||||
try {
|
||||
console.log("All nodes before formatting:", nodes);
|
||||
const blockIdToNodeIdMap = {};
|
||||
|
@ -326,6 +325,20 @@ const FlowEditor: React.FC<{ flowID?: string; className?: string }> = ({
|
|||
|
||||
setNodes(updatedNodes);
|
||||
|
||||
return newAgentId;
|
||||
} catch (error) {
|
||||
console.error('Error running agent:', error);
|
||||
}
|
||||
};
|
||||
|
||||
const runAgent = async () => {
|
||||
try {
|
||||
const newAgentId = await saveAgent();
|
||||
if (!newAgentId) {
|
||||
console.error('Error saving agent');
|
||||
return;
|
||||
}
|
||||
|
||||
const executeData = await api.executeFlow(newAgentId);
|
||||
const runId = executeData.id;
|
||||
|
||||
|
@ -348,7 +361,7 @@ const FlowEditor: React.FC<{ flowID?: string; className?: string }> = ({
|
|||
};
|
||||
|
||||
|
||||
const updateNodesWithExecutionData = (executionData: any[]) => {
|
||||
const updateNodesWithExecutionData = (executionData: any[]) => {
|
||||
setNodes((nds) =>
|
||||
nds.map((node) => {
|
||||
const nodeExecution = executionData.find((exec) => exec.node_id === node.id);
|
||||
|
@ -366,7 +379,7 @@ const updateNodesWithExecutionData = (executionData: any[]) => {
|
|||
return node;
|
||||
})
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
const toggleSidebar = () => setIsSidebarOpen(!isSidebarOpen);
|
||||
|
||||
|
@ -406,7 +419,10 @@ const updateNodesWithExecutionData = (executionData: any[]) => {
|
|||
value={agentDescription}
|
||||
onChange={(e) => setAgentDescription(e.target.value)}
|
||||
/>
|
||||
<Button onClick={runAgent}>Run Agent</Button>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '10px' }}> {/* Added gap for spacing */}
|
||||
<Button onClick={saveAgent}>Save Agent</Button>
|
||||
<Button onClick={runAgent}>Save & Run Agent</Button>
|
||||
</div>
|
||||
</div>
|
||||
</ReactFlow>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue