Update app.py
Browse files
app.py
CHANGED
@@ -425,8 +425,6 @@ def process_gemini_output(output):
|
|
425 |
|
426 |
|
427 |
def generate_documentation_page():
|
428 |
-
import time
|
429 |
-
|
430 |
# Sidebar with "Log Out" and "Back to Project" buttons
|
431 |
st.sidebar.image("SimplifAI Logo Long.jpeg", use_container_width=True)
|
432 |
st.sidebar.title(f"Project: {st.session_state.current_project}")
|
@@ -449,14 +447,12 @@ def generate_documentation_page():
|
|
449 |
# Prompt user for functionality description
|
450 |
functionality = st.text_area(
|
451 |
"Describe the functionality",
|
452 |
-
placeholder="e.g.,
|
453 |
)
|
454 |
|
455 |
# Button to start analyzing functionality
|
456 |
if st.button("Analyze"):
|
457 |
if functionality.strip():
|
458 |
-
st.write("Analyzing project files... Please wait.")
|
459 |
-
|
460 |
# Get the path of the current project
|
461 |
user_folder = os.path.join("user_projects", st.session_state.username)
|
462 |
project_folder = os.path.join(user_folder, st.session_state.current_project)
|
@@ -471,19 +467,27 @@ def generate_documentation_page():
|
|
471 |
|
472 |
# Calculate estimated time based on lines of code
|
473 |
total_lines = sum(len(content.splitlines()) for content in file_contents.values())
|
474 |
-
estimated_time = (total_lines
|
475 |
estimated_time = max(estimated_time, 1) # Minimum 1 second for short tasks
|
476 |
|
477 |
-
# Show progress bar
|
478 |
progress_bar = st.progress(0)
|
479 |
progress_message = st.empty()
|
480 |
|
481 |
-
|
482 |
-
|
483 |
-
|
|
|
|
|
|
|
|
|
484 |
progress_message.write(
|
485 |
-
f"Estimated time remaining: {int(
|
486 |
)
|
|
|
|
|
|
|
|
|
487 |
|
488 |
# Generate documentation using Gemini
|
489 |
documentation = generate_detailed_documentation(file_contents, functionality)
|
@@ -493,11 +497,10 @@ def generate_documentation_page():
|
|
493 |
|
494 |
# Display the final documentation
|
495 |
progress_bar.progress(100) # Fill the progress bar to 100%
|
|
|
|
|
496 |
progress_message.empty() # Clear the message
|
497 |
|
498 |
-
time.sleep(1) # Pause briefly for visual effect
|
499 |
-
progress_bar.empty() # Remove the progress bar completely
|
500 |
-
|
501 |
st.success("Documentation generated successfully!")
|
502 |
st.text_area("Generated Documentation", documentation, height=600)
|
503 |
|
@@ -554,6 +557,7 @@ def generate_documentation_page():
|
|
554 |
|
555 |
|
556 |
|
|
|
557 |
# Helper function to generate PDF
|
558 |
def generate_pdf(documentation, pdf_path):
|
559 |
pdf = FPDF()
|
|
|
425 |
|
426 |
|
427 |
def generate_documentation_page():
|
|
|
|
|
428 |
# Sidebar with "Log Out" and "Back to Project" buttons
|
429 |
st.sidebar.image("SimplifAI Logo Long.jpeg", use_container_width=True)
|
430 |
st.sidebar.title(f"Project: {st.session_state.current_project}")
|
|
|
447 |
# Prompt user for functionality description
|
448 |
functionality = st.text_area(
|
449 |
"Describe the functionality",
|
450 |
+
placeholder="e.g., Displaying output to the screen",
|
451 |
)
|
452 |
|
453 |
# Button to start analyzing functionality
|
454 |
if st.button("Analyze"):
|
455 |
if functionality.strip():
|
|
|
|
|
456 |
# Get the path of the current project
|
457 |
user_folder = os.path.join("user_projects", st.session_state.username)
|
458 |
project_folder = os.path.join(user_folder, st.session_state.current_project)
|
|
|
467 |
|
468 |
# Calculate estimated time based on lines of code
|
469 |
total_lines = sum(len(content.splitlines()) for content in file_contents.values())
|
470 |
+
estimated_time = (total_lines / 2500) * 60 # 1 minute per 2500 lines
|
471 |
estimated_time = max(estimated_time, 1) # Minimum 1 second for short tasks
|
472 |
|
473 |
+
# Show progress bar and tracker
|
474 |
progress_bar = st.progress(0)
|
475 |
progress_message = st.empty()
|
476 |
|
477 |
+
# Progress simulation
|
478 |
+
start_time = time.time()
|
479 |
+
for i in range(101):
|
480 |
+
elapsed_time = time.time() - start_time
|
481 |
+
progress = min(i, int((elapsed_time / estimated_time) * 100))
|
482 |
+
progress_bar.progress(progress)
|
483 |
+
time_remaining = max(estimated_time - elapsed_time, 0)
|
484 |
progress_message.write(
|
485 |
+
f"Estimated time remaining: {int(time_remaining)} seconds"
|
486 |
)
|
487 |
+
time.sleep(estimated_time / 100)
|
488 |
+
|
489 |
+
if elapsed_time >= estimated_time:
|
490 |
+
break
|
491 |
|
492 |
# Generate documentation using Gemini
|
493 |
documentation = generate_detailed_documentation(file_contents, functionality)
|
|
|
497 |
|
498 |
# Display the final documentation
|
499 |
progress_bar.progress(100) # Fill the progress bar to 100%
|
500 |
+
time.sleep(1) # Brief pause
|
501 |
+
progress_bar.empty() # Remove the progress bar
|
502 |
progress_message.empty() # Clear the message
|
503 |
|
|
|
|
|
|
|
504 |
st.success("Documentation generated successfully!")
|
505 |
st.text_area("Generated Documentation", documentation, height=600)
|
506 |
|
|
|
557 |
|
558 |
|
559 |
|
560 |
+
|
561 |
# Helper function to generate PDF
|
562 |
def generate_pdf(documentation, pdf_path):
|
563 |
pdf = FPDF()
|