Spaces:
Sleeping
Sleeping
| """ | |
| PANSEA University Requirements Assistant - Gradio Version (Modular) | |
| A comprehensive tool for navigating university admission requirements across Southeast Asia. | |
| """ | |
| import gradio as gr | |
| import os | |
| import sys | |
| from datetime import datetime | |
| # Add the current directory to Python path for imports | |
| sys.path.append(os.path.dirname(os.path.abspath(__file__))) | |
| # Import our RAG system | |
| from utils.rag_system import DocumentIngestion, RAGSystem | |
| # Import modular tab components | |
| from tabs.initialize import create_initialize_tab | |
| from tabs.upload import create_upload_tab | |
| from tabs.query import create_query_tab | |
| from tabs.manage import create_manage_tab | |
| from tabs.help import create_help_tab | |
| def create_interface(): | |
| """Create the main Gradio interface using modular components""" | |
| # Global state management - shared across all tabs | |
| global_vars = { | |
| 'doc_ingestion': None, | |
| 'rag_system': None, | |
| 'vectorstore': None | |
| } | |
| # Custom CSS for better styling | |
| custom_css = """ | |
| .gradio-container { | |
| font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | |
| } | |
| .tab-nav button { | |
| font-weight: 500; | |
| font-size: 14px; | |
| } | |
| .tab-nav button[aria-selected="true"] { | |
| background: linear-gradient(45deg, #1e3a8a, #3b82f6); | |
| color: white; | |
| } | |
| .feedback-box { | |
| background: #f8fafc; | |
| border: 1px solid #e2e8f0; | |
| border-radius: 8px; | |
| padding: 16px; | |
| margin: 8px 0; | |
| } | |
| .success-message { | |
| background: #dcfce7; | |
| color: #166534; | |
| border: 1px solid #bbf7d0; | |
| padding: 12px; | |
| border-radius: 6px; | |
| margin: 8px 0; | |
| } | |
| .error-message { | |
| background: #fef2f2; | |
| color: #dc2626; | |
| border: 1px solid #fecaca; | |
| padding: 12px; | |
| border-radius: 6px; | |
| margin: 8px 0; | |
| } | |
| """ | |
| # Create the main interface | |
| with gr.Blocks( | |
| title="π PANSEA University Assistant", | |
| theme=gr.themes.Soft( | |
| primary_hue="blue", | |
| secondary_hue="slate" | |
| ), | |
| css=custom_css, | |
| analytics_enabled=False | |
| ) as interface: | |
| # Header | |
| gr.Markdown(""" | |
| # π TopEdu | |
| **Navigate University Admission Requirements Across Southeast Asia with AI-Powered Assistance** | |
| Upload university documents, ask questions, and get intelligent answers about admission requirements, | |
| programs, deadlines, and more across Southeast Asian universities. | |
| --- | |
| """) | |
| # Main tabs using modular components | |
| with gr.Tabs(): | |
| create_initialize_tab(global_vars) | |
| create_upload_tab(global_vars) | |
| create_query_tab(global_vars) | |
| create_manage_tab(global_vars) | |
| create_help_tab(global_vars) | |
| # Footer | |
| gr.Markdown(f""" | |
| --- | |
| **π§ System Status**: Ready | **π Session**: {datetime.now().strftime('%Y-%m-%d %H:%M')} | **π Version**: Modular Gradio | |
| π‘ **Tip**: Start by initializing the system, then upload your university documents, and begin querying! | |
| """) | |
| return interface | |
| def main(): | |
| """Launch the application""" | |
| interface = create_interface() | |
| # Launch configuration | |
| interface.launch( | |
| share=False, # Set to True for public sharing | |
| server_name="0.0.0.0", # Allow external connections | |
| server_port=7860, # Default Gradio port | |
| show_api=False, # Hide API documentation | |
| show_error=True, # Show detailed error messages | |
| quiet=False, # Show startup messages | |
| favicon_path=None, # Could add custom favicon | |
| app_kwargs={ | |
| "docs_url": None, # Disable FastAPI docs | |
| "redoc_url": None # Disable ReDoc docs | |
| } | |
| ) | |
| if __name__ == "__main__": | |
| print("π Starting PANSEA University Requirements Assistant...") | |
| print("π Access the application at: http://localhost:7860") | |
| print("π For public sharing, set share=True in the launch() method") | |
| print("-" * 60) | |
| main() | |