Spaces:
Running
Running
Update app.py
Browse files
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 |
-
#
|
166 |
-
|
167 |
-
|
168 |
if st.button("Generate Diagram"):
|
169 |
if prompt:
|
170 |
-
#
|
171 |
-
|
172 |
-
|
|
|
|
|
173 |
diagram_code = get_diagram_code(prompt, diagram_choice, api_key)
|
174 |
|
175 |
if diagram_code:
|
176 |
-
# Hide the
|
177 |
-
|
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')
|