Asish Karthikeya Gogineni commited on
Commit
0cc3949
·
1 Parent(s): 88779f3

Improve UX: Move upload UI to main area

Browse files
Files changed (1) hide show
  1. app.py +55 -56
app.py CHANGED
@@ -439,54 +439,7 @@ with st.sidebar:
439
 
440
  st.divider()
441
 
442
- # Ingestion Section
443
- st.header("Import Codebase")
444
- source_type = st.radio("Source Type", ["ZIP File", "GitHub Repository", "Web Documentation"])
445
-
446
- source_input = None
447
- if source_type == "ZIP File":
448
- uploaded_file = st.file_uploader("Upload .zip file", type="zip")
449
- if uploaded_file:
450
- # Use /tmp for Hugging Face compatibility (they only allow writes to /tmp)
451
- import tempfile
452
- upload_dir = tempfile.gettempdir()
453
- source_input = os.path.join(upload_dir, "uploaded.zip")
454
- with open(source_input, "wb") as f:
455
- f.write(uploaded_file.getbuffer())
456
- elif source_type == "GitHub Repository":
457
- source_input = st.text_input("GitHub URL", placeholder="https://github.com/owner/repo")
458
- elif source_type == "Web Documentation":
459
- source_input = st.text_input("Web URL", placeholder="https://docs.python.org/3/")
460
-
461
- if source_input and not st.session_state.processed_files:
462
- if st.button("Process & Index"):
463
- if not api_key:
464
- st.error(f"Please provide {provider} API Key.")
465
- elif provider == "groq" and not embedding_api_key:
466
- st.error(f"Please provide {embedding_provider} API Key for embeddings.")
467
- else:
468
- # Use the new progress-tracked indexer
469
- from code_chatbot.indexing_progress import index_with_progress
470
-
471
- chat_engine, success, repo_files, workspace_root = index_with_progress(
472
- source_input=source_input,
473
- source_type=source_type,
474
- provider=provider,
475
- embedding_provider=embedding_provider,
476
- embedding_api_key=embedding_api_key,
477
- vector_db_type=vector_db_type,
478
- use_agent=use_agent,
479
- api_key=api_key,
480
- gemini_model=gemini_model # Pass selected model
481
- )
482
-
483
- if success:
484
- st.session_state.chat_engine = chat_engine
485
- st.session_state.processed_files = True
486
- st.session_state.indexed_files = repo_files # For file tree
487
- st.session_state.workspace_root = workspace_root # For relative paths
488
- time.sleep(0.5) # Brief pause to show success
489
- st.switch_page("pages/1_⚡_Code_Studio.py")
490
 
491
  if st.session_state.processed_files:
492
  st.success(f"✅ Codebase Ready ({provider}) + AST 🧠")
@@ -540,14 +493,60 @@ st.title("🕷️ Code Crawler")
540
 
541
  if not st.session_state.processed_files:
542
  # Show onboarding message when no files are processed
543
- st.info("👈 Please upload and index a codebase (ZIP, GitHub, or Web URL) to start.")
544
- st.markdown("""
545
- ### 🚀 Getting Started
546
- 1. **Configure** your API key in the sidebar
547
- 2. **Upload** a ZIP file, enter a GitHub URL, or Web documentation URL
548
- 3. **Index** your codebase with one click
549
- 4. **Explore** your code with the file explorer and chat interface
550
- """)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
551
  else:
552
  # Codebase Ready! Redirect to Code Studio
553
  st.switch_page("pages/1_⚡_Code_Studio.py")
 
439
 
440
  st.divider()
441
 
442
+ # Ingestion moved to main area
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
443
 
444
  if st.session_state.processed_files:
445
  st.success(f"✅ Codebase Ready ({provider}) + AST 🧠")
 
493
 
494
  if not st.session_state.processed_files:
495
  # Show onboarding message when no files are processed
496
+ # --- Main Ingestion Section ---
497
+ st.header("🚀 Import Codebase")
498
+ st.caption("Upload your project to get started. Configure advanced settings in the sidebar (open with >).")
499
+
500
+ if not api_key:
501
+ st.warning(f"⚠️ {provider.capitalize()} API Key is missing. Open the sidebar (top-left) to configure it.")
502
+
503
+ source_type = st.radio("Source Type", ["ZIP File", "GitHub Repository", "Web Documentation"], horizontal=True)
504
+
505
+ source_input = None
506
+ if source_type == "ZIP File":
507
+ uploaded_file = st.file_uploader("Upload .zip file", type="zip")
508
+ if uploaded_file:
509
+ import tempfile
510
+ upload_dir = tempfile.gettempdir()
511
+ source_input = os.path.join(upload_dir, "uploaded.zip")
512
+ with open(source_input, "wb") as f:
513
+ f.write(uploaded_file.getbuffer())
514
+
515
+ elif source_type == "GitHub Repository":
516
+ source_input = st.text_input("GitHub URL", placeholder="https://github.com/owner/repo")
517
+
518
+ elif source_type == "Web Documentation":
519
+ source_input = st.text_input("Web URL", placeholder="https://docs.python.org/3/")
520
+
521
+ if source_input and not st.session_state.processed_files:
522
+ if st.button("🚀 Process & Index", type="primary"):
523
+ if not api_key:
524
+ st.error(f"Please configure {provider} API Key in the sidebar.")
525
+ elif provider == "groq" and not embedding_api_key:
526
+ st.error(f"Please configure {embedding_provider} API Key for embeddings in the sidebar.")
527
+ else:
528
+ # Use the new progress-tracked indexer
529
+ from code_chatbot.indexing_progress import index_with_progress
530
+
531
+ chat_engine, success, repo_files, workspace_root = index_with_progress(
532
+ source_input=source_input,
533
+ source_type=source_type,
534
+ provider=provider,
535
+ embedding_provider=embedding_provider,
536
+ embedding_api_key=embedding_api_key,
537
+ vector_db_type=vector_db_type,
538
+ use_agent=use_agent,
539
+ api_key=api_key,
540
+ gemini_model=gemini_model # Pass selected model
541
+ )
542
+
543
+ if success:
544
+ st.session_state.chat_engine = chat_engine
545
+ st.session_state.processed_files = True
546
+ st.session_state.indexed_files = repo_files
547
+ st.session_state.workspace_root = workspace_root
548
+ time.sleep(0.5)
549
+ st.switch_page("pages/1_⚡_Code_Studio.py")
550
  else:
551
  # Codebase Ready! Redirect to Code Studio
552
  st.switch_page("pages/1_⚡_Code_Studio.py")