ZahirJS commited on
Commit
fdd7ae2
·
verified ·
1 Parent(s): 0c0813a

Update process_flow_generator.py

Browse files
Files changed (1) hide show
  1. 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 Order Process",
24
  "nodes": [
25
- {"id": "customer_order", "label": "Customer Places Order", "type": "process"},
26
- {"id": "check_stock", "label": "Check Stock Availability", "type": "decision"},
27
- {"id": "stock_available", "label": "Stock Available?", "type": "decision"},
28
- {"id": "process_payment", "label": "Process Payment", "type": "process"},
29
- {"id": "order_confirmed", "label": "Order Confirmed", "type": "process"},
30
- {"id": "notify_customer_oos", "label": "Notify Customer (Out of Stock)", "type": "process"},
31
- {"id": "end_order_process", "label": "End Order Process", "type": "end"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  ],
33
  "connections": [
34
- {"from": "start_node", "to": "customer_order", "label": "Initiate"},
35
- {"from": "customer_order", "to": "check_stock", "label": "Proceed"},
36
- {"from": "check_stock", "to": "stock_available", "label": "Result"},
37
- {"from": "stock_available", "to": "process_payment", "label": "Yes"},
38
- {"from": "stock_available", "to": "notify_customer_oos", "label": "No"},
39
- {"from": "process_payment", "to": "order_confirmed", "label": "Success"},
40
- {"from": "order_confirmed", "to": "end_order_process", "label": "Complete"},
41
- {"from": "notify_customer_oos", "to": "end_order_process", "label": "Finish"}
 
 
 
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():