File size: 2,588 Bytes
a519263
 
2959ef9
a519263
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9679ba5
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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("""
        # 🏢 Rạng Đông Data Management System
        
        Hệ thống quản lý dữ liệu sản phẩm và giải pháp của Rạng Đông
        """)
        
        with gr.Tabs() as tabs:
            # Tab 1: Vector Indexing (MongoDB to Qdrant)
            with gr.Tab("🗄️ Vector 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: Vector 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
    )