|
|
""" |
|
|
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 |
|
|
|
|
|
|
|
|
sys.path.append(os.path.dirname(os.path.abspath(__file__))) |
|
|
|
|
|
|
|
|
from utils.rag_system import DocumentIngestion, RAGSystem |
|
|
|
|
|
|
|
|
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_vars = { |
|
|
'doc_ingestion': None, |
|
|
'rag_system': None, |
|
|
'vectorstore': None |
|
|
} |
|
|
|
|
|
|
|
|
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; |
|
|
} |
|
|
""" |
|
|
|
|
|
|
|
|
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: |
|
|
|
|
|
|
|
|
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. |
|
|
|
|
|
--- |
|
|
""") |
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
|
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() |
|
|
|
|
|
|
|
|
interface.launch( |
|
|
share=False, |
|
|
server_name="0.0.0.0", |
|
|
server_port=7860, |
|
|
show_api=False, |
|
|
show_error=True, |
|
|
quiet=False, |
|
|
favicon_path=None, |
|
|
app_kwargs={ |
|
|
"docs_url": None, |
|
|
"redoc_url": None |
|
|
} |
|
|
) |
|
|
|
|
|
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() |
|
|
|