File size: 1,865 Bytes
dc37a7f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import streamlit as st
from graphviz import Digraph

def generate_flow_diagram(objective):
    """Generates a process flow diagram based on the given objective."""
    # Example process based on a generic objective
    steps = [
        ("Start", "Define Objectives"),
        ("Define Objectives", "Identify Inputs"),
        ("Identify Inputs", "Analyze Process"),
        ("Analyze Process", "Develop Workflow"),
        ("Develop Workflow", "Implement Workflow"),
        ("Implement Workflow", "Monitor and Improve"),
        ("Monitor and Improve", "End")
    ]

    diagram = Digraph()
    for step in steps:
        diagram.edge(step[0], step[1])

    return diagram

def explain_diagram():
    """Provides an explanation for the process flow diagram."""
    explanation = (
        "This process flow diagram outlines the typical steps involved in achieving the objective. "
        "It begins with defining the objectives and identifying the necessary inputs, followed by analyzing "
        "the process and developing a workflow. After implementation, continuous monitoring and improvement "
        "ensure the process remains effective and efficient."
    )
    return explanation

def main():
    st.title("Process Flow Diagram Generator")

    st.sidebar.header("Input Parameters")
    objective = st.sidebar.text_input("Enter the objective of the process:")

    if st.sidebar.button("Generate Diagram"):
        if objective.strip():
            diagram = generate_flow_diagram(objective)
            explanation = explain_diagram()

            st.subheader("Process Flow Diagram")
            st.graphviz_chart(diagram)

            st.subheader("Explanation")
            st.write(explanation)
        else:
            st.error("Please enter a valid objective to generate the process flow diagram.")

if __name__ == "__main__":
    main()