shukdevdatta123 commited on
Commit
f068750
·
verified ·
1 Parent(s): 1505346

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -3,6 +3,7 @@ import openai
3
  import urllib.parse
4
  import io
5
  from PIL import Image
 
6
 
7
  # Function to call OpenAI GPT model for prompt processing
8
  def get_diagram_code(prompt, diagram_type, api_key):
@@ -162,19 +163,21 @@ def main():
162
  diagram_types = ["UML Diagram", "ER Diagram", "State Diagram", "Class Diagram", "Sequence Diagram"]
163
  diagram_choice = st.selectbox("Select the type of diagram to generate:", diagram_types)
164
 
165
- # Show loading spinner when generating the diagram
166
- loading_spinner = st.empty()
167
-
168
  if st.button("Generate Diagram"):
169
  if prompt:
170
- # Show loading animation
171
- loading_spinner.markdown("<div class='loading-spinner'></div>", unsafe_allow_html=True)
172
-
 
 
173
  diagram_code = get_diagram_code(prompt, diagram_choice, api_key)
174
 
175
  if diagram_code:
176
- # Hide the spinner after diagram code is generated
177
- loading_spinner.empty()
178
 
179
  # Render Mermaid code to Streamlit with animation
180
  st.code(diagram_code, language='mermaid')
 
3
  import urllib.parse
4
  import io
5
  from PIL import Image
6
+ import time # Used for simulating progress updates
7
 
8
  # Function to call OpenAI GPT model for prompt processing
9
  def get_diagram_code(prompt, diagram_type, api_key):
 
163
  diagram_types = ["UML Diagram", "ER Diagram", "State Diagram", "Class Diagram", "Sequence Diagram"]
164
  diagram_choice = st.selectbox("Select the type of diagram to generate:", diagram_types)
165
 
166
+ # Create a progress bar
167
+ progress_bar = st.progress(0)
168
+
169
  if st.button("Generate Diagram"):
170
  if prompt:
171
+ # Simulate the progress
172
+ for i in range(100):
173
+ progress_bar.progress(i + 1)
174
+ time.sleep(0.05) # Simulate processing time for loading bar
175
+
176
  diagram_code = get_diagram_code(prompt, diagram_choice, api_key)
177
 
178
  if diagram_code:
179
+ # Hide the progress bar once the diagram is generated
180
+ progress_bar.empty()
181
 
182
  # Render Mermaid code to Streamlit with animation
183
  st.code(diagram_code, language='mermaid')