Spaces:
Running
Running
Update process_flow_generator.py
Browse files
process_flow_generator.py
CHANGED
|
@@ -90,11 +90,9 @@ def generate_process_flow_diagram(json_input: str, output_format: str) -> str:
|
|
| 90 |
|
| 91 |
data = json.loads(json_input)
|
| 92 |
|
| 93 |
-
# Validate required top-level keys for a flowchart
|
| 94 |
if 'start_node' not in data or 'nodes' not in data or 'connections' not in data:
|
| 95 |
raise ValueError("Missing required fields: 'start_node', 'nodes', or 'connections'")
|
| 96 |
|
| 97 |
-
# Define specific node shapes for flowchart types
|
| 98 |
node_shapes = {
|
| 99 |
"process": "box", # Rectangle for processes
|
| 100 |
"decision": "diamond", # Diamond for decisions
|
|
@@ -118,15 +116,13 @@ def generate_process_flow_diagram(json_input: str, output_format: str) -> str:
|
|
| 118 |
}
|
| 119 |
)
|
| 120 |
|
| 121 |
-
base_color = '#19191a'
|
| 122 |
|
| 123 |
fill_color_for_nodes = base_color
|
| 124 |
font_color_for_nodes = 'white' if base_color == '#19191a' or base_color.lower() in ['#000000', '#19191a'] else 'black'
|
| 125 |
|
| 126 |
-
# Store all nodes by ID for easy lookup
|
| 127 |
all_defined_nodes = {node['id']: node for node in data['nodes']}
|
| 128 |
|
| 129 |
-
# Add start node explicitly
|
| 130 |
start_node_id = data['start_node']
|
| 131 |
dot.node(
|
| 132 |
start_node_id,
|
|
@@ -138,7 +134,6 @@ def generate_process_flow_diagram(json_input: str, output_format: str) -> str:
|
|
| 138 |
fontsize='14'
|
| 139 |
)
|
| 140 |
|
| 141 |
-
# Add all other nodes (process, decision, etc.)
|
| 142 |
for node_id, node_info in all_defined_nodes.items():
|
| 143 |
if node_id == start_node_id: # Skip if it's the start node, already added
|
| 144 |
continue
|
|
|
|
| 90 |
|
| 91 |
data = json.loads(json_input)
|
| 92 |
|
|
|
|
| 93 |
if 'start_node' not in data or 'nodes' not in data or 'connections' not in data:
|
| 94 |
raise ValueError("Missing required fields: 'start_node', 'nodes', or 'connections'")
|
| 95 |
|
|
|
|
| 96 |
node_shapes = {
|
| 97 |
"process": "box", # Rectangle for processes
|
| 98 |
"decision": "diamond", # Diamond for decisions
|
|
|
|
| 116 |
}
|
| 117 |
)
|
| 118 |
|
| 119 |
+
base_color = '#19191a'
|
| 120 |
|
| 121 |
fill_color_for_nodes = base_color
|
| 122 |
font_color_for_nodes = 'white' if base_color == '#19191a' or base_color.lower() in ['#000000', '#19191a'] else 'black'
|
| 123 |
|
|
|
|
| 124 |
all_defined_nodes = {node['id']: node for node in data['nodes']}
|
| 125 |
|
|
|
|
| 126 |
start_node_id = data['start_node']
|
| 127 |
dot.node(
|
| 128 |
start_node_id,
|
|
|
|
| 134 |
fontsize='14'
|
| 135 |
)
|
| 136 |
|
|
|
|
| 137 |
for node_id, node_info in all_defined_nodes.items():
|
| 138 |
if node_id == start_node_id: # Skip if it's the start node, already added
|
| 139 |
continue
|