Update process_flow_generator.py
Browse files- process_flow_generator.py +65 -19
process_flow_generator.py
CHANGED
|
@@ -15,32 +15,78 @@ def generate_process_flow_diagram(json_input: str) -> str: # Removed base_color
|
|
| 15 |
json_input (str): A JSON string describing the process flow structure.
|
| 16 |
It must follow the Expected JSON Format Example below.
|
| 17 |
|
| 18 |
-
Returns:
|
| 19 |
-
str: The filepath to the generated PNG image file.
|
| 20 |
-
|
| 21 |
Expected JSON Format Example:
|
| 22 |
{
|
| 23 |
-
"start_node": "Start
|
| 24 |
"nodes": [
|
| 25 |
-
{
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
{
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
],
|
| 33 |
"connections": [
|
| 34 |
-
{"from": "start_node", "to": "
|
| 35 |
-
{"from": "
|
| 36 |
-
{"from": "
|
| 37 |
-
{"from": "
|
| 38 |
-
{"from": "
|
| 39 |
-
{"from": "
|
| 40 |
-
{"from": "
|
| 41 |
-
{"from": "
|
|
|
|
|
|
|
|
|
|
| 42 |
]
|
| 43 |
}
|
|
|
|
|
|
|
|
|
|
| 44 |
"""
|
| 45 |
try:
|
| 46 |
if not json_input.strip():
|
|
|
|
| 15 |
json_input (str): A JSON string describing the process flow structure.
|
| 16 |
It must follow the Expected JSON Format Example below.
|
| 17 |
|
|
|
|
|
|
|
|
|
|
| 18 |
Expected JSON Format Example:
|
| 19 |
{
|
| 20 |
+
"start_node": "Start Inference Request",
|
| 21 |
"nodes": [
|
| 22 |
+
{
|
| 23 |
+
"id": "user_input",
|
| 24 |
+
"label": "Receive User Input (Data)",
|
| 25 |
+
"type": "io"
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"id": "preprocess_data",
|
| 29 |
+
"label": "Preprocess Data",
|
| 30 |
+
"type": "process"
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"id": "validate_data",
|
| 34 |
+
"label": "Validate Data Format/Type",
|
| 35 |
+
"type": "decision"
|
| 36 |
+
},
|
| 37 |
+
{
|
| 38 |
+
"id": "data_valid_yes",
|
| 39 |
+
"label": "Data Valid?",
|
| 40 |
+
"type": "decision"
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"id": "load_model",
|
| 44 |
+
"label": "Load AI Model (if not cached)",
|
| 45 |
+
"type": "process"
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"id": "run_inference",
|
| 49 |
+
"label": "Run AI Model Inference",
|
| 50 |
+
"type": "process"
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
"id": "postprocess_output",
|
| 54 |
+
"label": "Postprocess Model Output",
|
| 55 |
+
"type": "process"
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
"id": "send_response",
|
| 59 |
+
"label": "Send Response to User",
|
| 60 |
+
"type": "io"
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"id": "log_error",
|
| 64 |
+
"label": "Log Error & Notify User",
|
| 65 |
+
"type": "process"
|
| 66 |
+
},
|
| 67 |
+
{
|
| 68 |
+
"id": "end_inference_process",
|
| 69 |
+
"label": "End Inference Process",
|
| 70 |
+
"type": "end"
|
| 71 |
+
}
|
| 72 |
],
|
| 73 |
"connections": [
|
| 74 |
+
{"from": "start_node", "to": "user_input", "label": "Request"},
|
| 75 |
+
{"from": "user_input", "to": "preprocess_data", "label": "Data Received"},
|
| 76 |
+
{"from": "preprocess_data", "to": "validate_data", "label": "Cleaned"},
|
| 77 |
+
{"from": "validate_data", "to": "data_valid_yes", "label": "Check"},
|
| 78 |
+
{"from": "data_valid_yes", "to": "load_model", "label": "Yes"},
|
| 79 |
+
{"from": "data_valid_yes", "to": "log_error", "label": "No"},
|
| 80 |
+
{"from": "load_model", "to": "run_inference", "label": "Model Ready"},
|
| 81 |
+
{"from": "run_inference", "to": "postprocess_output", "label": "Output Generated"},
|
| 82 |
+
{"from": "postprocess_output", "to": "send_response", "label": "Ready"},
|
| 83 |
+
{"from": "send_response", "to": "end_inference_process", "label": "Response Sent"},
|
| 84 |
+
{"from": "log_error", "to": "end_inference_process", "label": "Error Handled"}
|
| 85 |
]
|
| 86 |
}
|
| 87 |
+
|
| 88 |
+
Returns:
|
| 89 |
+
str: The filepath to the generated PNG image file.
|
| 90 |
"""
|
| 91 |
try:
|
| 92 |
if not json_input.strip():
|