import sys import os import gradio as gr # Import your interfaces from data_indexing import create_indexing_interface from data_processing import create_processing_interface def create_combined_app(): """Create combined app with two tabs""" with gr.Blocks( title="Rạng Đông Data Management System", theme=gr.themes.Soft() ) as app: gr.Markdown(""" # 🏢 Sale Agent Data Management System Hệ thống quản lý dữ liệu sản phẩm của Sale Agent """) with gr.Tabs() as tabs: # Tab 1: Vector Indexing (MongoDB to Qdrant) with gr.Tab("🗄️ Data Indexing", id="indexing"): gr.Markdown(""" ## Indexing dữ liệu từ MongoDB lên Qdrant Tạo vector embeddings và index dữ liệu từ MongoDB lên Qdrant Vector Database """) # Create indexing interface indexing_interface = create_indexing_interface() # Tab 2: Data Processing (Excel to MongoDB) with gr.Tab("📊 Data Processing", id="processing"): gr.Markdown(""" ## Xử lý dữ liệu từ Excel lên MongoDB Upload file Excel, xử lý dữ liệu sản phẩm và đẩy lên MongoDB Atlas """) # Create processing interface processing_interface = create_processing_interface() gr.Markdown(""" --- ### 📖 Hướng dẫn sử dụng **Bước 1: Data Processing** 1. Upload file Excel chứa dữ liệu sản phẩm (product_Metadata.xlsx) 2. Cấu hình MongoDB connection string, database name và test connection 3. Chọn loại sản phẩm hoặc xử lý tất cả. **Bước 2: Data Indexing** 1. Chọn collection cần indexing 2. Hệ thống sẽ tạo embeddings và đẩy lên Qdrant """) return app if __name__ == "__main__": app = create_combined_app() # Launch with appropriate settings for Hugging Face Spaces app.launch( server_name="0.0.0.0", # Required for HF Spaces server_port=7860, # Default HF Spaces port share=False, # Don't need share link on HF Spaces show_error=True, debug=False )