added warning message for running with missing text input

this is because if a node is missing a hardcoded input the backend has an error, this is to prevent that
This commit is contained in:
Bentlybro
2024-06-28 12:25:45 +01:00
parent dd8a6f9793
commit ce5a89b1c0

View File

@@ -266,6 +266,22 @@ const Flow: React.FC = () => {
);
};
const validateNodeInputs = (nodes: Node[], edges: Edge[]): boolean => {
for (const node of nodes) {
const nodeSchema = availableNodes.find(n => n.id === node.data.block_id);
if (nodeSchema && nodeSchema.inputSchema) {
const inputProperties = nodeSchema.inputSchema.properties;
for (const prop of Object.keys(inputProperties)) {
const inputEdges = edges.filter(edge => edge.target === node.id && edge.targetHandle === prop);
if (inputEdges.length === 0 && !node.data.hardcodedValues[prop]) {
return false;
}
}
}
}
return true;
};
const runAgent = async () => {
if (nodes.length === 0) {
setFlashMessage("Please add nodes before pressing run");
@@ -273,6 +289,12 @@ const Flow: React.FC = () => {
return;
}
if (!validateNodeInputs(nodes, edges)) {
setFlashMessage("Please make sure you have added values to all inputs");
setTimeout(() => setFlashMessage(null), 3000); // Ensure the flash message disappears after 3 seconds
return;
}
try {
const formattedNodes = nodes.map(node => {
const inputDefault = prepareNodeInputData(node, nodes, edges);