|
|
import sys |
|
|
import os |
|
|
|
|
|
import gradio as gr |
|
|
|
|
|
|
|
|
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: |
|
|
|
|
|
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 |
|
|
""") |
|
|
|
|
|
|
|
|
indexing_interface = create_indexing_interface() |
|
|
|
|
|
|
|
|
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 |
|
|
""") |
|
|
|
|
|
|
|
|
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() |
|
|
|
|
|
|
|
|
app.launch( |
|
|
server_name="0.0.0.0", |
|
|
server_port=7860, |
|
|
share=False, |
|
|
show_error=True, |
|
|
debug=False |
|
|
) |