Spaces:
Sleeping
Sleeping
Pin Gradio to 6.0.1 (matching local version)
Browse files- app.py +1 -0
- src/ui/app.py +10 -11
app.py
CHANGED
|
@@ -24,6 +24,7 @@ def main():
|
|
| 24 |
theme=theme,
|
| 25 |
css=custom_css,
|
| 26 |
allowed_paths=[str(AUDIOS_DIR)],
|
|
|
|
| 27 |
)
|
| 28 |
|
| 29 |
|
|
|
|
| 24 |
theme=theme,
|
| 25 |
css=custom_css,
|
| 26 |
allowed_paths=[str(AUDIOS_DIR)],
|
| 27 |
+
ssr_mode=False, # Disable experimental SSR to improve responsiveness
|
| 28 |
)
|
| 29 |
|
| 30 |
|
src/ui/app.py
CHANGED
|
@@ -7,7 +7,7 @@ Implements the three-page layout: Generate, Explore, Settings.
|
|
| 7 |
|
| 8 |
import os
|
| 9 |
import json
|
| 10 |
-
import
|
| 11 |
import logging
|
| 12 |
import gradio as gr
|
| 13 |
from pathlib import Path
|
|
@@ -288,8 +288,8 @@ def create_app():
|
|
| 288 |
stats_output = gr.HTML("")
|
| 289 |
diagram_output = gr.HTML(make_loading_html("⏳", "Loading..."))
|
| 290 |
|
| 291 |
-
#
|
| 292 |
-
|
| 293 |
"""Process a pending analysis request with streaming updates."""
|
| 294 |
session = load_session_state()
|
| 295 |
pending = session.get("pending_request")
|
|
@@ -312,10 +312,9 @@ def create_app():
|
|
| 312 |
node_count=node_count,
|
| 313 |
edge_count=edge_count,
|
| 314 |
)
|
| 315 |
-
|
| 316 |
else:
|
| 317 |
-
|
| 318 |
-
return
|
| 319 |
|
| 320 |
# Get request details
|
| 321 |
github_url = pending.get("github_url")
|
|
@@ -343,7 +342,7 @@ def create_app():
|
|
| 343 |
# Step 1: Download/Process
|
| 344 |
display_name = ""
|
| 345 |
yield make_loading_html("📥", "Downloading repository..." if github_url else "Processing file..."), "", None
|
| 346 |
-
|
| 347 |
|
| 348 |
loader = get_repository_loader()
|
| 349 |
if github_url:
|
|
@@ -358,13 +357,13 @@ def create_app():
|
|
| 358 |
yield make_error_html(result.error), "", None
|
| 359 |
return
|
| 360 |
|
| 361 |
-
# Step 2: Show files found (display
|
| 362 |
yield make_loading_html(
|
| 363 |
"🔍",
|
| 364 |
f"Extracted {result.stats.files_processed} files",
|
| 365 |
f"{result.stats.total_characters:,} characters • Preparing AI analysis..."
|
| 366 |
), "", None
|
| 367 |
-
|
| 368 |
|
| 369 |
# Step 3: AI Analysis - this step shows while actual analysis happens
|
| 370 |
yield make_loading_html(
|
|
@@ -372,12 +371,12 @@ def create_app():
|
|
| 372 |
"AI analyzing code structure...",
|
| 373 |
f"Using {model_choice}"
|
| 374 |
), "", None
|
| 375 |
-
|
| 376 |
|
| 377 |
# Step 4: Generate diagram
|
| 378 |
try:
|
| 379 |
yield make_loading_html("🗺️", "Generating architecture diagram...", f"{model_choice} • This may take a moment..."), "", None
|
| 380 |
-
|
| 381 |
|
| 382 |
analyzer = CodeAnalyzer(api_key=api_key, model_name=model_name)
|
| 383 |
analysis = analyzer.generate_diagram(result.context)
|
|
|
|
| 7 |
|
| 8 |
import os
|
| 9 |
import json
|
| 10 |
+
import time
|
| 11 |
import logging
|
| 12 |
import gradio as gr
|
| 13 |
from pathlib import Path
|
|
|
|
| 288 |
stats_output = gr.HTML("")
|
| 289 |
diagram_output = gr.HTML(make_loading_html("⏳", "Loading..."))
|
| 290 |
|
| 291 |
+
# Process function with progress updates
|
| 292 |
+
def process_pending_request():
|
| 293 |
"""Process a pending analysis request with streaming updates."""
|
| 294 |
session = load_session_state()
|
| 295 |
pending = session.get("pending_request")
|
|
|
|
| 312 |
node_count=node_count,
|
| 313 |
edge_count=edge_count,
|
| 314 |
)
|
| 315 |
+
return diagram, stats, dot_source
|
| 316 |
else:
|
| 317 |
+
return make_empty_state_html(), "", None
|
|
|
|
| 318 |
|
| 319 |
# Get request details
|
| 320 |
github_url = pending.get("github_url")
|
|
|
|
| 342 |
# Step 1: Download/Process
|
| 343 |
display_name = ""
|
| 344 |
yield make_loading_html("📥", "Downloading repository..." if github_url else "Processing file..."), "", None
|
| 345 |
+
time.sleep(0.1) # Allow UI to update
|
| 346 |
|
| 347 |
loader = get_repository_loader()
|
| 348 |
if github_url:
|
|
|
|
| 357 |
yield make_error_html(result.error), "", None
|
| 358 |
return
|
| 359 |
|
| 360 |
+
# Step 2: Show files found (display briefly)
|
| 361 |
yield make_loading_html(
|
| 362 |
"🔍",
|
| 363 |
f"Extracted {result.stats.files_processed} files",
|
| 364 |
f"{result.stats.total_characters:,} characters • Preparing AI analysis..."
|
| 365 |
), "", None
|
| 366 |
+
time.sleep(0.5) # Brief pause to show extraction results
|
| 367 |
|
| 368 |
# Step 3: AI Analysis - this step shows while actual analysis happens
|
| 369 |
yield make_loading_html(
|
|
|
|
| 371 |
"AI analyzing code structure...",
|
| 372 |
f"Using {model_choice}"
|
| 373 |
), "", None
|
| 374 |
+
time.sleep(0.3) # Brief pause to render before heavy work
|
| 375 |
|
| 376 |
# Step 4: Generate diagram
|
| 377 |
try:
|
| 378 |
yield make_loading_html("🗺️", "Generating architecture diagram...", f"{model_choice} • This may take a moment..."), "", None
|
| 379 |
+
time.sleep(0.1) # Allow UI to update
|
| 380 |
|
| 381 |
analyzer = CodeAnalyzer(api_key=api_key, model_name=model_name)
|
| 382 |
analysis = analyzer.generate_diagram(result.context)
|